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,1445 @@
|
|
|
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 json
|
|
19
|
+
import logging
|
|
20
|
+
from typing import Any, Optional, Union
|
|
21
|
+
from urllib.parse import urlencode
|
|
22
|
+
|
|
23
|
+
from google.genai import _api_module
|
|
24
|
+
from google.genai import _common
|
|
25
|
+
from google.genai._common import get_value_by_path as getv
|
|
26
|
+
from google.genai._common import set_value_by_path as setv
|
|
27
|
+
|
|
28
|
+
from . import _transformers as t
|
|
29
|
+
from . import types
|
|
30
|
+
|
|
31
|
+
logger = logging.getLogger("agentplatform_genai.examplestores")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _CreateExampleStoreConfig_to_vertex(
|
|
35
|
+
from_object: Union[dict[str, Any], object],
|
|
36
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
37
|
+
) -> dict[str, Any]:
|
|
38
|
+
to_object: dict[str, Any] = {}
|
|
39
|
+
|
|
40
|
+
if getv(from_object, ["description"]) is not None:
|
|
41
|
+
setv(
|
|
42
|
+
to_object,
|
|
43
|
+
["_query", "exampleStore", "description"],
|
|
44
|
+
getv(from_object, ["description"]),
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
if getv(from_object, ["vertex_embedding_model"]) is not None:
|
|
48
|
+
setv(
|
|
49
|
+
to_object,
|
|
50
|
+
["_query", "exampleStore", "exampleStoreConfig", "vertexEmbeddingModel"],
|
|
51
|
+
getv(from_object, ["vertex_embedding_model"]),
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
return to_object
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _CreateExampleStoreParameters_to_vertex(
|
|
58
|
+
from_object: Union[dict[str, Any], object],
|
|
59
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
60
|
+
) -> dict[str, Any]:
|
|
61
|
+
to_object: dict[str, Any] = {}
|
|
62
|
+
if getv(from_object, ["display_name"]) is not None:
|
|
63
|
+
setv(
|
|
64
|
+
to_object,
|
|
65
|
+
["_query", "exampleStore", "displayName"],
|
|
66
|
+
getv(from_object, ["display_name"]),
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
if getv(from_object, ["config"]) is not None:
|
|
70
|
+
_CreateExampleStoreConfig_to_vertex(getv(from_object, ["config"]), to_object)
|
|
71
|
+
|
|
72
|
+
return to_object
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _DeleteExampleStoreConfig_to_vertex(
|
|
76
|
+
from_object: Union[dict[str, Any], object],
|
|
77
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
78
|
+
) -> dict[str, Any]:
|
|
79
|
+
to_object: dict[str, Any] = {}
|
|
80
|
+
|
|
81
|
+
return to_object
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _DeleteExampleStoreRequestParameters_to_vertex(
|
|
85
|
+
from_object: Union[dict[str, Any], object],
|
|
86
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
87
|
+
) -> dict[str, Any]:
|
|
88
|
+
to_object: dict[str, Any] = {}
|
|
89
|
+
if getv(from_object, ["name"]) is not None:
|
|
90
|
+
setv(
|
|
91
|
+
to_object, ["_url", "name"], t.t_example_store(getv(from_object, ["name"]))
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
if getv(from_object, ["config"]) is not None:
|
|
95
|
+
_DeleteExampleStoreConfig_to_vertex(getv(from_object, ["config"]), to_object)
|
|
96
|
+
|
|
97
|
+
return to_object
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _FetchExamplesConfig_to_vertex(
|
|
101
|
+
from_object: Union[dict[str, Any], object],
|
|
102
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
103
|
+
) -> dict[str, Any]:
|
|
104
|
+
to_object: dict[str, Any] = {}
|
|
105
|
+
|
|
106
|
+
if getv(from_object, ["example_ids"]) is not None:
|
|
107
|
+
setv(parent_object, ["exampleIds"], getv(from_object, ["example_ids"]))
|
|
108
|
+
|
|
109
|
+
if getv(from_object, ["stored_contents_example_filter"]) is not None:
|
|
110
|
+
setv(
|
|
111
|
+
parent_object,
|
|
112
|
+
["storedContentsExampleFilter"],
|
|
113
|
+
getv(from_object, ["stored_contents_example_filter"]),
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
if getv(from_object, ["page_size"]) is not None:
|
|
117
|
+
setv(parent_object, ["pageSize"], getv(from_object, ["page_size"]))
|
|
118
|
+
|
|
119
|
+
if getv(from_object, ["page_token"]) is not None:
|
|
120
|
+
setv(parent_object, ["pageToken"], getv(from_object, ["page_token"]))
|
|
121
|
+
|
|
122
|
+
return to_object
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _FetchExamplesParameters_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(
|
|
132
|
+
to_object,
|
|
133
|
+
["_url", "exampleStore"],
|
|
134
|
+
t.t_example_store(getv(from_object, ["name"])),
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
if getv(from_object, ["config"]) is not None:
|
|
138
|
+
_FetchExamplesConfig_to_vertex(getv(from_object, ["config"]), to_object)
|
|
139
|
+
|
|
140
|
+
return to_object
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _GetExampleStoreOperationParameters_to_vertex(
|
|
144
|
+
from_object: Union[dict[str, Any], object],
|
|
145
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
146
|
+
) -> dict[str, Any]:
|
|
147
|
+
to_object: dict[str, Any] = {}
|
|
148
|
+
if getv(from_object, ["operation_name"]) is not None:
|
|
149
|
+
setv(
|
|
150
|
+
to_object, ["_url", "operationName"], getv(from_object, ["operation_name"])
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
return to_object
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def _GetExampleStoreParameters_to_vertex(
|
|
157
|
+
from_object: Union[dict[str, Any], object],
|
|
158
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
159
|
+
) -> dict[str, Any]:
|
|
160
|
+
to_object: dict[str, Any] = {}
|
|
161
|
+
if getv(from_object, ["name"]) is not None:
|
|
162
|
+
setv(
|
|
163
|
+
to_object, ["_url", "name"], t.t_example_store(getv(from_object, ["name"]))
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
return to_object
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def _RemoveExamplesConfig_to_vertex(
|
|
170
|
+
from_object: Union[dict[str, Any], object],
|
|
171
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
172
|
+
) -> dict[str, Any]:
|
|
173
|
+
to_object: dict[str, Any] = {}
|
|
174
|
+
|
|
175
|
+
if getv(from_object, ["example_ids"]) is not None:
|
|
176
|
+
setv(parent_object, ["exampleIds"], getv(from_object, ["example_ids"]))
|
|
177
|
+
|
|
178
|
+
if getv(from_object, ["stored_contents_example_filter"]) is not None:
|
|
179
|
+
setv(
|
|
180
|
+
parent_object,
|
|
181
|
+
["storedContentsExampleFilter"],
|
|
182
|
+
getv(from_object, ["stored_contents_example_filter"]),
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
return to_object
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def _RemoveExamplesParameters_to_vertex(
|
|
189
|
+
from_object: Union[dict[str, Any], object],
|
|
190
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
191
|
+
) -> dict[str, Any]:
|
|
192
|
+
to_object: dict[str, Any] = {}
|
|
193
|
+
if getv(from_object, ["name"]) is not None:
|
|
194
|
+
setv(
|
|
195
|
+
to_object,
|
|
196
|
+
["_url", "exampleStore"],
|
|
197
|
+
t.t_example_store(getv(from_object, ["name"])),
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
if getv(from_object, ["config"]) is not None:
|
|
201
|
+
_RemoveExamplesConfig_to_vertex(getv(from_object, ["config"]), to_object)
|
|
202
|
+
|
|
203
|
+
return to_object
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def _SearchExamplesConfig_to_vertex(
|
|
207
|
+
from_object: Union[dict[str, Any], object],
|
|
208
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
209
|
+
) -> dict[str, Any]:
|
|
210
|
+
to_object: dict[str, Any] = {}
|
|
211
|
+
|
|
212
|
+
if getv(from_object, ["top_k"]) is not None:
|
|
213
|
+
setv(parent_object, ["topK"], getv(from_object, ["top_k"]))
|
|
214
|
+
|
|
215
|
+
return to_object
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def _SearchExamplesParameters_to_vertex(
|
|
219
|
+
from_object: Union[dict[str, Any], object],
|
|
220
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
221
|
+
) -> dict[str, Any]:
|
|
222
|
+
to_object: dict[str, Any] = {}
|
|
223
|
+
if getv(from_object, ["name"]) is not None:
|
|
224
|
+
setv(
|
|
225
|
+
to_object,
|
|
226
|
+
["_url", "exampleStore"],
|
|
227
|
+
t.t_example_store(getv(from_object, ["name"])),
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
if getv(from_object, ["stored_contents_example_parameters"]) is not None:
|
|
231
|
+
setv(
|
|
232
|
+
to_object,
|
|
233
|
+
["storedContentsExampleParameters"],
|
|
234
|
+
getv(from_object, ["stored_contents_example_parameters"]),
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
if getv(from_object, ["config"]) is not None:
|
|
238
|
+
_SearchExamplesConfig_to_vertex(getv(from_object, ["config"]), to_object)
|
|
239
|
+
|
|
240
|
+
return to_object
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def _UpsertExamplesConfig_to_vertex(
|
|
244
|
+
from_object: Union[dict[str, Any], object],
|
|
245
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
246
|
+
) -> dict[str, Any]:
|
|
247
|
+
to_object: dict[str, Any] = {}
|
|
248
|
+
|
|
249
|
+
if getv(from_object, ["overwrite"]) is not None:
|
|
250
|
+
setv(parent_object, ["overwrite"], getv(from_object, ["overwrite"]))
|
|
251
|
+
|
|
252
|
+
return to_object
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def _UpsertExamplesParameters_to_vertex(
|
|
256
|
+
from_object: Union[dict[str, Any], object],
|
|
257
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
258
|
+
) -> dict[str, Any]:
|
|
259
|
+
to_object: dict[str, Any] = {}
|
|
260
|
+
if getv(from_object, ["name"]) is not None:
|
|
261
|
+
setv(
|
|
262
|
+
to_object,
|
|
263
|
+
["_url", "exampleStore"],
|
|
264
|
+
t.t_example_store(getv(from_object, ["name"])),
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
if getv(from_object, ["examples"]) is not None:
|
|
268
|
+
setv(
|
|
269
|
+
to_object, ["examples"], [item for item in getv(from_object, ["examples"])]
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
if getv(from_object, ["config"]) is not None:
|
|
273
|
+
_UpsertExamplesConfig_to_vertex(getv(from_object, ["config"]), to_object)
|
|
274
|
+
|
|
275
|
+
return to_object
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
class ExampleStores(_api_module.BaseModule):
|
|
279
|
+
"""Class for managing Example Stores of few-shot examples."""
|
|
280
|
+
|
|
281
|
+
def _create(
|
|
282
|
+
self,
|
|
283
|
+
*,
|
|
284
|
+
display_name: str,
|
|
285
|
+
config: Optional[types.CreateExampleStoreConfigOrDict] = None,
|
|
286
|
+
) -> types.ExampleStoreOperation:
|
|
287
|
+
"""
|
|
288
|
+
Creates an Example Store.
|
|
289
|
+
"""
|
|
290
|
+
|
|
291
|
+
parameter_model = types._CreateExampleStoreParameters(
|
|
292
|
+
display_name=display_name,
|
|
293
|
+
config=config,
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
request_url_dict: Optional[dict[str, str]]
|
|
297
|
+
if not self._api_client.vertexai:
|
|
298
|
+
raise ValueError(
|
|
299
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
300
|
+
)
|
|
301
|
+
else:
|
|
302
|
+
request_dict = _CreateExampleStoreParameters_to_vertex(parameter_model)
|
|
303
|
+
request_url_dict = request_dict.get("_url")
|
|
304
|
+
if request_url_dict:
|
|
305
|
+
path = "{parent}/exampleStores:create".format_map(request_url_dict)
|
|
306
|
+
else:
|
|
307
|
+
path = "{parent}/exampleStores:create"
|
|
308
|
+
|
|
309
|
+
query_params = request_dict.get("_query")
|
|
310
|
+
if query_params:
|
|
311
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
312
|
+
# TODO: remove the hack that pops config.
|
|
313
|
+
request_dict.pop("config", None)
|
|
314
|
+
|
|
315
|
+
http_options: Optional[types.HttpOptions] = None
|
|
316
|
+
if (
|
|
317
|
+
parameter_model.config is not None
|
|
318
|
+
and parameter_model.config.http_options is not None
|
|
319
|
+
):
|
|
320
|
+
http_options = parameter_model.config.http_options
|
|
321
|
+
|
|
322
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
323
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
324
|
+
|
|
325
|
+
response = self._api_client.request("post", path, request_dict, http_options)
|
|
326
|
+
|
|
327
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
328
|
+
|
|
329
|
+
return_value = types.ExampleStoreOperation._from_response(
|
|
330
|
+
response=response_dict,
|
|
331
|
+
kwargs=(
|
|
332
|
+
{
|
|
333
|
+
"config": {
|
|
334
|
+
"response_schema": getattr(
|
|
335
|
+
parameter_model.config, "response_schema", None
|
|
336
|
+
),
|
|
337
|
+
"response_json_schema": getattr(
|
|
338
|
+
parameter_model.config, "response_json_schema", None
|
|
339
|
+
),
|
|
340
|
+
"include_all_fields": getattr(
|
|
341
|
+
parameter_model.config, "include_all_fields", None
|
|
342
|
+
),
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
if getattr(parameter_model, "config", None)
|
|
346
|
+
else {}
|
|
347
|
+
),
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
self._api_client._verify_response(return_value)
|
|
351
|
+
return return_value
|
|
352
|
+
|
|
353
|
+
def get(
|
|
354
|
+
self, *, name: str, config: Optional[types.GetExampleStoreConfigOrDict] = None
|
|
355
|
+
) -> types.ExampleStore:
|
|
356
|
+
"""
|
|
357
|
+
Retrieves a specific Example Store resource by its name.
|
|
358
|
+
"""
|
|
359
|
+
|
|
360
|
+
parameter_model = types._GetExampleStoreParameters(
|
|
361
|
+
name=name,
|
|
362
|
+
config=config,
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
request_url_dict: Optional[dict[str, str]]
|
|
366
|
+
if not self._api_client.vertexai:
|
|
367
|
+
raise ValueError(
|
|
368
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
369
|
+
)
|
|
370
|
+
else:
|
|
371
|
+
request_dict = _GetExampleStoreParameters_to_vertex(parameter_model)
|
|
372
|
+
request_url_dict = request_dict.get("_url")
|
|
373
|
+
if request_url_dict:
|
|
374
|
+
path = "{name}".format_map(request_url_dict)
|
|
375
|
+
else:
|
|
376
|
+
path = "{name}"
|
|
377
|
+
|
|
378
|
+
query_params = request_dict.get("_query")
|
|
379
|
+
if query_params:
|
|
380
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
381
|
+
# TODO: remove the hack that pops config.
|
|
382
|
+
request_dict.pop("config", None)
|
|
383
|
+
|
|
384
|
+
http_options: Optional[types.HttpOptions] = None
|
|
385
|
+
if (
|
|
386
|
+
parameter_model.config is not None
|
|
387
|
+
and parameter_model.config.http_options is not None
|
|
388
|
+
):
|
|
389
|
+
http_options = parameter_model.config.http_options
|
|
390
|
+
|
|
391
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
392
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
393
|
+
|
|
394
|
+
response = self._api_client.request("get", path, request_dict, http_options)
|
|
395
|
+
|
|
396
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
397
|
+
|
|
398
|
+
return_value = types.ExampleStore._from_response(
|
|
399
|
+
response=response_dict,
|
|
400
|
+
kwargs=(
|
|
401
|
+
{
|
|
402
|
+
"config": {
|
|
403
|
+
"response_schema": getattr(
|
|
404
|
+
parameter_model.config, "response_schema", None
|
|
405
|
+
),
|
|
406
|
+
"response_json_schema": getattr(
|
|
407
|
+
parameter_model.config, "response_json_schema", None
|
|
408
|
+
),
|
|
409
|
+
"include_all_fields": getattr(
|
|
410
|
+
parameter_model.config, "include_all_fields", None
|
|
411
|
+
),
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if getattr(parameter_model, "config", None)
|
|
415
|
+
else {}
|
|
416
|
+
),
|
|
417
|
+
)
|
|
418
|
+
|
|
419
|
+
self._api_client._verify_response(return_value)
|
|
420
|
+
return return_value
|
|
421
|
+
|
|
422
|
+
def _delete(
|
|
423
|
+
self,
|
|
424
|
+
*,
|
|
425
|
+
name: str,
|
|
426
|
+
config: Optional[types.DeleteExampleStoreConfigOrDict] = None,
|
|
427
|
+
) -> types.DeleteExampleStoreOperation:
|
|
428
|
+
"""
|
|
429
|
+
Deletes an Example Store.
|
|
430
|
+
"""
|
|
431
|
+
|
|
432
|
+
parameter_model = types._DeleteExampleStoreRequestParameters(
|
|
433
|
+
name=name,
|
|
434
|
+
config=config,
|
|
435
|
+
)
|
|
436
|
+
|
|
437
|
+
request_url_dict: Optional[dict[str, str]]
|
|
438
|
+
if not self._api_client.vertexai:
|
|
439
|
+
raise ValueError(
|
|
440
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
441
|
+
)
|
|
442
|
+
else:
|
|
443
|
+
request_dict = _DeleteExampleStoreRequestParameters_to_vertex(
|
|
444
|
+
parameter_model
|
|
445
|
+
)
|
|
446
|
+
request_url_dict = request_dict.get("_url")
|
|
447
|
+
if request_url_dict:
|
|
448
|
+
path = "{name}".format_map(request_url_dict)
|
|
449
|
+
else:
|
|
450
|
+
path = "{name}"
|
|
451
|
+
|
|
452
|
+
query_params = request_dict.get("_query")
|
|
453
|
+
if query_params:
|
|
454
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
455
|
+
# TODO: remove the hack that pops config.
|
|
456
|
+
request_dict.pop("config", None)
|
|
457
|
+
|
|
458
|
+
http_options: Optional[types.HttpOptions] = None
|
|
459
|
+
if (
|
|
460
|
+
parameter_model.config is not None
|
|
461
|
+
and parameter_model.config.http_options is not None
|
|
462
|
+
):
|
|
463
|
+
http_options = parameter_model.config.http_options
|
|
464
|
+
|
|
465
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
466
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
467
|
+
|
|
468
|
+
response = self._api_client.request("delete", path, request_dict, http_options)
|
|
469
|
+
|
|
470
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
471
|
+
|
|
472
|
+
return_value = types.DeleteExampleStoreOperation._from_response(
|
|
473
|
+
response=response_dict,
|
|
474
|
+
kwargs=(
|
|
475
|
+
{
|
|
476
|
+
"config": {
|
|
477
|
+
"response_schema": getattr(
|
|
478
|
+
parameter_model.config, "response_schema", None
|
|
479
|
+
),
|
|
480
|
+
"response_json_schema": getattr(
|
|
481
|
+
parameter_model.config, "response_json_schema", None
|
|
482
|
+
),
|
|
483
|
+
"include_all_fields": getattr(
|
|
484
|
+
parameter_model.config, "include_all_fields", None
|
|
485
|
+
),
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
if getattr(parameter_model, "config", None)
|
|
489
|
+
else {}
|
|
490
|
+
),
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
self._api_client._verify_response(return_value)
|
|
494
|
+
return return_value
|
|
495
|
+
|
|
496
|
+
def upsert_examples(
|
|
497
|
+
self,
|
|
498
|
+
*,
|
|
499
|
+
name: str,
|
|
500
|
+
examples: list[types.ExampleOrDict],
|
|
501
|
+
config: Optional[types.UpsertExamplesConfigOrDict] = None,
|
|
502
|
+
) -> types.UpsertExamplesResponse:
|
|
503
|
+
"""
|
|
504
|
+
Creates or updates examples in an Example Store.
|
|
505
|
+
"""
|
|
506
|
+
|
|
507
|
+
parameter_model = types._UpsertExamplesParameters(
|
|
508
|
+
name=name,
|
|
509
|
+
examples=examples,
|
|
510
|
+
config=config,
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
request_url_dict: Optional[dict[str, str]]
|
|
514
|
+
if not self._api_client.vertexai:
|
|
515
|
+
raise ValueError(
|
|
516
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
517
|
+
)
|
|
518
|
+
else:
|
|
519
|
+
request_dict = _UpsertExamplesParameters_to_vertex(parameter_model)
|
|
520
|
+
request_url_dict = request_dict.get("_url")
|
|
521
|
+
if request_url_dict:
|
|
522
|
+
path = "{exampleStore}:upsertExamples".format_map(request_url_dict)
|
|
523
|
+
else:
|
|
524
|
+
path = "{exampleStore}:upsertExamples"
|
|
525
|
+
|
|
526
|
+
query_params = request_dict.get("_query")
|
|
527
|
+
if query_params:
|
|
528
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
529
|
+
# TODO: remove the hack that pops config.
|
|
530
|
+
request_dict.pop("config", None)
|
|
531
|
+
|
|
532
|
+
http_options: Optional[types.HttpOptions] = None
|
|
533
|
+
if (
|
|
534
|
+
parameter_model.config is not None
|
|
535
|
+
and parameter_model.config.http_options is not None
|
|
536
|
+
):
|
|
537
|
+
http_options = parameter_model.config.http_options
|
|
538
|
+
|
|
539
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
540
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
541
|
+
|
|
542
|
+
response = self._api_client.request("post", path, request_dict, http_options)
|
|
543
|
+
|
|
544
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
545
|
+
|
|
546
|
+
return_value = types.UpsertExamplesResponse._from_response(
|
|
547
|
+
response=response_dict,
|
|
548
|
+
kwargs=(
|
|
549
|
+
{
|
|
550
|
+
"config": {
|
|
551
|
+
"response_schema": getattr(
|
|
552
|
+
parameter_model.config, "response_schema", None
|
|
553
|
+
),
|
|
554
|
+
"response_json_schema": getattr(
|
|
555
|
+
parameter_model.config, "response_json_schema", None
|
|
556
|
+
),
|
|
557
|
+
"include_all_fields": getattr(
|
|
558
|
+
parameter_model.config, "include_all_fields", None
|
|
559
|
+
),
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
if getattr(parameter_model, "config", None)
|
|
563
|
+
else {}
|
|
564
|
+
),
|
|
565
|
+
)
|
|
566
|
+
|
|
567
|
+
self._api_client._verify_response(return_value)
|
|
568
|
+
return return_value
|
|
569
|
+
|
|
570
|
+
def search_examples(
|
|
571
|
+
self,
|
|
572
|
+
*,
|
|
573
|
+
name: str,
|
|
574
|
+
stored_contents_example_parameters: Optional[
|
|
575
|
+
types.StoredContentsExampleParametersOrDict
|
|
576
|
+
] = None,
|
|
577
|
+
config: Optional[types.SearchExamplesConfigOrDict] = None,
|
|
578
|
+
) -> types.SearchExamplesResponse:
|
|
579
|
+
"""
|
|
580
|
+
Searches an Example Store for similar examples.
|
|
581
|
+
"""
|
|
582
|
+
|
|
583
|
+
parameter_model = types._SearchExamplesParameters(
|
|
584
|
+
name=name,
|
|
585
|
+
stored_contents_example_parameters=stored_contents_example_parameters,
|
|
586
|
+
config=config,
|
|
587
|
+
)
|
|
588
|
+
|
|
589
|
+
request_url_dict: Optional[dict[str, str]]
|
|
590
|
+
if not self._api_client.vertexai:
|
|
591
|
+
raise ValueError(
|
|
592
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
593
|
+
)
|
|
594
|
+
else:
|
|
595
|
+
request_dict = _SearchExamplesParameters_to_vertex(parameter_model)
|
|
596
|
+
request_url_dict = request_dict.get("_url")
|
|
597
|
+
if request_url_dict:
|
|
598
|
+
path = "{exampleStore}:searchExamples".format_map(request_url_dict)
|
|
599
|
+
else:
|
|
600
|
+
path = "{exampleStore}:searchExamples"
|
|
601
|
+
|
|
602
|
+
query_params = request_dict.get("_query")
|
|
603
|
+
if query_params:
|
|
604
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
605
|
+
# TODO: remove the hack that pops config.
|
|
606
|
+
request_dict.pop("config", None)
|
|
607
|
+
|
|
608
|
+
http_options: Optional[types.HttpOptions] = None
|
|
609
|
+
if (
|
|
610
|
+
parameter_model.config is not None
|
|
611
|
+
and parameter_model.config.http_options is not None
|
|
612
|
+
):
|
|
613
|
+
http_options = parameter_model.config.http_options
|
|
614
|
+
|
|
615
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
616
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
617
|
+
|
|
618
|
+
response = self._api_client.request("post", path, request_dict, http_options)
|
|
619
|
+
|
|
620
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
621
|
+
|
|
622
|
+
return_value = types.SearchExamplesResponse._from_response(
|
|
623
|
+
response=response_dict,
|
|
624
|
+
kwargs=(
|
|
625
|
+
{
|
|
626
|
+
"config": {
|
|
627
|
+
"response_schema": getattr(
|
|
628
|
+
parameter_model.config, "response_schema", None
|
|
629
|
+
),
|
|
630
|
+
"response_json_schema": getattr(
|
|
631
|
+
parameter_model.config, "response_json_schema", None
|
|
632
|
+
),
|
|
633
|
+
"include_all_fields": getattr(
|
|
634
|
+
parameter_model.config, "include_all_fields", None
|
|
635
|
+
),
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
if getattr(parameter_model, "config", None)
|
|
639
|
+
else {}
|
|
640
|
+
),
|
|
641
|
+
)
|
|
642
|
+
|
|
643
|
+
self._api_client._verify_response(return_value)
|
|
644
|
+
return return_value
|
|
645
|
+
|
|
646
|
+
def fetch_examples(
|
|
647
|
+
self, *, name: str, config: Optional[types.FetchExamplesConfigOrDict] = None
|
|
648
|
+
) -> types.FetchExamplesResponse:
|
|
649
|
+
"""
|
|
650
|
+
Fetches examples from an Example Store.
|
|
651
|
+
"""
|
|
652
|
+
|
|
653
|
+
parameter_model = types._FetchExamplesParameters(
|
|
654
|
+
name=name,
|
|
655
|
+
config=config,
|
|
656
|
+
)
|
|
657
|
+
|
|
658
|
+
request_url_dict: Optional[dict[str, str]]
|
|
659
|
+
if not self._api_client.vertexai:
|
|
660
|
+
raise ValueError(
|
|
661
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
662
|
+
)
|
|
663
|
+
else:
|
|
664
|
+
request_dict = _FetchExamplesParameters_to_vertex(parameter_model)
|
|
665
|
+
request_url_dict = request_dict.get("_url")
|
|
666
|
+
if request_url_dict:
|
|
667
|
+
path = "{exampleStore}:fetchExamples".format_map(request_url_dict)
|
|
668
|
+
else:
|
|
669
|
+
path = "{exampleStore}:fetchExamples"
|
|
670
|
+
|
|
671
|
+
query_params = request_dict.get("_query")
|
|
672
|
+
if query_params:
|
|
673
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
674
|
+
# TODO: remove the hack that pops config.
|
|
675
|
+
request_dict.pop("config", None)
|
|
676
|
+
|
|
677
|
+
http_options: Optional[types.HttpOptions] = None
|
|
678
|
+
if (
|
|
679
|
+
parameter_model.config is not None
|
|
680
|
+
and parameter_model.config.http_options is not None
|
|
681
|
+
):
|
|
682
|
+
http_options = parameter_model.config.http_options
|
|
683
|
+
|
|
684
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
685
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
686
|
+
|
|
687
|
+
response = self._api_client.request("post", path, request_dict, http_options)
|
|
688
|
+
|
|
689
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
690
|
+
|
|
691
|
+
return_value = types.FetchExamplesResponse._from_response(
|
|
692
|
+
response=response_dict,
|
|
693
|
+
kwargs=(
|
|
694
|
+
{
|
|
695
|
+
"config": {
|
|
696
|
+
"response_schema": getattr(
|
|
697
|
+
parameter_model.config, "response_schema", None
|
|
698
|
+
),
|
|
699
|
+
"response_json_schema": getattr(
|
|
700
|
+
parameter_model.config, "response_json_schema", None
|
|
701
|
+
),
|
|
702
|
+
"include_all_fields": getattr(
|
|
703
|
+
parameter_model.config, "include_all_fields", None
|
|
704
|
+
),
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
if getattr(parameter_model, "config", None)
|
|
708
|
+
else {}
|
|
709
|
+
),
|
|
710
|
+
)
|
|
711
|
+
|
|
712
|
+
self._api_client._verify_response(return_value)
|
|
713
|
+
return return_value
|
|
714
|
+
|
|
715
|
+
def remove_examples(
|
|
716
|
+
self, *, name: str, config: Optional[types.RemoveExamplesConfigOrDict] = None
|
|
717
|
+
) -> types.RemoveExamplesResponse:
|
|
718
|
+
"""
|
|
719
|
+
Removes examples from an Example Store.
|
|
720
|
+
"""
|
|
721
|
+
|
|
722
|
+
parameter_model = types._RemoveExamplesParameters(
|
|
723
|
+
name=name,
|
|
724
|
+
config=config,
|
|
725
|
+
)
|
|
726
|
+
|
|
727
|
+
request_url_dict: Optional[dict[str, str]]
|
|
728
|
+
if not self._api_client.vertexai:
|
|
729
|
+
raise ValueError(
|
|
730
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
731
|
+
)
|
|
732
|
+
else:
|
|
733
|
+
request_dict = _RemoveExamplesParameters_to_vertex(parameter_model)
|
|
734
|
+
request_url_dict = request_dict.get("_url")
|
|
735
|
+
if request_url_dict:
|
|
736
|
+
path = "{exampleStore}:removeExamples".format_map(request_url_dict)
|
|
737
|
+
else:
|
|
738
|
+
path = "{exampleStore}:removeExamples"
|
|
739
|
+
|
|
740
|
+
query_params = request_dict.get("_query")
|
|
741
|
+
if query_params:
|
|
742
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
743
|
+
# TODO: remove the hack that pops config.
|
|
744
|
+
request_dict.pop("config", None)
|
|
745
|
+
|
|
746
|
+
http_options: Optional[types.HttpOptions] = None
|
|
747
|
+
if (
|
|
748
|
+
parameter_model.config is not None
|
|
749
|
+
and parameter_model.config.http_options is not None
|
|
750
|
+
):
|
|
751
|
+
http_options = parameter_model.config.http_options
|
|
752
|
+
|
|
753
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
754
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
755
|
+
|
|
756
|
+
response = self._api_client.request("post", path, request_dict, http_options)
|
|
757
|
+
|
|
758
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
759
|
+
|
|
760
|
+
return_value = types.RemoveExamplesResponse._from_response(
|
|
761
|
+
response=response_dict,
|
|
762
|
+
kwargs=(
|
|
763
|
+
{
|
|
764
|
+
"config": {
|
|
765
|
+
"response_schema": getattr(
|
|
766
|
+
parameter_model.config, "response_schema", None
|
|
767
|
+
),
|
|
768
|
+
"response_json_schema": getattr(
|
|
769
|
+
parameter_model.config, "response_json_schema", None
|
|
770
|
+
),
|
|
771
|
+
"include_all_fields": getattr(
|
|
772
|
+
parameter_model.config, "include_all_fields", None
|
|
773
|
+
),
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
if getattr(parameter_model, "config", None)
|
|
777
|
+
else {}
|
|
778
|
+
),
|
|
779
|
+
)
|
|
780
|
+
|
|
781
|
+
self._api_client._verify_response(return_value)
|
|
782
|
+
return return_value
|
|
783
|
+
|
|
784
|
+
def _get_example_store_operation(
|
|
785
|
+
self,
|
|
786
|
+
*,
|
|
787
|
+
operation_name: str,
|
|
788
|
+
config: Optional[types.GetExampleStoreOperationConfigOrDict] = None,
|
|
789
|
+
) -> types.ExampleStoreOperation:
|
|
790
|
+
parameter_model = types._GetExampleStoreOperationParameters(
|
|
791
|
+
operation_name=operation_name,
|
|
792
|
+
config=config,
|
|
793
|
+
)
|
|
794
|
+
|
|
795
|
+
request_url_dict: Optional[dict[str, str]]
|
|
796
|
+
if not self._api_client.vertexai:
|
|
797
|
+
raise ValueError(
|
|
798
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
799
|
+
)
|
|
800
|
+
else:
|
|
801
|
+
request_dict = _GetExampleStoreOperationParameters_to_vertex(
|
|
802
|
+
parameter_model
|
|
803
|
+
)
|
|
804
|
+
request_url_dict = request_dict.get("_url")
|
|
805
|
+
if request_url_dict:
|
|
806
|
+
path = "{operationName}".format_map(request_url_dict)
|
|
807
|
+
else:
|
|
808
|
+
path = "{operationName}"
|
|
809
|
+
|
|
810
|
+
query_params = request_dict.get("_query")
|
|
811
|
+
if query_params:
|
|
812
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
813
|
+
# TODO: remove the hack that pops config.
|
|
814
|
+
request_dict.pop("config", None)
|
|
815
|
+
|
|
816
|
+
http_options: Optional[types.HttpOptions] = None
|
|
817
|
+
if (
|
|
818
|
+
parameter_model.config is not None
|
|
819
|
+
and parameter_model.config.http_options is not None
|
|
820
|
+
):
|
|
821
|
+
http_options = parameter_model.config.http_options
|
|
822
|
+
|
|
823
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
824
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
825
|
+
|
|
826
|
+
response = self._api_client.request("get", path, request_dict, http_options)
|
|
827
|
+
|
|
828
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
829
|
+
|
|
830
|
+
return_value = types.ExampleStoreOperation._from_response(
|
|
831
|
+
response=response_dict,
|
|
832
|
+
kwargs=(
|
|
833
|
+
{
|
|
834
|
+
"config": {
|
|
835
|
+
"response_schema": getattr(
|
|
836
|
+
parameter_model.config, "response_schema", None
|
|
837
|
+
),
|
|
838
|
+
"response_json_schema": getattr(
|
|
839
|
+
parameter_model.config, "response_json_schema", None
|
|
840
|
+
),
|
|
841
|
+
"include_all_fields": getattr(
|
|
842
|
+
parameter_model.config, "include_all_fields", None
|
|
843
|
+
),
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
if getattr(parameter_model, "config", None)
|
|
847
|
+
else {}
|
|
848
|
+
),
|
|
849
|
+
)
|
|
850
|
+
|
|
851
|
+
self._api_client._verify_response(return_value)
|
|
852
|
+
return return_value
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
class AsyncExampleStores(_api_module.BaseModule):
|
|
856
|
+
"""Class for managing Example Stores of few-shot examples."""
|
|
857
|
+
|
|
858
|
+
async def _create(
|
|
859
|
+
self,
|
|
860
|
+
*,
|
|
861
|
+
display_name: str,
|
|
862
|
+
config: Optional[types.CreateExampleStoreConfigOrDict] = None,
|
|
863
|
+
) -> types.ExampleStoreOperation:
|
|
864
|
+
"""
|
|
865
|
+
Creates an Example Store.
|
|
866
|
+
"""
|
|
867
|
+
|
|
868
|
+
parameter_model = types._CreateExampleStoreParameters(
|
|
869
|
+
display_name=display_name,
|
|
870
|
+
config=config,
|
|
871
|
+
)
|
|
872
|
+
|
|
873
|
+
request_url_dict: Optional[dict[str, str]]
|
|
874
|
+
if not self._api_client.vertexai:
|
|
875
|
+
raise ValueError(
|
|
876
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
877
|
+
)
|
|
878
|
+
else:
|
|
879
|
+
request_dict = _CreateExampleStoreParameters_to_vertex(parameter_model)
|
|
880
|
+
request_url_dict = request_dict.get("_url")
|
|
881
|
+
if request_url_dict:
|
|
882
|
+
path = "{parent}/exampleStores:create".format_map(request_url_dict)
|
|
883
|
+
else:
|
|
884
|
+
path = "{parent}/exampleStores:create"
|
|
885
|
+
|
|
886
|
+
query_params = request_dict.get("_query")
|
|
887
|
+
if query_params:
|
|
888
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
889
|
+
# TODO: remove the hack that pops config.
|
|
890
|
+
request_dict.pop("config", None)
|
|
891
|
+
|
|
892
|
+
http_options: Optional[types.HttpOptions] = None
|
|
893
|
+
if (
|
|
894
|
+
parameter_model.config is not None
|
|
895
|
+
and parameter_model.config.http_options is not None
|
|
896
|
+
):
|
|
897
|
+
http_options = parameter_model.config.http_options
|
|
898
|
+
|
|
899
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
900
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
901
|
+
|
|
902
|
+
response = await self._api_client.async_request(
|
|
903
|
+
"post", path, request_dict, http_options
|
|
904
|
+
)
|
|
905
|
+
|
|
906
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
907
|
+
|
|
908
|
+
return_value = types.ExampleStoreOperation._from_response(
|
|
909
|
+
response=response_dict,
|
|
910
|
+
kwargs=(
|
|
911
|
+
{
|
|
912
|
+
"config": {
|
|
913
|
+
"response_schema": getattr(
|
|
914
|
+
parameter_model.config, "response_schema", None
|
|
915
|
+
),
|
|
916
|
+
"response_json_schema": getattr(
|
|
917
|
+
parameter_model.config, "response_json_schema", None
|
|
918
|
+
),
|
|
919
|
+
"include_all_fields": getattr(
|
|
920
|
+
parameter_model.config, "include_all_fields", None
|
|
921
|
+
),
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
if getattr(parameter_model, "config", None)
|
|
925
|
+
else {}
|
|
926
|
+
),
|
|
927
|
+
)
|
|
928
|
+
|
|
929
|
+
self._api_client._verify_response(return_value)
|
|
930
|
+
return return_value
|
|
931
|
+
|
|
932
|
+
async def get(
|
|
933
|
+
self, *, name: str, config: Optional[types.GetExampleStoreConfigOrDict] = None
|
|
934
|
+
) -> types.ExampleStore:
|
|
935
|
+
"""
|
|
936
|
+
Retrieves a specific Example Store resource by its name.
|
|
937
|
+
"""
|
|
938
|
+
|
|
939
|
+
parameter_model = types._GetExampleStoreParameters(
|
|
940
|
+
name=name,
|
|
941
|
+
config=config,
|
|
942
|
+
)
|
|
943
|
+
|
|
944
|
+
request_url_dict: Optional[dict[str, str]]
|
|
945
|
+
if not self._api_client.vertexai:
|
|
946
|
+
raise ValueError(
|
|
947
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
948
|
+
)
|
|
949
|
+
else:
|
|
950
|
+
request_dict = _GetExampleStoreParameters_to_vertex(parameter_model)
|
|
951
|
+
request_url_dict = request_dict.get("_url")
|
|
952
|
+
if request_url_dict:
|
|
953
|
+
path = "{name}".format_map(request_url_dict)
|
|
954
|
+
else:
|
|
955
|
+
path = "{name}"
|
|
956
|
+
|
|
957
|
+
query_params = request_dict.get("_query")
|
|
958
|
+
if query_params:
|
|
959
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
960
|
+
# TODO: remove the hack that pops config.
|
|
961
|
+
request_dict.pop("config", None)
|
|
962
|
+
|
|
963
|
+
http_options: Optional[types.HttpOptions] = None
|
|
964
|
+
if (
|
|
965
|
+
parameter_model.config is not None
|
|
966
|
+
and parameter_model.config.http_options is not None
|
|
967
|
+
):
|
|
968
|
+
http_options = parameter_model.config.http_options
|
|
969
|
+
|
|
970
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
971
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
972
|
+
|
|
973
|
+
response = await self._api_client.async_request(
|
|
974
|
+
"get", path, request_dict, http_options
|
|
975
|
+
)
|
|
976
|
+
|
|
977
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
978
|
+
|
|
979
|
+
return_value = types.ExampleStore._from_response(
|
|
980
|
+
response=response_dict,
|
|
981
|
+
kwargs=(
|
|
982
|
+
{
|
|
983
|
+
"config": {
|
|
984
|
+
"response_schema": getattr(
|
|
985
|
+
parameter_model.config, "response_schema", None
|
|
986
|
+
),
|
|
987
|
+
"response_json_schema": getattr(
|
|
988
|
+
parameter_model.config, "response_json_schema", None
|
|
989
|
+
),
|
|
990
|
+
"include_all_fields": getattr(
|
|
991
|
+
parameter_model.config, "include_all_fields", None
|
|
992
|
+
),
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
if getattr(parameter_model, "config", None)
|
|
996
|
+
else {}
|
|
997
|
+
),
|
|
998
|
+
)
|
|
999
|
+
|
|
1000
|
+
self._api_client._verify_response(return_value)
|
|
1001
|
+
return return_value
|
|
1002
|
+
|
|
1003
|
+
async def _delete(
|
|
1004
|
+
self,
|
|
1005
|
+
*,
|
|
1006
|
+
name: str,
|
|
1007
|
+
config: Optional[types.DeleteExampleStoreConfigOrDict] = None,
|
|
1008
|
+
) -> types.DeleteExampleStoreOperation:
|
|
1009
|
+
"""
|
|
1010
|
+
Deletes an Example Store.
|
|
1011
|
+
"""
|
|
1012
|
+
|
|
1013
|
+
parameter_model = types._DeleteExampleStoreRequestParameters(
|
|
1014
|
+
name=name,
|
|
1015
|
+
config=config,
|
|
1016
|
+
)
|
|
1017
|
+
|
|
1018
|
+
request_url_dict: Optional[dict[str, str]]
|
|
1019
|
+
if not self._api_client.vertexai:
|
|
1020
|
+
raise ValueError(
|
|
1021
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
1022
|
+
)
|
|
1023
|
+
else:
|
|
1024
|
+
request_dict = _DeleteExampleStoreRequestParameters_to_vertex(
|
|
1025
|
+
parameter_model
|
|
1026
|
+
)
|
|
1027
|
+
request_url_dict = request_dict.get("_url")
|
|
1028
|
+
if request_url_dict:
|
|
1029
|
+
path = "{name}".format_map(request_url_dict)
|
|
1030
|
+
else:
|
|
1031
|
+
path = "{name}"
|
|
1032
|
+
|
|
1033
|
+
query_params = request_dict.get("_query")
|
|
1034
|
+
if query_params:
|
|
1035
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
1036
|
+
# TODO: remove the hack that pops config.
|
|
1037
|
+
request_dict.pop("config", None)
|
|
1038
|
+
|
|
1039
|
+
http_options: Optional[types.HttpOptions] = None
|
|
1040
|
+
if (
|
|
1041
|
+
parameter_model.config is not None
|
|
1042
|
+
and parameter_model.config.http_options is not None
|
|
1043
|
+
):
|
|
1044
|
+
http_options = parameter_model.config.http_options
|
|
1045
|
+
|
|
1046
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
1047
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
1048
|
+
|
|
1049
|
+
response = await self._api_client.async_request(
|
|
1050
|
+
"delete", path, request_dict, http_options
|
|
1051
|
+
)
|
|
1052
|
+
|
|
1053
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1054
|
+
|
|
1055
|
+
return_value = types.DeleteExampleStoreOperation._from_response(
|
|
1056
|
+
response=response_dict,
|
|
1057
|
+
kwargs=(
|
|
1058
|
+
{
|
|
1059
|
+
"config": {
|
|
1060
|
+
"response_schema": getattr(
|
|
1061
|
+
parameter_model.config, "response_schema", None
|
|
1062
|
+
),
|
|
1063
|
+
"response_json_schema": getattr(
|
|
1064
|
+
parameter_model.config, "response_json_schema", None
|
|
1065
|
+
),
|
|
1066
|
+
"include_all_fields": getattr(
|
|
1067
|
+
parameter_model.config, "include_all_fields", None
|
|
1068
|
+
),
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
if getattr(parameter_model, "config", None)
|
|
1072
|
+
else {}
|
|
1073
|
+
),
|
|
1074
|
+
)
|
|
1075
|
+
|
|
1076
|
+
self._api_client._verify_response(return_value)
|
|
1077
|
+
return return_value
|
|
1078
|
+
|
|
1079
|
+
async def upsert_examples(
|
|
1080
|
+
self,
|
|
1081
|
+
*,
|
|
1082
|
+
name: str,
|
|
1083
|
+
examples: list[types.ExampleOrDict],
|
|
1084
|
+
config: Optional[types.UpsertExamplesConfigOrDict] = None,
|
|
1085
|
+
) -> types.UpsertExamplesResponse:
|
|
1086
|
+
"""
|
|
1087
|
+
Creates or updates examples in an Example Store.
|
|
1088
|
+
"""
|
|
1089
|
+
|
|
1090
|
+
parameter_model = types._UpsertExamplesParameters(
|
|
1091
|
+
name=name,
|
|
1092
|
+
examples=examples,
|
|
1093
|
+
config=config,
|
|
1094
|
+
)
|
|
1095
|
+
|
|
1096
|
+
request_url_dict: Optional[dict[str, str]]
|
|
1097
|
+
if not self._api_client.vertexai:
|
|
1098
|
+
raise ValueError(
|
|
1099
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
1100
|
+
)
|
|
1101
|
+
else:
|
|
1102
|
+
request_dict = _UpsertExamplesParameters_to_vertex(parameter_model)
|
|
1103
|
+
request_url_dict = request_dict.get("_url")
|
|
1104
|
+
if request_url_dict:
|
|
1105
|
+
path = "{exampleStore}:upsertExamples".format_map(request_url_dict)
|
|
1106
|
+
else:
|
|
1107
|
+
path = "{exampleStore}:upsertExamples"
|
|
1108
|
+
|
|
1109
|
+
query_params = request_dict.get("_query")
|
|
1110
|
+
if query_params:
|
|
1111
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
1112
|
+
# TODO: remove the hack that pops config.
|
|
1113
|
+
request_dict.pop("config", None)
|
|
1114
|
+
|
|
1115
|
+
http_options: Optional[types.HttpOptions] = None
|
|
1116
|
+
if (
|
|
1117
|
+
parameter_model.config is not None
|
|
1118
|
+
and parameter_model.config.http_options is not None
|
|
1119
|
+
):
|
|
1120
|
+
http_options = parameter_model.config.http_options
|
|
1121
|
+
|
|
1122
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
1123
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
1124
|
+
|
|
1125
|
+
response = await self._api_client.async_request(
|
|
1126
|
+
"post", path, request_dict, http_options
|
|
1127
|
+
)
|
|
1128
|
+
|
|
1129
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1130
|
+
|
|
1131
|
+
return_value = types.UpsertExamplesResponse._from_response(
|
|
1132
|
+
response=response_dict,
|
|
1133
|
+
kwargs=(
|
|
1134
|
+
{
|
|
1135
|
+
"config": {
|
|
1136
|
+
"response_schema": getattr(
|
|
1137
|
+
parameter_model.config, "response_schema", None
|
|
1138
|
+
),
|
|
1139
|
+
"response_json_schema": getattr(
|
|
1140
|
+
parameter_model.config, "response_json_schema", None
|
|
1141
|
+
),
|
|
1142
|
+
"include_all_fields": getattr(
|
|
1143
|
+
parameter_model.config, "include_all_fields", None
|
|
1144
|
+
),
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
if getattr(parameter_model, "config", None)
|
|
1148
|
+
else {}
|
|
1149
|
+
),
|
|
1150
|
+
)
|
|
1151
|
+
|
|
1152
|
+
self._api_client._verify_response(return_value)
|
|
1153
|
+
return return_value
|
|
1154
|
+
|
|
1155
|
+
async def search_examples(
|
|
1156
|
+
self,
|
|
1157
|
+
*,
|
|
1158
|
+
name: str,
|
|
1159
|
+
stored_contents_example_parameters: Optional[
|
|
1160
|
+
types.StoredContentsExampleParametersOrDict
|
|
1161
|
+
] = None,
|
|
1162
|
+
config: Optional[types.SearchExamplesConfigOrDict] = None,
|
|
1163
|
+
) -> types.SearchExamplesResponse:
|
|
1164
|
+
"""
|
|
1165
|
+
Searches an Example Store for similar examples.
|
|
1166
|
+
"""
|
|
1167
|
+
|
|
1168
|
+
parameter_model = types._SearchExamplesParameters(
|
|
1169
|
+
name=name,
|
|
1170
|
+
stored_contents_example_parameters=stored_contents_example_parameters,
|
|
1171
|
+
config=config,
|
|
1172
|
+
)
|
|
1173
|
+
|
|
1174
|
+
request_url_dict: Optional[dict[str, str]]
|
|
1175
|
+
if not self._api_client.vertexai:
|
|
1176
|
+
raise ValueError(
|
|
1177
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
1178
|
+
)
|
|
1179
|
+
else:
|
|
1180
|
+
request_dict = _SearchExamplesParameters_to_vertex(parameter_model)
|
|
1181
|
+
request_url_dict = request_dict.get("_url")
|
|
1182
|
+
if request_url_dict:
|
|
1183
|
+
path = "{exampleStore}:searchExamples".format_map(request_url_dict)
|
|
1184
|
+
else:
|
|
1185
|
+
path = "{exampleStore}:searchExamples"
|
|
1186
|
+
|
|
1187
|
+
query_params = request_dict.get("_query")
|
|
1188
|
+
if query_params:
|
|
1189
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
1190
|
+
# TODO: remove the hack that pops config.
|
|
1191
|
+
request_dict.pop("config", None)
|
|
1192
|
+
|
|
1193
|
+
http_options: Optional[types.HttpOptions] = None
|
|
1194
|
+
if (
|
|
1195
|
+
parameter_model.config is not None
|
|
1196
|
+
and parameter_model.config.http_options is not None
|
|
1197
|
+
):
|
|
1198
|
+
http_options = parameter_model.config.http_options
|
|
1199
|
+
|
|
1200
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
1201
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
1202
|
+
|
|
1203
|
+
response = await self._api_client.async_request(
|
|
1204
|
+
"post", path, request_dict, http_options
|
|
1205
|
+
)
|
|
1206
|
+
|
|
1207
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1208
|
+
|
|
1209
|
+
return_value = types.SearchExamplesResponse._from_response(
|
|
1210
|
+
response=response_dict,
|
|
1211
|
+
kwargs=(
|
|
1212
|
+
{
|
|
1213
|
+
"config": {
|
|
1214
|
+
"response_schema": getattr(
|
|
1215
|
+
parameter_model.config, "response_schema", None
|
|
1216
|
+
),
|
|
1217
|
+
"response_json_schema": getattr(
|
|
1218
|
+
parameter_model.config, "response_json_schema", None
|
|
1219
|
+
),
|
|
1220
|
+
"include_all_fields": getattr(
|
|
1221
|
+
parameter_model.config, "include_all_fields", None
|
|
1222
|
+
),
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
if getattr(parameter_model, "config", None)
|
|
1226
|
+
else {}
|
|
1227
|
+
),
|
|
1228
|
+
)
|
|
1229
|
+
|
|
1230
|
+
self._api_client._verify_response(return_value)
|
|
1231
|
+
return return_value
|
|
1232
|
+
|
|
1233
|
+
async def fetch_examples(
|
|
1234
|
+
self, *, name: str, config: Optional[types.FetchExamplesConfigOrDict] = None
|
|
1235
|
+
) -> types.FetchExamplesResponse:
|
|
1236
|
+
"""
|
|
1237
|
+
Fetches examples from an Example Store.
|
|
1238
|
+
"""
|
|
1239
|
+
|
|
1240
|
+
parameter_model = types._FetchExamplesParameters(
|
|
1241
|
+
name=name,
|
|
1242
|
+
config=config,
|
|
1243
|
+
)
|
|
1244
|
+
|
|
1245
|
+
request_url_dict: Optional[dict[str, str]]
|
|
1246
|
+
if not self._api_client.vertexai:
|
|
1247
|
+
raise ValueError(
|
|
1248
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
1249
|
+
)
|
|
1250
|
+
else:
|
|
1251
|
+
request_dict = _FetchExamplesParameters_to_vertex(parameter_model)
|
|
1252
|
+
request_url_dict = request_dict.get("_url")
|
|
1253
|
+
if request_url_dict:
|
|
1254
|
+
path = "{exampleStore}:fetchExamples".format_map(request_url_dict)
|
|
1255
|
+
else:
|
|
1256
|
+
path = "{exampleStore}:fetchExamples"
|
|
1257
|
+
|
|
1258
|
+
query_params = request_dict.get("_query")
|
|
1259
|
+
if query_params:
|
|
1260
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
1261
|
+
# TODO: remove the hack that pops config.
|
|
1262
|
+
request_dict.pop("config", None)
|
|
1263
|
+
|
|
1264
|
+
http_options: Optional[types.HttpOptions] = None
|
|
1265
|
+
if (
|
|
1266
|
+
parameter_model.config is not None
|
|
1267
|
+
and parameter_model.config.http_options is not None
|
|
1268
|
+
):
|
|
1269
|
+
http_options = parameter_model.config.http_options
|
|
1270
|
+
|
|
1271
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
1272
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
1273
|
+
|
|
1274
|
+
response = await self._api_client.async_request(
|
|
1275
|
+
"post", path, request_dict, http_options
|
|
1276
|
+
)
|
|
1277
|
+
|
|
1278
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1279
|
+
|
|
1280
|
+
return_value = types.FetchExamplesResponse._from_response(
|
|
1281
|
+
response=response_dict,
|
|
1282
|
+
kwargs=(
|
|
1283
|
+
{
|
|
1284
|
+
"config": {
|
|
1285
|
+
"response_schema": getattr(
|
|
1286
|
+
parameter_model.config, "response_schema", None
|
|
1287
|
+
),
|
|
1288
|
+
"response_json_schema": getattr(
|
|
1289
|
+
parameter_model.config, "response_json_schema", None
|
|
1290
|
+
),
|
|
1291
|
+
"include_all_fields": getattr(
|
|
1292
|
+
parameter_model.config, "include_all_fields", None
|
|
1293
|
+
),
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
if getattr(parameter_model, "config", None)
|
|
1297
|
+
else {}
|
|
1298
|
+
),
|
|
1299
|
+
)
|
|
1300
|
+
|
|
1301
|
+
self._api_client._verify_response(return_value)
|
|
1302
|
+
return return_value
|
|
1303
|
+
|
|
1304
|
+
async def remove_examples(
|
|
1305
|
+
self, *, name: str, config: Optional[types.RemoveExamplesConfigOrDict] = None
|
|
1306
|
+
) -> types.RemoveExamplesResponse:
|
|
1307
|
+
"""
|
|
1308
|
+
Removes examples from an Example Store.
|
|
1309
|
+
"""
|
|
1310
|
+
|
|
1311
|
+
parameter_model = types._RemoveExamplesParameters(
|
|
1312
|
+
name=name,
|
|
1313
|
+
config=config,
|
|
1314
|
+
)
|
|
1315
|
+
|
|
1316
|
+
request_url_dict: Optional[dict[str, str]]
|
|
1317
|
+
if not self._api_client.vertexai:
|
|
1318
|
+
raise ValueError(
|
|
1319
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
1320
|
+
)
|
|
1321
|
+
else:
|
|
1322
|
+
request_dict = _RemoveExamplesParameters_to_vertex(parameter_model)
|
|
1323
|
+
request_url_dict = request_dict.get("_url")
|
|
1324
|
+
if request_url_dict:
|
|
1325
|
+
path = "{exampleStore}:removeExamples".format_map(request_url_dict)
|
|
1326
|
+
else:
|
|
1327
|
+
path = "{exampleStore}:removeExamples"
|
|
1328
|
+
|
|
1329
|
+
query_params = request_dict.get("_query")
|
|
1330
|
+
if query_params:
|
|
1331
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
1332
|
+
# TODO: remove the hack that pops config.
|
|
1333
|
+
request_dict.pop("config", None)
|
|
1334
|
+
|
|
1335
|
+
http_options: Optional[types.HttpOptions] = None
|
|
1336
|
+
if (
|
|
1337
|
+
parameter_model.config is not None
|
|
1338
|
+
and parameter_model.config.http_options is not None
|
|
1339
|
+
):
|
|
1340
|
+
http_options = parameter_model.config.http_options
|
|
1341
|
+
|
|
1342
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
1343
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
1344
|
+
|
|
1345
|
+
response = await self._api_client.async_request(
|
|
1346
|
+
"post", path, request_dict, http_options
|
|
1347
|
+
)
|
|
1348
|
+
|
|
1349
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1350
|
+
|
|
1351
|
+
return_value = types.RemoveExamplesResponse._from_response(
|
|
1352
|
+
response=response_dict,
|
|
1353
|
+
kwargs=(
|
|
1354
|
+
{
|
|
1355
|
+
"config": {
|
|
1356
|
+
"response_schema": getattr(
|
|
1357
|
+
parameter_model.config, "response_schema", None
|
|
1358
|
+
),
|
|
1359
|
+
"response_json_schema": getattr(
|
|
1360
|
+
parameter_model.config, "response_json_schema", None
|
|
1361
|
+
),
|
|
1362
|
+
"include_all_fields": getattr(
|
|
1363
|
+
parameter_model.config, "include_all_fields", None
|
|
1364
|
+
),
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
if getattr(parameter_model, "config", None)
|
|
1368
|
+
else {}
|
|
1369
|
+
),
|
|
1370
|
+
)
|
|
1371
|
+
|
|
1372
|
+
self._api_client._verify_response(return_value)
|
|
1373
|
+
return return_value
|
|
1374
|
+
|
|
1375
|
+
async def _get_example_store_operation(
|
|
1376
|
+
self,
|
|
1377
|
+
*,
|
|
1378
|
+
operation_name: str,
|
|
1379
|
+
config: Optional[types.GetExampleStoreOperationConfigOrDict] = None,
|
|
1380
|
+
) -> types.ExampleStoreOperation:
|
|
1381
|
+
parameter_model = types._GetExampleStoreOperationParameters(
|
|
1382
|
+
operation_name=operation_name,
|
|
1383
|
+
config=config,
|
|
1384
|
+
)
|
|
1385
|
+
|
|
1386
|
+
request_url_dict: Optional[dict[str, str]]
|
|
1387
|
+
if not self._api_client.vertexai:
|
|
1388
|
+
raise ValueError(
|
|
1389
|
+
"This method is only supported in Gemini Enterprise Agent Platform mode, not in Gemini Developer API mode."
|
|
1390
|
+
)
|
|
1391
|
+
else:
|
|
1392
|
+
request_dict = _GetExampleStoreOperationParameters_to_vertex(
|
|
1393
|
+
parameter_model
|
|
1394
|
+
)
|
|
1395
|
+
request_url_dict = request_dict.get("_url")
|
|
1396
|
+
if request_url_dict:
|
|
1397
|
+
path = "{operationName}".format_map(request_url_dict)
|
|
1398
|
+
else:
|
|
1399
|
+
path = "{operationName}"
|
|
1400
|
+
|
|
1401
|
+
query_params = request_dict.get("_query")
|
|
1402
|
+
if query_params:
|
|
1403
|
+
path = f"{path}?{urlencode(query_params)}"
|
|
1404
|
+
# TODO: remove the hack that pops config.
|
|
1405
|
+
request_dict.pop("config", None)
|
|
1406
|
+
|
|
1407
|
+
http_options: Optional[types.HttpOptions] = None
|
|
1408
|
+
if (
|
|
1409
|
+
parameter_model.config is not None
|
|
1410
|
+
and parameter_model.config.http_options is not None
|
|
1411
|
+
):
|
|
1412
|
+
http_options = parameter_model.config.http_options
|
|
1413
|
+
|
|
1414
|
+
request_dict = _common.convert_to_dict(request_dict)
|
|
1415
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
|
1416
|
+
|
|
1417
|
+
response = await self._api_client.async_request(
|
|
1418
|
+
"get", path, request_dict, http_options
|
|
1419
|
+
)
|
|
1420
|
+
|
|
1421
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1422
|
+
|
|
1423
|
+
return_value = types.ExampleStoreOperation._from_response(
|
|
1424
|
+
response=response_dict,
|
|
1425
|
+
kwargs=(
|
|
1426
|
+
{
|
|
1427
|
+
"config": {
|
|
1428
|
+
"response_schema": getattr(
|
|
1429
|
+
parameter_model.config, "response_schema", None
|
|
1430
|
+
),
|
|
1431
|
+
"response_json_schema": getattr(
|
|
1432
|
+
parameter_model.config, "response_json_schema", None
|
|
1433
|
+
),
|
|
1434
|
+
"include_all_fields": getattr(
|
|
1435
|
+
parameter_model.config, "include_all_fields", None
|
|
1436
|
+
),
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
if getattr(parameter_model, "config", None)
|
|
1440
|
+
else {}
|
|
1441
|
+
),
|
|
1442
|
+
)
|
|
1443
|
+
|
|
1444
|
+
self._api_client._verify_response(return_value)
|
|
1445
|
+
return return_value
|