Skip to content

Commit e81438f

Browse files
fix beginner case a2a sample
1 parent 5424417 commit e81438f

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

02-use-cases/beginner/a2a_simple/agent.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
from veadk import Agent, Runner
12
from veadk.a2a.remote_ve_agent import RemoteVeAgent
2-
from veadk.agent import Agent
3-
from veadk.memory import ShortTermMemory
4-
from agentkit.app import AgentkitA2aApp
3+
from agentkit.apps import AgentkitA2aApp
4+
from google.adk.a2a.executor.a2a_agent_executor import A2aAgentExecutor
55
from a2a.types import AgentCard, AgentProvider, AgentSkill, AgentCapabilities
66

77
remote_agent = RemoteVeAgent(
88
name="a2a_agent",
9-
url="http://localhost:8000/", # <--- url from cloud platform
9+
url="http://localhost:8001/", # <--- url from remote agent service
1010
)
1111

1212
def add(a: int, b: int) -> int:
@@ -15,33 +15,34 @@ def add(a: int, b: int) -> int:
1515

1616
agent = Agent(
1717
name="a2a_sample_agent",
18-
instruction="You are a helpful assistant.",
18+
instruction="You are a helpful assistant that can add numbers and delegate tasks to a remote agent that can roll dice and check prime numbers.",
1919
tools=[add],
2020
sub_agents=[remote_agent],
2121
)
2222

23-
a2aApp = AgentkitA2aApp(
24-
agent=agent,
25-
app_name="a2a_sample_app",
26-
short_term_memory=ShortTermMemory(),
27-
)
23+
runner = Runner(agent=agent)
24+
25+
26+
a2aApp = AgentkitA2aApp()
27+
28+
@a2aApp.agent_executor(runner=runner)
29+
class MyAgentExecutor(A2aAgentExecutor):
30+
pass
2831

2932
if __name__ == "__main__":
30-
from a2a.types import AgentCard, AgentProvider, AgentSkill, AgentCapabilities
31-
3233
agent_card = AgentCard(
33-
capabilities=AgentCapabilities(streaming=True), # 启用流式
34+
capabilities=AgentCapabilities(streaming=True),
3435
description=agent.description,
3536
name=agent.name,
3637
defaultInputModes=["text"],
3738
defaultOutputModes=["text"],
38-
provider=AgentProvider(organization="veadk", url=""),
39+
provider=AgentProvider(organization="agentkit", url=""),
3940
skills=[AgentSkill(id="0", name="chat", description="Chat", tags=["chat"])],
4041
url="http://0.0.0.0:8000",
4142
version="1.0.0",
4243
)
43-
44-
a2a_app.run(
44+
45+
a2aApp.run(
4546
agent_card=agent_card,
4647
host="0.0.0.0",
4748
port=8000,

02-use-cases/beginner/a2a_simple/local_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ async def test_trending_topics() -> None:
102102
"""Test news topics agent."""
103103
for i in range(0, 10):
104104
trending_topics = await a2a_client.create_task(
105-
f'http://localhost:8000', "hello , show me one number of 6-sided"
105+
f'http://localhost:8001', "hello , show me one number of 6-sided"
106106
)
107107
print(trending_topics)
108108

02-use-cases/beginner/a2a_simple/remote/agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ class MyAgentExecutor(A2aAgentExecutor):
5353
defaultOutputModes=["text"],
5454
provider=AgentProvider(organization="agentkit", url=""),
5555
skills=[AgentSkill(id="0", name="chat", description="Chat", tags=["chat"])],
56-
url="0.0.0.0",
56+
url="http://localhost:8001",
5757
version="1.0.0",
5858
)
5959

6060
print('agent start successfully ', root_agent.name)
6161

6262
# a2a_app = to_a2a(root_agent, port=8001)
6363
if __name__ == '__main__':
64-
a2a_app.run(agent_card=agent_card, host="0.0.0.0", port=8000)
64+
a2a_app.run(agent_card=agent_card, host="0.0.0.0", port=8001)

0 commit comments

Comments
 (0)