google-adk 0.4.0__py3-none-any.whl → 1.0.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.
- google/adk/agents/active_streaming_tool.py +1 -0
- google/adk/agents/base_agent.py +91 -47
- google/adk/agents/base_agent.py.orig +330 -0
- google/adk/agents/callback_context.py +4 -9
- google/adk/agents/invocation_context.py +1 -0
- google/adk/agents/langgraph_agent.py +1 -0
- google/adk/agents/live_request_queue.py +1 -0
- google/adk/agents/llm_agent.py +172 -35
- google/adk/agents/loop_agent.py +1 -1
- google/adk/agents/parallel_agent.py +7 -0
- google/adk/agents/readonly_context.py +7 -1
- google/adk/agents/run_config.py +5 -1
- google/adk/agents/sequential_agent.py +31 -0
- google/adk/agents/transcription_entry.py +5 -2
- google/adk/artifacts/base_artifact_service.py +5 -10
- google/adk/artifacts/gcs_artifact_service.py +9 -9
- google/adk/artifacts/in_memory_artifact_service.py +6 -6
- google/adk/auth/auth_credential.py +9 -5
- google/adk/auth/auth_preprocessor.py +7 -1
- google/adk/auth/auth_tool.py +3 -4
- google/adk/cli/agent_graph.py +5 -5
- google/adk/cli/browser/index.html +2 -2
- google/adk/cli/browser/{main-HWIBUY2R.js → main-QOEMUXM4.js} +58 -58
- google/adk/cli/cli.py +7 -7
- google/adk/cli/cli_deploy.py +7 -2
- google/adk/cli/cli_eval.py +181 -106
- google/adk/cli/cli_tools_click.py +147 -62
- google/adk/cli/fast_api.py +340 -158
- google/adk/cli/fast_api.py.orig +822 -0
- google/adk/cli/utils/common.py +23 -0
- google/adk/cli/utils/evals.py +83 -1
- google/adk/cli/utils/logs.py +13 -5
- google/adk/code_executors/__init__.py +3 -1
- google/adk/code_executors/built_in_code_executor.py +52 -0
- google/adk/evaluation/__init__.py +1 -1
- google/adk/evaluation/agent_evaluator.py +168 -128
- google/adk/evaluation/eval_case.py +102 -0
- google/adk/evaluation/eval_set.py +37 -0
- google/adk/evaluation/eval_sets_manager.py +42 -0
- google/adk/evaluation/evaluation_constants.py +1 -0
- google/adk/evaluation/evaluation_generator.py +89 -114
- google/adk/evaluation/evaluator.py +56 -0
- google/adk/evaluation/local_eval_sets_manager.py +264 -0
- google/adk/evaluation/response_evaluator.py +107 -3
- google/adk/evaluation/trajectory_evaluator.py +83 -2
- google/adk/events/event.py +7 -1
- google/adk/events/event_actions.py +7 -1
- google/adk/examples/example.py +1 -0
- google/adk/examples/example_util.py +3 -2
- google/adk/flows/__init__.py +0 -1
- google/adk/flows/llm_flows/_code_execution.py +19 -11
- google/adk/flows/llm_flows/audio_transcriber.py +4 -3
- google/adk/flows/llm_flows/base_llm_flow.py +86 -22
- google/adk/flows/llm_flows/basic.py +3 -0
- google/adk/flows/llm_flows/functions.py +10 -9
- google/adk/flows/llm_flows/instructions.py +28 -9
- google/adk/flows/llm_flows/single_flow.py +1 -1
- google/adk/memory/__init__.py +1 -1
- google/adk/memory/_utils.py +23 -0
- google/adk/memory/base_memory_service.py +25 -21
- google/adk/memory/base_memory_service.py.orig +76 -0
- google/adk/memory/in_memory_memory_service.py +59 -27
- google/adk/memory/memory_entry.py +37 -0
- google/adk/memory/vertex_ai_rag_memory_service.py +40 -17
- google/adk/models/anthropic_llm.py +36 -11
- google/adk/models/base_llm.py +45 -4
- google/adk/models/gemini_llm_connection.py +15 -2
- google/adk/models/google_llm.py +9 -44
- google/adk/models/google_llm.py.orig +305 -0
- google/adk/models/lite_llm.py +94 -38
- google/adk/models/llm_request.py +1 -1
- google/adk/models/llm_response.py +15 -3
- google/adk/models/registry.py +1 -1
- google/adk/runners.py +68 -44
- google/adk/sessions/__init__.py +1 -1
- google/adk/sessions/_session_util.py +14 -0
- google/adk/sessions/base_session_service.py +8 -32
- google/adk/sessions/database_session_service.py +58 -61
- google/adk/sessions/in_memory_session_service.py +108 -26
- google/adk/sessions/session.py +4 -0
- google/adk/sessions/vertex_ai_session_service.py +23 -45
- google/adk/telemetry.py +3 -0
- google/adk/tools/__init__.py +4 -7
- google/adk/tools/{built_in_code_execution_tool.py → _built_in_code_execution_tool.py} +11 -0
- google/adk/tools/_memory_entry_utils.py +30 -0
- google/adk/tools/agent_tool.py +16 -13
- google/adk/tools/apihub_tool/apihub_toolset.py +55 -74
- google/adk/tools/application_integration_tool/application_integration_toolset.py +107 -85
- google/adk/tools/application_integration_tool/clients/connections_client.py +29 -25
- google/adk/tools/application_integration_tool/clients/integration_client.py +6 -6
- google/adk/tools/application_integration_tool/integration_connector_tool.py +69 -26
- google/adk/tools/base_toolset.py +58 -0
- google/adk/tools/enterprise_search_tool.py +65 -0
- google/adk/tools/function_parameter_parse_util.py +2 -2
- google/adk/tools/google_api_tool/__init__.py +18 -70
- google/adk/tools/google_api_tool/google_api_tool.py +11 -5
- google/adk/tools/google_api_tool/google_api_toolset.py +126 -0
- google/adk/tools/google_api_tool/google_api_toolsets.py +102 -0
- google/adk/tools/google_api_tool/googleapi_to_openapi_converter.py +40 -42
- google/adk/tools/langchain_tool.py +96 -49
- google/adk/tools/load_artifacts_tool.py +4 -4
- google/adk/tools/load_memory_tool.py +16 -5
- google/adk/tools/mcp_tool/__init__.py +3 -2
- google/adk/tools/mcp_tool/conversion_utils.py +1 -1
- google/adk/tools/mcp_tool/mcp_session_manager.py +167 -16
- google/adk/tools/mcp_tool/mcp_session_manager.py.orig +322 -0
- google/adk/tools/mcp_tool/mcp_tool.py +12 -12
- google/adk/tools/mcp_tool/mcp_toolset.py +155 -195
- google/adk/tools/openapi_tool/common/common.py +2 -5
- google/adk/tools/openapi_tool/openapi_spec_parser/openapi_toolset.py +32 -7
- google/adk/tools/openapi_tool/openapi_spec_parser/operation_parser.py +43 -33
- google/adk/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.py +1 -1
- google/adk/tools/preload_memory_tool.py +27 -18
- google/adk/tools/retrieval/__init__.py +1 -1
- google/adk/tools/retrieval/vertex_ai_rag_retrieval.py +1 -1
- google/adk/tools/tool_context.py +4 -4
- google/adk/tools/toolbox_toolset.py +79 -0
- google/adk/tools/transfer_to_agent_tool.py +0 -1
- google/adk/version.py +1 -1
- {google_adk-0.4.0.dist-info → google_adk-1.0.0.dist-info}/METADATA +7 -5
- google_adk-1.0.0.dist-info/RECORD +195 -0
- google/adk/agents/remote_agent.py +0 -50
- google/adk/tools/google_api_tool/google_api_tool_set.py +0 -110
- google/adk/tools/google_api_tool/google_api_tool_sets.py +0 -112
- google/adk/tools/toolbox_tool.py +0 -46
- google_adk-0.4.0.dist-info/RECORD +0 -179
- {google_adk-0.4.0.dist-info → google_adk-1.0.0.dist-info}/WHEEL +0 -0
- {google_adk-0.4.0.dist-info → google_adk-1.0.0.dist-info}/entry_points.txt +0 -0
- {google_adk-0.4.0.dist-info → google_adk-1.0.0.dist-info}/licenses/LICENSE +0 -0
@@ -17,9 +17,13 @@ from textwrap import dedent
|
|
17
17
|
from typing import Any, Dict, List, Optional, Union
|
18
18
|
|
19
19
|
from fastapi.encoders import jsonable_encoder
|
20
|
-
from fastapi.openapi.models import Operation
|
20
|
+
from fastapi.openapi.models import Operation
|
21
|
+
from fastapi.openapi.models import Parameter
|
22
|
+
from fastapi.openapi.models import Schema
|
21
23
|
|
22
|
-
from ..common.common import ApiParameter
|
24
|
+
from ..common.common import ApiParameter
|
25
|
+
from ..common.common import PydocHelper
|
26
|
+
from ..common.common import to_snake_case
|
23
27
|
|
24
28
|
|
25
29
|
class OperationParser:
|
@@ -41,14 +45,14 @@ class OperationParser:
|
|
41
45
|
should_parse: Whether to parse the operation during initialization.
|
42
46
|
"""
|
43
47
|
if isinstance(operation, dict):
|
44
|
-
self.
|
48
|
+
self._operation = Operation.model_validate(operation)
|
45
49
|
elif isinstance(operation, str):
|
46
|
-
self.
|
50
|
+
self._operation = Operation.model_validate_json(operation)
|
47
51
|
else:
|
48
|
-
self.
|
52
|
+
self._operation = operation
|
49
53
|
|
50
|
-
self.
|
51
|
-
self.
|
54
|
+
self._params: List[ApiParameter] = []
|
55
|
+
self._return_value: Optional[ApiParameter] = None
|
52
56
|
if should_parse:
|
53
57
|
self._process_operation_parameters()
|
54
58
|
self._process_request_body()
|
@@ -63,32 +67,38 @@ class OperationParser:
|
|
63
67
|
return_value: Optional[ApiParameter] = None,
|
64
68
|
) -> 'OperationParser':
|
65
69
|
parser = cls(operation, should_parse=False)
|
66
|
-
parser.
|
67
|
-
parser.
|
70
|
+
parser._params = params
|
71
|
+
parser._return_value = return_value
|
68
72
|
return parser
|
69
73
|
|
70
74
|
def _process_operation_parameters(self):
|
71
75
|
"""Processes parameters from the OpenAPI operation."""
|
72
|
-
parameters = self.
|
76
|
+
parameters = self._operation.parameters or []
|
73
77
|
for param in parameters:
|
74
78
|
if isinstance(param, Parameter):
|
75
79
|
original_name = param.name
|
76
80
|
description = param.description or ''
|
77
81
|
location = param.in_ or ''
|
78
82
|
schema = param.schema_ or {} # Use schema_ instead of .schema
|
83
|
+
schema.description = (
|
84
|
+
description if not schema.description else schema.description
|
85
|
+
)
|
86
|
+
# param.required can be None
|
87
|
+
required = param.required if param.required is not None else False
|
79
88
|
|
80
|
-
self.
|
89
|
+
self._params.append(
|
81
90
|
ApiParameter(
|
82
91
|
original_name=original_name,
|
83
92
|
param_location=location,
|
84
93
|
param_schema=schema,
|
85
94
|
description=description,
|
95
|
+
required=required,
|
86
96
|
)
|
87
97
|
)
|
88
98
|
|
89
99
|
def _process_request_body(self):
|
90
100
|
"""Processes the request body from the OpenAPI operation."""
|
91
|
-
request_body = self.
|
101
|
+
request_body = self._operation.requestBody
|
92
102
|
if not request_body:
|
93
103
|
return
|
94
104
|
|
@@ -104,7 +114,7 @@ class OperationParser:
|
|
104
114
|
if schema and schema.type == 'object':
|
105
115
|
properties = schema.properties or {}
|
106
116
|
for prop_name, prop_details in properties.items():
|
107
|
-
self.
|
117
|
+
self._params.append(
|
108
118
|
ApiParameter(
|
109
119
|
original_name=prop_name,
|
110
120
|
param_location='body',
|
@@ -114,7 +124,7 @@ class OperationParser:
|
|
114
124
|
)
|
115
125
|
|
116
126
|
elif schema and schema.type == 'array':
|
117
|
-
self.
|
127
|
+
self._params.append(
|
118
128
|
ApiParameter(
|
119
129
|
original_name='array',
|
120
130
|
param_location='body',
|
@@ -123,7 +133,7 @@ class OperationParser:
|
|
123
133
|
)
|
124
134
|
)
|
125
135
|
else:
|
126
|
-
self.
|
136
|
+
self._params.append(
|
127
137
|
# Empty name for unnamed body param
|
128
138
|
ApiParameter(
|
129
139
|
original_name='',
|
@@ -137,7 +147,7 @@ class OperationParser:
|
|
137
147
|
def _dedupe_param_names(self):
|
138
148
|
"""Deduplicates parameter names to avoid conflicts."""
|
139
149
|
params_cnt = {}
|
140
|
-
for param in self.
|
150
|
+
for param in self._params:
|
141
151
|
name = param.py_name
|
142
152
|
if name not in params_cnt:
|
143
153
|
params_cnt[name] = 0
|
@@ -147,7 +157,7 @@ class OperationParser:
|
|
147
157
|
|
148
158
|
def _process_return_value(self) -> Parameter:
|
149
159
|
"""Returns a Parameter object representing the return type."""
|
150
|
-
responses = self.
|
160
|
+
responses = self._operation.responses or {}
|
151
161
|
# Default to Any if no 2xx response or if schema is missing
|
152
162
|
return_schema = Schema(type='Any')
|
153
163
|
|
@@ -164,7 +174,7 @@ class OperationParser:
|
|
164
174
|
return_schema = content[mime_type].schema_
|
165
175
|
break
|
166
176
|
|
167
|
-
self.
|
177
|
+
self._return_value = ApiParameter(
|
168
178
|
original_name='',
|
169
179
|
param_location='',
|
170
180
|
param_schema=return_schema,
|
@@ -172,42 +182,42 @@ class OperationParser:
|
|
172
182
|
|
173
183
|
def get_function_name(self) -> str:
|
174
184
|
"""Returns the generated function name."""
|
175
|
-
operation_id = self.
|
185
|
+
operation_id = self._operation.operationId
|
176
186
|
if not operation_id:
|
177
187
|
raise ValueError('Operation ID is missing')
|
178
188
|
return to_snake_case(operation_id)[:60]
|
179
189
|
|
180
190
|
def get_return_type_hint(self) -> str:
|
181
191
|
"""Returns the return type hint string (like 'str', 'int', etc.)."""
|
182
|
-
return self.
|
192
|
+
return self._return_value.type_hint
|
183
193
|
|
184
194
|
def get_return_type_value(self) -> Any:
|
185
195
|
"""Returns the return type value (like str, int, List[str], etc.)."""
|
186
|
-
return self.
|
196
|
+
return self._return_value.type_value
|
187
197
|
|
188
198
|
def get_parameters(self) -> List[ApiParameter]:
|
189
199
|
"""Returns the list of Parameter objects."""
|
190
|
-
return self.
|
200
|
+
return self._params
|
191
201
|
|
192
202
|
def get_return_value(self) -> ApiParameter:
|
193
203
|
"""Returns the list of Parameter objects."""
|
194
|
-
return self.
|
204
|
+
return self._return_value
|
195
205
|
|
196
206
|
def get_auth_scheme_name(self) -> str:
|
197
207
|
"""Returns the name of the auth scheme for this operation from the spec."""
|
198
|
-
if self.
|
199
|
-
scheme_name = list(self.
|
208
|
+
if self._operation.security:
|
209
|
+
scheme_name = list(self._operation.security[0].keys())[0]
|
200
210
|
return scheme_name
|
201
211
|
return ''
|
202
212
|
|
203
213
|
def get_pydoc_string(self) -> str:
|
204
214
|
"""Returns the generated PyDoc string."""
|
205
|
-
pydoc_params = [param.to_pydoc_string() for param in self.
|
215
|
+
pydoc_params = [param.to_pydoc_string() for param in self._params]
|
206
216
|
pydoc_description = (
|
207
|
-
self.
|
217
|
+
self._operation.summary or self._operation.description or ''
|
208
218
|
)
|
209
219
|
pydoc_return = PydocHelper.generate_return_doc(
|
210
|
-
self.
|
220
|
+
self._operation.responses or {}
|
211
221
|
)
|
212
222
|
pydoc_arg_list = chr(10).join(
|
213
223
|
f' {param_doc}' for param_doc in pydoc_params
|
@@ -226,12 +236,12 @@ class OperationParser:
|
|
226
236
|
"""Returns the JSON schema for the function arguments."""
|
227
237
|
properties = {
|
228
238
|
p.py_name: jsonable_encoder(p.param_schema, exclude_none=True)
|
229
|
-
for p in self.
|
239
|
+
for p in self._params
|
230
240
|
}
|
231
241
|
return {
|
232
242
|
'properties': properties,
|
233
|
-
'required': [p.py_name for p in self.
|
234
|
-
'title': f"{self.
|
243
|
+
'required': [p.py_name for p in self._params if p.required],
|
244
|
+
'title': f"{self._operation.operationId or 'unnamed'}_Arguments",
|
235
245
|
'type': 'object',
|
236
246
|
}
|
237
247
|
|
@@ -243,11 +253,11 @@ class OperationParser:
|
|
243
253
|
inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
244
254
|
annotation=param.type_value,
|
245
255
|
)
|
246
|
-
for param in self.
|
256
|
+
for param in self._params
|
247
257
|
]
|
248
258
|
|
249
259
|
def get_annotations(self) -> Dict[str, Any]:
|
250
260
|
"""Returns a dictionary of parameter annotations for the function."""
|
251
|
-
annotations = {p.py_name: p.type_value for p in self.
|
261
|
+
annotations = {p.py_name: p.type_value for p in self._params}
|
252
262
|
annotations['return'] = self.get_return_type_value()
|
253
263
|
return annotations
|
@@ -30,7 +30,7 @@ from ..auth.credential_exchangers.auto_auth_credential_exchanger import AutoAuth
|
|
30
30
|
from ..auth.credential_exchangers.base_credential_exchanger import AuthCredentialMissingError
|
31
31
|
from ..auth.credential_exchangers.base_credential_exchanger import BaseAuthCredentialExchanger
|
32
32
|
|
33
|
-
logger = logging.getLogger(__name__)
|
33
|
+
logger = logging.getLogger("google_adk." + __name__)
|
34
34
|
|
35
35
|
AuthPreparationState = Literal["pending", "done"]
|
36
36
|
|
@@ -14,11 +14,11 @@
|
|
14
14
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
|
-
from datetime import datetime
|
18
17
|
from typing import TYPE_CHECKING
|
19
18
|
|
20
19
|
from typing_extensions import override
|
21
20
|
|
21
|
+
from . import _memory_entry_utils
|
22
22
|
from .base_tool import BaseTool
|
23
23
|
from .tool_context import ToolContext
|
24
24
|
|
@@ -27,7 +27,10 @@ if TYPE_CHECKING:
|
|
27
27
|
|
28
28
|
|
29
29
|
class PreloadMemoryTool(BaseTool):
|
30
|
-
"""A tool that preloads the memory for the current user.
|
30
|
+
"""A tool that preloads the memory for the current user.
|
31
|
+
|
32
|
+
NOTE: Currently this tool only uses text part from the memory.
|
33
|
+
"""
|
31
34
|
|
32
35
|
def __init__(self):
|
33
36
|
# Name and description are not used because this tool only
|
@@ -41,29 +44,35 @@ class PreloadMemoryTool(BaseTool):
|
|
41
44
|
tool_context: ToolContext,
|
42
45
|
llm_request: LlmRequest,
|
43
46
|
) -> None:
|
44
|
-
|
45
|
-
if
|
47
|
+
user_content = tool_context.user_content
|
48
|
+
if (
|
49
|
+
not user_content
|
50
|
+
or not user_content.parts
|
51
|
+
or not user_content.parts[0].text
|
52
|
+
):
|
46
53
|
return
|
47
|
-
|
48
|
-
|
54
|
+
|
55
|
+
user_query: str = user_content.parts[0].text
|
56
|
+
response = await tool_context.search_memory(user_query)
|
49
57
|
if not response.memories:
|
50
58
|
return
|
51
|
-
|
59
|
+
|
60
|
+
memory_text_lines = []
|
52
61
|
for memory in response.memories:
|
53
|
-
time_str
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
62
|
+
if time_str := (f'Time: {memory.timestamp}' if memory.timestamp else ''):
|
63
|
+
memory_text_lines.append(time_str)
|
64
|
+
if memory_text := _memory_entry_utils.extract_text(memory):
|
65
|
+
memory_text_lines.append(
|
66
|
+
f'{memory.author}: {memory_text}' if memory.author else memory_text
|
67
|
+
)
|
68
|
+
if not memory_text_lines:
|
69
|
+
return
|
70
|
+
|
71
|
+
full_memory_text = '\n'.join(memory_text_lines)
|
63
72
|
si = f"""The following content is from your previous conversations with the user.
|
64
73
|
They may be useful for answering the user's current query.
|
65
74
|
<PAST_CONVERSATIONS>
|
66
|
-
{
|
75
|
+
{full_memory_text}
|
67
76
|
</PAST_CONVERSATIONS>
|
68
77
|
"""
|
69
78
|
llm_request.append_instructions([si])
|
@@ -29,7 +29,7 @@ try:
|
|
29
29
|
except ImportError:
|
30
30
|
import logging
|
31
31
|
|
32
|
-
logger = logging.getLogger(__name__)
|
32
|
+
logger = logging.getLogger('google_adk.' + __name__)
|
33
33
|
logger.debug(
|
34
34
|
'The Vertex sdk is not installed. If you want to use the Vertex RAG with'
|
35
35
|
' agents, please install it. If not, you can ignore this warning.'
|
@@ -30,7 +30,7 @@ from .base_retrieval_tool import BaseRetrievalTool
|
|
30
30
|
if TYPE_CHECKING:
|
31
31
|
from ...models.llm_request import LlmRequest
|
32
32
|
|
33
|
-
logger = logging.getLogger(__name__)
|
33
|
+
logger = logging.getLogger('google_adk.' + __name__)
|
34
34
|
|
35
35
|
|
36
36
|
class VertexAiRagRetrieval(BaseRetrievalTool):
|
google/adk/tools/tool_context.py
CHANGED
@@ -69,21 +69,21 @@ class ToolContext(CallbackContext):
|
|
69
69
|
def get_auth_response(self, auth_config: AuthConfig) -> AuthCredential:
|
70
70
|
return AuthHandler(auth_config).get_auth_response(self.state)
|
71
71
|
|
72
|
-
def list_artifacts(self) -> list[str]:
|
72
|
+
async def list_artifacts(self) -> list[str]:
|
73
73
|
"""Lists the filenames of the artifacts attached to the current session."""
|
74
74
|
if self._invocation_context.artifact_service is None:
|
75
75
|
raise ValueError('Artifact service is not initialized.')
|
76
|
-
return self._invocation_context.artifact_service.list_artifact_keys(
|
76
|
+
return await self._invocation_context.artifact_service.list_artifact_keys(
|
77
77
|
app_name=self._invocation_context.app_name,
|
78
78
|
user_id=self._invocation_context.user_id,
|
79
79
|
session_id=self._invocation_context.session.id,
|
80
80
|
)
|
81
81
|
|
82
|
-
def search_memory(self, query: str) ->
|
82
|
+
async def search_memory(self, query: str) -> SearchMemoryResponse:
|
83
83
|
"""Searches the memory of the current user."""
|
84
84
|
if self._invocation_context.memory_service is None:
|
85
85
|
raise ValueError('Memory service is not available.')
|
86
|
-
return self._invocation_context.memory_service.search_memory(
|
86
|
+
return await self._invocation_context.memory_service.search_memory(
|
87
87
|
app_name=self._invocation_context.app_name,
|
88
88
|
user_id=self._invocation_context.user_id,
|
89
89
|
query=query,
|
@@ -0,0 +1,79 @@
|
|
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
|
+
from typing import List
|
16
|
+
from typing import Optional
|
17
|
+
|
18
|
+
import toolbox_core as toolbox
|
19
|
+
from typing_extensions import override
|
20
|
+
|
21
|
+
from ..agents.readonly_context import ReadonlyContext
|
22
|
+
from .base_tool import BaseTool
|
23
|
+
from .base_toolset import BaseToolset
|
24
|
+
from .function_tool import FunctionTool
|
25
|
+
|
26
|
+
|
27
|
+
class ToolboxToolset(BaseToolset):
|
28
|
+
"""A class that provides access to toolbox toolsets.
|
29
|
+
|
30
|
+
Example:
|
31
|
+
```python
|
32
|
+
toolbox_toolset = ToolboxToolset("http://127.0.0.1:5000",
|
33
|
+
toolset_name="my-toolset")
|
34
|
+
)
|
35
|
+
```
|
36
|
+
"""
|
37
|
+
|
38
|
+
def __init__(
|
39
|
+
self,
|
40
|
+
server_url: str,
|
41
|
+
toolset_name: Optional[str] = None,
|
42
|
+
tool_names: Optional[List[str]] = None,
|
43
|
+
):
|
44
|
+
"""Args:
|
45
|
+
|
46
|
+
server_url: The URL of the toolbox server.
|
47
|
+
toolset_name: The name of the toolbox toolset to load.
|
48
|
+
tool_names: The names of the tools to load.
|
49
|
+
The resulting ToolboxToolset will contain both tools loaded by tool_names
|
50
|
+
and toolset_name.
|
51
|
+
"""
|
52
|
+
if not tool_names and not toolset_name:
|
53
|
+
raise ValueError("tool_names and toolset_name cannot both be None")
|
54
|
+
super().__init__()
|
55
|
+
self._server_url = server_url
|
56
|
+
self._toolbox_client = toolbox.ToolboxSyncClient(server_url)
|
57
|
+
self._toolset_name = toolset_name
|
58
|
+
self._tool_names = tool_names
|
59
|
+
|
60
|
+
@override
|
61
|
+
async def get_tools(
|
62
|
+
self, readonly_context: Optional[ReadonlyContext] = None
|
63
|
+
) -> list[BaseTool]:
|
64
|
+
tools = []
|
65
|
+
if self._toolset_name:
|
66
|
+
tools.extend([
|
67
|
+
FunctionTool(tool)
|
68
|
+
for tool in self._toolbox_client.load_toolset(self._toolset_name)
|
69
|
+
])
|
70
|
+
if self._tool_names:
|
71
|
+
tools.extend([
|
72
|
+
FunctionTool(self._toolbox_client.load_tool(tool_name))
|
73
|
+
for tool_name in self._tool_names
|
74
|
+
])
|
75
|
+
return tools
|
76
|
+
|
77
|
+
@override
|
78
|
+
async def close(self):
|
79
|
+
self._toolbox_client.close()
|
@@ -15,7 +15,6 @@
|
|
15
15
|
from .tool_context import ToolContext
|
16
16
|
|
17
17
|
|
18
|
-
# TODO: make this internal, since user doesn't need to use this tool directly.
|
19
18
|
def transfer_to_agent(agent_name: str, tool_context: ToolContext):
|
20
19
|
"""Transfer the question to another agent."""
|
21
20
|
tool_context.actions.transfer_to_agent = agent_name
|
google/adk/version.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: google-adk
|
3
|
-
Version: 0.
|
3
|
+
Version: 1.0.0
|
4
4
|
Summary: Agent Development Kit
|
5
5
|
Author-email: Google LLC <googleapis-packages@google.com>
|
6
6
|
Requires-Python: >=3.9
|
@@ -11,10 +11,10 @@ Classifier: Intended Audience :: Science/Research
|
|
11
11
|
Classifier: Programming Language :: Python
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
13
13
|
Classifier: Programming Language :: Python :: 3.9
|
14
|
-
Classifier: Programming Language :: Python :: 3.13
|
15
|
-
Classifier: Programming Language :: Python :: 3.12
|
16
|
-
Classifier: Programming Language :: Python :: 3.11
|
17
14
|
Classifier: Programming Language :: Python :: 3.10
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
18
18
|
Classifier: Operating System :: OS Independent
|
19
19
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
20
20
|
Classifier: License :: OSI Approved :: Apache Software License
|
@@ -27,7 +27,7 @@ Requires-Dist: google-cloud-aiplatform>=1.87.0
|
|
27
27
|
Requires-Dist: google-cloud-secret-manager>=2.22.0
|
28
28
|
Requires-Dist: google-cloud-speech>=2.30.0
|
29
29
|
Requires-Dist: google-cloud-storage>=2.18.0, <3.0.0
|
30
|
-
Requires-Dist: google-genai>=1.
|
30
|
+
Requires-Dist: google-genai>=1.14.0
|
31
31
|
Requires-Dist: graphviz>=0.20.2
|
32
32
|
Requires-Dist: mcp>=1.5.0;python_version>='3.10'
|
33
33
|
Requires-Dist: opentelemetry-api>=1.31.0
|
@@ -43,6 +43,7 @@ Requires-Dist: flit>=3.10.0 ; extra == "dev"
|
|
43
43
|
Requires-Dist: isort>=6.0.0 ; extra == "dev"
|
44
44
|
Requires-Dist: pyink>=24.10.0 ; extra == "dev"
|
45
45
|
Requires-Dist: pylint>=2.6.0 ; extra == "dev"
|
46
|
+
Requires-Dist: mypy>=1.15.0 ; extra == "dev"
|
46
47
|
Requires-Dist: autodoc_pydantic ; extra == "docs"
|
47
48
|
Requires-Dist: furo ; extra == "docs"
|
48
49
|
Requires-Dist: myst-parser ; extra == "docs"
|
@@ -60,6 +61,7 @@ Requires-Dist: langgraph>=0.2.60 ; extra == "extensions"
|
|
60
61
|
Requires-Dist: litellm>=1.63.11 ; extra == "extensions"
|
61
62
|
Requires-Dist: llama-index-readers-file>=0.4.0 ; extra == "extensions"
|
62
63
|
Requires-Dist: lxml>=5.3.0 ; extra == "extensions"
|
64
|
+
Requires-Dist: toolbox-core>=0.1.0 ; extra == "extensions"
|
63
65
|
Requires-Dist: anthropic>=0.43.0 ; extra == "test"
|
64
66
|
Requires-Dist: langchain-community>=0.3.17 ; extra == "test"
|
65
67
|
Requires-Dist: langgraph>=0.2.60 ; extra == "test"
|