|
9 | 9 | from a2a.client.jsonrpc_client import NewJsonRpcClient |
10 | 10 | from a2a.client.middleware import ClientCallInterceptor |
11 | 11 | from a2a.client.rest_client import NewRestfulClient |
12 | | -from a2a.types import AgentCapabilities, AgentCard, AgentInterface |
13 | | -from a2a.utils import Transports |
| 12 | +from a2a.types import ( |
| 13 | + AgentCapabilities, |
| 14 | + AgentCard, |
| 15 | + AgentInterface, |
| 16 | + TransportProtocol, |
| 17 | +) |
14 | 18 |
|
15 | 19 |
|
16 | 20 | logger = logging.getLogger(__name__) |
@@ -54,12 +58,12 @@ def __init__( |
54 | 58 | self._registry: dict[str, ClientProducer] = {} |
55 | 59 | # By default register the 3 core transports if in the config. |
56 | 60 | # Can be overridden with custom clients via the register method. |
57 | | - if Transports.JSONRPC in self._config.supported_transports: |
58 | | - self._registry[Transports.JSONRPC] = NewJsonRpcClient |
59 | | - if Transports.RESTful in self._config.supported_transports: |
60 | | - self._registry[Transports.RESTful] = NewRestfulClient |
61 | | - if Transports.GRPC in self._config.supported_transports: |
62 | | - self._registry[Transports.GRPC] = NewGrpcClient |
| 61 | + if TransportProtocol.jsonrpc in self._config.supported_transports: |
| 62 | + self._registry[TransportProtocol.jsonrpc] = NewJsonRpcClient |
| 63 | + if TransportProtocol.http_json in self._config.supported_transports: |
| 64 | + self._registry[TransportProtocol.http_json] = NewRestfulClient |
| 65 | + if TransportProtocol.grpc in self._config.supported_transports: |
| 66 | + self._registry[TransportProtocol.grpc] = NewGrpcClient |
63 | 67 |
|
64 | 68 | def register(self, label: str, generator: ClientProducer) -> None: |
65 | 69 | """Register a new client producer for a given transport label.""" |
@@ -88,10 +92,12 @@ def create( |
88 | 92 | server configuration, a `ValueError` is raised. |
89 | 93 | """ |
90 | 94 | # Determine preferential transport |
91 | | - server_set = [card.preferred_transport or 'JSONRPC'] |
| 95 | + server_set = [card.preferred_transport or TransportProtocol.jsonrpc] |
92 | 96 | if card.additional_interfaces: |
93 | 97 | server_set.extend([x.transport for x in card.additional_interfaces]) |
94 | | - client_set = self._config.supported_transports or ['JSONRPC'] |
| 98 | + client_set = self._config.supported_transports or [ |
| 99 | + TransportProtocol.jsonrpc |
| 100 | + ] |
95 | 101 | transport = None |
96 | 102 | # Two options, use the client ordering or the server ordering. |
97 | 103 | if self._config.use_client_preference: |
|
0 commit comments