Skip to content

Commit 1bd73cf

Browse files
authored
Merge pull request volcengine#27 from codingmokey2025/feat/optimze-beginer-samples
optimize beginner case
2 parents 1bd2a04 + eff04ce commit 1bd73cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+4707
-1039
lines changed

02-use-cases/beginner/README.md

Lines changed: 427 additions & 0 deletions
Large diffs are not rendered by default.
File renamed without changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This directory contains an A2A agent that requires a remote service to be running first.
2+
# It is not suitable for loading in veadk web interface.
3+
# Please refer to the README.md for proper usage instructions.

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313

14-
from .agent import root_agent # noqa
14+
# 注意:此模块不适合在 veadk web 中自动加载
15+
# a2a_simple 需要先启动远程服务,然后才能运行客户端
16+
# 请参考 README.md 中的运行方式说明
1517

16-
__all__ = ["root_agent"]
18+
# 不导入 root_agent,避免在模块加载时初始化 RemoteVeAgent
19+
# from .agent import root_agent # noqa
Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,48 @@
11
from veadk.a2a.remote_ve_agent import RemoteVeAgent
22
from veadk.agent import Agent
3+
from veadk.memory import ShortTermMemory
4+
from agentkit.app import AgentkitA2aApp
5+
from a2a.types import AgentCard, AgentProvider, AgentSkill, AgentCapabilities
36

47
remote_agent = RemoteVeAgent(
58
name="a2a_agent",
6-
url="http://localhost:8001/", # <--- url from cloud platform
9+
url="http://localhost:8000/", # <--- url from cloud platform
710
)
811

912
def add(a: int, b: int) -> int:
1013
"""Adds two numbers."""
1114
return a + b
1215

13-
root_agent = Agent(
16+
agent = Agent(
1417
name="a2a_sample_agent",
1518
instruction="You are a helpful assistant.",
1619
tools=[add],
1720
sub_agents=[remote_agent],
18-
)
21+
)
22+
23+
a2aApp = AgentkitA2aApp(
24+
agent=agent,
25+
app_name="a2a_sample_app",
26+
short_term_memory=ShortTermMemory(),
27+
)
28+
29+
if __name__ == "__main__":
30+
from a2a.types import AgentCard, AgentProvider, AgentSkill, AgentCapabilities
31+
32+
agent_card = AgentCard(
33+
capabilities=AgentCapabilities(streaming=True), # 启用流式
34+
description=agent.description,
35+
name=agent.name,
36+
defaultInputModes=["text"],
37+
defaultOutputModes=["text"],
38+
provider=AgentProvider(organization="veadk", url=""),
39+
skills=[AgentSkill(id="0", name="chat", description="Chat", tags=["chat"])],
40+
url="http://0.0.0.0:8000",
41+
version="1.0.0",
42+
)
43+
44+
a2a_app.run(
45+
agent_card=agent_card,
46+
host="0.0.0.0",
47+
port=8000,
48+
)
220 KB
Loading

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:8001', "hello , show me one number of 6-sided"
105+
f'http://localhost:8000', "hello , show me one number of 6-sided"
106106
)
107107
print(trending_topics)
108108

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[project]
2+
name = "a2a-simple"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
dependencies = [
8+
"agentkit-sdk-python==0.1.14",
9+
"google-adk==1.18.0",
10+
"veadk-python==0.2.29",
11+
]

0 commit comments

Comments
 (0)