|
19 | 19 | from a2a.server.apps import A2AStarletteApplication |
20 | 20 | from a2a.server.request_handlers import DefaultRequestHandler |
21 | 21 | 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 |
24 | 22 | from agent import ContactAgent |
25 | 23 | from agent_executor import ContactAgentExecutor |
26 | 24 | from dotenv import load_dotenv |
@@ -49,39 +47,19 @@ def main(host, port): |
49 | 47 | "GEMINI_API_KEY environment variable not set and GOOGLE_GENAI_USE_VERTEXAI is not TRUE." |
50 | 48 | ) |
51 | 49 |
|
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 | | - ) |
63 | 50 |
|
64 | 51 | 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) |
65 | 54 |
|
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) |
78 | 56 |
|
79 | 57 | request_handler = DefaultRequestHandler( |
80 | 58 | agent_executor=agent_executor, |
81 | 59 | task_store=InMemoryTaskStore(), |
82 | 60 | ) |
83 | 61 | server = A2AStarletteApplication( |
84 | | - agent_card=agent_card, http_handler=request_handler |
| 62 | + agent_card=ui_agent.get_agent_card(), http_handler=request_handler |
85 | 63 | ) |
86 | 64 | import uvicorn |
87 | 65 |
|
|
0 commit comments