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,543 @@
|
|
|
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 datetime
|
|
19
|
+
import functools
|
|
20
|
+
import json
|
|
21
|
+
import logging
|
|
22
|
+
from typing import Any, Iterator, Optional, Union
|
|
23
|
+
from urllib.parse import urlencode
|
|
24
|
+
|
|
25
|
+
from google.genai import _api_module
|
|
26
|
+
from google.genai import _common
|
|
27
|
+
from google.genai._common import get_value_by_path as getv
|
|
28
|
+
from google.genai._common import set_value_by_path as setv
|
|
29
|
+
from google.genai.pagers import AsyncPager, Pager
|
|
30
|
+
|
|
31
|
+
from . import types
|
|
32
|
+
|
|
33
|
+
logger = logging.getLogger("agentplatform_genai.sessionevents")
|
|
34
|
+
|
|
35
|
+
logger.setLevel(logging.INFO)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _AppendAgentEngineSessionEventConfig_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
|
+
|
|
44
|
+
if getv(from_object, ["content"]) is not None:
|
|
45
|
+
setv(parent_object, ["content"], getv(from_object, ["content"]))
|
|
46
|
+
|
|
47
|
+
if getv(from_object, ["actions"]) is not None:
|
|
48
|
+
setv(parent_object, ["actions"], getv(from_object, ["actions"]))
|
|
49
|
+
|
|
50
|
+
if getv(from_object, ["error_code"]) is not None:
|
|
51
|
+
setv(parent_object, ["errorCode"], getv(from_object, ["error_code"]))
|
|
52
|
+
|
|
53
|
+
if getv(from_object, ["error_message"]) is not None:
|
|
54
|
+
setv(parent_object, ["errorMessage"], getv(from_object, ["error_message"]))
|
|
55
|
+
|
|
56
|
+
if getv(from_object, ["event_metadata"]) is not None:
|
|
57
|
+
setv(parent_object, ["eventMetadata"], getv(from_object, ["event_metadata"]))
|
|
58
|
+
|
|
59
|
+
if getv(from_object, ["raw_event"]) is not None:
|
|
60
|
+
setv(parent_object, ["rawEvent"], getv(from_object, ["raw_event"]))
|
|
61
|
+
|
|
62
|
+
return to_object
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _AppendAgentEngineSessionEventRequestParameters_to_vertex(
|
|
66
|
+
from_object: Union[dict[str, Any], object],
|
|
67
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
68
|
+
) -> dict[str, Any]:
|
|
69
|
+
to_object: dict[str, Any] = {}
|
|
70
|
+
if getv(from_object, ["name"]) is not None:
|
|
71
|
+
setv(to_object, ["_url", "name"], getv(from_object, ["name"]))
|
|
72
|
+
|
|
73
|
+
if getv(from_object, ["author"]) is not None:
|
|
74
|
+
setv(to_object, ["author"], getv(from_object, ["author"]))
|
|
75
|
+
|
|
76
|
+
if getv(from_object, ["invocation_id"]) is not None:
|
|
77
|
+
setv(to_object, ["invocationId"], getv(from_object, ["invocation_id"]))
|
|
78
|
+
|
|
79
|
+
if getv(from_object, ["timestamp"]) is not None:
|
|
80
|
+
setv(to_object, ["timestamp"], getv(from_object, ["timestamp"]))
|
|
81
|
+
|
|
82
|
+
if getv(from_object, ["config"]) is not None:
|
|
83
|
+
_AppendAgentEngineSessionEventConfig_to_vertex(
|
|
84
|
+
getv(from_object, ["config"]), to_object
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
return to_object
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _ListAgentEngineSessionEventsConfig_to_vertex(
|
|
91
|
+
from_object: Union[dict[str, Any], object],
|
|
92
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
93
|
+
) -> dict[str, Any]:
|
|
94
|
+
to_object: dict[str, Any] = {}
|
|
95
|
+
|
|
96
|
+
if getv(from_object, ["page_size"]) is not None:
|
|
97
|
+
setv(parent_object, ["_query", "pageSize"], getv(from_object, ["page_size"]))
|
|
98
|
+
|
|
99
|
+
if getv(from_object, ["page_token"]) is not None:
|
|
100
|
+
setv(parent_object, ["_query", "pageToken"], getv(from_object, ["page_token"]))
|
|
101
|
+
|
|
102
|
+
if getv(from_object, ["filter"]) is not None:
|
|
103
|
+
setv(parent_object, ["_query", "filter"], getv(from_object, ["filter"]))
|
|
104
|
+
|
|
105
|
+
return to_object
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def _ListAgentEngineSessionEventsRequestParameters_to_vertex(
|
|
109
|
+
from_object: Union[dict[str, Any], object],
|
|
110
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
111
|
+
) -> dict[str, Any]:
|
|
112
|
+
to_object: dict[str, Any] = {}
|
|
113
|
+
if getv(from_object, ["name"]) is not None:
|
|
114
|
+
setv(to_object, ["_url", "name"], getv(from_object, ["name"]))
|
|
115
|
+
|
|
116
|
+
if getv(from_object, ["config"]) is not None:
|
|
117
|
+
_ListAgentEngineSessionEventsConfig_to_vertex(
|
|
118
|
+
getv(from_object, ["config"]), to_object
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
return to_object
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class SessionEvents(_api_module.BaseModule):
|
|
125
|
+
|
|
126
|
+
def append(
|
|
127
|
+
self,
|
|
128
|
+
*,
|
|
129
|
+
name: str,
|
|
130
|
+
author: str,
|
|
131
|
+
invocation_id: str,
|
|
132
|
+
timestamp: datetime.datetime,
|
|
133
|
+
config: Optional[types.AppendAgentEngineSessionEventConfigOrDict] = None,
|
|
134
|
+
) -> types.AppendAgentEngineSessionEventResponse:
|
|
135
|
+
"""
|
|
136
|
+
Appends Agent Engine session event.
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
name (str): Required. The name of the Agent Engine session to append the event to. Format:
|
|
140
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}/sessions/{session_id}`.
|
|
141
|
+
author (str): Required. The author of the Agent Engine session event.
|
|
142
|
+
invocation_id (str): Required. The invocation ID of the Agent Engine session event.
|
|
143
|
+
timestamp (datetime.datetime): Required. The timestamp of the Agent Engine session event.
|
|
144
|
+
config (AppendAgentEngineSessionEventConfig):
|
|
145
|
+
Optional. Additional configurations for appending the Agent Engine session event.
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
AppendAgentEngineSessionEventResponse: The requested Agent Engine session event.
|
|
149
|
+
|
|
150
|
+
"""
|
|
151
|
+
|
|
152
|
+
parameter_model = types._AppendAgentEngineSessionEventRequestParameters(
|
|
153
|
+
name=name,
|
|
154
|
+
author=author,
|
|
155
|
+
invocation_id=invocation_id,
|
|
156
|
+
timestamp=timestamp,
|
|
157
|
+
config=config,
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
request_url_dict: Optional[dict[str, str]]
|
|
161
|
+
if not self._api_client.vertexai:
|
|
162
|
+
raise ValueError(
|
|
163
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
164
|
+
)
|
|
165
|
+
else:
|
|
166
|
+
request_dict = _AppendAgentEngineSessionEventRequestParameters_to_vertex(
|
|
167
|
+
parameter_model
|
|
168
|
+
)
|
|
169
|
+
request_url_dict = request_dict.get("_url")
|
|
170
|
+
if request_url_dict:
|
|
171
|
+
path = "{name}:appendEvent".format_map(request_url_dict)
|
|
172
|
+
else:
|
|
173
|
+
path = "{name}:appendEvent"
|
|
174
|
+
|
|
175
|
+
query_params = request_dict.get("_query")
|
|
176
|
+
if query_params:
|
|
177
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
178
|
+
# TODO: remove the hack that pops config.
|
|
179
|
+
request_dict.pop("config", None)
|
|
180
|
+
|
|
181
|
+
http_options: Optional[types.HttpOptions] = None
|
|
182
|
+
if (
|
|
183
|
+
parameter_model.config is not None
|
|
184
|
+
and parameter_model.config.http_options is not None
|
|
185
|
+
):
|
|
186
|
+
http_options = parameter_model.config.http_options
|
|
187
|
+
|
|
188
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
189
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
190
|
+
|
|
191
|
+
response = self._api_client.request("post", path, request_dict, http_options)
|
|
192
|
+
|
|
193
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
194
|
+
|
|
195
|
+
return_value = types.AppendAgentEngineSessionEventResponse._from_response(
|
|
196
|
+
response=response_dict,
|
|
197
|
+
kwargs=(
|
|
198
|
+
{
|
|
199
|
+
"config": {
|
|
200
|
+
"response_schema": getattr(
|
|
201
|
+
parameter_model.config, "response_schema", None
|
|
202
|
+
),
|
|
203
|
+
"response_json_schema": getattr(
|
|
204
|
+
parameter_model.config, "response_json_schema", None
|
|
205
|
+
),
|
|
206
|
+
"include_all_fields": getattr(
|
|
207
|
+
parameter_model.config, "include_all_fields", None
|
|
208
|
+
),
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if getattr(parameter_model, "config", None)
|
|
212
|
+
else {}
|
|
213
|
+
),
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
self._api_client._verify_response(return_value)
|
|
217
|
+
return return_value
|
|
218
|
+
|
|
219
|
+
def _list(
|
|
220
|
+
self,
|
|
221
|
+
*,
|
|
222
|
+
name: str,
|
|
223
|
+
config: Optional[types.ListAgentEngineSessionEventsConfigOrDict] = None,
|
|
224
|
+
) -> types.ListAgentEngineSessionEventsResponse:
|
|
225
|
+
"""
|
|
226
|
+
Lists Agent Engine session events.
|
|
227
|
+
|
|
228
|
+
Args:
|
|
229
|
+
name (str): Required. The name of the Agent Engine session to list events for. Format:
|
|
230
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}/sessions/{session_id}`.
|
|
231
|
+
config (ListAgentEngineSessionEventsConfig):
|
|
232
|
+
Optional. Additional configurations for listing the Agent Engine session events.
|
|
233
|
+
|
|
234
|
+
Returns:
|
|
235
|
+
ListAgentEngineSessionEventsResponse: The requested Agent Engine session events.
|
|
236
|
+
|
|
237
|
+
"""
|
|
238
|
+
|
|
239
|
+
parameter_model = types._ListAgentEngineSessionEventsRequestParameters(
|
|
240
|
+
name=name,
|
|
241
|
+
config=config,
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
request_url_dict: Optional[dict[str, str]]
|
|
245
|
+
if not self._api_client.vertexai:
|
|
246
|
+
raise ValueError(
|
|
247
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
248
|
+
)
|
|
249
|
+
else:
|
|
250
|
+
request_dict = _ListAgentEngineSessionEventsRequestParameters_to_vertex(
|
|
251
|
+
parameter_model
|
|
252
|
+
)
|
|
253
|
+
request_url_dict = request_dict.get("_url")
|
|
254
|
+
if request_url_dict:
|
|
255
|
+
path = "{name}/events".format_map(request_url_dict)
|
|
256
|
+
else:
|
|
257
|
+
path = "{name}/events"
|
|
258
|
+
|
|
259
|
+
query_params = request_dict.get("_query")
|
|
260
|
+
if query_params:
|
|
261
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
262
|
+
# TODO: remove the hack that pops config.
|
|
263
|
+
request_dict.pop("config", None)
|
|
264
|
+
|
|
265
|
+
http_options: Optional[types.HttpOptions] = None
|
|
266
|
+
if (
|
|
267
|
+
parameter_model.config is not None
|
|
268
|
+
and parameter_model.config.http_options is not None
|
|
269
|
+
):
|
|
270
|
+
http_options = parameter_model.config.http_options
|
|
271
|
+
|
|
272
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
273
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
274
|
+
|
|
275
|
+
response = self._api_client.request("get", path, request_dict, http_options)
|
|
276
|
+
|
|
277
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
278
|
+
|
|
279
|
+
return_value = types.ListAgentEngineSessionEventsResponse._from_response(
|
|
280
|
+
response=response_dict,
|
|
281
|
+
kwargs=(
|
|
282
|
+
{
|
|
283
|
+
"config": {
|
|
284
|
+
"response_schema": getattr(
|
|
285
|
+
parameter_model.config, "response_schema", None
|
|
286
|
+
),
|
|
287
|
+
"response_json_schema": getattr(
|
|
288
|
+
parameter_model.config, "response_json_schema", None
|
|
289
|
+
),
|
|
290
|
+
"include_all_fields": getattr(
|
|
291
|
+
parameter_model.config, "include_all_fields", None
|
|
292
|
+
),
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if getattr(parameter_model, "config", None)
|
|
296
|
+
else {}
|
|
297
|
+
),
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
self._api_client._verify_response(return_value)
|
|
301
|
+
return return_value
|
|
302
|
+
|
|
303
|
+
def list(
|
|
304
|
+
self,
|
|
305
|
+
*,
|
|
306
|
+
name: str,
|
|
307
|
+
config: Optional[types.ListAgentEngineSessionEventsConfigOrDict] = None,
|
|
308
|
+
) -> Iterator[types.SessionEvent]:
|
|
309
|
+
"""Lists Agent Engine session events.
|
|
310
|
+
|
|
311
|
+
Args:
|
|
312
|
+
name (str): Required. The name of the agent engine to list session
|
|
313
|
+
events for.
|
|
314
|
+
config (ListAgentEngineSessionEventsConfig): Optional. The configuration
|
|
315
|
+
for the session events to list. Currently, the `filter` field in
|
|
316
|
+
`config` only supports filtering by `timestamp`. The timestamp
|
|
317
|
+
value must be enclosed in double quotes and include the time zone
|
|
318
|
+
information. For example:
|
|
319
|
+
`config={'filter': 'timestamp>="2025-08-07T19:44:38.4Z"'}`.
|
|
320
|
+
|
|
321
|
+
Returns:
|
|
322
|
+
Iterator[SessionEvent]: An iterable of session events.
|
|
323
|
+
"""
|
|
324
|
+
|
|
325
|
+
return Pager(
|
|
326
|
+
"session_events",
|
|
327
|
+
functools.partial(self._list, name=name),
|
|
328
|
+
self._list(name=name, config=config),
|
|
329
|
+
config,
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
class AsyncSessionEvents(_api_module.BaseModule):
|
|
334
|
+
|
|
335
|
+
async def append(
|
|
336
|
+
self,
|
|
337
|
+
*,
|
|
338
|
+
name: str,
|
|
339
|
+
author: str,
|
|
340
|
+
invocation_id: str,
|
|
341
|
+
timestamp: datetime.datetime,
|
|
342
|
+
config: Optional[types.AppendAgentEngineSessionEventConfigOrDict] = None,
|
|
343
|
+
) -> types.AppendAgentEngineSessionEventResponse:
|
|
344
|
+
"""
|
|
345
|
+
Appends Agent Engine session event.
|
|
346
|
+
|
|
347
|
+
Args:
|
|
348
|
+
name (str): Required. The name of the Agent Engine session to append the event to. Format:
|
|
349
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}/sessions/{session_id}`.
|
|
350
|
+
author (str): Required. The author of the Agent Engine session event.
|
|
351
|
+
invocation_id (str): Required. The invocation ID of the Agent Engine session event.
|
|
352
|
+
timestamp (datetime.datetime): Required. The timestamp of the Agent Engine session event.
|
|
353
|
+
config (AppendAgentEngineSessionEventConfig):
|
|
354
|
+
Optional. Additional configurations for appending the Agent Engine session event.
|
|
355
|
+
|
|
356
|
+
Returns:
|
|
357
|
+
AppendAgentEngineSessionEventResponse: The requested Agent Engine session event.
|
|
358
|
+
|
|
359
|
+
"""
|
|
360
|
+
|
|
361
|
+
parameter_model = types._AppendAgentEngineSessionEventRequestParameters(
|
|
362
|
+
name=name,
|
|
363
|
+
author=author,
|
|
364
|
+
invocation_id=invocation_id,
|
|
365
|
+
timestamp=timestamp,
|
|
366
|
+
config=config,
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
request_url_dict: Optional[dict[str, str]]
|
|
370
|
+
if not self._api_client.vertexai:
|
|
371
|
+
raise ValueError(
|
|
372
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
373
|
+
)
|
|
374
|
+
else:
|
|
375
|
+
request_dict = _AppendAgentEngineSessionEventRequestParameters_to_vertex(
|
|
376
|
+
parameter_model
|
|
377
|
+
)
|
|
378
|
+
request_url_dict = request_dict.get("_url")
|
|
379
|
+
if request_url_dict:
|
|
380
|
+
path = "{name}:appendEvent".format_map(request_url_dict)
|
|
381
|
+
else:
|
|
382
|
+
path = "{name}:appendEvent"
|
|
383
|
+
|
|
384
|
+
query_params = request_dict.get("_query")
|
|
385
|
+
if query_params:
|
|
386
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
387
|
+
# TODO: remove the hack that pops config.
|
|
388
|
+
request_dict.pop("config", None)
|
|
389
|
+
|
|
390
|
+
http_options: Optional[types.HttpOptions] = None
|
|
391
|
+
if (
|
|
392
|
+
parameter_model.config is not None
|
|
393
|
+
and parameter_model.config.http_options is not None
|
|
394
|
+
):
|
|
395
|
+
http_options = parameter_model.config.http_options
|
|
396
|
+
|
|
397
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
398
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
399
|
+
|
|
400
|
+
response = await self._api_client.async_request(
|
|
401
|
+
"post", path, request_dict, http_options
|
|
402
|
+
)
|
|
403
|
+
|
|
404
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
405
|
+
|
|
406
|
+
return_value = types.AppendAgentEngineSessionEventResponse._from_response(
|
|
407
|
+
response=response_dict,
|
|
408
|
+
kwargs=(
|
|
409
|
+
{
|
|
410
|
+
"config": {
|
|
411
|
+
"response_schema": getattr(
|
|
412
|
+
parameter_model.config, "response_schema", None
|
|
413
|
+
),
|
|
414
|
+
"response_json_schema": getattr(
|
|
415
|
+
parameter_model.config, "response_json_schema", None
|
|
416
|
+
),
|
|
417
|
+
"include_all_fields": getattr(
|
|
418
|
+
parameter_model.config, "include_all_fields", None
|
|
419
|
+
),
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
if getattr(parameter_model, "config", None)
|
|
423
|
+
else {}
|
|
424
|
+
),
|
|
425
|
+
)
|
|
426
|
+
|
|
427
|
+
self._api_client._verify_response(return_value)
|
|
428
|
+
return return_value
|
|
429
|
+
|
|
430
|
+
async def _list(
|
|
431
|
+
self,
|
|
432
|
+
*,
|
|
433
|
+
name: str,
|
|
434
|
+
config: Optional[types.ListAgentEngineSessionEventsConfigOrDict] = None,
|
|
435
|
+
) -> types.ListAgentEngineSessionEventsResponse:
|
|
436
|
+
"""
|
|
437
|
+
Lists Agent Engine session events.
|
|
438
|
+
|
|
439
|
+
Args:
|
|
440
|
+
name (str): Required. The name of the Agent Engine session to list events for. Format:
|
|
441
|
+
`projects/{project}/locations/{location}/reasoningEngines/{resource_id}/sessions/{session_id}`.
|
|
442
|
+
config (ListAgentEngineSessionEventsConfig):
|
|
443
|
+
Optional. Additional configurations for listing the Agent Engine session events.
|
|
444
|
+
|
|
445
|
+
Returns:
|
|
446
|
+
ListAgentEngineSessionEventsResponse: The requested Agent Engine session events.
|
|
447
|
+
|
|
448
|
+
"""
|
|
449
|
+
|
|
450
|
+
parameter_model = types._ListAgentEngineSessionEventsRequestParameters(
|
|
451
|
+
name=name,
|
|
452
|
+
config=config,
|
|
453
|
+
)
|
|
454
|
+
|
|
455
|
+
request_url_dict: Optional[dict[str, str]]
|
|
456
|
+
if not self._api_client.vertexai:
|
|
457
|
+
raise ValueError(
|
|
458
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
459
|
+
)
|
|
460
|
+
else:
|
|
461
|
+
request_dict = _ListAgentEngineSessionEventsRequestParameters_to_vertex(
|
|
462
|
+
parameter_model
|
|
463
|
+
)
|
|
464
|
+
request_url_dict = request_dict.get("_url")
|
|
465
|
+
if request_url_dict:
|
|
466
|
+
path = "{name}/events".format_map(request_url_dict)
|
|
467
|
+
else:
|
|
468
|
+
path = "{name}/events"
|
|
469
|
+
|
|
470
|
+
query_params = request_dict.get("_query")
|
|
471
|
+
if query_params:
|
|
472
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
473
|
+
# TODO: remove the hack that pops config.
|
|
474
|
+
request_dict.pop("config", None)
|
|
475
|
+
|
|
476
|
+
http_options: Optional[types.HttpOptions] = None
|
|
477
|
+
if (
|
|
478
|
+
parameter_model.config is not None
|
|
479
|
+
and parameter_model.config.http_options is not None
|
|
480
|
+
):
|
|
481
|
+
http_options = parameter_model.config.http_options
|
|
482
|
+
|
|
483
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
484
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
485
|
+
|
|
486
|
+
response = await self._api_client.async_request(
|
|
487
|
+
"get", path, request_dict, http_options
|
|
488
|
+
)
|
|
489
|
+
|
|
490
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
491
|
+
|
|
492
|
+
return_value = types.ListAgentEngineSessionEventsResponse._from_response(
|
|
493
|
+
response=response_dict,
|
|
494
|
+
kwargs=(
|
|
495
|
+
{
|
|
496
|
+
"config": {
|
|
497
|
+
"response_schema": getattr(
|
|
498
|
+
parameter_model.config, "response_schema", None
|
|
499
|
+
),
|
|
500
|
+
"response_json_schema": getattr(
|
|
501
|
+
parameter_model.config, "response_json_schema", None
|
|
502
|
+
),
|
|
503
|
+
"include_all_fields": getattr(
|
|
504
|
+
parameter_model.config, "include_all_fields", None
|
|
505
|
+
),
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
if getattr(parameter_model, "config", None)
|
|
509
|
+
else {}
|
|
510
|
+
),
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
self._api_client._verify_response(return_value)
|
|
514
|
+
return return_value
|
|
515
|
+
|
|
516
|
+
async def list(
|
|
517
|
+
self,
|
|
518
|
+
*,
|
|
519
|
+
name: str,
|
|
520
|
+
config: Optional[types.ListAgentEngineSessionEventsConfigOrDict] = None,
|
|
521
|
+
) -> AsyncPager[types.SessionEvent]:
|
|
522
|
+
"""Lists Agent Engine session events.
|
|
523
|
+
|
|
524
|
+
Args:
|
|
525
|
+
name (str): Required. The name of the agent engine to list session
|
|
526
|
+
events for.
|
|
527
|
+
config (ListAgentEngineSessionEventsConfig): Optional. The configuration
|
|
528
|
+
for the session events to list. Currently, the `filter` field in
|
|
529
|
+
`config` only supports filtering by `timestamp`. The timestamp
|
|
530
|
+
value must be enclosed in double quotes and include the time zone
|
|
531
|
+
information. For example:
|
|
532
|
+
`config={'filter': 'timestamp>="2025-08-07T19:44:38.4Z"'}`.
|
|
533
|
+
|
|
534
|
+
Returns:
|
|
535
|
+
AsyncPager[SessionEvent]: An async pager of session events.
|
|
536
|
+
"""
|
|
537
|
+
|
|
538
|
+
return AsyncPager(
|
|
539
|
+
"session_events",
|
|
540
|
+
functools.partial(self._list, name=name),
|
|
541
|
+
await self._list(name=name, config=config),
|
|
542
|
+
config,
|
|
543
|
+
)
|