agent功能开发增加MCP后端

This commit is contained in:
2025-11-07 23:18:20 +08:00
parent a8edb8bde3
commit 6899b9d0d2
2 changed files with 143 additions and 53 deletions

View File

@@ -1679,6 +1679,9 @@ async def agent_chat(request: AgentChatRequest):
ensure_ascii=False
)
# 将 plan 转换为 JSON 字符串ES 中 plan 字段是 text 类型)
plan_json = json.dumps(response.plan.dict(), ensure_ascii=False) if response.plan else None
es_client.save_chat_message(
session_id=session_id,
user_id=request.user_id or "anonymous",
@@ -1686,7 +1689,7 @@ async def agent_chat(request: AgentChatRequest):
user_avatar=request.user_avatar or "",
message_type="assistant",
message=response.final_summary, # 使用 final_summary 而不是 final_answer
plan=response.plan.dict() if response.plan else None, # 转换为字典
plan=plan_json, # 传递 JSON 字符串而不是字典
steps=steps_json,
)
except Exception as e: