1
0

test_analysis_agent.py 950 B

12345678910111213141516171819202122232425262728293031
  1. from hello_agents import HelloAgentsLLM
  2. from agents.react_agent import NewReActAgent
  3. from agents.agent_prompts import ANALYSIS_AGENT_PROMPT
  4. from tools.data_analysis import create_data_analysis_registry
  5. if __name__ == "__main__":
  6. llm = HelloAgentsLLM()
  7. registry = create_data_analysis_registry()
  8. analysis_agent = NewReActAgent(
  9. name="AnalysisAgent",
  10. llm=llm,
  11. custom_prompt=ANALYSIS_AGENT_PROMPT,
  12. tool_registry=registry,
  13. max_steps=5
  14. )
  15. plan_result = ["分析不同年龄段用户的偏好"]
  16. task_result = []
  17. for task in plan_result:
  18. print(f"执行任务: {task}")
  19. try:
  20. answer = analysis_agent.run(task)
  21. task_result.append({ "task": task, "result": answer })
  22. print(f"任务结果: {answer}")
  23. except Exception as e:
  24. print(f"执行过程中出现错误: {e}")
  25. print(f"\n所有任务结果: {task_result}")