Merge pull request #1244 from Rail1bc/master

修复:dequeue_context_length的配置项的实际行为与描述不一致;调用函数工具可能导致400错误
This commit is contained in:
Soulter
2025-04-13 14:41:16 +08:00
committed by GitHub
@@ -146,8 +146,12 @@ class LLMRequestSubStage(Stage):
):
logger.debug("上下文长度超过限制,将截断。")
req.contexts = req.contexts[
-(self.max_context_length - self.dequeue_context_length) * 2 :
-(self.max_context_length - self.dequeue_context_length + 1) * 2 :
]
# 找到第一个role 为 user 的索引,确保上下文格式正确
index = next((i for i, item in enumerate(req.contexts) if item.get("role") == "user"), None)
if index is not None and index > 0:
req.contexts = req.contexts[index:]
# session_id
if not req.session_id: