feat: 增加报告智能体
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user