File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed
Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 11"""Client-side components for interacting with an A2A agent."""
22
3+ import logging
4+
35from a2a .client .auth import (
46 AuthInterceptor ,
57 CredentialService ,
1214 A2AClientJSONError ,
1315 A2AClientTimeoutError ,
1416)
15- from a2a .client .grpc_client import A2AGrpcClient
1617from a2a .client .helpers import create_text_message_object
1718from a2a .client .middleware import ClientCallContext , ClientCallInterceptor
1819
1920
21+ logger = logging .getLogger (__name__ )
22+
23+ try :
24+ from a2a .client .grpc_client import A2AGrpcClient # type: ignore
25+ except ImportError as e :
26+ _original_error = e
27+ logger .debug (
28+ 'A2AGrpcClient not loaded. This is expected if gRPC dependencies are not installed. Error: %s' ,
29+ _original_error ,
30+ )
31+
32+ class A2AGrpcClient : # type: ignore
33+ """Placeholder for A2AGrpcClient when dependencies are not installed."""
34+
35+ def __init__ (self , * args , ** kwargs ):
36+ raise ImportError (
37+ 'To use A2AGrpcClient, its dependencies must be installed. '
38+ 'You can install them with \' pip install "a2a-sdk[grpc]"\' '
39+ ) from _original_error
40+
41+
2042__all__ = [
2143 'A2ACardResolver' ,
2244 'A2AClient' ,
Original file line number Diff line number Diff line change 22
33from collections .abc import AsyncGenerator
44
5- import grpc
5+
6+ try :
7+ import grpc
8+ except ImportError as e :
9+ raise ImportError (
10+ 'A2AGrpcClient requires grpcio and grpcio-tools to be installed. '
11+ 'Install with: '
12+ "'pip install a2a-sdk[grpc]'"
13+ ) from e
14+
615
716from a2a .grpc import a2a_pb2 , a2a_pb2_grpc
817from a2a .types import (
Original file line number Diff line number Diff line change 2323 _original_error = e
2424 logger .debug (
2525 'GrpcHandler not loaded. This is expected if gRPC dependencies are not installed. Error: %s' ,
26+ _original_error ,
2627 )
2728
2829 class GrpcHandler : # type: ignore
You can’t perform that action at this time.
0 commit comments