google-adk 0.5.0__py3-none-any.whl → 1.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. google/adk/agents/base_agent.py +76 -30
  2. google/adk/agents/callback_context.py +2 -6
  3. google/adk/agents/llm_agent.py +122 -30
  4. google/adk/agents/loop_agent.py +1 -1
  5. google/adk/agents/parallel_agent.py +7 -0
  6. google/adk/agents/readonly_context.py +8 -0
  7. google/adk/agents/run_config.py +1 -1
  8. google/adk/agents/sequential_agent.py +31 -0
  9. google/adk/agents/transcription_entry.py +4 -2
  10. google/adk/artifacts/gcs_artifact_service.py +1 -1
  11. google/adk/artifacts/in_memory_artifact_service.py +1 -1
  12. google/adk/auth/auth_credential.py +10 -2
  13. google/adk/auth/auth_preprocessor.py +7 -1
  14. google/adk/auth/auth_tool.py +3 -4
  15. google/adk/cli/agent_graph.py +5 -5
  16. google/adk/cli/browser/index.html +4 -4
  17. google/adk/cli/browser/{main-ULN5R5I5.js → main-PKDNKWJE.js} +59 -60
  18. google/adk/cli/browser/polyfills-B6TNHZQ6.js +17 -0
  19. google/adk/cli/cli.py +10 -9
  20. google/adk/cli/cli_deploy.py +7 -2
  21. google/adk/cli/cli_eval.py +109 -115
  22. google/adk/cli/cli_tools_click.py +179 -67
  23. google/adk/cli/fast_api.py +248 -197
  24. google/adk/cli/utils/agent_loader.py +137 -0
  25. google/adk/cli/utils/cleanup.py +40 -0
  26. google/adk/cli/utils/common.py +23 -0
  27. google/adk/cli/utils/evals.py +83 -0
  28. google/adk/cli/utils/logs.py +8 -5
  29. google/adk/code_executors/__init__.py +3 -1
  30. google/adk/code_executors/built_in_code_executor.py +52 -0
  31. google/adk/code_executors/code_execution_utils.py +2 -1
  32. google/adk/code_executors/container_code_executor.py +0 -1
  33. google/adk/code_executors/vertex_ai_code_executor.py +6 -8
  34. google/adk/evaluation/__init__.py +1 -1
  35. google/adk/evaluation/agent_evaluator.py +168 -128
  36. google/adk/evaluation/eval_case.py +104 -0
  37. google/adk/evaluation/eval_metrics.py +74 -0
  38. google/adk/evaluation/eval_result.py +86 -0
  39. google/adk/evaluation/eval_set.py +39 -0
  40. google/adk/evaluation/eval_set_results_manager.py +47 -0
  41. google/adk/evaluation/eval_sets_manager.py +43 -0
  42. google/adk/evaluation/evaluation_generator.py +88 -113
  43. google/adk/evaluation/evaluator.py +58 -0
  44. google/adk/evaluation/local_eval_set_results_manager.py +113 -0
  45. google/adk/evaluation/local_eval_sets_manager.py +264 -0
  46. google/adk/evaluation/response_evaluator.py +106 -1
  47. google/adk/evaluation/trajectory_evaluator.py +84 -2
  48. google/adk/events/event.py +6 -1
  49. google/adk/events/event_actions.py +6 -1
  50. google/adk/examples/base_example_provider.py +1 -0
  51. google/adk/examples/example_util.py +3 -2
  52. google/adk/flows/llm_flows/_code_execution.py +9 -1
  53. google/adk/flows/llm_flows/audio_transcriber.py +4 -3
  54. google/adk/flows/llm_flows/base_llm_flow.py +58 -21
  55. google/adk/flows/llm_flows/contents.py +3 -1
  56. google/adk/flows/llm_flows/functions.py +9 -8
  57. google/adk/flows/llm_flows/instructions.py +18 -80
  58. google/adk/flows/llm_flows/single_flow.py +2 -2
  59. google/adk/memory/__init__.py +1 -1
  60. google/adk/memory/_utils.py +23 -0
  61. google/adk/memory/base_memory_service.py +23 -21
  62. google/adk/memory/in_memory_memory_service.py +57 -25
  63. google/adk/memory/memory_entry.py +37 -0
  64. google/adk/memory/vertex_ai_rag_memory_service.py +38 -15
  65. google/adk/models/anthropic_llm.py +16 -9
  66. google/adk/models/base_llm.py +2 -1
  67. google/adk/models/base_llm_connection.py +2 -0
  68. google/adk/models/gemini_llm_connection.py +11 -11
  69. google/adk/models/google_llm.py +12 -2
  70. google/adk/models/lite_llm.py +80 -23
  71. google/adk/models/llm_response.py +16 -3
  72. google/adk/models/registry.py +1 -1
  73. google/adk/runners.py +98 -42
  74. google/adk/sessions/__init__.py +1 -1
  75. google/adk/sessions/_session_util.py +2 -1
  76. google/adk/sessions/base_session_service.py +6 -33
  77. google/adk/sessions/database_session_service.py +57 -67
  78. google/adk/sessions/in_memory_session_service.py +106 -24
  79. google/adk/sessions/session.py +3 -0
  80. google/adk/sessions/vertex_ai_session_service.py +44 -51
  81. google/adk/telemetry.py +7 -2
  82. google/adk/tools/__init__.py +4 -7
  83. google/adk/tools/_memory_entry_utils.py +30 -0
  84. google/adk/tools/agent_tool.py +10 -10
  85. google/adk/tools/apihub_tool/apihub_toolset.py +55 -74
  86. google/adk/tools/apihub_tool/clients/apihub_client.py +10 -3
  87. google/adk/tools/apihub_tool/clients/secret_client.py +1 -0
  88. google/adk/tools/application_integration_tool/application_integration_toolset.py +111 -85
  89. google/adk/tools/application_integration_tool/clients/connections_client.py +28 -1
  90. google/adk/tools/application_integration_tool/clients/integration_client.py +7 -5
  91. google/adk/tools/application_integration_tool/integration_connector_tool.py +69 -26
  92. google/adk/tools/base_toolset.py +96 -0
  93. google/adk/tools/bigquery/__init__.py +28 -0
  94. google/adk/tools/bigquery/bigquery_credentials.py +216 -0
  95. google/adk/tools/bigquery/bigquery_tool.py +116 -0
  96. google/adk/tools/{built_in_code_execution_tool.py → enterprise_search_tool.py} +17 -11
  97. google/adk/tools/function_parameter_parse_util.py +9 -2
  98. google/adk/tools/function_tool.py +33 -3
  99. google/adk/tools/get_user_choice_tool.py +1 -0
  100. google/adk/tools/google_api_tool/__init__.py +24 -70
  101. google/adk/tools/google_api_tool/google_api_tool.py +12 -6
  102. google/adk/tools/google_api_tool/{google_api_tool_set.py → google_api_toolset.py} +57 -55
  103. google/adk/tools/google_api_tool/google_api_toolsets.py +108 -0
  104. google/adk/tools/google_api_tool/googleapi_to_openapi_converter.py +40 -42
  105. google/adk/tools/google_search_tool.py +2 -2
  106. google/adk/tools/langchain_tool.py +96 -49
  107. google/adk/tools/load_memory_tool.py +14 -5
  108. google/adk/tools/mcp_tool/__init__.py +3 -2
  109. google/adk/tools/mcp_tool/conversion_utils.py +6 -2
  110. google/adk/tools/mcp_tool/mcp_session_manager.py +80 -69
  111. google/adk/tools/mcp_tool/mcp_tool.py +35 -32
  112. google/adk/tools/mcp_tool/mcp_toolset.py +99 -194
  113. google/adk/tools/openapi_tool/auth/credential_exchangers/base_credential_exchanger.py +1 -3
  114. google/adk/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.py +6 -7
  115. google/adk/tools/openapi_tool/common/common.py +5 -1
  116. google/adk/tools/openapi_tool/openapi_spec_parser/__init__.py +7 -2
  117. google/adk/tools/openapi_tool/openapi_spec_parser/openapi_toolset.py +27 -7
  118. google/adk/tools/openapi_tool/openapi_spec_parser/operation_parser.py +36 -32
  119. google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py +11 -1
  120. google/adk/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.py +1 -1
  121. google/adk/tools/preload_memory_tool.py +27 -18
  122. google/adk/tools/retrieval/__init__.py +1 -1
  123. google/adk/tools/retrieval/vertex_ai_rag_retrieval.py +1 -1
  124. google/adk/tools/toolbox_toolset.py +107 -0
  125. google/adk/tools/transfer_to_agent_tool.py +0 -1
  126. google/adk/utils/__init__.py +13 -0
  127. google/adk/utils/instructions_utils.py +131 -0
  128. google/adk/version.py +1 -1
  129. {google_adk-0.5.0.dist-info → google_adk-1.1.0.dist-info}/METADATA +18 -19
  130. google_adk-1.1.0.dist-info/RECORD +200 -0
  131. google/adk/agents/remote_agent.py +0 -50
  132. google/adk/cli/browser/polyfills-FFHMD2TL.js +0 -18
  133. google/adk/cli/fast_api.py.orig +0 -728
  134. google/adk/tools/google_api_tool/google_api_tool_sets.py +0 -112
  135. google/adk/tools/toolbox_tool.py +0 -46
  136. google_adk-0.5.0.dist-info/RECORD +0 -180
  137. {google_adk-0.5.0.dist-info → google_adk-1.1.0.dist-info}/WHEEL +0 -0
  138. {google_adk-0.5.0.dist-info → google_adk-1.1.0.dist-info}/entry_points.txt +0 -0
  139. {google_adk-0.5.0.dist-info → google_adk-1.1.0.dist-info}/licenses/LICENSE +0 -0
