google-cloud-agentplatform 1.165.1.dev0__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.
- agentplatform/__init__.py +72 -0
- agentplatform/_genai/__init__.py +43 -0
- agentplatform/_genai/_agent_engines_utils.py +2341 -0
- agentplatform/_genai/_bigquery_utils.py +49 -0
- agentplatform/_genai/_datasets_utils.py +344 -0
- agentplatform/_genai/_evals_builtin_tools.py +209 -0
- agentplatform/_genai/_evals_common.py +4268 -0
- agentplatform/_genai/_evals_constant.py +122 -0
- agentplatform/_genai/_evals_data_converters.py +926 -0
- agentplatform/_genai/_evals_metric_handlers.py +1783 -0
- agentplatform/_genai/_evals_metric_loaders.py +401 -0
- agentplatform/_genai/_evals_utils.py +1043 -0
- agentplatform/_genai/_evals_visualization.py +2070 -0
- agentplatform/_genai/_gcs_utils.py +262 -0
- agentplatform/_genai/_logging_utils.py +47 -0
- agentplatform/_genai/_memory_bank_utils.py +206 -0
- agentplatform/_genai/_observability_data_converter.py +186 -0
- agentplatform/_genai/_operations_utils.py +94 -0
- agentplatform/_genai/_prompt_management_utils.py +147 -0
- agentplatform/_genai/_prompt_optimizer_utils.py +215 -0
- agentplatform/_genai/_skills_utils.py +69 -0
- agentplatform/_genai/_transformers.py +628 -0
- agentplatform/_genai/a2a_task_events.py +509 -0
- agentplatform/_genai/a2a_tasks.py +861 -0
- agentplatform/_genai/agent_engines.py +3931 -0
- agentplatform/_genai/client.py +519 -0
- agentplatform/_genai/datasets.py +3045 -0
- agentplatform/_genai/endpoints.py +1149 -0
- agentplatform/_genai/evals.py +6883 -0
- agentplatform/_genai/example_stores.py +1445 -0
- agentplatform/_genai/feedback_contexts.py +700 -0
- agentplatform/_genai/feedback_entries.py +1644 -0
- agentplatform/_genai/live.py +64 -0
- agentplatform/_genai/live_agent_engines.py +179 -0
- agentplatform/_genai/memories.py +2962 -0
- agentplatform/_genai/memory_banks.py +1927 -0
- agentplatform/_genai/memory_revisions.py +465 -0
- agentplatform/_genai/model_garden.py +2638 -0
- agentplatform/_genai/prompt_optimizer.py +995 -0
- agentplatform/_genai/prompts.py +4515 -0
- agentplatform/_genai/rag.py +4961 -0
- agentplatform/_genai/runtime_revisions.py +1257 -0
- agentplatform/_genai/runtimes.py +78 -0
- agentplatform/_genai/sandbox_snapshots.py +1015 -0
- agentplatform/_genai/sandbox_templates.py +1088 -0
- agentplatform/_genai/sandboxes.py +1604 -0
- agentplatform/_genai/session_events.py +543 -0
- agentplatform/_genai/sessions.py +1449 -0
- agentplatform/_genai/skill_revisions.py +377 -0
- agentplatform/_genai/skills.py +1708 -0
- agentplatform/_genai/types/__init__.py +4695 -0
- agentplatform/_genai/types/agent_engines.py +16 -0
- agentplatform/_genai/types/common.py +32784 -0
- agentplatform/_genai/types/evals.py +1031 -0
- agentplatform/_genai/types/prompt_optimizer.py +107 -0
- agentplatform/_genai/types/prompts.py +107 -0
- agentplatform/version.py +17 -0
- google_cloud_agentplatform-1.165.1.dev0.dist-info/METADATA +79 -0
- google_cloud_agentplatform-1.165.1.dev0.dist-info/RECORD +62 -0
- google_cloud_agentplatform-1.165.1.dev0.dist-info/WHEEL +5 -0
- google_cloud_agentplatform-1.165.1.dev0.dist-info/licenses/LICENSE +202 -0
- google_cloud_agentplatform-1.165.1.dev0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,861 @@
|
|
|
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
|
+
# Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
17
|
+
|
|
18
|
+
import functools
|
|
19
|
+
import importlib
|
|
20
|
+
import json
|
|
21
|
+
import logging
|
|
22
|
+
import typing
|
|
23
|
+
from typing import Any, Iterator, Optional, Union
|
|
24
|
+
from urllib.parse import urlencode
|
|
25
|
+
|
|
26
|
+
from google.genai import _api_module
|
|
27
|
+
from google.genai import _common
|
|
28
|
+
from google.genai._common import get_value_by_path as getv
|
|
29
|
+
from google.genai._common import set_value_by_path as setv
|
|
30
|
+
from google.genai.pagers import AsyncPager, Pager
|
|
31
|
+
|
|
32
|
+
from . import types
|
|
33
|
+
|
|
34
|
+
if typing.TYPE_CHECKING:
|
|
35
|
+
from . import a2a_task_events as a2a_task_events_module
|
|
36
|
+
|
|
37
|
+
_ = a2a_task_events_module
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
logger = logging.getLogger("agentplatform_genai.a2atasks")
|
|
41
|
+
|
|
42
|
+
logger.setLevel(logging.INFO)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _CreateAgentEngineTaskConfig_to_vertex(
|
|
46
|
+
from_object: Union[dict[str, Any], object],
|
|
47
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
48
|
+
) -> dict[str, Any]:
|
|
49
|
+
to_object: dict[str, Any] = {}
|
|
50
|
+
|
|
51
|
+
if getv(from_object, ["context_id"]) is not None:
|
|
52
|
+
setv(parent_object, ["contextId"], getv(from_object, ["context_id"]))
|
|
53
|
+
|
|
54
|
+
if getv(from_object, ["metadata"]) is not None:
|
|
55
|
+
setv(parent_object, ["metadata"], getv(from_object, ["metadata"]))
|
|
56
|
+
|
|
57
|
+
if getv(from_object, ["status_details"]) is not None:
|
|
58
|
+
setv(parent_object, ["statusDetails"], getv(from_object, ["status_details"]))
|
|
59
|
+
|
|
60
|
+
if getv(from_object, ["output"]) is not None:
|
|
61
|
+
setv(parent_object, ["output"], getv(from_object, ["output"]))
|
|
62
|
+
|
|
63
|
+
return to_object
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _CreateAgentEngineTaskRequestParameters_to_vertex(
|
|
67
|
+
from_object: Union[dict[str, Any], object],
|
|
68
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
69
|
+
) -> dict[str, Any]:
|
|
70
|
+
to_object: dict[str, Any] = {}
|
|
71
|
+
if getv(from_object, ["name"]) is not None:
|
|
72
|
+
setv(to_object, ["_url", "name"], getv(from_object, ["name"]))
|
|
73
|
+
|
|
74
|
+
if getv(from_object, ["a2a_task_id"]) is not None:
|
|
75
|
+
setv(to_object, ["_query", "a2a_task_id"], getv(from_object, ["a2a_task_id"]))
|
|
76
|
+
|
|
77
|
+
if getv(from_object, ["config"]) is not None:
|
|
78
|
+
_CreateAgentEngineTaskConfig_to_vertex(getv(from_object, ["config"]), to_object)
|
|
79
|
+
|
|
80
|
+
return to_object
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _DeleteAgentEngineTaskRequestParameters_to_vertex(
|
|
84
|
+
from_object: Union[dict[str, Any], object],
|
|
85
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
86
|
+
) -> dict[str, Any]:
|
|
87
|
+
to_object: dict[str, Any] = {}
|
|
88
|
+
if getv(from_object, ["name"]) is not None:
|
|
89
|
+
setv(to_object, ["_url", "name"], getv(from_object, ["name"]))
|
|
90
|
+
|
|
91
|
+
return to_object
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _GetAgentEngineTaskRequestParameters_to_vertex(
|
|
95
|
+
from_object: Union[dict[str, Any], object],
|
|
96
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
97
|
+
) -> dict[str, Any]:
|
|
98
|
+
to_object: dict[str, Any] = {}
|
|
99
|
+
if getv(from_object, ["name"]) is not None:
|
|
100
|
+
setv(to_object, ["_url", "name"], getv(from_object, ["name"]))
|
|
101
|
+
|
|
102
|
+
return to_object
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _ListAgentEngineTasksConfig_to_vertex(
|
|
106
|
+
from_object: Union[dict[str, Any], object],
|
|
107
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
108
|
+
) -> dict[str, Any]:
|
|
109
|
+
to_object: dict[str, Any] = {}
|
|
110
|
+
|
|
111
|
+
if getv(from_object, ["page_size"]) is not None:
|
|
112
|
+
setv(parent_object, ["_query", "pageSize"], getv(from_object, ["page_size"]))
|
|
113
|
+
|
|
114
|
+
if getv(from_object, ["page_token"]) is not None:
|
|
115
|
+
setv(parent_object, ["_query", "pageToken"], getv(from_object, ["page_token"]))
|
|
116
|
+
|
|
117
|
+
if getv(from_object, ["filter"]) is not None:
|
|
118
|
+
setv(parent_object, ["_query", "filter"], getv(from_object, ["filter"]))
|
|
119
|
+
|
|
120
|
+
if getv(from_object, ["order_by"]) is not None:
|
|
121
|
+
setv(parent_object, ["_query", "orderBy"], getv(from_object, ["order_by"]))
|
|
122
|
+
|
|
123
|
+
return to_object
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _ListAgentEngineTasksRequestParameters_to_vertex(
|
|
127
|
+
from_object: Union[dict[str, Any], object],
|
|
128
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
129
|
+
) -> dict[str, Any]:
|
|
130
|
+
to_object: dict[str, Any] = {}
|
|
131
|
+
if getv(from_object, ["name"]) is not None:
|
|
132
|
+
setv(to_object, ["_url", "name"], getv(from_object, ["name"]))
|
|
133
|
+
|
|
134
|
+
if getv(from_object, ["config"]) is not None:
|
|
135
|
+
_ListAgentEngineTasksConfig_to_vertex(getv(from_object, ["config"]), to_object)
|
|
136
|
+
|
|
137
|
+
return to_object
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class A2aTasks(_api_module.BaseModule):
|
|
141
|
+
|
|
142
|
+
def delete(
|
|
143
|
+
self,
|
|
144
|
+
*,
|
|
145
|
+
name: str,
|
|
146
|
+
config: Optional[types.DeleteAgentEngineTaskConfigOrDict] = None,
|
|
147
|
+
) -> None:
|
|
148
|
+
"""
|
|
149
|
+
Deletes an agent engine task.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
name (str): Required. The name of the Agent Engine task to delete. Format:
|
|
153
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}/a2aTasks/{task_id}`.
|
|
154
|
+
config (DeleteAgentEngineTaskConfig):
|
|
155
|
+
Optional. Additional configurations for deleting the Agent Engine task.
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
None
|
|
159
|
+
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
parameter_model = types._DeleteAgentEngineTaskRequestParameters(
|
|
163
|
+
name=name,
|
|
164
|
+
config=config,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
request_url_dict: Optional[dict[str, str]]
|
|
168
|
+
if not self._api_client.vertexai:
|
|
169
|
+
raise ValueError(
|
|
170
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
171
|
+
)
|
|
172
|
+
else:
|
|
173
|
+
request_dict = _DeleteAgentEngineTaskRequestParameters_to_vertex(
|
|
174
|
+
parameter_model
|
|
175
|
+
)
|
|
176
|
+
request_url_dict = request_dict.get("_url")
|
|
177
|
+
if request_url_dict:
|
|
178
|
+
path = "{name}".format_map(request_url_dict)
|
|
179
|
+
else:
|
|
180
|
+
path = "{name}"
|
|
181
|
+
|
|
182
|
+
query_params = request_dict.get("_query")
|
|
183
|
+
if query_params:
|
|
184
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
185
|
+
# TODO: remove the hack that pops config.
|
|
186
|
+
request_dict.pop("config", None)
|
|
187
|
+
|
|
188
|
+
http_options: Optional[types.HttpOptions] = None
|
|
189
|
+
if (
|
|
190
|
+
parameter_model.config is not None
|
|
191
|
+
and parameter_model.config.http_options is not None
|
|
192
|
+
):
|
|
193
|
+
http_options = parameter_model.config.http_options
|
|
194
|
+
|
|
195
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
196
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
197
|
+
|
|
198
|
+
self._api_client.request("delete", path, request_dict, http_options)
|
|
199
|
+
|
|
200
|
+
def get(
|
|
201
|
+
self,
|
|
202
|
+
*,
|
|
203
|
+
name: str,
|
|
204
|
+
config: Optional[types.GetAgentEngineTaskConfigOrDict] = None,
|
|
205
|
+
) -> types.A2aTask:
|
|
206
|
+
"""
|
|
207
|
+
Gets an agent engine task.
|
|
208
|
+
|
|
209
|
+
Args:
|
|
210
|
+
name (str): Required. The name of the Agent Engine task to get. Format:
|
|
211
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}/a2aTasks/{task_id}`.
|
|
212
|
+
config (GetAgentEngineTaskConfig):
|
|
213
|
+
Optional. Additional configurations for getting the Agent Engine task.
|
|
214
|
+
|
|
215
|
+
Returns:
|
|
216
|
+
AgentEngineTask: The requested Agent Engine task.
|
|
217
|
+
|
|
218
|
+
"""
|
|
219
|
+
|
|
220
|
+
parameter_model = types._GetAgentEngineTaskRequestParameters(
|
|
221
|
+
name=name,
|
|
222
|
+
config=config,
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
request_url_dict: Optional[dict[str, str]]
|
|
226
|
+
if not self._api_client.vertexai:
|
|
227
|
+
raise ValueError(
|
|
228
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
229
|
+
)
|
|
230
|
+
else:
|
|
231
|
+
request_dict = _GetAgentEngineTaskRequestParameters_to_vertex(
|
|
232
|
+
parameter_model
|
|
233
|
+
)
|
|
234
|
+
request_url_dict = request_dict.get("_url")
|
|
235
|
+
if request_url_dict:
|
|
236
|
+
path = "{name}".format_map(request_url_dict)
|
|
237
|
+
else:
|
|
238
|
+
path = "{name}"
|
|
239
|
+
|
|
240
|
+
query_params = request_dict.get("_query")
|
|
241
|
+
if query_params:
|
|
242
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
243
|
+
# TODO: remove the hack that pops config.
|
|
244
|
+
request_dict.pop("config", None)
|
|
245
|
+
|
|
246
|
+
http_options: Optional[types.HttpOptions] = None
|
|
247
|
+
if (
|
|
248
|
+
parameter_model.config is not None
|
|
249
|
+
and parameter_model.config.http_options is not None
|
|
250
|
+
):
|
|
251
|
+
http_options = parameter_model.config.http_options
|
|
252
|
+
|
|
253
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
254
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
255
|
+
|
|
256
|
+
response = self._api_client.request("get", path, request_dict, http_options)
|
|
257
|
+
|
|
258
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
259
|
+
|
|
260
|
+
return_value = types.A2aTask._from_response(
|
|
261
|
+
response=response_dict,
|
|
262
|
+
kwargs=(
|
|
263
|
+
{
|
|
264
|
+
"config": {
|
|
265
|
+
"response_schema": getattr(
|
|
266
|
+
parameter_model.config, "response_schema", None
|
|
267
|
+
),
|
|
268
|
+
"response_json_schema": getattr(
|
|
269
|
+
parameter_model.config, "response_json_schema", None
|
|
270
|
+
),
|
|
271
|
+
"include_all_fields": getattr(
|
|
272
|
+
parameter_model.config, "include_all_fields", None
|
|
273
|
+
),
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if getattr(parameter_model, "config", None)
|
|
277
|
+
else {}
|
|
278
|
+
),
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
self._api_client._verify_response(return_value)
|
|
282
|
+
return return_value
|
|
283
|
+
|
|
284
|
+
def _list(
|
|
285
|
+
self,
|
|
286
|
+
*,
|
|
287
|
+
name: str,
|
|
288
|
+
config: Optional[types.ListAgentEngineTasksConfigOrDict] = None,
|
|
289
|
+
) -> types.ListAgentEngineTasksResponse:
|
|
290
|
+
"""
|
|
291
|
+
Lists Agent Engine tasks.
|
|
292
|
+
|
|
293
|
+
Args:
|
|
294
|
+
name (str): Required. The name of the Agent Engine to list tasks for. Format:
|
|
295
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}`.
|
|
296
|
+
config (ListAgentEngineTasksConfig):
|
|
297
|
+
Optional. Additional configurations for listing the Agent Engine tasks.
|
|
298
|
+
|
|
299
|
+
Returns:
|
|
300
|
+
ListAgentEngineTasksResponse: The requested Agent Engine tasks.
|
|
301
|
+
|
|
302
|
+
"""
|
|
303
|
+
|
|
304
|
+
parameter_model = types._ListAgentEngineTasksRequestParameters(
|
|
305
|
+
name=name,
|
|
306
|
+
config=config,
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
request_url_dict: Optional[dict[str, str]]
|
|
310
|
+
if not self._api_client.vertexai:
|
|
311
|
+
raise ValueError(
|
|
312
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
313
|
+
)
|
|
314
|
+
else:
|
|
315
|
+
request_dict = _ListAgentEngineTasksRequestParameters_to_vertex(
|
|
316
|
+
parameter_model
|
|
317
|
+
)
|
|
318
|
+
request_url_dict = request_dict.get("_url")
|
|
319
|
+
if request_url_dict:
|
|
320
|
+
path = "{name}/a2aTasks".format_map(request_url_dict)
|
|
321
|
+
else:
|
|
322
|
+
path = "{name}/a2aTasks"
|
|
323
|
+
|
|
324
|
+
query_params = request_dict.get("_query")
|
|
325
|
+
if query_params:
|
|
326
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
327
|
+
# TODO: remove the hack that pops config.
|
|
328
|
+
request_dict.pop("config", None)
|
|
329
|
+
|
|
330
|
+
http_options: Optional[types.HttpOptions] = None
|
|
331
|
+
if (
|
|
332
|
+
parameter_model.config is not None
|
|
333
|
+
and parameter_model.config.http_options is not None
|
|
334
|
+
):
|
|
335
|
+
http_options = parameter_model.config.http_options
|
|
336
|
+
|
|
337
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
338
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
339
|
+
|
|
340
|
+
response = self._api_client.request("get", path, request_dict, http_options)
|
|
341
|
+
|
|
342
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
343
|
+
|
|
344
|
+
return_value = types.ListAgentEngineTasksResponse._from_response(
|
|
345
|
+
response=response_dict,
|
|
346
|
+
kwargs=(
|
|
347
|
+
{
|
|
348
|
+
"config": {
|
|
349
|
+
"response_schema": getattr(
|
|
350
|
+
parameter_model.config, "response_schema", None
|
|
351
|
+
),
|
|
352
|
+
"response_json_schema": getattr(
|
|
353
|
+
parameter_model.config, "response_json_schema", None
|
|
354
|
+
),
|
|
355
|
+
"include_all_fields": getattr(
|
|
356
|
+
parameter_model.config, "include_all_fields", None
|
|
357
|
+
),
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if getattr(parameter_model, "config", None)
|
|
361
|
+
else {}
|
|
362
|
+
),
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
self._api_client._verify_response(return_value)
|
|
366
|
+
return return_value
|
|
367
|
+
|
|
368
|
+
def create(
|
|
369
|
+
self,
|
|
370
|
+
*,
|
|
371
|
+
name: str,
|
|
372
|
+
a2a_task_id: str,
|
|
373
|
+
config: Optional[types.CreateAgentEngineTaskConfigOrDict] = None,
|
|
374
|
+
) -> types.A2aTask:
|
|
375
|
+
"""
|
|
376
|
+
Creates a new task in the Agent Engine.
|
|
377
|
+
|
|
378
|
+
Args:
|
|
379
|
+
name (str): Required. The name of the Agent Engine to create the task under. Format:
|
|
380
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}`.
|
|
381
|
+
a2a_task_id (str): Required. The user ID of the task.
|
|
382
|
+
context_id (str): Required. The ID of the context to use for the task.
|
|
383
|
+
config (CreateAgentEngineTaskConfig):
|
|
384
|
+
Optional. Additional configurations for creating the Agent Engine task.
|
|
385
|
+
|
|
386
|
+
Returns:
|
|
387
|
+
A2aTask: The created Agent Engine task.
|
|
388
|
+
|
|
389
|
+
"""
|
|
390
|
+
|
|
391
|
+
parameter_model = types._CreateAgentEngineTaskRequestParameters(
|
|
392
|
+
name=name,
|
|
393
|
+
a2a_task_id=a2a_task_id,
|
|
394
|
+
config=config,
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
request_url_dict: Optional[dict[str, str]]
|
|
398
|
+
if not self._api_client.vertexai:
|
|
399
|
+
raise ValueError(
|
|
400
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
401
|
+
)
|
|
402
|
+
else:
|
|
403
|
+
request_dict = _CreateAgentEngineTaskRequestParameters_to_vertex(
|
|
404
|
+
parameter_model
|
|
405
|
+
)
|
|
406
|
+
request_url_dict = request_dict.get("_url")
|
|
407
|
+
if request_url_dict:
|
|
408
|
+
path = "{name}/a2aTasks".format_map(request_url_dict)
|
|
409
|
+
else:
|
|
410
|
+
path = "{name}/a2aTasks"
|
|
411
|
+
|
|
412
|
+
query_params = request_dict.get("_query")
|
|
413
|
+
if query_params:
|
|
414
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
415
|
+
# TODO: remove the hack that pops config.
|
|
416
|
+
request_dict.pop("config", None)
|
|
417
|
+
|
|
418
|
+
http_options: Optional[types.HttpOptions] = None
|
|
419
|
+
if (
|
|
420
|
+
parameter_model.config is not None
|
|
421
|
+
and parameter_model.config.http_options is not None
|
|
422
|
+
):
|
|
423
|
+
http_options = parameter_model.config.http_options
|
|
424
|
+
|
|
425
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
426
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
427
|
+
|
|
428
|
+
response = self._api_client.request("post", path, request_dict, http_options)
|
|
429
|
+
|
|
430
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
431
|
+
|
|
432
|
+
return_value = types.A2aTask._from_response(
|
|
433
|
+
response=response_dict,
|
|
434
|
+
kwargs=(
|
|
435
|
+
{
|
|
436
|
+
"config": {
|
|
437
|
+
"response_schema": getattr(
|
|
438
|
+
parameter_model.config, "response_schema", None
|
|
439
|
+
),
|
|
440
|
+
"response_json_schema": getattr(
|
|
441
|
+
parameter_model.config, "response_json_schema", None
|
|
442
|
+
),
|
|
443
|
+
"include_all_fields": getattr(
|
|
444
|
+
parameter_model.config, "include_all_fields", None
|
|
445
|
+
),
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
if getattr(parameter_model, "config", None)
|
|
449
|
+
else {}
|
|
450
|
+
),
|
|
451
|
+
)
|
|
452
|
+
|
|
453
|
+
self._api_client._verify_response(return_value)
|
|
454
|
+
return return_value
|
|
455
|
+
|
|
456
|
+
_events = None
|
|
457
|
+
|
|
458
|
+
def list(
|
|
459
|
+
self,
|
|
460
|
+
*,
|
|
461
|
+
name: str,
|
|
462
|
+
config: Optional[types.ListAgentEngineTasksConfigOrDict] = None,
|
|
463
|
+
) -> Iterator[types.A2aTask]:
|
|
464
|
+
"""Lists the A2A tasks of an Agent Engine.
|
|
465
|
+
|
|
466
|
+
Args:
|
|
467
|
+
name (str):
|
|
468
|
+
Required. The name of the agent engine to list tasks for.
|
|
469
|
+
config (List):
|
|
470
|
+
Optional. The configuration for the tasks to list.
|
|
471
|
+
|
|
472
|
+
Returns:
|
|
473
|
+
Iterable[A2aTask]: An iterable of A2A tasks.
|
|
474
|
+
"""
|
|
475
|
+
|
|
476
|
+
return Pager(
|
|
477
|
+
"a2aTasks",
|
|
478
|
+
functools.partial(self._list, name=name),
|
|
479
|
+
self._list(name=name, config=config),
|
|
480
|
+
config,
|
|
481
|
+
)
|
|
482
|
+
|
|
483
|
+
@property
|
|
484
|
+
def events(self) -> "a2a_task_events_module.A2aTaskEvents":
|
|
485
|
+
if self._events is None:
|
|
486
|
+
try:
|
|
487
|
+
# We need to lazy load the events module to handle the
|
|
488
|
+
# possibility of ImportError when dependencies are not installed.
|
|
489
|
+
self._events = importlib.import_module(".a2a_task_events", __package__)
|
|
490
|
+
except ImportError as e:
|
|
491
|
+
raise ImportError(
|
|
492
|
+
"The 'agent_engines.a2a_tasks.events' module requires additional "
|
|
493
|
+
"packages. Please install them using pip install "
|
|
494
|
+
"google-cloud-aiplatform[agent_engines]"
|
|
495
|
+
) from e
|
|
496
|
+
return self._events.A2aTaskEvents(self._api_client) # type: ignore[no-any-return]
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
class AsyncA2aTasks(_api_module.BaseModule):
|
|
500
|
+
|
|
501
|
+
async def delete(
|
|
502
|
+
self,
|
|
503
|
+
*,
|
|
504
|
+
name: str,
|
|
505
|
+
config: Optional[types.DeleteAgentEngineTaskConfigOrDict] = None,
|
|
506
|
+
) -> None:
|
|
507
|
+
"""
|
|
508
|
+
Deletes an agent engine task.
|
|
509
|
+
|
|
510
|
+
Args:
|
|
511
|
+
name (str): Required. The name of the Agent Engine task to delete. Format:
|
|
512
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}/a2aTasks/{task_id}`.
|
|
513
|
+
config (DeleteAgentEngineTaskConfig):
|
|
514
|
+
Optional. Additional configurations for deleting the Agent Engine task.
|
|
515
|
+
|
|
516
|
+
Returns:
|
|
517
|
+
None
|
|
518
|
+
|
|
519
|
+
"""
|
|
520
|
+
|
|
521
|
+
parameter_model = types._DeleteAgentEngineTaskRequestParameters(
|
|
522
|
+
name=name,
|
|
523
|
+
config=config,
|
|
524
|
+
)
|
|
525
|
+
|
|
526
|
+
request_url_dict: Optional[dict[str, str]]
|
|
527
|
+
if not self._api_client.vertexai:
|
|
528
|
+
raise ValueError(
|
|
529
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
530
|
+
)
|
|
531
|
+
else:
|
|
532
|
+
request_dict = _DeleteAgentEngineTaskRequestParameters_to_vertex(
|
|
533
|
+
parameter_model
|
|
534
|
+
)
|
|
535
|
+
request_url_dict = request_dict.get("_url")
|
|
536
|
+
if request_url_dict:
|
|
537
|
+
path = "{name}".format_map(request_url_dict)
|
|
538
|
+
else:
|
|
539
|
+
path = "{name}"
|
|
540
|
+
|
|
541
|
+
query_params = request_dict.get("_query")
|
|
542
|
+
if query_params:
|
|
543
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
544
|
+
# TODO: remove the hack that pops config.
|
|
545
|
+
request_dict.pop("config", None)
|
|
546
|
+
|
|
547
|
+
http_options: Optional[types.HttpOptions] = None
|
|
548
|
+
if (
|
|
549
|
+
parameter_model.config is not None
|
|
550
|
+
and parameter_model.config.http_options is not None
|
|
551
|
+
):
|
|
552
|
+
http_options = parameter_model.config.http_options
|
|
553
|
+
|
|
554
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
555
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
556
|
+
|
|
557
|
+
await self._api_client.async_request("delete", path, request_dict, http_options)
|
|
558
|
+
|
|
559
|
+
async def get(
|
|
560
|
+
self,
|
|
561
|
+
*,
|
|
562
|
+
name: str,
|
|
563
|
+
config: Optional[types.GetAgentEngineTaskConfigOrDict] = None,
|
|
564
|
+
) -> types.A2aTask:
|
|
565
|
+
"""
|
|
566
|
+
Gets an agent engine task.
|
|
567
|
+
|
|
568
|
+
Args:
|
|
569
|
+
name (str): Required. The name of the Agent Engine task to get. Format:
|
|
570
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}/a2aTasks/{task_id}`.
|
|
571
|
+
config (GetAgentEngineTaskConfig):
|
|
572
|
+
Optional. Additional configurations for getting the Agent Engine task.
|
|
573
|
+
|
|
574
|
+
Returns:
|
|
575
|
+
AgentEngineTask: The requested Agent Engine task.
|
|
576
|
+
|
|
577
|
+
"""
|
|
578
|
+
|
|
579
|
+
parameter_model = types._GetAgentEngineTaskRequestParameters(
|
|
580
|
+
name=name,
|
|
581
|
+
config=config,
|
|
582
|
+
)
|
|
583
|
+
|
|
584
|
+
request_url_dict: Optional[dict[str, str]]
|
|
585
|
+
if not self._api_client.vertexai:
|
|
586
|
+
raise ValueError(
|
|
587
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
588
|
+
)
|
|
589
|
+
else:
|
|
590
|
+
request_dict = _GetAgentEngineTaskRequestParameters_to_vertex(
|
|
591
|
+
parameter_model
|
|
592
|
+
)
|
|
593
|
+
request_url_dict = request_dict.get("_url")
|
|
594
|
+
if request_url_dict:
|
|
595
|
+
path = "{name}".format_map(request_url_dict)
|
|
596
|
+
else:
|
|
597
|
+
path = "{name}"
|
|
598
|
+
|
|
599
|
+
query_params = request_dict.get("_query")
|
|
600
|
+
if query_params:
|
|
601
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
602
|
+
# TODO: remove the hack that pops config.
|
|
603
|
+
request_dict.pop("config", None)
|
|
604
|
+
|
|
605
|
+
http_options: Optional[types.HttpOptions] = None
|
|
606
|
+
if (
|
|
607
|
+
parameter_model.config is not None
|
|
608
|
+
and parameter_model.config.http_options is not None
|
|
609
|
+
):
|
|
610
|
+
http_options = parameter_model.config.http_options
|
|
611
|
+
|
|
612
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
613
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
614
|
+
|
|
615
|
+
response = await self._api_client.async_request(
|
|
616
|
+
"get", path, request_dict, http_options
|
|
617
|
+
)
|
|
618
|
+
|
|
619
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
620
|
+
|
|
621
|
+
return_value = types.A2aTask._from_response(
|
|
622
|
+
response=response_dict,
|
|
623
|
+
kwargs=(
|
|
624
|
+
{
|
|
625
|
+
"config": {
|
|
626
|
+
"response_schema": getattr(
|
|
627
|
+
parameter_model.config, "response_schema", None
|
|
628
|
+
),
|
|
629
|
+
"response_json_schema": getattr(
|
|
630
|
+
parameter_model.config, "response_json_schema", None
|
|
631
|
+
),
|
|
632
|
+
"include_all_fields": getattr(
|
|
633
|
+
parameter_model.config, "include_all_fields", None
|
|
634
|
+
),
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
if getattr(parameter_model, "config", None)
|
|
638
|
+
else {}
|
|
639
|
+
),
|
|
640
|
+
)
|
|
641
|
+
|
|
642
|
+
self._api_client._verify_response(return_value)
|
|
643
|
+
return return_value
|
|
644
|
+
|
|
645
|
+
async def _list(
|
|
646
|
+
self,
|
|
647
|
+
*,
|
|
648
|
+
name: str,
|
|
649
|
+
config: Optional[types.ListAgentEngineTasksConfigOrDict] = None,
|
|
650
|
+
) -> types.ListAgentEngineTasksResponse:
|
|
651
|
+
"""
|
|
652
|
+
Lists Agent Engine tasks.
|
|
653
|
+
|
|
654
|
+
Args:
|
|
655
|
+
name (str): Required. The name of the Agent Engine to list tasks for. Format:
|
|
656
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}`.
|
|
657
|
+
config (ListAgentEngineTasksConfig):
|
|
658
|
+
Optional. Additional configurations for listing the Agent Engine tasks.
|
|
659
|
+
|
|
660
|
+
Returns:
|
|
661
|
+
ListAgentEngineTasksResponse: The requested Agent Engine tasks.
|
|
662
|
+
|
|
663
|
+
"""
|
|
664
|
+
|
|
665
|
+
parameter_model = types._ListAgentEngineTasksRequestParameters(
|
|
666
|
+
name=name,
|
|
667
|
+
config=config,
|
|
668
|
+
)
|
|
669
|
+
|
|
670
|
+
request_url_dict: Optional[dict[str, str]]
|
|
671
|
+
if not self._api_client.vertexai:
|
|
672
|
+
raise ValueError(
|
|
673
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
674
|
+
)
|
|
675
|
+
else:
|
|
676
|
+
request_dict = _ListAgentEngineTasksRequestParameters_to_vertex(
|
|
677
|
+
parameter_model
|
|
678
|
+
)
|
|
679
|
+
request_url_dict = request_dict.get("_url")
|
|
680
|
+
if request_url_dict:
|
|
681
|
+
path = "{name}/a2aTasks".format_map(request_url_dict)
|
|
682
|
+
else:
|
|
683
|
+
path = "{name}/a2aTasks"
|
|
684
|
+
|
|
685
|
+
query_params = request_dict.get("_query")
|
|
686
|
+
if query_params:
|
|
687
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
688
|
+
# TODO: remove the hack that pops config.
|
|
689
|
+
request_dict.pop("config", None)
|
|
690
|
+
|
|
691
|
+
http_options: Optional[types.HttpOptions] = None
|
|
692
|
+
if (
|
|
693
|
+
parameter_model.config is not None
|
|
694
|
+
and parameter_model.config.http_options is not None
|
|
695
|
+
):
|
|
696
|
+
http_options = parameter_model.config.http_options
|
|
697
|
+
|
|
698
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
699
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
700
|
+
|
|
701
|
+
response = await self._api_client.async_request(
|
|
702
|
+
"get", path, request_dict, http_options
|
|
703
|
+
)
|
|
704
|
+
|
|
705
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
706
|
+
|
|
707
|
+
return_value = types.ListAgentEngineTasksResponse._from_response(
|
|
708
|
+
response=response_dict,
|
|
709
|
+
kwargs=(
|
|
710
|
+
{
|
|
711
|
+
"config": {
|
|
712
|
+
"response_schema": getattr(
|
|
713
|
+
parameter_model.config, "response_schema", None
|
|
714
|
+
),
|
|
715
|
+
"response_json_schema": getattr(
|
|
716
|
+
parameter_model.config, "response_json_schema", None
|
|
717
|
+
),
|
|
718
|
+
"include_all_fields": getattr(
|
|
719
|
+
parameter_model.config, "include_all_fields", None
|
|
720
|
+
),
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
if getattr(parameter_model, "config", None)
|
|
724
|
+
else {}
|
|
725
|
+
),
|
|
726
|
+
)
|
|
727
|
+
|
|
728
|
+
self._api_client._verify_response(return_value)
|
|
729
|
+
return return_value
|
|
730
|
+
|
|
731
|
+
async def create(
|
|
732
|
+
self,
|
|
733
|
+
*,
|
|
734
|
+
name: str,
|
|
735
|
+
a2a_task_id: str,
|
|
736
|
+
config: Optional[types.CreateAgentEngineTaskConfigOrDict] = None,
|
|
737
|
+
) -> types.A2aTask:
|
|
738
|
+
"""
|
|
739
|
+
Creates a new task in the Agent Engine.
|
|
740
|
+
|
|
741
|
+
Args:
|
|
742
|
+
name (str): Required. The name of the Agent Engine to create the task under. Format:
|
|
743
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}`.
|
|
744
|
+
a2a_task_id (str): Required. The user ID of the task.
|
|
745
|
+
context_id (str): Required. The ID of the context to use for the task.
|
|
746
|
+
config (CreateAgentEngineTaskConfig):
|
|
747
|
+
Optional. Additional configurations for creating the Agent Engine task.
|
|
748
|
+
|
|
749
|
+
Returns:
|
|
750
|
+
A2aTask: The created Agent Engine task.
|
|
751
|
+
|
|
752
|
+
"""
|
|
753
|
+
|
|
754
|
+
parameter_model = types._CreateAgentEngineTaskRequestParameters(
|
|
755
|
+
name=name,
|
|
756
|
+
a2a_task_id=a2a_task_id,
|
|
757
|
+
config=config,
|
|
758
|
+
)
|
|
759
|
+
|
|
760
|
+
request_url_dict: Optional[dict[str, str]]
|
|
761
|
+
if not self._api_client.vertexai:
|
|
762
|
+
raise ValueError(
|
|
763
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
764
|
+
)
|
|
765
|
+
else:
|
|
766
|
+
request_dict = _CreateAgentEngineTaskRequestParameters_to_vertex(
|
|
767
|
+
parameter_model
|
|
768
|
+
)
|
|
769
|
+
request_url_dict = request_dict.get("_url")
|
|
770
|
+
if request_url_dict:
|
|
771
|
+
path = "{name}/a2aTasks".format_map(request_url_dict)
|
|
772
|
+
else:
|
|
773
|
+
path = "{name}/a2aTasks"
|
|
774
|
+
|
|
775
|
+
query_params = request_dict.get("_query")
|
|
776
|
+
if query_params:
|
|
777
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
778
|
+
# TODO: remove the hack that pops config.
|
|
779
|
+
request_dict.pop("config", None)
|
|
780
|
+
|
|
781
|
+
http_options: Optional[types.HttpOptions] = None
|
|
782
|
+
if (
|
|
783
|
+
parameter_model.config is not None
|
|
784
|
+
and parameter_model.config.http_options is not None
|
|
785
|
+
):
|
|
786
|
+
http_options = parameter_model.config.http_options
|
|
787
|
+
|
|
788
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
789
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
790
|
+
|
|
791
|
+
response = await self._api_client.async_request(
|
|
792
|
+
"post", path, request_dict, http_options
|
|
793
|
+
)
|
|
794
|
+
|
|
795
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
796
|
+
|
|
797
|
+
return_value = types.A2aTask._from_response(
|
|
798
|
+
response=response_dict,
|
|
799
|
+
kwargs=(
|
|
800
|
+
{
|
|
801
|
+
"config": {
|
|
802
|
+
"response_schema": getattr(
|
|
803
|
+
parameter_model.config, "response_schema", None
|
|
804
|
+
),
|
|
805
|
+
"response_json_schema": getattr(
|
|
806
|
+
parameter_model.config, "response_json_schema", None
|
|
807
|
+
),
|
|
808
|
+
"include_all_fields": getattr(
|
|
809
|
+
parameter_model.config, "include_all_fields", None
|
|
810
|
+
),
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
if getattr(parameter_model, "config", None)
|
|
814
|
+
else {}
|
|
815
|
+
),
|
|
816
|
+
)
|
|
817
|
+
|
|
818
|
+
self._api_client._verify_response(return_value)
|
|
819
|
+
return return_value
|
|
820
|
+
|
|
821
|
+
_events = None
|
|
822
|
+
|
|
823
|
+
async def list(
|
|
824
|
+
self,
|
|
825
|
+
*,
|
|
826
|
+
name: str,
|
|
827
|
+
config: Optional[types.ListAgentEngineTasksConfigOrDict] = None,
|
|
828
|
+
) -> AsyncPager[types.A2aTask]:
|
|
829
|
+
"""Lists the A2A tasks of an Agent Engine.
|
|
830
|
+
|
|
831
|
+
Args:
|
|
832
|
+
name (str):
|
|
833
|
+
Required. The name of the agent engine to list tasks for.
|
|
834
|
+
config (List):
|
|
835
|
+
Optional. The configuration for the tasks to list.
|
|
836
|
+
|
|
837
|
+
Returns:
|
|
838
|
+
AsyncPager[A2aTask]: An async pager of A2A tasks.
|
|
839
|
+
"""
|
|
840
|
+
|
|
841
|
+
return AsyncPager(
|
|
842
|
+
"a2aTasks",
|
|
843
|
+
functools.partial(self._list, name=name),
|
|
844
|
+
await self._list(name=name, config=config),
|
|
845
|
+
config,
|
|
846
|
+
)
|
|
847
|
+
|
|
848
|
+
@property
|
|
849
|
+
def events(self) -> "a2a_task_events_module.AsyncA2aTaskEvents":
|
|
850
|
+
if self._events is None:
|
|
851
|
+
try:
|
|
852
|
+
# We need to lazy load the events module to handle the
|
|
853
|
+
# possibility of ImportError when dependencies are not installed.
|
|
854
|
+
self._events = importlib.import_module(".a2a_task_events", __package__)
|
|
855
|
+
except ImportError as e:
|
|
856
|
+
raise ImportError(
|
|
857
|
+
"The 'agent_engines.a2a_tasks.events' module requires additional "
|
|
858
|
+
"packages. Please install them using pip install "
|
|
859
|
+
"google-cloud-aiplatform[agent_engines]"
|
|
860
|
+
) from e
|
|
861
|
+
return self._events.AsyncA2aTaskEvents(self._api_client) # type: ignore[no-any-return]
|