feat 接入report

This commit is contained in:
zcr
2026-03-03 17:33:51 +08:00
parent 1ecb02d706
commit 1ade907828
23 changed files with 4079 additions and 516 deletions

View File

@@ -0,0 +1,38 @@
from typing import Literal
from langchain_core.tools import tool
from pydantic import BaseModel, Field
class TerminateInput(BaseModel):
"""終止對話的輸入參數"""
status: Literal["success", "failure"] = Field(
description="互動結束的狀態:'success' 表示任務完成,'failure' 表示無法繼續",
examples=["success", "failure"]
)
reason: str = Field(
default="",
description="可選:簡單說明為什麼結束(例如 '報告已生成''缺少關鍵資訊'",
examples=["報告已成功生成", "無法取得足夠資料"]
)
@tool(args_schema=TerminateInput)
def terminate(status: str, reason: str = "") -> str:
"""
當任務完成、報告已生成,或無法繼續進行時,呼叫此工具來結束本次互動。
使用時機:
- 已經成功產生最終報告report_generator 已完成)
- 遇到無法解決的錯誤或缺少關鍵資訊
- 用戶需求已完全滿足
請在呼叫前確保所有必要步驟已完成,並在 reason 中簡單說明結束原因。
"""
if status not in ("success", "failure"):
status = "failure" # 防呆
msg = f"互動已終止,狀態:{status.upper()}"
if reason:
msg += f"\n原因:{reason}"
return msg