You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
731 B
Python

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"""
10.3.4 在智能体中使用A2A工具
1使用A2ATool包装器
"""
from hello_agents import SimpleAgent, HelloAgentsLLM
from hello_agents.tools import A2ATool
from dotenv import load_dotenv
load_dotenv()
llm = HelloAgentsLLM()
# 假设已经有一个研究员Agent服务运行在 http://localhost:5000
# 创建协调者Agent
coordinator = SimpleAgent(name="协调者", llm=llm)
# 添加A2A工具连接到研究员Agent
researcher_tool = A2ATool(agent_url="http://localhost:5000")
coordinator.add_tool(researcher_tool)
# 协调者可以调用研究员Agent
# 使用 action="ask" 向 Agent 提问
response = coordinator.run("使用a2a工具向Agent提问请研究AI在教育领域的应用")
print(response)