@@ -48,27 +48,22 @@ def __init__(
4848 extended_agent_card = extended_agent_card ,
4949 context_builder = context_builder ,
5050 )
51-
52- def build (
53- self ,
51+
52+ def add_routes_to_app (
53+ self ,
54+ app : FastAPI ,
5455 agent_card_url : str = '/.well-known/agent.json' ,
5556 rpc_url : str = '/' ,
56- extended_agent_card_url : str = '/agent/authenticatedExtendedCard' ,
57- ** kwargs : Any ,
58- ) -> FastAPI :
59- """Builds and returns the FastAPI application instance.
57+ extended_agent_card_url : str = '/agent/authenticatedExtendedCard'
58+ ):
59+ """Adds the routes to the FastAPI application.
6060
6161 Args:
62+ app: The FastAPI application to add the routes to.
6263 agent_card_url: The URL for the agent card endpoint.
63- rpc_url: The URL for the A2A JSON-RPC endpoint.
64+ rpc_url: The URL for the A2A JSON-RPC endpoint.
6465 extended_agent_card_url: The URL for the authenticated extended agent card endpoint.
65- **kwargs: Additional keyword arguments to pass to the FastAPI constructor.
66-
67- Returns:
68- A configured FastAPI application instance.
6966 """
70- app = FastAPI (** kwargs )
71-
7267 @app .post (rpc_url )
7368 async def handle_a2a_request (request : Request ) -> Response :
7469 return await self ._handle_requests (request )
@@ -84,5 +79,26 @@ async def get_extended_agent_card(request: Request) -> Response:
8479 return await self ._handle_get_authenticated_extended_agent_card (
8580 request
8681 )
82+ def build (
83+ self ,
84+ agent_card_url : str = '/.well-known/agent.json' ,
85+ rpc_url : str = '/' ,
86+ extended_agent_card_url : str = '/agent/authenticatedExtendedCard' ,
87+ ** kwargs : Any ,
88+ ) -> FastAPI :
89+ """Builds and returns the FastAPI application instance.
90+
91+ Args:
92+ agent_card_url: The URL for the agent card endpoint.
93+ rpc_url: The URL for the A2A JSON-RPC endpoint.
94+ extended_agent_card_url: The URL for the authenticated extended agent card endpoint.
95+ **kwargs: Additional keyword arguments to pass to the FastAPI constructor.
96+
97+ Returns:
98+ A configured FastAPI application instance.
99+ """
100+ app = FastAPI (** kwargs )
101+
102+ self .add_routes_to_app (app , agent_card_url , rpc_url , extended_agent_card_url )
87103
88104 return app
0 commit comments