Skip to content

Commit 36fa487

Browse files
committed
Update the agent/contact_lookup sample to use the a2ui-agent python SDK
Tested: - [x] The contact_lookup client successfully connected to the contact_lookup agent and rendered the response correctly.
1 parent 5b088e8 commit 36fa487

12 files changed

Lines changed: 478 additions & 1093 deletions

File tree

a2a_agents/python/a2ui_agent/src/a2ui/inference/schema/manager.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
find_repo_root,
3737
)
3838
from .catalog import CustomCatalogConfig, A2uiCatalog
39-
from ...extension.a2ui_extension import INLINE_CATALOGS_KEY, SUPPORTED_CATALOG_IDS_KEY
39+
from ...extension.a2ui_extension import INLINE_CATALOGS_KEY, SUPPORTED_CATALOG_IDS_KEY, get_a2ui_agent_extension
40+
from a2a.types import AgentExtension
4041

4142

4243
def _load_basic_component(version: str, spec_name: str) -> Dict:
@@ -322,3 +323,7 @@ def generate_system_prompt(
322323
parts.append(f"### Examples:\n{examples_str}")
323324

324325
return "\n\n".join(parts)
326+
327+
def get_agent_extension(self) -> AgentExtension:
328+
catalog_ids = self._supported_catalogs.keys()
329+
return get_a2ui_agent_extension(supported_catalog_ids=list(catalog_ids))

samples/agent/adk/contact_lookup/__main__.py

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
from a2a.server.apps import A2AStarletteApplication
2020
from a2a.server.request_handlers import DefaultRequestHandler
2121
from a2a.server.tasks import InMemoryTaskStore
22-
from a2a.types import AgentCapabilities, AgentCard, AgentSkill
23-
from a2ui.extension.a2ui_extension import get_a2ui_agent_extension
2422
from agent import ContactAgent
2523
from agent_executor import ContactAgentExecutor
2624
from dotenv import load_dotenv
@@ -50,44 +48,18 @@ def main(host, port):
5048
" is not TRUE."
5149
)
5250

53-
capabilities = AgentCapabilities(
54-
streaming=True,
55-
extensions=[get_a2ui_agent_extension()],
56-
)
57-
skill = AgentSkill(
58-
id="find_contact",
59-
name="Find Contact Tool",
60-
description=(
61-
"Helps find contact information for colleagues (e.g., email, location,"
62-
" team)."
63-
),
64-
tags=["contact", "directory", "people", "finder"],
65-
examples=["Who is David Chen in marketing?", "Find Sarah Lee from engineering"],
66-
)
67-
6851
base_url = f"http://{host}:{port}"
52+
ui_agent = ContactAgent(base_url=base_url, use_ui=True)
53+
text_agent = ContactAgent(base_url=base_url, use_ui=False)
6954

70-
agent_card = AgentCard(
71-
name="Contact Lookup Agent",
72-
description=(
73-
"This agent helps find contact info for people in your organization."
74-
),
75-
url=base_url, # <-- Use base_url here
76-
version="1.0.0",
77-
default_input_modes=ContactAgent.SUPPORTED_CONTENT_TYPES,
78-
default_output_modes=ContactAgent.SUPPORTED_CONTENT_TYPES,
79-
capabilities=capabilities,
80-
skills=[skill],
81-
)
82-
83-
agent_executor = ContactAgentExecutor(base_url=base_url)
55+
agent_executor = ContactAgentExecutor(ui_agent=ui_agent, text_agent=text_agent)
8456

8557
request_handler = DefaultRequestHandler(
8658
agent_executor=agent_executor,
8759
task_store=InMemoryTaskStore(),
8860
)
8961
server = A2AStarletteApplication(
90-
agent_card=agent_card, http_handler=request_handler
62+
agent_card=ui_agent.get_agent_card(), http_handler=request_handler
9163
)
9264
import uvicorn
9365

samples/agent/adk/contact_lookup/a2ui_examples.py

Lines changed: 0 additions & 162 deletions
This file was deleted.

0 commit comments

Comments
 (0)