Skip to content

Commit 90a030f

Browse files
committed
fix sample
1 parent 94ee11d commit 90a030f

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

samples/hello_world_agent.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from a2a.compat.v0_3.grpc_handler import CompatGrpcHandler
1212
from a2a.server.agent_execution.agent_executor import AgentExecutor
1313
from a2a.server.agent_execution.context import RequestContext
14-
from a2a.server.apps import A2AFastAPIApplication, A2ARESTFastAPIApplication
14+
from a2a.server.routes import AgentCardRoutes, JsonRpcRoutes, RestRoutes
1515
from a2a.server.events.event_queue import EventQueue
1616
from a2a.server.request_handlers import GrpcHandler
1717
from a2a.server.request_handlers.default_request_handler import (
@@ -190,22 +190,29 @@ async def serve(
190190
agent_executor=SampleAgentExecutor(), task_store=task_store
191191
)
192192

193-
rest_app_builder = A2ARESTFastAPIApplication(
193+
agent_card_routes = AgentCardRoutes(
194194
agent_card=agent_card,
195-
http_handler=request_handler,
195+
card_url='/.well-known/agent-card.json',
196+
)
197+
# JSON-RPC
198+
jsonrpc_routes = JsonRpcRoutes(
199+
agent_card=agent_card,
200+
request_handler=request_handler,
201+
rpc_url='/a2a/jsonrpc/',
196202
enable_v0_3_compat=True,
197203
)
198-
rest_app = rest_app_builder.build()
199-
200-
jsonrpc_app_builder = A2AFastAPIApplication(
204+
# REST
205+
rest_routes = RestRoutes(
201206
agent_card=agent_card,
202-
http_handler=request_handler,
207+
request_handler=request_handler,
208+
rpc_url='/a2a/rest',
203209
enable_v0_3_compat=True,
204210
)
205211

206212
app = FastAPI()
207-
jsonrpc_app_builder.add_routes_to_app(app, rpc_url='/a2a/jsonrpc/')
208-
app.mount('/a2a/rest', rest_app)
213+
app.routes.extend(agent_card_routes.routes)
214+
app.routes.extend(jsonrpc_routes.routes)
215+
app.routes.extend(rest_routes.routes)
209216

210217
grpc_server = grpc.aio.server()
211218
grpc_server.add_insecure_port(f'{host}:{grpc_port}')

0 commit comments

Comments
 (0)