feat: 增加报告智能体

This commit is contained in:
2026-09-03 17:25:06 +08:00
parent cc39d7b19d
commit 38310f7b1c
6 changed files with 104 additions and 88 deletions

View File

@@ -4,7 +4,8 @@ from typing import Dict, Any
from langchain_core.messages import HumanMessage, SystemMessage
from agent.health import tip_agent, recipe_agent
from agent.health import tip_agent, recipe_agent, report_agent
from schema.agent import ReportRequest
memory_store: Dict[str, Any] = {
"articles": [],
@@ -76,3 +77,20 @@ def query_recipe_agent():
def get_latest_recipe():
return memory_store["recipe"]
def query_report_agent(req: ReportRequest):
try:
print("开始生成报告")
today = datetime.today().strftime("%Y-%m-%d")
resp = report_agent.invoke({
"messages": [SystemMessage(content=f"当前系统日期:{today} \n\n"),
HumanMessage(content=f"用户数据:${req.query}")]
})
print("结束生成报告")
last_msg = resp["messages"][-1]
return last_msg.content.strip()
except Exception as e:
print(f"\n[生成报告错误]: {str(e)}")
return False