google-adk 1.6.1__py3-none-any.whl → 1.7.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/a2a/converters/event_converter.py +5 -85
- google/adk/a2a/executor/a2a_agent_executor.py +45 -16
- google/adk/agents/__init__.py +5 -0
- google/adk/agents/agent_config.py +46 -0
- google/adk/agents/base_agent.py +234 -41
- google/adk/agents/callback_context.py +41 -0
- google/adk/agents/common_configs.py +79 -0
- google/adk/agents/config_agent_utils.py +184 -0
- google/adk/agents/config_schemas/AgentConfig.json +544 -0
- google/adk/agents/invocation_context.py +5 -1
- google/adk/agents/llm_agent.py +190 -9
- google/adk/agents/loop_agent.py +29 -0
- google/adk/agents/parallel_agent.py +24 -3
- google/adk/agents/remote_a2a_agent.py +15 -3
- google/adk/agents/sequential_agent.py +22 -1
- google/adk/artifacts/gcs_artifact_service.py +24 -2
- google/adk/auth/auth_handler.py +3 -3
- google/adk/auth/credential_manager.py +23 -23
- google/adk/auth/credential_service/base_credential_service.py +6 -6
- google/adk/auth/credential_service/in_memory_credential_service.py +10 -8
- google/adk/auth/credential_service/session_state_credential_service.py +8 -8
- google/adk/auth/exchanger/oauth2_credential_exchanger.py +3 -3
- google/adk/auth/oauth2_credential_util.py +2 -2
- google/adk/auth/refresher/oauth2_credential_refresher.py +4 -4
- google/adk/cli/agent_graph.py +3 -1
- google/adk/cli/browser/index.html +1 -1
- google/adk/cli/browser/main-SRBSE46V.js +3914 -0
- google/adk/cli/browser/polyfills-B6TNHZQ6.js +17 -0
- google/adk/cli/fast_api.py +42 -2
- google/adk/cli/utils/agent_loader.py +35 -1
- google/adk/code_executors/base_code_executor.py +14 -19
- google/adk/code_executors/built_in_code_executor.py +4 -1
- google/adk/evaluation/base_eval_service.py +46 -2
- google/adk/evaluation/evaluation_generator.py +1 -1
- google/adk/evaluation/in_memory_eval_sets_manager.py +151 -0
- google/adk/evaluation/local_eval_service.py +389 -0
- google/adk/evaluation/local_eval_sets_manager.py +23 -8
- google/adk/flows/llm_flows/auto_flow.py +6 -11
- google/adk/flows/llm_flows/base_llm_flow.py +41 -23
- google/adk/flows/llm_flows/contents.py +16 -10
- google/adk/flows/llm_flows/functions.py +76 -33
- google/adk/memory/in_memory_memory_service.py +20 -14
- google/adk/models/anthropic_llm.py +44 -5
- google/adk/models/google_llm.py +11 -6
- google/adk/models/lite_llm.py +21 -4
- google/adk/plugins/__init__.py +17 -0
- google/adk/plugins/base_plugin.py +317 -0
- google/adk/plugins/plugin_manager.py +265 -0
- google/adk/runners.py +122 -18
- google/adk/sessions/database_session_service.py +26 -28
- google/adk/sessions/vertex_ai_session_service.py +14 -7
- google/adk/tools/agent_tool.py +1 -0
- google/adk/tools/apihub_tool/apihub_toolset.py +38 -39
- google/adk/tools/application_integration_tool/application_integration_toolset.py +35 -37
- google/adk/tools/application_integration_tool/integration_connector_tool.py +2 -3
- google/adk/tools/base_tool.py +9 -9
- google/adk/tools/base_toolset.py +7 -5
- google/adk/tools/bigquery/__init__.py +3 -3
- google/adk/tools/enterprise_search_tool.py +4 -2
- google/adk/tools/google_api_tool/google_api_tool.py +16 -1
- google/adk/tools/google_api_tool/google_api_toolset.py +9 -7
- google/adk/tools/google_api_tool/google_api_toolsets.py +41 -20
- google/adk/tools/google_search_tool.py +4 -2
- google/adk/tools/langchain_tool.py +2 -3
- google/adk/tools/long_running_tool.py +21 -0
- google/adk/tools/mcp_tool/mcp_toolset.py +27 -28
- google/adk/tools/openapi_tool/openapi_spec_parser/openapi_toolset.py +8 -8
- google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py +4 -6
- google/adk/tools/retrieval/vertex_ai_rag_retrieval.py +3 -2
- google/adk/tools/tool_context.py +0 -10
- google/adk/tools/url_context_tool.py +4 -2
- google/adk/tools/vertex_ai_search_tool.py +4 -2
- google/adk/utils/model_name_utils.py +90 -0
- google/adk/version.py +1 -1
- {google_adk-1.6.1.dist-info → google_adk-1.7.0.dist-info}/METADATA +2 -2
- {google_adk-1.6.1.dist-info → google_adk-1.7.0.dist-info}/RECORD +79 -69
- google/adk/cli/browser/main-RXDVX3K6.js +0 -3914
- google/adk/cli/browser/polyfills-FFHMD2TL.js +0 -17
- {google_adk-1.6.1.dist-info → google_adk-1.7.0.dist-info}/WHEEL +0 -0
- {google_adk-1.6.1.dist-info → google_adk-1.7.0.dist-info}/entry_points.txt +0 -0
- {google_adk-1.6.1.dist-info → google_adk-1.7.0.dist-info}/licenses/LICENSE +0 -0
@@ -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
|
+
"""Common configuration classes for agent YAML configs."""
|
16
|
+
from __future__ import annotations
|
17
|
+
|
18
|
+
from typing import Any
|
19
|
+
from typing import List
|
20
|
+
from typing import Optional
|
21
|
+
|
22
|
+
from pydantic import BaseModel
|
23
|
+
from pydantic import ConfigDict
|
24
|
+
|
25
|
+
from ..utils.feature_decorator import working_in_progress
|
26
|
+
|
27
|
+
|
28
|
+
@working_in_progress("ArgumentConfig is not ready for use.")
|
29
|
+
class ArgumentConfig(BaseModel):
|
30
|
+
"""An argument passed to a function or a class's constructor."""
|
31
|
+
|
32
|
+
model_config = ConfigDict(extra="forbid")
|
33
|
+
|
34
|
+
name: Optional[str] = None
|
35
|
+
"""Optional. The argument name.
|
36
|
+
|
37
|
+
When the argument is for a positional argument, this can be omitted.
|
38
|
+
"""
|
39
|
+
|
40
|
+
value: Any
|
41
|
+
"""The argument value."""
|
42
|
+
|
43
|
+
|
44
|
+
@working_in_progress("CodeConfig is not ready for use.")
|
45
|
+
class CodeConfig(BaseModel):
|
46
|
+
"""Code reference config for a variable, a function, or a class.
|
47
|
+
|
48
|
+
This config is used for configuring callbacks and tools.
|
49
|
+
"""
|
50
|
+
|
51
|
+
model_config = ConfigDict(extra="forbid")
|
52
|
+
|
53
|
+
name: str
|
54
|
+
"""Required. The name of the variable, function, class, etc. in code.
|
55
|
+
|
56
|
+
Examples:
|
57
|
+
|
58
|
+
When used for tools,
|
59
|
+
- It can be ADK built-in tools, such as `google_search` and `AgentTool`.
|
60
|
+
- It can also be users' custom tools, e.g. my_library.my_tools.my_tool.
|
61
|
+
|
62
|
+
When used for callbacks, it refers to a function, e.g. `my_library.my_callbacks.my_callback`
|
63
|
+
"""
|
64
|
+
|
65
|
+
args: Optional[List[ArgumentConfig]] = None
|
66
|
+
"""Optional. The arguments for the code when `name` refers to a function or a
|
67
|
+
class's contructor.
|
68
|
+
|
69
|
+
Examples:
|
70
|
+
```
|
71
|
+
tools
|
72
|
+
- name: AgentTool
|
73
|
+
args:
|
74
|
+
- name: agent
|
75
|
+
value: search_agent.yaml
|
76
|
+
- name: skip_summarization
|
77
|
+
value: True
|
78
|
+
```
|
79
|
+
"""
|
@@ -0,0 +1,184 @@
|
|
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 __future__ import annotations
|
16
|
+
|
17
|
+
import importlib
|
18
|
+
import os
|
19
|
+
from typing import Any
|
20
|
+
from typing import List
|
21
|
+
|
22
|
+
import yaml
|
23
|
+
|
24
|
+
from ..utils.feature_decorator import working_in_progress
|
25
|
+
from .agent_config import AgentConfig
|
26
|
+
from .base_agent import BaseAgent
|
27
|
+
from .base_agent import SubAgentConfig
|
28
|
+
from .common_configs import CodeConfig
|
29
|
+
from .llm_agent import LlmAgent
|
30
|
+
from .llm_agent import LlmAgentConfig
|
31
|
+
from .loop_agent import LoopAgent
|
32
|
+
from .loop_agent import LoopAgentConfig
|
33
|
+
from .parallel_agent import ParallelAgent
|
34
|
+
from .parallel_agent import ParallelAgentConfig
|
35
|
+
from .sequential_agent import SequentialAgent
|
36
|
+
from .sequential_agent import SequentialAgentConfig
|
37
|
+
|
38
|
+
|
39
|
+
@working_in_progress("from_config is not ready for use.")
|
40
|
+
def from_config(config_path: str) -> BaseAgent:
|
41
|
+
"""Build agent from a configfile path.
|
42
|
+
|
43
|
+
Args:
|
44
|
+
config: the path to a YAML config file.
|
45
|
+
|
46
|
+
Returns:
|
47
|
+
The created agent instance.
|
48
|
+
|
49
|
+
Raises:
|
50
|
+
FileNotFoundError: If config file doesn't exist.
|
51
|
+
ValidationError: If config file's content is invalid YAML.
|
52
|
+
ValueError: If agent type is unsupported.
|
53
|
+
"""
|
54
|
+
abs_path = os.path.abspath(config_path)
|
55
|
+
config = _load_config_from_path(abs_path)
|
56
|
+
|
57
|
+
if isinstance(config.root, LlmAgentConfig):
|
58
|
+
return LlmAgent.from_config(config.root, abs_path)
|
59
|
+
elif isinstance(config.root, LoopAgentConfig):
|
60
|
+
return LoopAgent.from_config(config.root, abs_path)
|
61
|
+
elif isinstance(config.root, ParallelAgentConfig):
|
62
|
+
return ParallelAgent.from_config(config.root, abs_path)
|
63
|
+
elif isinstance(config.root, SequentialAgentConfig):
|
64
|
+
return SequentialAgent.from_config(config.root, abs_path)
|
65
|
+
else:
|
66
|
+
raise ValueError("Unsupported config type")
|
67
|
+
|
68
|
+
|
69
|
+
@working_in_progress("_load_config_from_path is not ready for use.")
|
70
|
+
def _load_config_from_path(config_path: str) -> AgentConfig:
|
71
|
+
"""Load an agent's configuration from a YAML file.
|
72
|
+
|
73
|
+
Args:
|
74
|
+
config_path: Path to the YAML config file. Both relative and absolute
|
75
|
+
paths are accepted.
|
76
|
+
|
77
|
+
Returns:
|
78
|
+
The loaded and validated AgentConfig object.
|
79
|
+
|
80
|
+
Raises:
|
81
|
+
FileNotFoundError: If config file doesn't exist.
|
82
|
+
ValidationError: If config file's content is invalid YAML.
|
83
|
+
"""
|
84
|
+
if not os.path.exists(config_path):
|
85
|
+
raise FileNotFoundError(f"Config file not found: {config_path}")
|
86
|
+
|
87
|
+
with open(config_path, "r", encoding="utf-8") as f:
|
88
|
+
config_data = yaml.safe_load(f)
|
89
|
+
|
90
|
+
return AgentConfig.model_validate(config_data)
|
91
|
+
|
92
|
+
|
93
|
+
@working_in_progress("build_sub_agent is not ready for use.")
|
94
|
+
def build_sub_agent(
|
95
|
+
sub_config: SubAgentConfig, parent_agent_folder_path: str
|
96
|
+
) -> BaseAgent:
|
97
|
+
"""Build a sub-agent from configuration.
|
98
|
+
|
99
|
+
Args:
|
100
|
+
sub_config: The sub-agent configuration (SubAgentConfig).
|
101
|
+
parent_agent_folder_path: The folder path to the parent agent's YAML config.
|
102
|
+
|
103
|
+
Returns:
|
104
|
+
The created sub-agent instance.
|
105
|
+
"""
|
106
|
+
if sub_config.config:
|
107
|
+
if os.path.isabs(sub_config.config):
|
108
|
+
return from_config(sub_config.config)
|
109
|
+
else:
|
110
|
+
return from_config(
|
111
|
+
os.path.join(parent_agent_folder_path, sub_config.config)
|
112
|
+
)
|
113
|
+
elif sub_config.code:
|
114
|
+
return _resolve_sub_agent_code_reference(sub_config.code)
|
115
|
+
else:
|
116
|
+
raise ValueError("SubAgentConfig must have either 'code' or 'config'")
|
117
|
+
|
118
|
+
|
119
|
+
@working_in_progress("_resolve_sub_agent_code_reference is not ready for use.")
|
120
|
+
def _resolve_sub_agent_code_reference(code: str) -> Any:
|
121
|
+
"""Resolve a code reference to an actual agent object.
|
122
|
+
|
123
|
+
Args:
|
124
|
+
code: The code reference to the sub-agent.
|
125
|
+
|
126
|
+
Returns:
|
127
|
+
The resolved agent object.
|
128
|
+
|
129
|
+
Raises:
|
130
|
+
ValueError: If the code reference cannot be resolved.
|
131
|
+
"""
|
132
|
+
if "." not in code:
|
133
|
+
raise ValueError(f"Invalid code reference: {code}")
|
134
|
+
|
135
|
+
module_path, obj_name = code.rsplit(".", 1)
|
136
|
+
module = importlib.import_module(module_path)
|
137
|
+
obj = getattr(module, obj_name)
|
138
|
+
|
139
|
+
if callable(obj):
|
140
|
+
raise ValueError(f"Invalid code reference to a callable: {code}")
|
141
|
+
|
142
|
+
return obj
|
143
|
+
|
144
|
+
|
145
|
+
@working_in_progress("resolve_code_reference is not ready for use.")
|
146
|
+
def resolve_code_reference(code_config: CodeConfig) -> Any:
|
147
|
+
"""Resolve a code reference to actual Python object.
|
148
|
+
|
149
|
+
Args:
|
150
|
+
code_config: The code configuration (CodeConfig).
|
151
|
+
|
152
|
+
Returns:
|
153
|
+
The resolved Python object.
|
154
|
+
|
155
|
+
Raises:
|
156
|
+
ValueError: If the code reference cannot be resolved.
|
157
|
+
"""
|
158
|
+
if not code_config or not code_config.name:
|
159
|
+
raise ValueError("Invalid CodeConfig.")
|
160
|
+
|
161
|
+
module_path, obj_name = code_config.name.rsplit(".", 1)
|
162
|
+
module = importlib.import_module(module_path)
|
163
|
+
obj = getattr(module, obj_name)
|
164
|
+
|
165
|
+
if code_config.args and callable(obj):
|
166
|
+
kwargs = {arg.name: arg.value for arg in code_config.args if arg.name}
|
167
|
+
positional_args = [arg.value for arg in code_config.args if not arg.name]
|
168
|
+
|
169
|
+
return obj(*positional_args, **kwargs)
|
170
|
+
else:
|
171
|
+
return obj
|
172
|
+
|
173
|
+
|
174
|
+
@working_in_progress("resolve_callbacks is not ready for use.")
|
175
|
+
def resolve_callbacks(callbacks_config: List[CodeConfig]) -> Any:
|
176
|
+
"""Resolve callbacks from configuration.
|
177
|
+
|
178
|
+
Args:
|
179
|
+
callbacks_config: List of callback configurations (CodeConfig objects).
|
180
|
+
|
181
|
+
Returns:
|
182
|
+
List of resolved callback objects.
|
183
|
+
"""
|
184
|
+
return [resolve_code_reference(config) for config in callbacks_config]
|