Skip to content

Commit 557fe78

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 8f7adb5 commit 557fe78

11 files changed

Lines changed: 459 additions & 1087 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:
@@ -326,3 +327,7 @@ def generate_system_prompt(
326327
parts.append(f"### Examples:\n{examples_str}")
327328

328329
return "\n\n".join(parts)
330+
331+
def get_agent_extension(self) -> AgentExtension:
332+
catalog_ids = self.catalog_schemas.keys()
333+
return get_a2ui_agent_extension(supported_catalog_ids=list(catalog_ids))

samples/agent/adk/contact_lookup/__main__.py

Lines changed: 4 additions & 26 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
@@ -49,39 +47,19 @@ def main(host, port):
4947
"GEMINI_API_KEY environment variable not set and GOOGLE_GENAI_USE_VERTEXAI is not TRUE."
5048
)
5149

52-
capabilities = AgentCapabilities(
53-
streaming=True,
54-
extensions=[get_a2ui_agent_extension()],
55-
)
56-
skill = AgentSkill(
57-
id="find_contact",
58-
name="Find Contact Tool",
59-
description="Helps find contact information for colleagues (e.g., email, location, team).",
60-
tags=["contact", "directory", "people", "finder"],
61-
examples=["Who is David Chen in marketing?", "Find Sarah Lee from engineering"],
62-
)
6350

6451
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)
6554

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

7957
request_handler = DefaultRequestHandler(
8058
agent_executor=agent_executor,
8159
task_store=InMemoryTaskStore(),
8260
)
8361
server = A2AStarletteApplication(
84-
agent_card=agent_card, http_handler=request_handler
62+
agent_card=ui_agent.get_agent_card(), http_handler=request_handler
8563
)
8664
import uvicorn
8765

samples/agent/adk/contact_lookup/a2ui_examples.py

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

0 commit comments

Comments
 (0)