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,1257 @@
|
|
|
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 json
|
|
20
|
+
import logging
|
|
21
|
+
from typing import Any, AsyncIterator, Iterator, Optional, Union
|
|
22
|
+
from urllib.parse import urlencode
|
|
23
|
+
|
|
24
|
+
from google.genai import _api_module
|
|
25
|
+
from google.genai import _common
|
|
26
|
+
from google.genai._common import get_value_by_path as getv
|
|
27
|
+
from google.genai._common import set_value_by_path as setv
|
|
28
|
+
from google.genai.pagers import AsyncPager, Pager
|
|
29
|
+
|
|
30
|
+
from . import _agent_engines_utils
|
|
31
|
+
from . import types
|
|
32
|
+
|
|
33
|
+
logger = logging.getLogger("agentplatform_genai.runtimerevisions")
|
|
34
|
+
|
|
35
|
+
logger.setLevel(logging.INFO)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _DeleteAgentEngineRuntimeRevisionRequestParameters_to_vertex(
|
|
39
|
+
from_object: Union[dict[str, Any], object],
|
|
40
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
41
|
+
) -> dict[str, Any]:
|
|
42
|
+
to_object: dict[str, Any] = {}
|
|
43
|
+
if getv(from_object, ["name"]) is not None:
|
|
44
|
+
setv(to_object, ["_url", "name"], getv(from_object, ["name"]))
|
|
45
|
+
|
|
46
|
+
return to_object
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _GetAgentEngineRuntimeRevisionRequestParameters_to_vertex(
|
|
50
|
+
from_object: Union[dict[str, Any], object],
|
|
51
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
52
|
+
) -> dict[str, Any]:
|
|
53
|
+
to_object: dict[str, Any] = {}
|
|
54
|
+
if getv(from_object, ["name"]) is not None:
|
|
55
|
+
setv(to_object, ["_url", "name"], getv(from_object, ["name"]))
|
|
56
|
+
|
|
57
|
+
return to_object
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _GetDeleteAgentEngineRuntimeRevisionOperationParameters_to_vertex(
|
|
61
|
+
from_object: Union[dict[str, Any], object],
|
|
62
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
63
|
+
) -> dict[str, Any]:
|
|
64
|
+
to_object: dict[str, Any] = {}
|
|
65
|
+
if getv(from_object, ["operation_name"]) is not None:
|
|
66
|
+
setv(
|
|
67
|
+
to_object, ["_url", "operationName"], getv(from_object, ["operation_name"])
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
return to_object
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _ListAgentEngineRuntimeRevisionsConfig_to_vertex(
|
|
74
|
+
from_object: Union[dict[str, Any], object],
|
|
75
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
76
|
+
) -> dict[str, Any]:
|
|
77
|
+
to_object: dict[str, Any] = {}
|
|
78
|
+
|
|
79
|
+
if getv(from_object, ["page_size"]) is not None:
|
|
80
|
+
setv(parent_object, ["_query", "pageSize"], getv(from_object, ["page_size"]))
|
|
81
|
+
|
|
82
|
+
if getv(from_object, ["page_token"]) is not None:
|
|
83
|
+
setv(parent_object, ["_query", "pageToken"], getv(from_object, ["page_token"]))
|
|
84
|
+
|
|
85
|
+
if getv(from_object, ["filter"]) is not None:
|
|
86
|
+
setv(parent_object, ["_query", "filter"], getv(from_object, ["filter"]))
|
|
87
|
+
|
|
88
|
+
return to_object
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _ListAgentEngineRuntimeRevisionsRequestParameters_to_vertex(
|
|
92
|
+
from_object: Union[dict[str, Any], object],
|
|
93
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
94
|
+
) -> dict[str, Any]:
|
|
95
|
+
to_object: dict[str, Any] = {}
|
|
96
|
+
if getv(from_object, ["name"]) is not None:
|
|
97
|
+
setv(to_object, ["_url", "name"], getv(from_object, ["name"]))
|
|
98
|
+
|
|
99
|
+
if getv(from_object, ["config"]) is not None:
|
|
100
|
+
_ListAgentEngineRuntimeRevisionsConfig_to_vertex(
|
|
101
|
+
getv(from_object, ["config"]), to_object
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
return to_object
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _QueryAgentEngineRuntimeRevisionConfig_to_vertex(
|
|
108
|
+
from_object: Union[dict[str, Any], object],
|
|
109
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
110
|
+
) -> dict[str, Any]:
|
|
111
|
+
to_object: dict[str, Any] = {}
|
|
112
|
+
|
|
113
|
+
if getv(from_object, ["class_method"]) is not None:
|
|
114
|
+
setv(parent_object, ["classMethod"], getv(from_object, ["class_method"]))
|
|
115
|
+
|
|
116
|
+
if getv(from_object, ["input"]) is not None:
|
|
117
|
+
setv(parent_object, ["input"], getv(from_object, ["input"]))
|
|
118
|
+
|
|
119
|
+
if getv(from_object, ["include_all_fields"]) is not None:
|
|
120
|
+
setv(to_object, ["includeAllFields"], getv(from_object, ["include_all_fields"]))
|
|
121
|
+
|
|
122
|
+
return to_object
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _QueryAgentEngineRuntimeRevisionRequestParameters_to_vertex(
|
|
126
|
+
from_object: Union[dict[str, Any], object],
|
|
127
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
128
|
+
) -> dict[str, Any]:
|
|
129
|
+
to_object: dict[str, Any] = {}
|
|
130
|
+
if getv(from_object, ["name"]) is not None:
|
|
131
|
+
setv(to_object, ["_url", "name"], getv(from_object, ["name"]))
|
|
132
|
+
|
|
133
|
+
if getv(from_object, ["config"]) is not None:
|
|
134
|
+
_QueryAgentEngineRuntimeRevisionConfig_to_vertex(
|
|
135
|
+
getv(from_object, ["config"]), to_object
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
return to_object
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class RuntimeRevisions(_api_module.BaseModule):
|
|
142
|
+
|
|
143
|
+
def _get(
|
|
144
|
+
self,
|
|
145
|
+
*,
|
|
146
|
+
name: str,
|
|
147
|
+
config: Optional[types.GetAgentEngineRuntimeRevisionConfigOrDict] = None,
|
|
148
|
+
) -> types.ReasoningEngineRuntimeRevision:
|
|
149
|
+
"""
|
|
150
|
+
Get an agent engine runtime revision instance.
|
|
151
|
+
"""
|
|
152
|
+
|
|
153
|
+
parameter_model = types._GetAgentEngineRuntimeRevisionRequestParameters(
|
|
154
|
+
name=name,
|
|
155
|
+
config=config,
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
request_url_dict: Optional[dict[str, str]]
|
|
159
|
+
if not self._api_client.vertexai:
|
|
160
|
+
raise ValueError(
|
|
161
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
162
|
+
)
|
|
163
|
+
else:
|
|
164
|
+
request_dict = _GetAgentEngineRuntimeRevisionRequestParameters_to_vertex(
|
|
165
|
+
parameter_model
|
|
166
|
+
)
|
|
167
|
+
request_url_dict = request_dict.get("_url")
|
|
168
|
+
if request_url_dict:
|
|
169
|
+
path = "{name}".format_map(request_url_dict)
|
|
170
|
+
else:
|
|
171
|
+
path = "{name}"
|
|
172
|
+
|
|
173
|
+
query_params = request_dict.get("_query")
|
|
174
|
+
if query_params:
|
|
175
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
176
|
+
# TODO: remove the hack that pops config.
|
|
177
|
+
request_dict.pop("config", None)
|
|
178
|
+
|
|
179
|
+
http_options: Optional[types.HttpOptions] = None
|
|
180
|
+
if (
|
|
181
|
+
parameter_model.config is not None
|
|
182
|
+
and parameter_model.config.http_options is not None
|
|
183
|
+
):
|
|
184
|
+
http_options = parameter_model.config.http_options
|
|
185
|
+
|
|
186
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
187
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
188
|
+
|
|
189
|
+
response = self._api_client.request("get", path, request_dict, http_options)
|
|
190
|
+
|
|
191
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
192
|
+
|
|
193
|
+
return_value = types.ReasoningEngineRuntimeRevision._from_response(
|
|
194
|
+
response=response_dict,
|
|
195
|
+
kwargs=(
|
|
196
|
+
{
|
|
197
|
+
"config": {
|
|
198
|
+
"response_schema": getattr(
|
|
199
|
+
parameter_model.config, "response_schema", None
|
|
200
|
+
),
|
|
201
|
+
"response_json_schema": getattr(
|
|
202
|
+
parameter_model.config, "response_json_schema", None
|
|
203
|
+
),
|
|
204
|
+
"include_all_fields": getattr(
|
|
205
|
+
parameter_model.config, "include_all_fields", None
|
|
206
|
+
),
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if getattr(parameter_model, "config", None)
|
|
210
|
+
else {}
|
|
211
|
+
),
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
self._api_client._verify_response(return_value)
|
|
215
|
+
return return_value
|
|
216
|
+
|
|
217
|
+
def _list(
|
|
218
|
+
self,
|
|
219
|
+
*,
|
|
220
|
+
name: str,
|
|
221
|
+
config: Optional[types.ListAgentEngineRuntimeRevisionsConfigOrDict] = None,
|
|
222
|
+
) -> types.ListReasoningEnginesRuntimeRevisionsResponse:
|
|
223
|
+
"""
|
|
224
|
+
Lists reasoning engine runtime revisions.
|
|
225
|
+
|
|
226
|
+
Args:
|
|
227
|
+
name (str): Required. The name of the reasoning engine to list runtime revisions for. Format:
|
|
228
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}`.
|
|
229
|
+
config (ListAgentEngineRuntimeRevisionsConfig):
|
|
230
|
+
Optional. Additional configurations for listing the reasoning engine runtime revisions.
|
|
231
|
+
|
|
232
|
+
Returns:
|
|
233
|
+
ListReasoningEnginesRuntimeRevisionsResponse: The requested reasoning engine runtime revisions.
|
|
234
|
+
|
|
235
|
+
"""
|
|
236
|
+
|
|
237
|
+
parameter_model = types._ListAgentEngineRuntimeRevisionsRequestParameters(
|
|
238
|
+
name=name,
|
|
239
|
+
config=config,
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
request_url_dict: Optional[dict[str, str]]
|
|
243
|
+
if not self._api_client.vertexai:
|
|
244
|
+
raise ValueError(
|
|
245
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
246
|
+
)
|
|
247
|
+
else:
|
|
248
|
+
request_dict = _ListAgentEngineRuntimeRevisionsRequestParameters_to_vertex(
|
|
249
|
+
parameter_model
|
|
250
|
+
)
|
|
251
|
+
request_url_dict = request_dict.get("_url")
|
|
252
|
+
if request_url_dict:
|
|
253
|
+
path = "{name}/runtimeRevisions".format_map(request_url_dict)
|
|
254
|
+
else:
|
|
255
|
+
path = "{name}/runtimeRevisions"
|
|
256
|
+
|
|
257
|
+
query_params = request_dict.get("_query")
|
|
258
|
+
if query_params:
|
|
259
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
260
|
+
# TODO: remove the hack that pops config.
|
|
261
|
+
request_dict.pop("config", None)
|
|
262
|
+
|
|
263
|
+
http_options: Optional[types.HttpOptions] = None
|
|
264
|
+
if (
|
|
265
|
+
parameter_model.config is not None
|
|
266
|
+
and parameter_model.config.http_options is not None
|
|
267
|
+
):
|
|
268
|
+
http_options = parameter_model.config.http_options
|
|
269
|
+
|
|
270
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
271
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
272
|
+
|
|
273
|
+
response = self._api_client.request("get", path, request_dict, http_options)
|
|
274
|
+
|
|
275
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
276
|
+
|
|
277
|
+
return_value = (
|
|
278
|
+
types.ListReasoningEnginesRuntimeRevisionsResponse._from_response(
|
|
279
|
+
response=response_dict,
|
|
280
|
+
kwargs=(
|
|
281
|
+
{
|
|
282
|
+
"config": {
|
|
283
|
+
"response_schema": getattr(
|
|
284
|
+
parameter_model.config, "response_schema", None
|
|
285
|
+
),
|
|
286
|
+
"response_json_schema": getattr(
|
|
287
|
+
parameter_model.config, "response_json_schema", None
|
|
288
|
+
),
|
|
289
|
+
"include_all_fields": getattr(
|
|
290
|
+
parameter_model.config, "include_all_fields", None
|
|
291
|
+
),
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if getattr(parameter_model, "config", None)
|
|
295
|
+
else {}
|
|
296
|
+
),
|
|
297
|
+
)
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
self._api_client._verify_response(return_value)
|
|
301
|
+
return return_value
|
|
302
|
+
|
|
303
|
+
def _delete(
|
|
304
|
+
self,
|
|
305
|
+
*,
|
|
306
|
+
name: str,
|
|
307
|
+
config: Optional[types.DeleteAgentEngineRuntimeRevisionConfigOrDict] = None,
|
|
308
|
+
) -> types.DeleteAgentEngineRuntimeRevisionOperation:
|
|
309
|
+
"""
|
|
310
|
+
Delete an Agent Engine runtime revision.
|
|
311
|
+
|
|
312
|
+
Args:
|
|
313
|
+
name (str): Required. The name of the Agent Engine runtime revision to be deleted. Format:
|
|
314
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}/runtimeRevisions/{runtime_revision_id}`.
|
|
315
|
+
config (DeleteAgentEngineRuntimeRevisionConfig):
|
|
316
|
+
Optional. Additional configurations for deleting the Agent Engine runtime revision.
|
|
317
|
+
|
|
318
|
+
Returns:
|
|
319
|
+
DeleteAgentEngineRuntimeRevisionOperation: The operation for deleting the Agent Engine runtime revision.
|
|
320
|
+
|
|
321
|
+
"""
|
|
322
|
+
|
|
323
|
+
parameter_model = types._DeleteAgentEngineRuntimeRevisionRequestParameters(
|
|
324
|
+
name=name,
|
|
325
|
+
config=config,
|
|
326
|
+
)
|
|
327
|
+
|
|
328
|
+
request_url_dict: Optional[dict[str, str]]
|
|
329
|
+
if not self._api_client.vertexai:
|
|
330
|
+
raise ValueError(
|
|
331
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
332
|
+
)
|
|
333
|
+
else:
|
|
334
|
+
request_dict = _DeleteAgentEngineRuntimeRevisionRequestParameters_to_vertex(
|
|
335
|
+
parameter_model
|
|
336
|
+
)
|
|
337
|
+
request_url_dict = request_dict.get("_url")
|
|
338
|
+
if request_url_dict:
|
|
339
|
+
path = "{name}".format_map(request_url_dict)
|
|
340
|
+
else:
|
|
341
|
+
path = "{name}"
|
|
342
|
+
|
|
343
|
+
query_params = request_dict.get("_query")
|
|
344
|
+
if query_params:
|
|
345
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
346
|
+
# TODO: remove the hack that pops config.
|
|
347
|
+
request_dict.pop("config", None)
|
|
348
|
+
|
|
349
|
+
http_options: Optional[types.HttpOptions] = None
|
|
350
|
+
if (
|
|
351
|
+
parameter_model.config is not None
|
|
352
|
+
and parameter_model.config.http_options is not None
|
|
353
|
+
):
|
|
354
|
+
http_options = parameter_model.config.http_options
|
|
355
|
+
|
|
356
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
357
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
358
|
+
|
|
359
|
+
response = self._api_client.request("delete", path, request_dict, http_options)
|
|
360
|
+
|
|
361
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
362
|
+
|
|
363
|
+
return_value = types.DeleteAgentEngineRuntimeRevisionOperation._from_response(
|
|
364
|
+
response=response_dict,
|
|
365
|
+
kwargs=(
|
|
366
|
+
{
|
|
367
|
+
"config": {
|
|
368
|
+
"response_schema": getattr(
|
|
369
|
+
parameter_model.config, "response_schema", None
|
|
370
|
+
),
|
|
371
|
+
"response_json_schema": getattr(
|
|
372
|
+
parameter_model.config, "response_json_schema", None
|
|
373
|
+
),
|
|
374
|
+
"include_all_fields": getattr(
|
|
375
|
+
parameter_model.config, "include_all_fields", None
|
|
376
|
+
),
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if getattr(parameter_model, "config", None)
|
|
380
|
+
else {}
|
|
381
|
+
),
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
self._api_client._verify_response(return_value)
|
|
385
|
+
return return_value
|
|
386
|
+
|
|
387
|
+
def _get_delete_runtime_revision_operation(
|
|
388
|
+
self,
|
|
389
|
+
*,
|
|
390
|
+
operation_name: str,
|
|
391
|
+
config: Optional[
|
|
392
|
+
types.GetDeleteAgentEngineRuntimeRevisionOperationConfigOrDict
|
|
393
|
+
] = None,
|
|
394
|
+
) -> types.DeleteAgentEngineRuntimeRevisionOperation:
|
|
395
|
+
parameter_model = types._GetDeleteAgentEngineRuntimeRevisionOperationParameters(
|
|
396
|
+
operation_name=operation_name,
|
|
397
|
+
config=config,
|
|
398
|
+
)
|
|
399
|
+
|
|
400
|
+
request_url_dict: Optional[dict[str, str]]
|
|
401
|
+
if not self._api_client.vertexai:
|
|
402
|
+
raise ValueError(
|
|
403
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
404
|
+
)
|
|
405
|
+
else:
|
|
406
|
+
request_dict = (
|
|
407
|
+
_GetDeleteAgentEngineRuntimeRevisionOperationParameters_to_vertex(
|
|
408
|
+
parameter_model
|
|
409
|
+
)
|
|
410
|
+
)
|
|
411
|
+
request_url_dict = request_dict.get("_url")
|
|
412
|
+
if request_url_dict:
|
|
413
|
+
path = "{operationName}".format_map(request_url_dict)
|
|
414
|
+
else:
|
|
415
|
+
path = "{operationName}"
|
|
416
|
+
|
|
417
|
+
query_params = request_dict.get("_query")
|
|
418
|
+
if query_params:
|
|
419
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
420
|
+
# TODO: remove the hack that pops config.
|
|
421
|
+
request_dict.pop("config", None)
|
|
422
|
+
|
|
423
|
+
http_options: Optional[types.HttpOptions] = None
|
|
424
|
+
if (
|
|
425
|
+
parameter_model.config is not None
|
|
426
|
+
and parameter_model.config.http_options is not None
|
|
427
|
+
):
|
|
428
|
+
http_options = parameter_model.config.http_options
|
|
429
|
+
|
|
430
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
431
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
432
|
+
|
|
433
|
+
response = self._api_client.request("get", path, request_dict, http_options)
|
|
434
|
+
|
|
435
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
436
|
+
|
|
437
|
+
return_value = types.DeleteAgentEngineRuntimeRevisionOperation._from_response(
|
|
438
|
+
response=response_dict,
|
|
439
|
+
kwargs=(
|
|
440
|
+
{
|
|
441
|
+
"config": {
|
|
442
|
+
"response_schema": getattr(
|
|
443
|
+
parameter_model.config, "response_schema", None
|
|
444
|
+
),
|
|
445
|
+
"response_json_schema": getattr(
|
|
446
|
+
parameter_model.config, "response_json_schema", None
|
|
447
|
+
),
|
|
448
|
+
"include_all_fields": getattr(
|
|
449
|
+
parameter_model.config, "include_all_fields", None
|
|
450
|
+
),
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
if getattr(parameter_model, "config", None)
|
|
454
|
+
else {}
|
|
455
|
+
),
|
|
456
|
+
)
|
|
457
|
+
|
|
458
|
+
self._api_client._verify_response(return_value)
|
|
459
|
+
return return_value
|
|
460
|
+
|
|
461
|
+
def _query(
|
|
462
|
+
self,
|
|
463
|
+
*,
|
|
464
|
+
name: str,
|
|
465
|
+
config: Optional[types.QueryAgentEngineRuntimeRevisionConfigOrDict] = None,
|
|
466
|
+
) -> types.QueryReasoningEngineResponse:
|
|
467
|
+
"""
|
|
468
|
+
Query an Agent Engine runtime revision.
|
|
469
|
+
"""
|
|
470
|
+
|
|
471
|
+
parameter_model = types._QueryAgentEngineRuntimeRevisionRequestParameters(
|
|
472
|
+
name=name,
|
|
473
|
+
config=config,
|
|
474
|
+
)
|
|
475
|
+
|
|
476
|
+
request_url_dict: Optional[dict[str, str]]
|
|
477
|
+
if not self._api_client.vertexai:
|
|
478
|
+
raise ValueError(
|
|
479
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
480
|
+
)
|
|
481
|
+
else:
|
|
482
|
+
request_dict = _QueryAgentEngineRuntimeRevisionRequestParameters_to_vertex(
|
|
483
|
+
parameter_model
|
|
484
|
+
)
|
|
485
|
+
request_url_dict = request_dict.get("_url")
|
|
486
|
+
if request_url_dict:
|
|
487
|
+
path = "{name}:query".format_map(request_url_dict)
|
|
488
|
+
else:
|
|
489
|
+
path = "{name}:query"
|
|
490
|
+
|
|
491
|
+
query_params = request_dict.get("_query")
|
|
492
|
+
if query_params:
|
|
493
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
494
|
+
# TODO: remove the hack that pops config.
|
|
495
|
+
request_dict.pop("config", None)
|
|
496
|
+
|
|
497
|
+
http_options: Optional[types.HttpOptions] = None
|
|
498
|
+
if (
|
|
499
|
+
parameter_model.config is not None
|
|
500
|
+
and parameter_model.config.http_options is not None
|
|
501
|
+
):
|
|
502
|
+
http_options = parameter_model.config.http_options
|
|
503
|
+
|
|
504
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
505
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
506
|
+
|
|
507
|
+
response = self._api_client.request("post", path, request_dict, http_options)
|
|
508
|
+
|
|
509
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
510
|
+
|
|
511
|
+
return_value = types.QueryReasoningEngineResponse._from_response(
|
|
512
|
+
response=response_dict,
|
|
513
|
+
kwargs=(
|
|
514
|
+
{
|
|
515
|
+
"config": {
|
|
516
|
+
"response_schema": getattr(
|
|
517
|
+
parameter_model.config, "response_schema", None
|
|
518
|
+
),
|
|
519
|
+
"response_json_schema": getattr(
|
|
520
|
+
parameter_model.config, "response_json_schema", None
|
|
521
|
+
),
|
|
522
|
+
"include_all_fields": getattr(
|
|
523
|
+
parameter_model.config, "include_all_fields", None
|
|
524
|
+
),
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
if getattr(parameter_model, "config", None)
|
|
528
|
+
else {}
|
|
529
|
+
),
|
|
530
|
+
)
|
|
531
|
+
|
|
532
|
+
self._api_client._verify_response(return_value)
|
|
533
|
+
return return_value
|
|
534
|
+
|
|
535
|
+
def get(
|
|
536
|
+
self,
|
|
537
|
+
*,
|
|
538
|
+
name: str,
|
|
539
|
+
config: Optional[types.GetAgentEngineRuntimeRevisionConfigOrDict] = None,
|
|
540
|
+
) -> types.AgentEngineRuntimeRevision:
|
|
541
|
+
"""Gets an agent engine runtime revision.
|
|
542
|
+
|
|
543
|
+
Args:
|
|
544
|
+
name (str): Required. The name of the Agent Engine runtime revision to get. Format:
|
|
545
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}/runtimeRevisions/{runtime_revision_id}`.
|
|
546
|
+
config (GetAgentEngineRuntimeRevisionConfigOrDict):
|
|
547
|
+
Optional. Additional configurations for getting the Agent Engine runtime revision.
|
|
548
|
+
|
|
549
|
+
Returns:
|
|
550
|
+
AgentEngineRuntimeRevision: The requested Agent Engine runtime revision instance.
|
|
551
|
+
"""
|
|
552
|
+
api_resource = self._get(name=name, config=config)
|
|
553
|
+
agent_engine_runtime_revision = types.AgentEngineRuntimeRevision(
|
|
554
|
+
api_client=self,
|
|
555
|
+
api_async_client=AsyncRuntimeRevisions(api_client_=self._api_client),
|
|
556
|
+
api_resource=api_resource,
|
|
557
|
+
)
|
|
558
|
+
if api_resource.spec:
|
|
559
|
+
self._register_api_methods(
|
|
560
|
+
agent_engine_runtime_revision=agent_engine_runtime_revision
|
|
561
|
+
)
|
|
562
|
+
return agent_engine_runtime_revision
|
|
563
|
+
|
|
564
|
+
def list(
|
|
565
|
+
self,
|
|
566
|
+
*,
|
|
567
|
+
name: str,
|
|
568
|
+
config: Optional[types.ListAgentEngineRuntimeRevisionsConfigOrDict] = None,
|
|
569
|
+
) -> Iterator[types.AgentEngineRuntimeRevision]:
|
|
570
|
+
"""Lists all reasoning engine runtime revision instances matching the given query.
|
|
571
|
+
|
|
572
|
+
Args:
|
|
573
|
+
name (str): Required. The name of the reasoning engine to list runtime revisions for. Format:
|
|
574
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}`.
|
|
575
|
+
config (ListAgentEngineRuntimeRevisionsConfig):
|
|
576
|
+
Optional. Additional configurations for listing the reasoning engine runtime revisions.
|
|
577
|
+
|
|
578
|
+
Returns:
|
|
579
|
+
Iterable[AgentEngineRuntimeRevision]: An iterable of runtime revisions.
|
|
580
|
+
"""
|
|
581
|
+
list_pager: Pager[types.ReasoningEngineRuntimeRevision] = Pager(
|
|
582
|
+
"reasoning_engine_runtime_revisions",
|
|
583
|
+
functools.partial(self._list, name=name),
|
|
584
|
+
self._list(name=name, config=config),
|
|
585
|
+
config,
|
|
586
|
+
)
|
|
587
|
+
|
|
588
|
+
return (
|
|
589
|
+
types.AgentEngineRuntimeRevision(
|
|
590
|
+
api_client=self,
|
|
591
|
+
api_async_client=AsyncRuntimeRevisions(api_client_=self._api_client),
|
|
592
|
+
api_resource=runtime_revision,
|
|
593
|
+
)
|
|
594
|
+
for runtime_revision in list_pager
|
|
595
|
+
)
|
|
596
|
+
|
|
597
|
+
def delete(
|
|
598
|
+
self,
|
|
599
|
+
*,
|
|
600
|
+
name: str,
|
|
601
|
+
config: Optional[types.DeleteAgentEngineRuntimeRevisionConfigOrDict] = None,
|
|
602
|
+
) -> types.DeleteAgentEngineRuntimeRevisionOperation:
|
|
603
|
+
"""Delete an Agent Engine runtime revision.
|
|
604
|
+
|
|
605
|
+
Args:
|
|
606
|
+
name (str): Required. The name of the Agent Engine runtime revision to be deleted. Format:
|
|
607
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}/runtimeRevisions/{runtime_revision_id}`.
|
|
608
|
+
config (DeleteAgentEngineRuntimeRevisionConfig):
|
|
609
|
+
Optional. Additional configurations for deleting the Agent Engine runtime revision.
|
|
610
|
+
|
|
611
|
+
Returns:
|
|
612
|
+
DeleteAgentEngineRuntimeRevisionOperation: The operation for deleting the Agent Engine runtime revision.
|
|
613
|
+
"""
|
|
614
|
+
if config is None:
|
|
615
|
+
config = types.DeleteAgentEngineRuntimeRevisionConfig()
|
|
616
|
+
elif isinstance(config, dict):
|
|
617
|
+
config = types.DeleteAgentEngineRuntimeRevisionConfig.model_validate(config)
|
|
618
|
+
operation = self._delete(
|
|
619
|
+
name=name,
|
|
620
|
+
config=config,
|
|
621
|
+
)
|
|
622
|
+
if config.wait_for_completion and not operation.done:
|
|
623
|
+
operation = _agent_engines_utils._await_operation(
|
|
624
|
+
operation_name=operation.name,
|
|
625
|
+
get_operation_fn=self._get_delete_runtime_revision_operation,
|
|
626
|
+
poll_interval_seconds=0.5,
|
|
627
|
+
)
|
|
628
|
+
if operation.error:
|
|
629
|
+
raise RuntimeError(
|
|
630
|
+
f"Failed to delete runtime revision: {operation.error}"
|
|
631
|
+
)
|
|
632
|
+
return operation
|
|
633
|
+
|
|
634
|
+
def _register_api_methods(
|
|
635
|
+
self,
|
|
636
|
+
*,
|
|
637
|
+
agent_engine_runtime_revision: types.AgentEngineRuntimeRevision,
|
|
638
|
+
) -> types.AgentEngineRuntimeRevision:
|
|
639
|
+
"""Registers the API methods for the agent engine runtime revision."""
|
|
640
|
+
try:
|
|
641
|
+
_agent_engines_utils._register_api_methods_or_raise(
|
|
642
|
+
agent_engine=agent_engine_runtime_revision,
|
|
643
|
+
wrap_operation_fn={
|
|
644
|
+
"": _agent_engines_utils._wrap_query_operation, # type: ignore[dict-item]
|
|
645
|
+
"async": _agent_engines_utils._wrap_async_query_operation, # type: ignore[dict-item]
|
|
646
|
+
"stream": _agent_engines_utils._wrap_stream_query_operation, # type: ignore[dict-item]
|
|
647
|
+
"async_stream": _agent_engines_utils._wrap_async_stream_query_operation, # type: ignore[dict-item]
|
|
648
|
+
"a2a_extension": _agent_engines_utils._wrap_a2a_operation,
|
|
649
|
+
},
|
|
650
|
+
)
|
|
651
|
+
except Exception as e:
|
|
652
|
+
logger.warning(
|
|
653
|
+
_agent_engines_utils._FAILED_TO_REGISTER_API_METHODS_WARNING_TEMPLATE, e
|
|
654
|
+
)
|
|
655
|
+
return agent_engine_runtime_revision
|
|
656
|
+
|
|
657
|
+
def _stream_query(
|
|
658
|
+
self,
|
|
659
|
+
*,
|
|
660
|
+
name: str,
|
|
661
|
+
config: Optional[types.QueryAgentEngineRuntimeRevisionConfigOrDict] = None,
|
|
662
|
+
) -> Iterator[Any]:
|
|
663
|
+
"""Streams the response of the agent engine."""
|
|
664
|
+
parameter_model = types._QueryAgentEngineRuntimeRevisionRequestParameters(
|
|
665
|
+
name=name,
|
|
666
|
+
config=config,
|
|
667
|
+
)
|
|
668
|
+
request_dict = _QueryAgentEngineRuntimeRevisionRequestParameters_to_vertex(
|
|
669
|
+
parameter_model
|
|
670
|
+
)
|
|
671
|
+
request_url_dict = request_dict.get("_url")
|
|
672
|
+
if request_url_dict:
|
|
673
|
+
path = "{name}:streamQuery?alt=sse".format_map(request_url_dict)
|
|
674
|
+
else:
|
|
675
|
+
path = "{name}:streamQuery?alt=sse"
|
|
676
|
+
query_params = request_dict.get("_query")
|
|
677
|
+
if query_params:
|
|
678
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
679
|
+
# TODO: remove the hack that pops config.
|
|
680
|
+
request_dict.pop("config", None)
|
|
681
|
+
http_options = None
|
|
682
|
+
if (
|
|
683
|
+
parameter_model.config is not None
|
|
684
|
+
and parameter_model.config.http_options is not None
|
|
685
|
+
):
|
|
686
|
+
http_options = parameter_model.config.http_options
|
|
687
|
+
|
|
688
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
689
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
690
|
+
for response in self._api_client.request_streamed(
|
|
691
|
+
"post", path, request_dict, http_options
|
|
692
|
+
):
|
|
693
|
+
yield response
|
|
694
|
+
|
|
695
|
+
async def _async_stream_query(
|
|
696
|
+
self,
|
|
697
|
+
*,
|
|
698
|
+
name: str,
|
|
699
|
+
config: Optional[types.QueryAgentEngineRuntimeRevisionConfigOrDict] = None,
|
|
700
|
+
) -> AsyncIterator[Any]:
|
|
701
|
+
"""Streams the response of the agent engine."""
|
|
702
|
+
parameter_model = types._QueryAgentEngineRuntimeRevisionRequestParameters(
|
|
703
|
+
name=name,
|
|
704
|
+
config=config,
|
|
705
|
+
)
|
|
706
|
+
request_dict = _QueryAgentEngineRuntimeRevisionRequestParameters_to_vertex(
|
|
707
|
+
parameter_model
|
|
708
|
+
)
|
|
709
|
+
request_url_dict = request_dict.get("_url")
|
|
710
|
+
if request_url_dict:
|
|
711
|
+
path = "{name}:streamQuery?alt=sse".format_map(request_url_dict)
|
|
712
|
+
else:
|
|
713
|
+
path = "{name}:streamQuery?alt=sse"
|
|
714
|
+
query_params = request_dict.get("_query")
|
|
715
|
+
if query_params:
|
|
716
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
717
|
+
# TODO: remove the hack that pops config.
|
|
718
|
+
request_dict.pop("config", None)
|
|
719
|
+
http_options = None
|
|
720
|
+
if (
|
|
721
|
+
parameter_model.config is not None
|
|
722
|
+
and parameter_model.config.http_options is not None
|
|
723
|
+
):
|
|
724
|
+
http_options = parameter_model.config.http_options
|
|
725
|
+
|
|
726
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
727
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
728
|
+
async_iterator = await self._api_client.async_request_streamed(
|
|
729
|
+
"post", path, request_dict, http_options
|
|
730
|
+
)
|
|
731
|
+
async for response in async_iterator:
|
|
732
|
+
yield response
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
class AsyncRuntimeRevisions(_api_module.BaseModule):
|
|
736
|
+
|
|
737
|
+
async def _get(
|
|
738
|
+
self,
|
|
739
|
+
*,
|
|
740
|
+
name: str,
|
|
741
|
+
config: Optional[types.GetAgentEngineRuntimeRevisionConfigOrDict] = None,
|
|
742
|
+
) -> types.ReasoningEngineRuntimeRevision:
|
|
743
|
+
"""
|
|
744
|
+
Get an agent engine runtime revision instance.
|
|
745
|
+
"""
|
|
746
|
+
|
|
747
|
+
parameter_model = types._GetAgentEngineRuntimeRevisionRequestParameters(
|
|
748
|
+
name=name,
|
|
749
|
+
config=config,
|
|
750
|
+
)
|
|
751
|
+
|
|
752
|
+
request_url_dict: Optional[dict[str, str]]
|
|
753
|
+
if not self._api_client.vertexai:
|
|
754
|
+
raise ValueError(
|
|
755
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
756
|
+
)
|
|
757
|
+
else:
|
|
758
|
+
request_dict = _GetAgentEngineRuntimeRevisionRequestParameters_to_vertex(
|
|
759
|
+
parameter_model
|
|
760
|
+
)
|
|
761
|
+
request_url_dict = request_dict.get("_url")
|
|
762
|
+
if request_url_dict:
|
|
763
|
+
path = "{name}".format_map(request_url_dict)
|
|
764
|
+
else:
|
|
765
|
+
path = "{name}"
|
|
766
|
+
|
|
767
|
+
query_params = request_dict.get("_query")
|
|
768
|
+
if query_params:
|
|
769
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
770
|
+
# TODO: remove the hack that pops config.
|
|
771
|
+
request_dict.pop("config", None)
|
|
772
|
+
|
|
773
|
+
http_options: Optional[types.HttpOptions] = None
|
|
774
|
+
if (
|
|
775
|
+
parameter_model.config is not None
|
|
776
|
+
and parameter_model.config.http_options is not None
|
|
777
|
+
):
|
|
778
|
+
http_options = parameter_model.config.http_options
|
|
779
|
+
|
|
780
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
781
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
782
|
+
|
|
783
|
+
response = await self._api_client.async_request(
|
|
784
|
+
"get", path, request_dict, http_options
|
|
785
|
+
)
|
|
786
|
+
|
|
787
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
788
|
+
|
|
789
|
+
return_value = types.ReasoningEngineRuntimeRevision._from_response(
|
|
790
|
+
response=response_dict,
|
|
791
|
+
kwargs=(
|
|
792
|
+
{
|
|
793
|
+
"config": {
|
|
794
|
+
"response_schema": getattr(
|
|
795
|
+
parameter_model.config, "response_schema", None
|
|
796
|
+
),
|
|
797
|
+
"response_json_schema": getattr(
|
|
798
|
+
parameter_model.config, "response_json_schema", None
|
|
799
|
+
),
|
|
800
|
+
"include_all_fields": getattr(
|
|
801
|
+
parameter_model.config, "include_all_fields", None
|
|
802
|
+
),
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
if getattr(parameter_model, "config", None)
|
|
806
|
+
else {}
|
|
807
|
+
),
|
|
808
|
+
)
|
|
809
|
+
|
|
810
|
+
self._api_client._verify_response(return_value)
|
|
811
|
+
return return_value
|
|
812
|
+
|
|
813
|
+
async def _list(
|
|
814
|
+
self,
|
|
815
|
+
*,
|
|
816
|
+
name: str,
|
|
817
|
+
config: Optional[types.ListAgentEngineRuntimeRevisionsConfigOrDict] = None,
|
|
818
|
+
) -> types.ListReasoningEnginesRuntimeRevisionsResponse:
|
|
819
|
+
"""
|
|
820
|
+
Lists reasoning engine runtime revisions.
|
|
821
|
+
|
|
822
|
+
Args:
|
|
823
|
+
name (str): Required. The name of the reasoning engine to list runtime revisions for. Format:
|
|
824
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}`.
|
|
825
|
+
config (ListAgentEngineRuntimeRevisionsConfig):
|
|
826
|
+
Optional. Additional configurations for listing the reasoning engine runtime revisions.
|
|
827
|
+
|
|
828
|
+
Returns:
|
|
829
|
+
ListReasoningEnginesRuntimeRevisionsResponse: The requested reasoning engine runtime revisions.
|
|
830
|
+
|
|
831
|
+
"""
|
|
832
|
+
|
|
833
|
+
parameter_model = types._ListAgentEngineRuntimeRevisionsRequestParameters(
|
|
834
|
+
name=name,
|
|
835
|
+
config=config,
|
|
836
|
+
)
|
|
837
|
+
|
|
838
|
+
request_url_dict: Optional[dict[str, str]]
|
|
839
|
+
if not self._api_client.vertexai:
|
|
840
|
+
raise ValueError(
|
|
841
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
842
|
+
)
|
|
843
|
+
else:
|
|
844
|
+
request_dict = _ListAgentEngineRuntimeRevisionsRequestParameters_to_vertex(
|
|
845
|
+
parameter_model
|
|
846
|
+
)
|
|
847
|
+
request_url_dict = request_dict.get("_url")
|
|
848
|
+
if request_url_dict:
|
|
849
|
+
path = "{name}/runtimeRevisions".format_map(request_url_dict)
|
|
850
|
+
else:
|
|
851
|
+
path = "{name}/runtimeRevisions"
|
|
852
|
+
|
|
853
|
+
query_params = request_dict.get("_query")
|
|
854
|
+
if query_params:
|
|
855
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
856
|
+
# TODO: remove the hack that pops config.
|
|
857
|
+
request_dict.pop("config", None)
|
|
858
|
+
|
|
859
|
+
http_options: Optional[types.HttpOptions] = None
|
|
860
|
+
if (
|
|
861
|
+
parameter_model.config is not None
|
|
862
|
+
and parameter_model.config.http_options is not None
|
|
863
|
+
):
|
|
864
|
+
http_options = parameter_model.config.http_options
|
|
865
|
+
|
|
866
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
867
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
868
|
+
|
|
869
|
+
response = await self._api_client.async_request(
|
|
870
|
+
"get", path, request_dict, http_options
|
|
871
|
+
)
|
|
872
|
+
|
|
873
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
874
|
+
|
|
875
|
+
return_value = (
|
|
876
|
+
types.ListReasoningEnginesRuntimeRevisionsResponse._from_response(
|
|
877
|
+
response=response_dict,
|
|
878
|
+
kwargs=(
|
|
879
|
+
{
|
|
880
|
+
"config": {
|
|
881
|
+
"response_schema": getattr(
|
|
882
|
+
parameter_model.config, "response_schema", None
|
|
883
|
+
),
|
|
884
|
+
"response_json_schema": getattr(
|
|
885
|
+
parameter_model.config, "response_json_schema", None
|
|
886
|
+
),
|
|
887
|
+
"include_all_fields": getattr(
|
|
888
|
+
parameter_model.config, "include_all_fields", None
|
|
889
|
+
),
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
if getattr(parameter_model, "config", None)
|
|
893
|
+
else {}
|
|
894
|
+
),
|
|
895
|
+
)
|
|
896
|
+
)
|
|
897
|
+
|
|
898
|
+
self._api_client._verify_response(return_value)
|
|
899
|
+
return return_value
|
|
900
|
+
|
|
901
|
+
async def _delete(
|
|
902
|
+
self,
|
|
903
|
+
*,
|
|
904
|
+
name: str,
|
|
905
|
+
config: Optional[types.DeleteAgentEngineRuntimeRevisionConfigOrDict] = None,
|
|
906
|
+
) -> types.DeleteAgentEngineRuntimeRevisionOperation:
|
|
907
|
+
"""
|
|
908
|
+
Delete an Agent Engine runtime revision.
|
|
909
|
+
|
|
910
|
+
Args:
|
|
911
|
+
name (str): Required. The name of the Agent Engine runtime revision to be deleted. Format:
|
|
912
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}/runtimeRevisions/{runtime_revision_id}`.
|
|
913
|
+
config (DeleteAgentEngineRuntimeRevisionConfig):
|
|
914
|
+
Optional. Additional configurations for deleting the Agent Engine runtime revision.
|
|
915
|
+
|
|
916
|
+
Returns:
|
|
917
|
+
DeleteAgentEngineRuntimeRevisionOperation: The operation for deleting the Agent Engine runtime revision.
|
|
918
|
+
|
|
919
|
+
"""
|
|
920
|
+
|
|
921
|
+
parameter_model = types._DeleteAgentEngineRuntimeRevisionRequestParameters(
|
|
922
|
+
name=name,
|
|
923
|
+
config=config,
|
|
924
|
+
)
|
|
925
|
+
|
|
926
|
+
request_url_dict: Optional[dict[str, str]]
|
|
927
|
+
if not self._api_client.vertexai:
|
|
928
|
+
raise ValueError(
|
|
929
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
930
|
+
)
|
|
931
|
+
else:
|
|
932
|
+
request_dict = _DeleteAgentEngineRuntimeRevisionRequestParameters_to_vertex(
|
|
933
|
+
parameter_model
|
|
934
|
+
)
|
|
935
|
+
request_url_dict = request_dict.get("_url")
|
|
936
|
+
if request_url_dict:
|
|
937
|
+
path = "{name}".format_map(request_url_dict)
|
|
938
|
+
else:
|
|
939
|
+
path = "{name}"
|
|
940
|
+
|
|
941
|
+
query_params = request_dict.get("_query")
|
|
942
|
+
if query_params:
|
|
943
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
944
|
+
# TODO: remove the hack that pops config.
|
|
945
|
+
request_dict.pop("config", None)
|
|
946
|
+
|
|
947
|
+
http_options: Optional[types.HttpOptions] = None
|
|
948
|
+
if (
|
|
949
|
+
parameter_model.config is not None
|
|
950
|
+
and parameter_model.config.http_options is not None
|
|
951
|
+
):
|
|
952
|
+
http_options = parameter_model.config.http_options
|
|
953
|
+
|
|
954
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
955
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
956
|
+
|
|
957
|
+
response = await self._api_client.async_request(
|
|
958
|
+
"delete", path, request_dict, http_options
|
|
959
|
+
)
|
|
960
|
+
|
|
961
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
962
|
+
|
|
963
|
+
return_value = types.DeleteAgentEngineRuntimeRevisionOperation._from_response(
|
|
964
|
+
response=response_dict,
|
|
965
|
+
kwargs=(
|
|
966
|
+
{
|
|
967
|
+
"config": {
|
|
968
|
+
"response_schema": getattr(
|
|
969
|
+
parameter_model.config, "response_schema", None
|
|
970
|
+
),
|
|
971
|
+
"response_json_schema": getattr(
|
|
972
|
+
parameter_model.config, "response_json_schema", None
|
|
973
|
+
),
|
|
974
|
+
"include_all_fields": getattr(
|
|
975
|
+
parameter_model.config, "include_all_fields", None
|
|
976
|
+
),
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
if getattr(parameter_model, "config", None)
|
|
980
|
+
else {}
|
|
981
|
+
),
|
|
982
|
+
)
|
|
983
|
+
|
|
984
|
+
self._api_client._verify_response(return_value)
|
|
985
|
+
return return_value
|
|
986
|
+
|
|
987
|
+
async def _get_delete_runtime_revision_operation(
|
|
988
|
+
self,
|
|
989
|
+
*,
|
|
990
|
+
operation_name: str,
|
|
991
|
+
config: Optional[
|
|
992
|
+
types.GetDeleteAgentEngineRuntimeRevisionOperationConfigOrDict
|
|
993
|
+
] = None,
|
|
994
|
+
) -> types.DeleteAgentEngineRuntimeRevisionOperation:
|
|
995
|
+
parameter_model = types._GetDeleteAgentEngineRuntimeRevisionOperationParameters(
|
|
996
|
+
operation_name=operation_name,
|
|
997
|
+
config=config,
|
|
998
|
+
)
|
|
999
|
+
|
|
1000
|
+
request_url_dict: Optional[dict[str, str]]
|
|
1001
|
+
if not self._api_client.vertexai:
|
|
1002
|
+
raise ValueError(
|
|
1003
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
1004
|
+
)
|
|
1005
|
+
else:
|
|
1006
|
+
request_dict = (
|
|
1007
|
+
_GetDeleteAgentEngineRuntimeRevisionOperationParameters_to_vertex(
|
|
1008
|
+
parameter_model
|
|
1009
|
+
)
|
|
1010
|
+
)
|
|
1011
|
+
request_url_dict = request_dict.get("_url")
|
|
1012
|
+
if request_url_dict:
|
|
1013
|
+
path = "{operationName}".format_map(request_url_dict)
|
|
1014
|
+
else:
|
|
1015
|
+
path = "{operationName}"
|
|
1016
|
+
|
|
1017
|
+
query_params = request_dict.get("_query")
|
|
1018
|
+
if query_params:
|
|
1019
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
1020
|
+
# TODO: remove the hack that pops config.
|
|
1021
|
+
request_dict.pop("config", None)
|
|
1022
|
+
|
|
1023
|
+
http_options: Optional[types.HttpOptions] = None
|
|
1024
|
+
if (
|
|
1025
|
+
parameter_model.config is not None
|
|
1026
|
+
and parameter_model.config.http_options is not None
|
|
1027
|
+
):
|
|
1028
|
+
http_options = parameter_model.config.http_options
|
|
1029
|
+
|
|
1030
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
1031
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
1032
|
+
|
|
1033
|
+
response = await self._api_client.async_request(
|
|
1034
|
+
"get", path, request_dict, http_options
|
|
1035
|
+
)
|
|
1036
|
+
|
|
1037
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1038
|
+
|
|
1039
|
+
return_value = types.DeleteAgentEngineRuntimeRevisionOperation._from_response(
|
|
1040
|
+
response=response_dict,
|
|
1041
|
+
kwargs=(
|
|
1042
|
+
{
|
|
1043
|
+
"config": {
|
|
1044
|
+
"response_schema": getattr(
|
|
1045
|
+
parameter_model.config, "response_schema", None
|
|
1046
|
+
),
|
|
1047
|
+
"response_json_schema": getattr(
|
|
1048
|
+
parameter_model.config, "response_json_schema", None
|
|
1049
|
+
),
|
|
1050
|
+
"include_all_fields": getattr(
|
|
1051
|
+
parameter_model.config, "include_all_fields", None
|
|
1052
|
+
),
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
if getattr(parameter_model, "config", None)
|
|
1056
|
+
else {}
|
|
1057
|
+
),
|
|
1058
|
+
)
|
|
1059
|
+
|
|
1060
|
+
self._api_client._verify_response(return_value)
|
|
1061
|
+
return return_value
|
|
1062
|
+
|
|
1063
|
+
async def _query(
|
|
1064
|
+
self,
|
|
1065
|
+
*,
|
|
1066
|
+
name: str,
|
|
1067
|
+
config: Optional[types.QueryAgentEngineRuntimeRevisionConfigOrDict] = None,
|
|
1068
|
+
) -> types.QueryReasoningEngineResponse:
|
|
1069
|
+
"""
|
|
1070
|
+
Query an Agent Engine runtime revision.
|
|
1071
|
+
"""
|
|
1072
|
+
|
|
1073
|
+
parameter_model = types._QueryAgentEngineRuntimeRevisionRequestParameters(
|
|
1074
|
+
name=name,
|
|
1075
|
+
config=config,
|
|
1076
|
+
)
|
|
1077
|
+
|
|
1078
|
+
request_url_dict: Optional[dict[str, str]]
|
|
1079
|
+
if not self._api_client.vertexai:
|
|
1080
|
+
raise ValueError(
|
|
1081
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
1082
|
+
)
|
|
1083
|
+
else:
|
|
1084
|
+
request_dict = _QueryAgentEngineRuntimeRevisionRequestParameters_to_vertex(
|
|
1085
|
+
parameter_model
|
|
1086
|
+
)
|
|
1087
|
+
request_url_dict = request_dict.get("_url")
|
|
1088
|
+
if request_url_dict:
|
|
1089
|
+
path = "{name}:query".format_map(request_url_dict)
|
|
1090
|
+
else:
|
|
1091
|
+
path = "{name}:query"
|
|
1092
|
+
|
|
1093
|
+
query_params = request_dict.get("_query")
|
|
1094
|
+
if query_params:
|
|
1095
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
1096
|
+
# TODO: remove the hack that pops config.
|
|
1097
|
+
request_dict.pop("config", None)
|
|
1098
|
+
|
|
1099
|
+
http_options: Optional[types.HttpOptions] = None
|
|
1100
|
+
if (
|
|
1101
|
+
parameter_model.config is not None
|
|
1102
|
+
and parameter_model.config.http_options is not None
|
|
1103
|
+
):
|
|
1104
|
+
http_options = parameter_model.config.http_options
|
|
1105
|
+
|
|
1106
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
1107
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
1108
|
+
|
|
1109
|
+
response = await self._api_client.async_request(
|
|
1110
|
+
"post", path, request_dict, http_options
|
|
1111
|
+
)
|
|
1112
|
+
|
|
1113
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1114
|
+
|
|
1115
|
+
return_value = types.QueryReasoningEngineResponse._from_response(
|
|
1116
|
+
response=response_dict,
|
|
1117
|
+
kwargs=(
|
|
1118
|
+
{
|
|
1119
|
+
"config": {
|
|
1120
|
+
"response_schema": getattr(
|
|
1121
|
+
parameter_model.config, "response_schema", None
|
|
1122
|
+
),
|
|
1123
|
+
"response_json_schema": getattr(
|
|
1124
|
+
parameter_model.config, "response_json_schema", None
|
|
1125
|
+
),
|
|
1126
|
+
"include_all_fields": getattr(
|
|
1127
|
+
parameter_model.config, "include_all_fields", None
|
|
1128
|
+
),
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
if getattr(parameter_model, "config", None)
|
|
1132
|
+
else {}
|
|
1133
|
+
),
|
|
1134
|
+
)
|
|
1135
|
+
|
|
1136
|
+
self._api_client._verify_response(return_value)
|
|
1137
|
+
return return_value
|
|
1138
|
+
|
|
1139
|
+
async def get(
|
|
1140
|
+
self,
|
|
1141
|
+
*,
|
|
1142
|
+
name: str,
|
|
1143
|
+
config: Optional[types.GetAgentEngineRuntimeRevisionConfigOrDict] = None,
|
|
1144
|
+
) -> types.AgentEngineRuntimeRevision:
|
|
1145
|
+
"""Gets an agent engine runtime revision.
|
|
1146
|
+
|
|
1147
|
+
Args:
|
|
1148
|
+
name (str): Required. The name of the Agent Engine runtime revision to get. Format:
|
|
1149
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}/runtimeRevisions/{runtime_revision_id}`.
|
|
1150
|
+
config (GetAgentEngineRuntimeRevisionConfigOrDict):
|
|
1151
|
+
Optional. Additional configurations for getting the Agent Engine runtime revision.
|
|
1152
|
+
|
|
1153
|
+
Returns:
|
|
1154
|
+
AgentEngineRuntimeRevision: The requested Agent Engine runtime revision instance.
|
|
1155
|
+
"""
|
|
1156
|
+
api_resource = await self._get(name=name, config=config)
|
|
1157
|
+
agent_engine_runtime_revision = types.AgentEngineRuntimeRevision(
|
|
1158
|
+
api_client=self,
|
|
1159
|
+
api_async_client=AsyncRuntimeRevisions(api_client_=self._api_client),
|
|
1160
|
+
api_resource=api_resource,
|
|
1161
|
+
)
|
|
1162
|
+
if api_resource.spec:
|
|
1163
|
+
self._register_api_methods(
|
|
1164
|
+
agent_engine_runtime_revision=agent_engine_runtime_revision
|
|
1165
|
+
)
|
|
1166
|
+
return agent_engine_runtime_revision
|
|
1167
|
+
|
|
1168
|
+
async def list(
|
|
1169
|
+
self,
|
|
1170
|
+
*,
|
|
1171
|
+
name: str,
|
|
1172
|
+
config: Optional[types.ListAgentEngineRuntimeRevisionsConfigOrDict] = None,
|
|
1173
|
+
) -> AsyncIterator[types.AgentEngineRuntimeRevision]:
|
|
1174
|
+
"""Lists reasoning engine runtime revisions.
|
|
1175
|
+
|
|
1176
|
+
Args:
|
|
1177
|
+
name (str): Required. The name of the reasoning engine to list runtime revisions for. Format:
|
|
1178
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}`.
|
|
1179
|
+
config (ListAgentEngineRuntimeRevisionsConfig):
|
|
1180
|
+
Optional. Additional configurations for listing the reasoning engine runtime revisions.
|
|
1181
|
+
|
|
1182
|
+
Returns:
|
|
1183
|
+
AsyncIterator[AgentEngineRuntimeRevision]: An async iterator of runtime revisions.
|
|
1184
|
+
"""
|
|
1185
|
+
list_pager: AsyncPager[types.ReasoningEngineRuntimeRevision] = AsyncPager(
|
|
1186
|
+
"reasoning_engine_runtime_revisions",
|
|
1187
|
+
functools.partial(self._list, name=name),
|
|
1188
|
+
await self._list(name=name, config=config),
|
|
1189
|
+
config,
|
|
1190
|
+
)
|
|
1191
|
+
|
|
1192
|
+
async for runtime_revision in list_pager:
|
|
1193
|
+
yield types.AgentEngineRuntimeRevision(
|
|
1194
|
+
api_client=self,
|
|
1195
|
+
api_async_client=AsyncRuntimeRevisions(api_client_=self._api_client),
|
|
1196
|
+
api_resource=runtime_revision,
|
|
1197
|
+
)
|
|
1198
|
+
|
|
1199
|
+
async def delete(
|
|
1200
|
+
self,
|
|
1201
|
+
*,
|
|
1202
|
+
name: str,
|
|
1203
|
+
config: Optional[types.DeleteAgentEngineRuntimeRevisionConfigOrDict] = None,
|
|
1204
|
+
) -> types.DeleteAgentEngineRuntimeRevisionOperation:
|
|
1205
|
+
"""Delete an Agent Engine runtime revision.
|
|
1206
|
+
|
|
1207
|
+
Args:
|
|
1208
|
+
name (str): Required. The name of the Agent Engine runtime revision to be deleted. Format:
|
|
1209
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}/runtimeRevisions/{runtime_revision_id}`.
|
|
1210
|
+
config (DeleteAgentEngineRuntimeRevisionConfig):
|
|
1211
|
+
Optional. Additional configurations for deleting the Agent Engine runtime revision.
|
|
1212
|
+
|
|
1213
|
+
Returns:
|
|
1214
|
+
DeleteAgentEngineRuntimeRevisionOperation: The operation for deleting the Agent Engine runtime revision.
|
|
1215
|
+
"""
|
|
1216
|
+
if config is None:
|
|
1217
|
+
config = types.DeleteAgentEngineRuntimeRevisionConfig()
|
|
1218
|
+
elif isinstance(config, dict):
|
|
1219
|
+
config = types.DeleteAgentEngineRuntimeRevisionConfig.model_validate(config)
|
|
1220
|
+
operation = await self._delete(
|
|
1221
|
+
name=name,
|
|
1222
|
+
config=config,
|
|
1223
|
+
)
|
|
1224
|
+
if config.wait_for_completion and not operation.done:
|
|
1225
|
+
operation = await _agent_engines_utils._await_async_operation(
|
|
1226
|
+
operation_name=operation.name,
|
|
1227
|
+
get_operation_fn=self._get_delete_runtime_revision_operation,
|
|
1228
|
+
poll_interval_seconds=0.5,
|
|
1229
|
+
)
|
|
1230
|
+
if operation.error:
|
|
1231
|
+
raise RuntimeError(
|
|
1232
|
+
f"Failed to delete runtime revision: {operation.error}"
|
|
1233
|
+
)
|
|
1234
|
+
return operation
|
|
1235
|
+
|
|
1236
|
+
def _register_api_methods(
|
|
1237
|
+
self,
|
|
1238
|
+
*,
|
|
1239
|
+
agent_engine_runtime_revision: types.AgentEngineRuntimeRevision,
|
|
1240
|
+
) -> types.AgentEngineRuntimeRevision:
|
|
1241
|
+
"""Registers the API methods for the agent engine runtime revision."""
|
|
1242
|
+
try:
|
|
1243
|
+
_agent_engines_utils._register_api_methods_or_raise(
|
|
1244
|
+
agent_engine=agent_engine_runtime_revision,
|
|
1245
|
+
wrap_operation_fn={
|
|
1246
|
+
"": _agent_engines_utils._wrap_query_operation, # type: ignore[dict-item]
|
|
1247
|
+
"async": _agent_engines_utils._wrap_async_query_operation, # type: ignore[dict-item]
|
|
1248
|
+
"stream": _agent_engines_utils._wrap_stream_query_operation, # type: ignore[dict-item]
|
|
1249
|
+
"async_stream": _agent_engines_utils._wrap_async_stream_query_operation, # type: ignore[dict-item]
|
|
1250
|
+
"a2a_extension": _agent_engines_utils._wrap_a2a_operation,
|
|
1251
|
+
},
|
|
1252
|
+
)
|
|
1253
|
+
except Exception as e:
|
|
1254
|
+
logger.warning(
|
|
1255
|
+
_agent_engines_utils._FAILED_TO_REGISTER_API_METHODS_WARNING_TEMPLATE, e
|
|
1256
|
+
)
|
|
1257
|
+
return agent_engine_runtime_revision
|