feat:优化流式输出,增加临时多轮对话记录

This commit is contained in:
2026-09-29 09:55:17 -07:00
parent 6a38a5f15e
commit a89a458c22
10 changed files with 153 additions and 23 deletions
+6 -2
View File
@@ -49,10 +49,14 @@ REQUIREMENT_INPUT_TEMPLATE = """历史会话:
def build_requirement_input(
context: InputContext, intent: Intent, *, history_text: str = "未提供"
context: InputContext, intent: Intent, *, history_text: str | None = None
) -> str:
"""整理本次模型输入,历史会话由调用方加载后传入"""
"""整理本次模型输入,历史会话默认取输入上下文中由服务端写入的记录"""
data = context.model_dump(mode="json", exclude_unset=True)
# 会话历史
history = data.pop("history", [])
if history_text is None:
history_text = json.dumps(history, ensure_ascii=False) if history else "未提供"
content = REQUIREMENT_INPUT_TEMPLATE.format(
history_text=history_text,
clarification_text=json.dumps(