|
26 | 26 | 'BuiltInCodeExecutor',
|
27 | 27 | 'CodeExecutorContext',
|
28 | 28 | 'UnsafeLocalCodeExecutor',
|
| 29 | + 'VertexAiCodeExecutor', |
| 30 | + 'ContainerCodeExecutor', |
29 | 31 | ]
|
30 | 32 |
|
31 |
| -try: |
32 |
| - from .vertex_ai_code_executor import VertexAiCodeExecutor |
33 |
| - |
34 |
| - __all__.append('VertexAiCodeExecutor') |
35 |
| -except ImportError: |
36 |
| - logger.debug( |
37 |
| - 'The Vertex sdk is not installed. If you want to use the Vertex Code' |
38 |
| - ' Interpreter with agents, please install it. If not, you can ignore this' |
39 |
| - ' warning.' |
40 |
| - ) |
41 |
| - |
42 |
| -try: |
43 |
| - from .container_code_executor import ContainerCodeExecutor |
44 |
| - |
45 |
| - __all__.append('ContainerCodeExecutor') |
46 |
| -except ImportError: |
47 |
| - logger.debug( |
48 |
| - 'The docker sdk is not installed. If you want to use the Container Code' |
49 |
| - ' Executor with agents, please install it. If not, you can ignore this' |
50 |
| - ' warning.' |
51 |
| - ) |
| 33 | + |
| 34 | +def __getattr__(name: str): |
| 35 | + if name == 'VertexAiCodeExecutor': |
| 36 | + try: |
| 37 | + from .vertex_ai_code_executor import VertexAiCodeExecutor |
| 38 | + |
| 39 | + return VertexAiCodeExecutor |
| 40 | + except ImportError as e: |
| 41 | + raise ImportError( |
| 42 | + 'VertexAiCodeExecutor requires additional dependencies. ' |
| 43 | + 'Please install with: pip install "google-adk[extensions]"' |
| 44 | + ) from e |
| 45 | + elif name == 'ContainerCodeExecutor': |
| 46 | + try: |
| 47 | + from .container_code_executor import ContainerCodeExecutor |
| 48 | + |
| 49 | + return ContainerCodeExecutor |
| 50 | + except ImportError as e: |
| 51 | + raise ImportError( |
| 52 | + 'ContainerCodeExecutor requires additional dependencies. ' |
| 53 | + 'Please install with: pip install "google-adk[extensions]"' |
| 54 | + ) from e |
| 55 | + raise AttributeError(f"module '{__name__}' has no attribute '{name}'") |
0 commit comments