@@ -35,7 +35,7 @@ _py_builtin_type_to_schema_type = {
35
35
  dict: types.Type.OBJECT,
36
36
  }
37
37
 
38
- logger = logging.getLogger(__name__)
38
+ logger = logging.getLogger('google_adk.' + __name__)
39
39
 
40
40
 
41
41
  def _is_builtin_primitive_or_compound(
@@ -289,10 +289,17 @@ def _parse_schema_from_parameter(
289
289
  )
290
290
  _raise_if_schema_unsupported(variant, schema)
291
291
  return schema
292
+ if param.annotation is None:
293
+ # https://swagger.io/docs/specification/v3_0/data-models/data-types/#null
294
+ # null is not a valid type in schema, use object instead.
295
+ schema.type = types.Type.OBJECT
296
+ schema.nullable = True
297
+ _raise_if_schema_unsupported(variant, schema)
298
+ return schema
292
299
  raise ValueError(
293
300
  f'Failed to parse the parameter {param} of function {func_name} for'
294
301
  ' automatic function calling. Automatic function calling works best with'
295
- ' simpler function signature schema,consider manually parse your'
302
+ ' simpler function signature schema, consider manually parsing your'
296
303
  f' function declaration for function {func_name}.'
297
304
  )
298
305
 
@@ -33,8 +33,31 @@ class FunctionTool(BaseTool):
33
33
  """
34
34
 
35
35
  def __init__(self, func: Callable[..., Any]):
36
- super().__init__(name=func.__name__, description=func.__doc__)
36
+ """Extract metadata from a callable object."""
37
+ name = ''
38
+ doc = ''
39
+ # Handle different types of callables
40
+ if hasattr(func, '__name__'):
41
+ # Regular functions, unbound methods, etc.
42
+ name = func.__name__
43
+ elif hasattr(func, '__class__'):
44
+ # Callable objects, bound methods, etc.
45
+ name = func.__class__.__name__
46
+
47
+ # Get documentation (prioritize direct __doc__ if available)
48
+ if hasattr(func, '__doc__') and func.__doc__:
49
+ doc = func.__doc__
50
+ elif (
51
+ hasattr(func, '__call__')
52
+ and hasattr(func.__call__, '__doc__')
53
+ and func.__call__.__doc__
54
+ ):
55
+ # For callable objects, try to get docstring from __call__ method
56
+ doc = func.__call__.__doc__
57
+
58
+ super().__init__(name=name, description=doc)
37
59
  self.func = func
60
+ self._ignore_params = ['tool_context', 'input_stream']
38
61
 
39
62
  @override
40
63
  def _get_declaration(self) -> Optional[types.FunctionDeclaration]:
@@ -43,7 +66,7 @@ class FunctionTool(BaseTool):
43
66
  func=self.func,
44
67
  # The model doesn't understand the function context.
45
68
  # input_stream is for streaming tool
46
- ignore_params=['tool_context', 'input_stream'],
69
+ ignore_params=self._ignore_params,
47
70
  variant=self._api_variant,
48
71
  )
49
72
  )
@@ -76,7 +99,14 @@ class FunctionTool(BaseTool):
76
99
  You could retry calling this tool, but it is IMPORTANT for you to provide all the mandatory parameters."""
77
100
  return {'error': error_str}
78
101
 
79
- if inspect.iscoroutinefunction(self.func):
102
+ # Functions are callable objects, but not all callable objects are functions
103
+ # checking coroutine function is not enough. We also need to check whether
104
+ # Callable's __call__ function is a coroutine funciton
105
+ if (
106
+ inspect.iscoroutinefunction(self.func)
107
+ or hasattr(self.func, '__call__')
108
+ and inspect.iscoroutinefunction(self.func.__call__)
109
+ ):
80
110
  return await self.func(**args_to_call) or {}
81
111
  else:
82
112
  return self.func(**args_to_call) or {}
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  from typing import Optional
16
+
16
17
  from .long_running_tool import LongRunningFunctionTool
17
18
  from .tool_context import ToolContext
18
19
 
@@ -11,77 +11,31 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- __all__ = [
15
- 'bigquery_tool_set',
16
- 'calendar_tool_set',
17
- 'gmail_tool_set',
18
- 'youtube_tool_set',
19
- 'slides_tool_set',
20
- 'sheets_tool_set',
21
- 'docs_tool_set',
22
- ]
23
-
24
- # Nothing is imported here automatically
25
- # Each tool set will only be imported when accessed
26
-
27
- _bigquery_tool_set = None
28
- _calendar_tool_set = None
29
- _gmail_tool_set = None
30
- _youtube_tool_set = None
31
- _slides_tool_set = None
32
- _sheets_tool_set = None
33
- _docs_tool_set = None
34
-
35
-
36
- def __getattr__(name):
37
- global _bigquery_tool_set, _calendar_tool_set, _gmail_tool_set, _youtube_tool_set, _slides_tool_set, _sheets_tool_set, _docs_tool_set
38
-
39
- match name:
40
- case 'bigquery_tool_set':
41
- if _bigquery_tool_set is None:
42
- from .google_api_tool_sets import bigquery_tool_set as bigquery
43
-
44
- _bigquery_tool_set = bigquery
45
- return _bigquery_tool_set
46
-
47
- case 'calendar_tool_set':
48
- if _calendar_tool_set is None:
49
- from .google_api_tool_sets import calendar_tool_set as calendar
50
14
 
51
- _calendar_tool_set = calendar
52
- return _calendar_tool_set
15
+ """Auto-generated tools and toolsets for Google APIs.
53
16
 
54
- case 'gmail_tool_set':
55
- if _gmail_tool_set is None:
56
- from .google_api_tool_sets import gmail_tool_set as gmail
17
+ These tools and toolsets are auto-generated based on the API specifications
18
+ provided by the Google API Discovery API.
19
+ """
57
20
 
58
- _gmail_tool_set = gmail
59
- return _gmail_tool_set
21
+ from .google_api_tool import GoogleApiTool
22
+ from .google_api_toolset import GoogleApiToolset
23
+ from .google_api_toolsets import BigQueryToolset
24
+ from .google_api_toolsets import CalendarToolset
25
+ from .google_api_toolsets import DocsToolset
26
+ from .google_api_toolsets import GmailToolset
27
+ from .google_api_toolsets import SheetsToolset
28
+ from .google_api_toolsets import SlidesToolset
29
+ from .google_api_toolsets import YoutubeToolset
60
30
 
61
- case 'youtube_tool_set':
62
- if _youtube_tool_set is None:
63
- from .google_api_tool_sets import youtube_tool_set as youtube
64
-
65
- _youtube_tool_set = youtube
66
- return _youtube_tool_set
67
-
68
- case 'slides_tool_set':
69
- if _slides_tool_set is None:
70
- from .google_api_tool_sets import slides_tool_set as slides
71
-
72
- _slides_tool_set = slides
73
- return _slides_tool_set
74
-
75
- case 'sheets_tool_set':
76
- if _sheets_tool_set is None:
77
- from .google_api_tool_sets import sheets_tool_set as sheets
78
-
79
- _sheets_tool_set = sheets
80
- return _sheets_tool_set
81
-
82
- case 'docs_tool_set':
83
- if _docs_tool_set is None:
84
- from .google_api_tool_sets import docs_tool_set as docs
85
-
86
- _docs_tool_set = docs
87
- return _docs_tool_set
31
+ __all__ = [
32
+ 'BigQueryToolset',
33
+ 'CalendarToolset',
34
+ 'GmailToolset',
35
+ 'YoutubeToolset',
36
+ 'SlidesToolset',
37
+ 'SheetsToolset',
38
+ 'DocsToolset',
39
+ 'GoogleApiToolset',
40
+ 'GoogleApiTool',
41
+ ]
@@ -19,38 +19,44 @@ from typing import Optional
19
19
  from google.genai.types import FunctionDeclaration
20
20
  from typing_extensions import override
21
21
 
22
+ from .. import BaseTool
22
23
  from ...auth import AuthCredential
23
24
  from ...auth import AuthCredentialTypes
24
25
  from ...auth import OAuth2Auth
25
- from .. import BaseTool
26
26
  from ..openapi_tool import RestApiTool
27
27
  from ..tool_context import ToolContext
28
28
 
29
29
 
30
30
  class GoogleApiTool(BaseTool):
31
31
 
32
- def __init__(self, rest_api_tool: RestApiTool):
32
+ def __init__(
33
+ self,
34
+ rest_api_tool: RestApiTool,
35
+ client_id: Optional[str] = None,
36
+ client_secret: Optional[str] = None,
37
+ ):
33
38
  super().__init__(
34
39
  name=rest_api_tool.name,
35
40
  description=rest_api_tool.description,
36
41
  is_long_running=rest_api_tool.is_long_running,
37
42
  )
38
- self.rest_api_tool = rest_api_tool
43
+ self._rest_api_tool = rest_api_tool
44
+ self.configure_auth(client_id, client_secret)
39
45
 
40
46
  @override
41
47
  def _get_declaration(self) -> FunctionDeclaration:
42
- return self.rest_api_tool._get_declaration()
48
+ return self._rest_api_tool._get_declaration()
43
49
 
44
50
  @override
45
51
  async def run_async(
46
52
  self, *, args: dict[str, Any], tool_context: Optional[ToolContext]
47
53
  ) -> Dict[str, Any]:
48
- return await self.rest_api_tool.run_async(
54
+ return await self._rest_api_tool.run_async(
49
55
  args=args, tool_context=tool_context
50
56
  )
51
57
 
52
58
  def configure_auth(self, client_id: str, client_secret: str):
53
- self.rest_api_tool.auth_credential = AuthCredential(
59
+ self._rest_api_tool.auth_credential = AuthCredential(
54
60
  auth_type=AuthCredentialTypes.OPEN_ID_CONNECT,
55
61
  oauth2=OAuth2Auth(
56
62
  client_id=client_id,
@@ -17,56 +17,72 @@ from __future__ import annotations
17
17
  import inspect
18
18
  import os
19
19
  from typing import Any
20
- from typing import Final
21
20
  from typing import List
22
21
  from typing import Optional
23
22
  from typing import Type
23
+ from typing import Union
24
24
 
25
+ from typing_extensions import override
26
+
27
+ from ...agents.readonly_context import ReadonlyContext
25
28
  from ...auth import OpenIdConnectWithConfig
29
+ from ...tools.base_toolset import BaseToolset
30
+ from ...tools.base_toolset import ToolPredicate
26
31
  from ..openapi_tool import OpenAPIToolset
27
- from ..openapi_tool import RestApiTool
28
32
  from .google_api_tool import GoogleApiTool
29
33
  from .googleapi_to_openapi_converter import GoogleApiToOpenApiConverter
30
34
 
31
35
 
32
- class GoogleApiToolSet:
33
- """Google API Tool Set."""
36
+ class GoogleApiToolset(BaseToolset):
37
+ """Google API Toolset contains tools for interacting with Google APIs.
34
38
 
35
- def __init__(self, tools: List[RestApiTool]):
36
- self.tools: Final[List[GoogleApiTool]] = [
37
- GoogleApiTool(tool) for tool in tools
38
- ]
39
+ Usually one toolsets will contains tools only related to one Google API, e.g.
40
+ Google Bigquery API toolset will contains tools only related to Google
41
+ Bigquery API, like list dataset tool, list table tool etc.
42
+ """
43
+
44
+ def __init__(
45
+ self,
46
+ api_name: str,
47
+ api_version: str,
48
+ client_id: Optional[str] = None,
49
+ client_secret: Optional[str] = None,
50
+ tool_filter: Optional[Union[ToolPredicate, List[str]]] = None,
51
+ ):
52
+ self.api_name = api_name
53
+ self.api_version = api_version
54
+ self._client_id = client_id
55
+ self._client_secret = client_secret
56
+ self._openapi_toolset = self._load_toolset_with_oidc_auth()
57
+ self.tool_filter = tool_filter
39
58
 
40
- def get_tools(self) -> List[GoogleApiTool]:
59
+ @override
60
+ async def get_tools(
61
+ self, readonly_context: Optional[ReadonlyContext] = None
62
+ ) -> List[GoogleApiTool]:
41
63
  """Get all tools in the toolset."""
42
- return self.tools
64
+ tools = []
43
65
 
44
- def get_tool(self, tool_name: str) -> Optional[GoogleApiTool]:
45
- """Get a tool by name."""
46
- matching_tool = filter(lambda t: t.name == tool_name, self.tools)
47
- return next(matching_tool, None)
66
+ return [
67
+ GoogleApiTool(tool, self._client_id, self._client_secret)
68
+ for tool in await self._openapi_toolset.get_tools(readonly_context)
69
+ if self._is_tool_selected(tool, readonly_context)
70
+ ]
71
+
72
+ def set_tool_filter(self, tool_filter: Union[ToolPredicate, List[str]]):
73
+ self.tool_filter = tool_filter
48
74
 
49
- @staticmethod
50
- def _load_tool_set_with_oidc_auth(
51
- spec_file: Optional[str] = None,
52
- spec_dict: Optional[dict[str, Any]] = None,
53
- scopes: Optional[list[str]] = None,
54
- ) -> OpenAPIToolset:
55
- spec_str = None
56
- if spec_file:
57
- # Get the frame of the caller
58
- caller_frame = inspect.stack()[1]
59
- # Get the filename of the caller
60
- caller_filename = caller_frame.filename
61
- # Get the directory of the caller
62
- caller_dir = os.path.dirname(os.path.abspath(caller_filename))
63
- # Join the directory path with the filename
64
- yaml_path = os.path.join(caller_dir, spec_file)
65
- with open(yaml_path, 'r', encoding='utf-8') as file:
66
- spec_str = file.read()
67
- tool_set = OpenAPIToolset(
75
+ def _load_toolset_with_oidc_auth(self) -> OpenAPIToolset:
76
+ spec_dict = GoogleApiToOpenApiConverter(
77
+ self.api_name, self.api_version
78
+ ).convert()
79
+ scope = list(
80
+ spec_dict['components']['securitySchemes']['oauth2']['flows'][
81
+ 'authorizationCode'
82
+ ]['scopes'].keys()
83
+ )[0]
84
+ return OpenAPIToolset(
68
85
  spec_dict=spec_dict,
69
- spec_str=spec_str,
70
86
  spec_str_type='yaml',
71
87
  auth_scheme=OpenIdConnectWithConfig(
72
88
  authorization_endpoint=(
@@ -82,29 +98,15 @@ class GoogleApiToolSet:
82
98
  'client_secret_basic',
83
99
  ],
84
100
  grant_types_supported=['authorization_code'],
85
- scopes=scopes,
101
+ scopes=[scope],
86
102
  ),
87
103
  )
88
- return tool_set
89
104
 
90
105
  def configure_auth(self, client_id: str, client_secret: str):
91
- for tool in self.tools:
92
- tool.configure_auth(client_id, client_secret)
106
+ self._client_id = client_id
107
+ self._client_secret = client_secret
93
108
 
94
- @classmethod
95
- def load_tool_set(
96
- cls: Type[GoogleApiToolSet],
97
- api_name: str,
98
- api_version: str,
99
- ) -> GoogleApiToolSet:
100
- spec_dict = GoogleApiToOpenApiConverter(api_name, api_version).convert()
101
- scope = list(
102
- spec_dict['components']['securitySchemes']['oauth2']['flows'][
103
- 'authorizationCode'
104
- ]['scopes'].keys()
105
- )[0]
106
- return cls(
107
- cls._load_tool_set_with_oidc_auth(
108
- spec_dict=spec_dict, scopes=[scope]
109
- ).get_tools()
110
- )
109
+ @override
110
+ async def close(self):
111
+ if self._openapi_toolset:
112
+ await self._openapi_toolset.close()
@@ -0,0 +1,108 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ import logging
17
+ from typing import List
18
+ from typing import Optional
19
+ from typing import Union
20
+
21
+ from ..base_toolset import ToolPredicate
22
+ from .google_api_toolset import GoogleApiToolset
23
+
24
+ logger = logging.getLogger("google_adk." + __name__)
25
+
26
+
27
+ class BigQueryToolset(GoogleApiToolset):
28
+ """Auto-generated Bigquery toolset based on Google BigQuery API v2 spec exposed by Google API discovery API"""
29
+
30
+ def __init__(
31
+ self,
32
+ client_id: str = None,
33
+ client_secret: str = None,
34
+ tool_filter: Optional[Union[ToolPredicate, List[str]]] = None,
35
+ ):
36
+ super().__init__("bigquery", "v2", client_id, client_secret, tool_filter)
37
+
38
+
39
+ class CalendarToolset(GoogleApiToolset):
40
+ """Auto-generated Calendar toolset based on Google Calendar API v3 spec exposed by Google API discovery API"""
41
+
42
+ def __init__(
43
+ self,
44
+ client_id: str = None,
45
+ client_secret: str = None,
46
+ tool_filter: Optional[Union[ToolPredicate, List[str]]] = None,
47
+ ):
48
+ super().__init__("calendar", "v3", client_id, client_secret, tool_filter)
49
+
50
+
51
+ class GmailToolset(GoogleApiToolset):
52
+ """Auto-generated Gmail toolset based on Google Gmail API v1 spec exposed by Google API discovery API"""
53
+
54
+ def __init__(
55
+ self,
56
+ client_id: str = None,
57
+ client_secret: str = None,
58
+ tool_filter: Optional[Union[ToolPredicate, List[str]]] = None,
59
+ ):
60
+ super().__init__("gmail", "v1", client_id, client_secret, tool_filter)
61
+
62
+
63
+ class YoutubeToolset(GoogleApiToolset):
64
+ """Auto-generated Youtube toolset based on Youtube API v3 spec exposed by Google API discovery API"""
65
+
66
+ def __init__(
67
+ self,
68
+ client_id: str = None,
69
+ client_secret: str = None,
70
+ tool_filter: Optional[Union[ToolPredicate, List[str]]] = None,
71
+ ):
72
+ super().__init__("youtube", "v3", client_id, client_secret, tool_filter)
73
+
74
+
75
+ class SlidesToolset(GoogleApiToolset):
76
+ """Auto-generated Slides toolset based on Google Slides API v1 spec exposed by Google API discovery API"""
77
+
78
+ def __init__(
79
+ self,
80
+ client_id: str = None,
81
+ client_secret: str = None,
82
+ tool_filter: Optional[Union[ToolPredicate, List[str]]] = None,
83
+ ):
84
+ super().__init__("slides", "v1", client_id, client_secret, tool_filter)
85
+
86
+
87
+ class SheetsToolset(GoogleApiToolset):
88
+ """Auto-generated Sheets toolset based on Google Sheets API v4 spec exposed by Google API discovery API"""
89
+
90
+ def __init__(
91
+ self,
92
+ client_id: str = None,
93
+ client_secret: str = None,
94
+ tool_filter: Optional[Union[ToolPredicate, List[str]]] = None,
95
+ ):
96
+ super().__init__("sheets", "v4", client_id, client_secret, tool_filter)
97
+
98
+
99
+ class DocsToolset(GoogleApiToolset):
100
+ """Auto-generated Docs toolset based on Google Docs API v1 spec exposed by Google API discovery API"""
101
+
102
+ def __init__(
103
+ self,
104
+ client_id: str = None,
105
+ client_secret: str = None,
106
+ tool_filter: Optional[Union[ToolPredicate, List[str]]] = None,
107
+ ):
108
+ super().__init__("docs", "v1", client_id, client_secret, tool_filter)