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
+1 -1
View File
@@ -9,7 +9,7 @@ def build_intent_question() -> ChoiceDecision:
instructions=(
"Classify the user's primary intent. "
"Classify the latest user answer in `clarification_history`, or `prompt` when there is no history. "
"Use earlier turns and the selected option to resolve references; the latest answer overrides earlier conflicting intent. "
"Use earlier turns, `history` (previous turns of this conversation) and the selected option to resolve references; the latest answer overrides earlier conflicting intent. "
"Once the requested action or response is clear, earlier ambiguity does not require another confirmation. "
"Choose modify_screen only when the user explicitly requests an actual edit. "
"Choose qa for clear requests for a textual answer or general conversation, including information, explanation, diagnosis, advice, and assistant identity or capabilities. "
+2 -1
View File
@@ -5,7 +5,8 @@ QA_SYSTEM_PROMPT = """## 任务
也可回答助手身份、能力等一般交流请求;介绍自己时以大屏助手的职责和已知能力为依据,不编造模型身份或未提供的能力
## 回答依据
结合当前问题、大屏快照和 clarification_history,以用户后续明确补充或纠正为准
结合当前问题、大屏快照、history(此前各轮的用户输入与助手摘要)和 clarification_history,以用户后续明确补充或纠正为准
理解“刚才那个”“再大一点”等指代时参考 history,但当前大屏快照才是最新事实
仅在与请求相关时使用大屏快照;一般交流无需强行关联大屏或要求用户补充大屏信息
区分快照事实与待验证的推测,证据不足时说明缺少的信息,不编造故障原因
+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(