新增对话接口

This commit is contained in:
zcr
2026-03-12 13:13:52 +08:00
parent 7042d428fa
commit a6393df0e3
35 changed files with 843 additions and 1163 deletions

View File

@@ -17,13 +17,22 @@ class TerminateInput(BaseModel):
@tool(args_schema=TerminateInput)
def terminate(status: str, reason: str = "") -> dict:
def terminate(status: str, reason: str = "") -> str:
"""
终止本次互
當任務完成、報告已生成,或無法繼續進行時,呼叫此工具來結束本次互
使用時機:
- 已經成功產生最終報告report_generator 已完成)
- 遇到無法解決的錯誤或缺少關鍵資訊
- 用戶需求已完全滿足
請在呼叫前確保所有必要步驟已完成,並在 reason 中簡單說明結束原因。
"""
return {
"messages": [], # 清空追加消息
"__end__": True, # 结束标记
"status": status,
"reason": reason
}
if status not in ("success", "failure"):
status = "failure" # 防呆
msg = f"互動已終止,狀態:{status.upper()}"
if reason:
msg += f"\n原因:{reason}"
return msg