Skip to content

Commit a6a851c

Browse files
committed
update: samples
1 parent 9078ab5 commit a6a851c

1,869 files changed

Lines changed: 81021 additions & 306807 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ template.html
88
git_cmp_needs_update.csv
99
git_cmp_index_incremental.csv
1010
/__pycache__
11+
/.vscode

agent/a2a_server_client/samples/python/.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ wheels/
99
# Virtual environments
1010
.venv
1111

12-
.DS_Store
12+
.DS_Store
13+
14+
.env

agent/a2a_server_client/samples/python/agents/google_adk/agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ def invoke(self, query, session_id) -> str:
126126
state={},
127127
session_id=session_id,
128128
)
129-
events = self._runner.run(
129+
events = list(self._runner.run(
130130
user_id=self._user_id, session_id=session.id, new_message=content
131-
)
131+
))
132132
if not events or not events[-1].content or not events[-1].content.parts:
133133
return ""
134134
return "\n".join([p.text for p in events[-1].content.parts if p.text])
@@ -183,7 +183,7 @@ def _build_agent(self) -> LlmAgent:
183183
" given the amount and purpose of the reimbursement."
184184
),
185185
instruction="""
186-
You are an agent who handle the reimbursement process for employees.
186+
You are an agent who handles the reimbursement process for employees.
187187
188188
When you receive an reimbursement request, you should first create a new request form using create_request_form(). Only provide default values if they are provided by the user, otherwise use an empty string as the default value.
189189
1. 'Date': the date of the transaction.

agent/a2a_server_client/samples/python/agents/marvin/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

agent/a2a_server_client/samples/python/hosts/cli/__main__.py

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
from common.client import A2AClient, A2ACardResolver
2-
from common.types import TaskState, Task
3-
from common.utils.push_notification_auth import PushNotificationReceiverAuth
41
import asyncclick as click
52
import asyncio
6-
from uuid import uuid4
3+
import base64
4+
import os
75
import urllib
6+
from uuid import uuid4
7+
8+
from common.client import A2AClient, A2ACardResolver
9+
from common.types import TaskState, Task, TextPart, FilePart, FileContent
10+
from common.utils.push_notification_auth import PushNotificationReceiverAuth
11+
812

913
@click.command()
1014
@click.option("--agent", default="http://localhost:10000")
@@ -60,20 +64,42 @@ async def completeTask(client: A2AClient, streaming, use_push_notifications: boo
6064
)
6165
if prompt == ":q" or prompt == "quit":
6266
return False
63-
67+
68+
message = {
69+
"role": "user",
70+
"parts": [
71+
{
72+
"type": "text",
73+
"text": prompt,
74+
}
75+
]
76+
}
77+
78+
file_path = click.prompt(
79+
"Select a file path to attach? (press enter to skip)",
80+
default="",
81+
show_default=False,
82+
)
83+
if file_path and file_path.strip() != "":
84+
with open(file_path, "rb") as f:
85+
file_content = base64.b64encode(f.read()).decode('utf-8')
86+
file_name = os.path.basename(file_path)
87+
88+
message["parts"].append(
89+
{
90+
"type": "file",
91+
"file": {
92+
"name": file_name,
93+
"bytes": file_content,
94+
}
95+
}
96+
)
97+
6498
payload = {
6599
"id": taskId,
66100
"sessionId": sessionId,
67101
"acceptedOutputModes": ["text"],
68-
"message": {
69-
"role": "user",
70-
"parts": [
71-
{
72-
"type": "text",
73-
"text": prompt,
74-
}
75-
],
76-
},
102+
"message": message,
77103
}
78104

79105
if use_push_notifications:

agent/a2a_server_client/samples/python/hosts/cli/push_notification_listener.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self, host, port, notification_receiver_auth: PushNotificationRecei
2323

2424
def start(self):
2525
try:
26-
# Need to start server is separate thread as current thread
26+
# Need to start server in separate thread as current thread
2727
# will be blocked when it is waiting on user prompt.
2828
asyncio.run_coroutine_threadsafe(
2929
self.start_server(),

agent/a2a_server_client/samples/python/hosts/multiagent/host_agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def create_agent(self) -> Agent:
8585

8686
def root_instruction(self, context: ReadonlyContext) -> str:
8787
current_agent = self.check_state(context)
88-
return f"""You are a expert delegator that can delegate the user request to the
88+
return f"""You are an expert delegator that can delegate the user request to the
8989
appropriate remote agents.
9090
9191
Discovery:
@@ -94,12 +94,12 @@ def root_instruction(self, context: ReadonlyContext) -> str:
9494
9595
Execution:
9696
- For actionable tasks, you can use `create_task` to assign tasks to remote agents to perform.
97-
Be sure to include the remote agent name when you response to the user.
97+
Be sure to include the remote agent name when you respond to the user.
9898
9999
You can use `check_pending_task_states` to check the states of the pending
100100
tasks.
101101
102-
Please rely on tools to address the request, don't make up the response. If you are not sure, please ask the user for more details.
102+
Please rely on tools to address the request, and don't make up the response. If you are not sure, please ask the user for more details.
103103
Focus on the most recent parts of the conversation primarily.
104104
105105
If there is an active agent, send the request to that agent with the update task tool.

agent/a2a_server_client/samples/python/hosts/multiagent/remote_agent_connection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from common.client import A2AClient
1313

1414
TaskCallbackArg = Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent
15-
TaskUpdateCallback = Callable[[TaskCallbackArg], Task]
15+
TaskUpdateCallback = Callable[[TaskCallbackArg, AgentCard], Task]
1616

1717
class RemoteAgentConnections:
1818
"""A class to hold the connections to the remote agents."""
@@ -44,7 +44,7 @@ async def send_task(
4444
message=request.message,
4545
),
4646
history=[request.message],
47-
))
47+
), self.card)
4848
async for response in self.agent_client.send_task_streaming(request.model_dump()):
4949
merge_metadata(response.result, request)
5050
# For task status updates, we need to propagate metadata and provide
@@ -60,7 +60,7 @@ async def send_task(
6060
m.metadata['last_message_id'] = m.metadata['message_id']
6161
m.metadata['message_id'] = str(uuid.uuid4())
6262
if task_callback:
63-
task = task_callback(response.result)
63+
task = task_callback(response.result, self.card)
6464
if hasattr(response.result, 'final') and response.result.final:
6565
break
6666
return task
@@ -81,7 +81,7 @@ async def send_task(
8181
m.metadata['message_id'] = str(uuid.uuid4())
8282

8383
if task_callback:
84-
task_callback(response.result)
84+
task_callback(response.result, self.card)
8585
return response.result
8686

8787
def merge_metadata(target, source):

agent/a2a_server_client/samples/python/pyproject.toml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,35 @@ description = "Agent2Agent samples"
55
readme = "README.md"
66
requires-python = ">=3.12"
77
dependencies = [
8-
"asyncclick>=8.1.8",
9-
"asyncio>=3.4.3",
10-
"click>=8.1.8",
11-
"google-genai>=1.9.0",
128
"httpx>=0.28.1",
139
"httpx-sse>=0.4.0",
14-
"langchain-google-genai>=2.0.10",
15-
"langgraph>=0.3.18",
10+
"jwcrypto>=1.5.6",
1611
"pydantic>=2.10.6",
12+
"pyjwt>=2.10.1",
1713
"sse-starlette>=2.2.1",
1814
"starlette>=0.46.1",
19-
"streamlit>=1.44.0",
15+
"typing-extensions>=4.12.2",
2016
"uvicorn>=0.34.0",
21-
"google-adk>=0.0.3",
22-
"jwcrypto>=1.5.6",
23-
"pyjwt>=2.10.1",
2417
]
2518

2619
[tool.hatch.build.targets.wheel]
2720
packages = ["common", "hosts"]
2821

2922
[tool.uv.workspace]
30-
members = ["agents/crewai"]
23+
members = [
24+
"agents/crewai",
25+
"agents/google_adk",
26+
"agents/langgraph",
27+
"agents/marvin",
28+
"hosts/cli",
29+
"hosts/multiagent",
30+
"agents/llama_index_file_chat",
31+
"agents/semantickernel",
32+
]
3133

3234
[build-system]
3335
requires = ["hatchling"]
3436
build-backend = "hatchling.build"
3537

3638
[dependency-groups]
37-
dev = [
38-
"pytest>=8.3.5",
39-
"pytest-mock>=3.14.0",
40-
"ruff>=0.11.2",
41-
]
39+
dev = ["pytest>=8.3.5", "pytest-mock>=3.14.0", "ruff>=0.11.2"]

0 commit comments

Comments
 (0)