Skip to content

Commit 27ce68e

Browse files
add-fastapi-application
1 parent 1da4b3b commit 27ce68e

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

src/a2a/server/apps/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from a2a.server.apps.http_app import HttpApp
21
from a2a.server.apps.default_app import DefaultA2AApplication
3-
from a2a.server.apps.starlette_app import A2AStarletteApplication
42
from a2a.server.apps.fastapi_app import A2AFastAPIApplication
3+
from a2a.server.apps.http_app import HttpApp
4+
from a2a.server.apps.starlette_app import A2AStarletteApplication
55

66

77
__all__ = [
8+
'A2AFastAPIApplication',
9+
'A2AStarletteApplication',
810
'DefaultA2AApplication',
9-
'A2AStarletteApplication',
10-
'A2AFastAPIApplication',
11-
'HttpApp'
11+
'HttpApp',
1212
]

src/a2a/server/apps/default_app.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import json
22
import logging
33
import traceback
4-
from abc import ABC, abstractmethod
54

5+
from abc import ABC, abstractmethod
66
from collections.abc import AsyncGenerator
7-
from typing import Any, Optional, Union
7+
from typing import Any
88

9+
from fastapi import FastAPI
910
from pydantic import ValidationError
1011
from sse_starlette.sse import EventSourceResponse
1112
from starlette.applications import Starlette
12-
from fastapi import FastAPI
1313
from starlette.requests import Request
1414
from starlette.responses import JSONResponse, Response
1515

@@ -39,6 +39,7 @@
3939
)
4040
from a2a.utils.errors import MethodNotImplementedError
4141

42+
4243
logger = logging.getLogger(__name__)
4344

4445

@@ -258,7 +259,7 @@ def build(
258259
agent_card_url: str = '/.well-known/agent.json',
259260
rpc_url: str = '/',
260261
**kwargs: Any,
261-
) -> Union[Starlette, FastAPI]:
262+
) -> Starlette | FastAPI:
262263
"""Builds and returns the FastAPI application instance.
263264
264265
Args:
@@ -269,4 +270,3 @@ def build(
269270
Returns:
270271
A configured FastAPI application instance.
271272
"""
272-
pass

src/a2a/server/apps/fastapi_app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
23
from typing import Any
34

45
from fastapi import FastAPI, Request
@@ -7,6 +8,7 @@
78
from a2a.server.request_handlers.jsonrpc_handler import RequestHandler
89
from a2a.types import AgentCard
910

11+
1012
logger = logging.getLogger(__name__)
1113

1214

@@ -15,7 +17,8 @@ class A2AFastAPIApplication(DefaultA2AApplication):
1517
1618
Handles incoming JSON-RPC requests, routes them to the appropriate
1719
handler methods, and manages response generation including Server-Sent Events
18-
(SSE)."""
20+
(SSE).
21+
"""
1922

2023
def __init__(self, agent_card: AgentCard, http_handler: RequestHandler):
2124
"""Initializes the A2A FastAPI application.

src/a2a/server/apps/starlette_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def routes(
5959
name='agent_card',
6060
),
6161
]
62-
62+
6363
def build(
6464
self,
6565
agent_card_url: str = '/.well-known/agent.json',

0 commit comments

Comments
 (0)