google-genai 1.33.0__py3-none-any.whl → 1.53.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- google/genai/_api_client.py +361 -208
- google/genai/_common.py +260 -69
- google/genai/_extra_utils.py +142 -12
- google/genai/_live_converters.py +691 -2746
- google/genai/_local_tokenizer_loader.py +0 -9
- google/genai/_operations_converters.py +186 -99
- google/genai/_replay_api_client.py +48 -51
- google/genai/_tokens_converters.py +169 -489
- google/genai/_transformers.py +193 -90
- google/genai/batches.py +1014 -1307
- google/genai/caches.py +458 -1107
- google/genai/client.py +101 -0
- google/genai/documents.py +532 -0
- google/genai/errors.py +58 -4
- google/genai/file_search_stores.py +1296 -0
- google/genai/files.py +108 -358
- google/genai/live.py +90 -32
- google/genai/live_music.py +24 -27
- google/genai/local_tokenizer.py +36 -3
- google/genai/models.py +2308 -3375
- google/genai/operations.py +129 -21
- google/genai/pagers.py +7 -1
- google/genai/tokens.py +2 -12
- google/genai/tunings.py +770 -436
- google/genai/types.py +4341 -1218
- google/genai/version.py +1 -1
- {google_genai-1.33.0.dist-info → google_genai-1.53.0.dist-info}/METADATA +359 -201
- google_genai-1.53.0.dist-info/RECORD +41 -0
- google_genai-1.33.0.dist-info/RECORD +0 -39
- {google_genai-1.33.0.dist-info → google_genai-1.53.0.dist-info}/WHEEL +0 -0
- {google_genai-1.33.0.dist-info → google_genai-1.53.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.33.0.dist-info → google_genai-1.53.0.dist-info}/top_level.txt +0 -0
google/genai/caches.py
CHANGED
|
@@ -33,1433 +33,800 @@ from .pagers import AsyncPager, Pager
|
|
|
33
33
|
logger = logging.getLogger('google_genai.caches')
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
def _VideoMetadata_to_mldev(
|
|
37
|
-
from_object: Union[dict[str, Any], object],
|
|
38
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
39
|
-
) -> dict[str, Any]:
|
|
40
|
-
to_object: dict[str, Any] = {}
|
|
41
|
-
if getv(from_object, ['fps']) is not None:
|
|
42
|
-
setv(to_object, ['fps'], getv(from_object, ['fps']))
|
|
43
|
-
|
|
44
|
-
if getv(from_object, ['end_offset']) is not None:
|
|
45
|
-
setv(to_object, ['endOffset'], getv(from_object, ['end_offset']))
|
|
46
|
-
|
|
47
|
-
if getv(from_object, ['start_offset']) is not None:
|
|
48
|
-
setv(to_object, ['startOffset'], getv(from_object, ['start_offset']))
|
|
49
|
-
|
|
50
|
-
return to_object
|
|
51
|
-
|
|
52
|
-
|
|
53
36
|
def _Blob_to_mldev(
|
|
54
37
|
from_object: Union[dict[str, Any], object],
|
|
55
38
|
parent_object: Optional[dict[str, Any]] = None,
|
|
56
39
|
) -> dict[str, Any]:
|
|
57
40
|
to_object: dict[str, Any] = {}
|
|
58
|
-
if getv(from_object, ['display_name']) is not None:
|
|
59
|
-
raise ValueError('display_name parameter is not supported in Gemini API.')
|
|
60
|
-
|
|
61
41
|
if getv(from_object, ['data']) is not None:
|
|
62
42
|
setv(to_object, ['data'], getv(from_object, ['data']))
|
|
63
43
|
|
|
44
|
+
if getv(from_object, ['display_name']) is not None:
|
|
45
|
+
raise ValueError('display_name parameter is not supported in Gemini API.')
|
|
46
|
+
|
|
64
47
|
if getv(from_object, ['mime_type']) is not None:
|
|
65
48
|
setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
|
|
66
49
|
|
|
67
50
|
return to_object
|
|
68
51
|
|
|
69
52
|
|
|
70
|
-
def
|
|
53
|
+
def _Content_to_mldev(
|
|
71
54
|
from_object: Union[dict[str, Any], object],
|
|
72
55
|
parent_object: Optional[dict[str, Any]] = None,
|
|
73
56
|
) -> dict[str, Any]:
|
|
74
57
|
to_object: dict[str, Any] = {}
|
|
75
|
-
if getv(from_object, ['
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
58
|
+
if getv(from_object, ['parts']) is not None:
|
|
59
|
+
setv(
|
|
60
|
+
to_object,
|
|
61
|
+
['parts'],
|
|
62
|
+
[
|
|
63
|
+
_Part_to_mldev(item, to_object)
|
|
64
|
+
for item in getv(from_object, ['parts'])
|
|
65
|
+
],
|
|
66
|
+
)
|
|
80
67
|
|
|
81
|
-
if getv(from_object, ['
|
|
82
|
-
setv(to_object, ['
|
|
68
|
+
if getv(from_object, ['role']) is not None:
|
|
69
|
+
setv(to_object, ['role'], getv(from_object, ['role']))
|
|
83
70
|
|
|
84
71
|
return to_object
|
|
85
72
|
|
|
86
73
|
|
|
87
|
-
def
|
|
74
|
+
def _CreateCachedContentConfig_to_mldev(
|
|
88
75
|
from_object: Union[dict[str, Any], object],
|
|
89
76
|
parent_object: Optional[dict[str, Any]] = None,
|
|
90
77
|
) -> dict[str, Any]:
|
|
91
78
|
to_object: dict[str, Any] = {}
|
|
92
|
-
if getv(from_object, ['video_metadata']) is not None:
|
|
93
|
-
setv(
|
|
94
|
-
to_object,
|
|
95
|
-
['videoMetadata'],
|
|
96
|
-
_VideoMetadata_to_mldev(
|
|
97
|
-
getv(from_object, ['video_metadata']), to_object
|
|
98
|
-
),
|
|
99
|
-
)
|
|
100
79
|
|
|
101
|
-
if getv(from_object, ['
|
|
102
|
-
setv(
|
|
80
|
+
if getv(from_object, ['ttl']) is not None:
|
|
81
|
+
setv(parent_object, ['ttl'], getv(from_object, ['ttl']))
|
|
103
82
|
|
|
104
|
-
if getv(from_object, ['
|
|
105
|
-
setv(
|
|
106
|
-
to_object,
|
|
107
|
-
['inlineData'],
|
|
108
|
-
_Blob_to_mldev(getv(from_object, ['inline_data']), to_object),
|
|
109
|
-
)
|
|
83
|
+
if getv(from_object, ['expire_time']) is not None:
|
|
84
|
+
setv(parent_object, ['expireTime'], getv(from_object, ['expire_time']))
|
|
110
85
|
|
|
111
|
-
if getv(from_object, ['
|
|
86
|
+
if getv(from_object, ['display_name']) is not None:
|
|
87
|
+
setv(parent_object, ['displayName'], getv(from_object, ['display_name']))
|
|
88
|
+
|
|
89
|
+
if getv(from_object, ['contents']) is not None:
|
|
112
90
|
setv(
|
|
113
|
-
|
|
114
|
-
['
|
|
115
|
-
|
|
91
|
+
parent_object,
|
|
92
|
+
['contents'],
|
|
93
|
+
[
|
|
94
|
+
_Content_to_mldev(item, to_object)
|
|
95
|
+
for item in t.t_contents(getv(from_object, ['contents']))
|
|
96
|
+
],
|
|
116
97
|
)
|
|
117
98
|
|
|
118
|
-
if getv(from_object, ['
|
|
99
|
+
if getv(from_object, ['system_instruction']) is not None:
|
|
119
100
|
setv(
|
|
120
|
-
|
|
121
|
-
['
|
|
122
|
-
|
|
101
|
+
parent_object,
|
|
102
|
+
['systemInstruction'],
|
|
103
|
+
_Content_to_mldev(
|
|
104
|
+
t.t_content(getv(from_object, ['system_instruction'])), to_object
|
|
105
|
+
),
|
|
123
106
|
)
|
|
124
107
|
|
|
125
|
-
if getv(from_object, ['
|
|
108
|
+
if getv(from_object, ['tools']) is not None:
|
|
126
109
|
setv(
|
|
127
|
-
|
|
128
|
-
['
|
|
129
|
-
|
|
110
|
+
parent_object,
|
|
111
|
+
['tools'],
|
|
112
|
+
[
|
|
113
|
+
_Tool_to_mldev(item, to_object)
|
|
114
|
+
for item in getv(from_object, ['tools'])
|
|
115
|
+
],
|
|
130
116
|
)
|
|
131
117
|
|
|
132
|
-
if getv(from_object, ['
|
|
133
|
-
setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
|
|
134
|
-
|
|
135
|
-
if getv(from_object, ['function_call']) is not None:
|
|
136
|
-
setv(to_object, ['functionCall'], getv(from_object, ['function_call']))
|
|
137
|
-
|
|
138
|
-
if getv(from_object, ['function_response']) is not None:
|
|
118
|
+
if getv(from_object, ['tool_config']) is not None:
|
|
139
119
|
setv(
|
|
140
|
-
|
|
141
|
-
['
|
|
142
|
-
getv(from_object, ['
|
|
120
|
+
parent_object,
|
|
121
|
+
['toolConfig'],
|
|
122
|
+
_ToolConfig_to_mldev(getv(from_object, ['tool_config']), to_object),
|
|
143
123
|
)
|
|
144
124
|
|
|
145
|
-
if getv(from_object, ['
|
|
146
|
-
|
|
125
|
+
if getv(from_object, ['kms_key_name']) is not None:
|
|
126
|
+
raise ValueError('kms_key_name parameter is not supported in Gemini API.')
|
|
147
127
|
|
|
148
128
|
return to_object
|
|
149
129
|
|
|
150
130
|
|
|
151
|
-
def
|
|
131
|
+
def _CreateCachedContentConfig_to_vertex(
|
|
152
132
|
from_object: Union[dict[str, Any], object],
|
|
153
133
|
parent_object: Optional[dict[str, Any]] = None,
|
|
154
134
|
) -> dict[str, Any]:
|
|
155
135
|
to_object: dict[str, Any] = {}
|
|
156
|
-
if getv(from_object, ['parts']) is not None:
|
|
157
|
-
setv(
|
|
158
|
-
to_object,
|
|
159
|
-
['parts'],
|
|
160
|
-
[
|
|
161
|
-
_Part_to_mldev(item, to_object)
|
|
162
|
-
for item in getv(from_object, ['parts'])
|
|
163
|
-
],
|
|
164
|
-
)
|
|
165
|
-
|
|
166
|
-
if getv(from_object, ['role']) is not None:
|
|
167
|
-
setv(to_object, ['role'], getv(from_object, ['role']))
|
|
168
|
-
|
|
169
|
-
return to_object
|
|
170
136
|
|
|
137
|
+
if getv(from_object, ['ttl']) is not None:
|
|
138
|
+
setv(parent_object, ['ttl'], getv(from_object, ['ttl']))
|
|
171
139
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
175
|
-
) -> dict[str, Any]:
|
|
176
|
-
to_object: dict[str, Any] = {}
|
|
177
|
-
if getv(from_object, ['behavior']) is not None:
|
|
178
|
-
setv(to_object, ['behavior'], getv(from_object, ['behavior']))
|
|
140
|
+
if getv(from_object, ['expire_time']) is not None:
|
|
141
|
+
setv(parent_object, ['expireTime'], getv(from_object, ['expire_time']))
|
|
179
142
|
|
|
180
|
-
if getv(from_object, ['
|
|
181
|
-
setv(
|
|
143
|
+
if getv(from_object, ['display_name']) is not None:
|
|
144
|
+
setv(parent_object, ['displayName'], getv(from_object, ['display_name']))
|
|
182
145
|
|
|
183
|
-
if getv(from_object, ['
|
|
184
|
-
setv(
|
|
146
|
+
if getv(from_object, ['contents']) is not None:
|
|
147
|
+
setv(
|
|
148
|
+
parent_object,
|
|
149
|
+
['contents'],
|
|
150
|
+
[item for item in t.t_contents(getv(from_object, ['contents']))],
|
|
151
|
+
)
|
|
185
152
|
|
|
186
|
-
if getv(from_object, ['
|
|
187
|
-
setv(
|
|
153
|
+
if getv(from_object, ['system_instruction']) is not None:
|
|
154
|
+
setv(
|
|
155
|
+
parent_object,
|
|
156
|
+
['systemInstruction'],
|
|
157
|
+
t.t_content(getv(from_object, ['system_instruction'])),
|
|
158
|
+
)
|
|
188
159
|
|
|
189
|
-
if getv(from_object, ['
|
|
160
|
+
if getv(from_object, ['tools']) is not None:
|
|
190
161
|
setv(
|
|
191
|
-
|
|
192
|
-
['
|
|
193
|
-
|
|
162
|
+
parent_object,
|
|
163
|
+
['tools'],
|
|
164
|
+
[
|
|
165
|
+
_Tool_to_vertex(item, to_object)
|
|
166
|
+
for item in getv(from_object, ['tools'])
|
|
167
|
+
],
|
|
194
168
|
)
|
|
195
169
|
|
|
196
|
-
if getv(from_object, ['
|
|
197
|
-
setv(
|
|
170
|
+
if getv(from_object, ['tool_config']) is not None:
|
|
171
|
+
setv(parent_object, ['toolConfig'], getv(from_object, ['tool_config']))
|
|
198
172
|
|
|
199
|
-
if getv(from_object, ['
|
|
173
|
+
if getv(from_object, ['kms_key_name']) is not None:
|
|
200
174
|
setv(
|
|
201
|
-
|
|
202
|
-
['
|
|
203
|
-
getv(from_object, ['
|
|
175
|
+
parent_object,
|
|
176
|
+
['encryption_spec', 'kmsKeyName'],
|
|
177
|
+
getv(from_object, ['kms_key_name']),
|
|
204
178
|
)
|
|
205
179
|
|
|
206
180
|
return to_object
|
|
207
181
|
|
|
208
182
|
|
|
209
|
-
def
|
|
183
|
+
def _CreateCachedContentParameters_to_mldev(
|
|
184
|
+
api_client: BaseApiClient,
|
|
210
185
|
from_object: Union[dict[str, Any], object],
|
|
211
186
|
parent_object: Optional[dict[str, Any]] = None,
|
|
212
187
|
) -> dict[str, Any]:
|
|
213
188
|
to_object: dict[str, Any] = {}
|
|
214
|
-
if getv(from_object, ['
|
|
215
|
-
setv(
|
|
189
|
+
if getv(from_object, ['model']) is not None:
|
|
190
|
+
setv(
|
|
191
|
+
to_object,
|
|
192
|
+
['model'],
|
|
193
|
+
t.t_caches_model(api_client, getv(from_object, ['model'])),
|
|
194
|
+
)
|
|
216
195
|
|
|
217
|
-
if getv(from_object, ['
|
|
218
|
-
|
|
196
|
+
if getv(from_object, ['config']) is not None:
|
|
197
|
+
_CreateCachedContentConfig_to_mldev(
|
|
198
|
+
getv(from_object, ['config']), to_object
|
|
199
|
+
)
|
|
219
200
|
|
|
220
201
|
return to_object
|
|
221
202
|
|
|
222
203
|
|
|
223
|
-
def
|
|
204
|
+
def _CreateCachedContentParameters_to_vertex(
|
|
205
|
+
api_client: BaseApiClient,
|
|
224
206
|
from_object: Union[dict[str, Any], object],
|
|
225
207
|
parent_object: Optional[dict[str, Any]] = None,
|
|
226
208
|
) -> dict[str, Any]:
|
|
227
209
|
to_object: dict[str, Any] = {}
|
|
228
|
-
if getv(from_object, ['
|
|
210
|
+
if getv(from_object, ['model']) is not None:
|
|
229
211
|
setv(
|
|
230
212
|
to_object,
|
|
231
|
-
['
|
|
232
|
-
|
|
213
|
+
['model'],
|
|
214
|
+
t.t_caches_model(api_client, getv(from_object, ['model'])),
|
|
233
215
|
)
|
|
234
216
|
|
|
235
|
-
if getv(from_object, ['
|
|
236
|
-
|
|
237
|
-
'
|
|
217
|
+
if getv(from_object, ['config']) is not None:
|
|
218
|
+
_CreateCachedContentConfig_to_vertex(
|
|
219
|
+
getv(from_object, ['config']), to_object
|
|
238
220
|
)
|
|
239
221
|
|
|
240
222
|
return to_object
|
|
241
223
|
|
|
242
224
|
|
|
243
|
-
def
|
|
225
|
+
def _DeleteCachedContentParameters_to_mldev(
|
|
226
|
+
api_client: BaseApiClient,
|
|
244
227
|
from_object: Union[dict[str, Any], object],
|
|
245
228
|
parent_object: Optional[dict[str, Any]] = None,
|
|
246
229
|
) -> dict[str, Any]:
|
|
247
230
|
to_object: dict[str, Any] = {}
|
|
248
|
-
if getv(from_object, ['
|
|
249
|
-
setv(to_object, ['mode'], getv(from_object, ['mode']))
|
|
250
|
-
|
|
251
|
-
if getv(from_object, ['dynamic_threshold']) is not None:
|
|
231
|
+
if getv(from_object, ['name']) is not None:
|
|
252
232
|
setv(
|
|
253
233
|
to_object,
|
|
254
|
-
['
|
|
255
|
-
getv(from_object, ['
|
|
234
|
+
['_url', 'name'],
|
|
235
|
+
t.t_cached_content_name(api_client, getv(from_object, ['name'])),
|
|
256
236
|
)
|
|
257
237
|
|
|
258
238
|
return to_object
|
|
259
239
|
|
|
260
240
|
|
|
261
|
-
def
|
|
241
|
+
def _DeleteCachedContentParameters_to_vertex(
|
|
242
|
+
api_client: BaseApiClient,
|
|
262
243
|
from_object: Union[dict[str, Any], object],
|
|
263
244
|
parent_object: Optional[dict[str, Any]] = None,
|
|
264
245
|
) -> dict[str, Any]:
|
|
265
246
|
to_object: dict[str, Any] = {}
|
|
266
|
-
if getv(from_object, ['
|
|
247
|
+
if getv(from_object, ['name']) is not None:
|
|
267
248
|
setv(
|
|
268
249
|
to_object,
|
|
269
|
-
['
|
|
270
|
-
|
|
271
|
-
getv(from_object, ['dynamic_retrieval_config']), to_object
|
|
272
|
-
),
|
|
250
|
+
['_url', 'name'],
|
|
251
|
+
t.t_cached_content_name(api_client, getv(from_object, ['name'])),
|
|
273
252
|
)
|
|
274
253
|
|
|
275
254
|
return to_object
|
|
276
255
|
|
|
277
256
|
|
|
278
|
-
def
|
|
257
|
+
def _DeleteCachedContentResponse_from_mldev(
|
|
279
258
|
from_object: Union[dict[str, Any], object],
|
|
280
259
|
parent_object: Optional[dict[str, Any]] = None,
|
|
281
260
|
) -> dict[str, Any]:
|
|
282
261
|
to_object: dict[str, Any] = {}
|
|
262
|
+
if getv(from_object, ['sdkHttpResponse']) is not None:
|
|
263
|
+
setv(
|
|
264
|
+
to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
|
|
265
|
+
)
|
|
283
266
|
|
|
284
267
|
return to_object
|
|
285
268
|
|
|
286
269
|
|
|
287
|
-
def
|
|
270
|
+
def _DeleteCachedContentResponse_from_vertex(
|
|
288
271
|
from_object: Union[dict[str, Any], object],
|
|
289
272
|
parent_object: Optional[dict[str, Any]] = None,
|
|
290
273
|
) -> dict[str, Any]:
|
|
291
274
|
to_object: dict[str, Any] = {}
|
|
292
|
-
if getv(from_object, ['
|
|
293
|
-
setv(
|
|
275
|
+
if getv(from_object, ['sdkHttpResponse']) is not None:
|
|
276
|
+
setv(
|
|
277
|
+
to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
|
|
278
|
+
)
|
|
294
279
|
|
|
295
280
|
return to_object
|
|
296
281
|
|
|
297
282
|
|
|
298
|
-
def
|
|
283
|
+
def _FileData_to_mldev(
|
|
299
284
|
from_object: Union[dict[str, Any], object],
|
|
300
285
|
parent_object: Optional[dict[str, Any]] = None,
|
|
301
286
|
) -> dict[str, Any]:
|
|
302
287
|
to_object: dict[str, Any] = {}
|
|
303
|
-
if getv(from_object, ['
|
|
304
|
-
|
|
305
|
-
to_object,
|
|
306
|
-
['functionDeclarations'],
|
|
307
|
-
[
|
|
308
|
-
_FunctionDeclaration_to_mldev(item, to_object)
|
|
309
|
-
for item in getv(from_object, ['function_declarations'])
|
|
310
|
-
],
|
|
311
|
-
)
|
|
312
|
-
|
|
313
|
-
if getv(from_object, ['retrieval']) is not None:
|
|
314
|
-
raise ValueError('retrieval parameter is not supported in Gemini API.')
|
|
315
|
-
|
|
316
|
-
if getv(from_object, ['google_search']) is not None:
|
|
317
|
-
setv(
|
|
318
|
-
to_object,
|
|
319
|
-
['googleSearch'],
|
|
320
|
-
_GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
|
|
321
|
-
)
|
|
322
|
-
|
|
323
|
-
if getv(from_object, ['google_search_retrieval']) is not None:
|
|
324
|
-
setv(
|
|
325
|
-
to_object,
|
|
326
|
-
['googleSearchRetrieval'],
|
|
327
|
-
_GoogleSearchRetrieval_to_mldev(
|
|
328
|
-
getv(from_object, ['google_search_retrieval']), to_object
|
|
329
|
-
),
|
|
330
|
-
)
|
|
331
|
-
|
|
332
|
-
if getv(from_object, ['enterprise_web_search']) is not None:
|
|
333
|
-
raise ValueError(
|
|
334
|
-
'enterprise_web_search parameter is not supported in Gemini API.'
|
|
335
|
-
)
|
|
336
|
-
|
|
337
|
-
if getv(from_object, ['google_maps']) is not None:
|
|
338
|
-
raise ValueError('google_maps parameter is not supported in Gemini API.')
|
|
288
|
+
if getv(from_object, ['display_name']) is not None:
|
|
289
|
+
raise ValueError('display_name parameter is not supported in Gemini API.')
|
|
339
290
|
|
|
340
|
-
if getv(from_object, ['
|
|
341
|
-
setv(
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
)
|
|
346
|
-
|
|
347
|
-
if getv(from_object, ['computer_use']) is not None:
|
|
348
|
-
setv(
|
|
349
|
-
to_object,
|
|
350
|
-
['computerUse'],
|
|
351
|
-
_ToolComputerUse_to_mldev(
|
|
352
|
-
getv(from_object, ['computer_use']), to_object
|
|
353
|
-
),
|
|
354
|
-
)
|
|
355
|
-
|
|
356
|
-
if getv(from_object, ['code_execution']) is not None:
|
|
357
|
-
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
|
358
|
-
|
|
359
|
-
return to_object
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
def _FunctionCallingConfig_to_mldev(
|
|
363
|
-
from_object: Union[dict[str, Any], object],
|
|
364
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
365
|
-
) -> dict[str, Any]:
|
|
366
|
-
to_object: dict[str, Any] = {}
|
|
367
|
-
if getv(from_object, ['mode']) is not None:
|
|
368
|
-
setv(to_object, ['mode'], getv(from_object, ['mode']))
|
|
369
|
-
|
|
370
|
-
if getv(from_object, ['allowed_function_names']) is not None:
|
|
371
|
-
setv(
|
|
372
|
-
to_object,
|
|
373
|
-
['allowedFunctionNames'],
|
|
374
|
-
getv(from_object, ['allowed_function_names']),
|
|
375
|
-
)
|
|
376
|
-
|
|
377
|
-
return to_object
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
def _LatLng_to_mldev(
|
|
381
|
-
from_object: Union[dict[str, Any], object],
|
|
382
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
383
|
-
) -> dict[str, Any]:
|
|
384
|
-
to_object: dict[str, Any] = {}
|
|
385
|
-
if getv(from_object, ['latitude']) is not None:
|
|
386
|
-
setv(to_object, ['latitude'], getv(from_object, ['latitude']))
|
|
387
|
-
|
|
388
|
-
if getv(from_object, ['longitude']) is not None:
|
|
389
|
-
setv(to_object, ['longitude'], getv(from_object, ['longitude']))
|
|
390
|
-
|
|
391
|
-
return to_object
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
def _RetrievalConfig_to_mldev(
|
|
395
|
-
from_object: Union[dict[str, Any], object],
|
|
396
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
397
|
-
) -> dict[str, Any]:
|
|
398
|
-
to_object: dict[str, Any] = {}
|
|
399
|
-
if getv(from_object, ['lat_lng']) is not None:
|
|
400
|
-
setv(
|
|
401
|
-
to_object,
|
|
402
|
-
['latLng'],
|
|
403
|
-
_LatLng_to_mldev(getv(from_object, ['lat_lng']), to_object),
|
|
404
|
-
)
|
|
405
|
-
|
|
406
|
-
if getv(from_object, ['language_code']) is not None:
|
|
407
|
-
setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
|
|
408
|
-
|
|
409
|
-
return to_object
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
def _ToolConfig_to_mldev(
|
|
413
|
-
from_object: Union[dict[str, Any], object],
|
|
414
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
415
|
-
) -> dict[str, Any]:
|
|
416
|
-
to_object: dict[str, Any] = {}
|
|
417
|
-
if getv(from_object, ['function_calling_config']) is not None:
|
|
418
|
-
setv(
|
|
419
|
-
to_object,
|
|
420
|
-
['functionCallingConfig'],
|
|
421
|
-
_FunctionCallingConfig_to_mldev(
|
|
422
|
-
getv(from_object, ['function_calling_config']), to_object
|
|
423
|
-
),
|
|
424
|
-
)
|
|
425
|
-
|
|
426
|
-
if getv(from_object, ['retrieval_config']) is not None:
|
|
427
|
-
setv(
|
|
428
|
-
to_object,
|
|
429
|
-
['retrievalConfig'],
|
|
430
|
-
_RetrievalConfig_to_mldev(
|
|
431
|
-
getv(from_object, ['retrieval_config']), to_object
|
|
432
|
-
),
|
|
433
|
-
)
|
|
434
|
-
|
|
435
|
-
return to_object
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
def _CreateCachedContentConfig_to_mldev(
|
|
439
|
-
from_object: Union[dict[str, Any], object],
|
|
440
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
441
|
-
) -> dict[str, Any]:
|
|
442
|
-
to_object: dict[str, Any] = {}
|
|
443
|
-
|
|
444
|
-
if getv(from_object, ['ttl']) is not None:
|
|
445
|
-
setv(parent_object, ['ttl'], getv(from_object, ['ttl']))
|
|
446
|
-
|
|
447
|
-
if getv(from_object, ['expire_time']) is not None:
|
|
448
|
-
setv(parent_object, ['expireTime'], getv(from_object, ['expire_time']))
|
|
449
|
-
|
|
450
|
-
if getv(from_object, ['display_name']) is not None:
|
|
451
|
-
setv(parent_object, ['displayName'], getv(from_object, ['display_name']))
|
|
452
|
-
|
|
453
|
-
if getv(from_object, ['contents']) is not None:
|
|
454
|
-
setv(
|
|
455
|
-
parent_object,
|
|
456
|
-
['contents'],
|
|
457
|
-
[
|
|
458
|
-
_Content_to_mldev(item, to_object)
|
|
459
|
-
for item in t.t_contents(getv(from_object, ['contents']))
|
|
460
|
-
],
|
|
461
|
-
)
|
|
462
|
-
|
|
463
|
-
if getv(from_object, ['system_instruction']) is not None:
|
|
464
|
-
setv(
|
|
465
|
-
parent_object,
|
|
466
|
-
['systemInstruction'],
|
|
467
|
-
_Content_to_mldev(
|
|
468
|
-
t.t_content(getv(from_object, ['system_instruction'])), to_object
|
|
469
|
-
),
|
|
470
|
-
)
|
|
471
|
-
|
|
472
|
-
if getv(from_object, ['tools']) is not None:
|
|
473
|
-
setv(
|
|
474
|
-
parent_object,
|
|
475
|
-
['tools'],
|
|
476
|
-
[
|
|
477
|
-
_Tool_to_mldev(item, to_object)
|
|
478
|
-
for item in getv(from_object, ['tools'])
|
|
479
|
-
],
|
|
480
|
-
)
|
|
481
|
-
|
|
482
|
-
if getv(from_object, ['tool_config']) is not None:
|
|
483
|
-
setv(
|
|
484
|
-
parent_object,
|
|
485
|
-
['toolConfig'],
|
|
486
|
-
_ToolConfig_to_mldev(getv(from_object, ['tool_config']), to_object),
|
|
487
|
-
)
|
|
488
|
-
|
|
489
|
-
if getv(from_object, ['kms_key_name']) is not None:
|
|
490
|
-
raise ValueError('kms_key_name parameter is not supported in Gemini API.')
|
|
491
|
-
|
|
492
|
-
return to_object
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
def _CreateCachedContentParameters_to_mldev(
|
|
496
|
-
api_client: BaseApiClient,
|
|
497
|
-
from_object: Union[dict[str, Any], object],
|
|
498
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
499
|
-
) -> dict[str, Any]:
|
|
500
|
-
to_object: dict[str, Any] = {}
|
|
501
|
-
if getv(from_object, ['model']) is not None:
|
|
502
|
-
setv(
|
|
503
|
-
to_object,
|
|
504
|
-
['model'],
|
|
505
|
-
t.t_caches_model(api_client, getv(from_object, ['model'])),
|
|
506
|
-
)
|
|
507
|
-
|
|
508
|
-
if getv(from_object, ['config']) is not None:
|
|
509
|
-
setv(
|
|
510
|
-
to_object,
|
|
511
|
-
['config'],
|
|
512
|
-
_CreateCachedContentConfig_to_mldev(
|
|
513
|
-
getv(from_object, ['config']), to_object
|
|
514
|
-
),
|
|
515
|
-
)
|
|
516
|
-
|
|
517
|
-
return to_object
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
def _GetCachedContentParameters_to_mldev(
|
|
521
|
-
api_client: BaseApiClient,
|
|
522
|
-
from_object: Union[dict[str, Any], object],
|
|
523
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
524
|
-
) -> dict[str, Any]:
|
|
525
|
-
to_object: dict[str, Any] = {}
|
|
526
|
-
if getv(from_object, ['name']) is not None:
|
|
527
|
-
setv(
|
|
528
|
-
to_object,
|
|
529
|
-
['_url', 'name'],
|
|
530
|
-
t.t_cached_content_name(api_client, getv(from_object, ['name'])),
|
|
531
|
-
)
|
|
532
|
-
|
|
533
|
-
if getv(from_object, ['config']) is not None:
|
|
534
|
-
setv(to_object, ['config'], getv(from_object, ['config']))
|
|
535
|
-
|
|
536
|
-
return to_object
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
def _DeleteCachedContentParameters_to_mldev(
|
|
540
|
-
api_client: BaseApiClient,
|
|
541
|
-
from_object: Union[dict[str, Any], object],
|
|
542
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
543
|
-
) -> dict[str, Any]:
|
|
544
|
-
to_object: dict[str, Any] = {}
|
|
545
|
-
if getv(from_object, ['name']) is not None:
|
|
546
|
-
setv(
|
|
547
|
-
to_object,
|
|
548
|
-
['_url', 'name'],
|
|
549
|
-
t.t_cached_content_name(api_client, getv(from_object, ['name'])),
|
|
550
|
-
)
|
|
551
|
-
|
|
552
|
-
if getv(from_object, ['config']) is not None:
|
|
553
|
-
setv(to_object, ['config'], getv(from_object, ['config']))
|
|
554
|
-
|
|
555
|
-
return to_object
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
def _UpdateCachedContentConfig_to_mldev(
|
|
559
|
-
from_object: Union[dict[str, Any], object],
|
|
560
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
561
|
-
) -> dict[str, Any]:
|
|
562
|
-
to_object: dict[str, Any] = {}
|
|
563
|
-
|
|
564
|
-
if getv(from_object, ['ttl']) is not None:
|
|
565
|
-
setv(parent_object, ['ttl'], getv(from_object, ['ttl']))
|
|
566
|
-
|
|
567
|
-
if getv(from_object, ['expire_time']) is not None:
|
|
568
|
-
setv(parent_object, ['expireTime'], getv(from_object, ['expire_time']))
|
|
569
|
-
|
|
570
|
-
return to_object
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
def _UpdateCachedContentParameters_to_mldev(
|
|
574
|
-
api_client: BaseApiClient,
|
|
575
|
-
from_object: Union[dict[str, Any], object],
|
|
576
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
577
|
-
) -> dict[str, Any]:
|
|
578
|
-
to_object: dict[str, Any] = {}
|
|
579
|
-
if getv(from_object, ['name']) is not None:
|
|
580
|
-
setv(
|
|
581
|
-
to_object,
|
|
582
|
-
['_url', 'name'],
|
|
583
|
-
t.t_cached_content_name(api_client, getv(from_object, ['name'])),
|
|
584
|
-
)
|
|
585
|
-
|
|
586
|
-
if getv(from_object, ['config']) is not None:
|
|
587
|
-
setv(
|
|
588
|
-
to_object,
|
|
589
|
-
['config'],
|
|
590
|
-
_UpdateCachedContentConfig_to_mldev(
|
|
591
|
-
getv(from_object, ['config']), to_object
|
|
592
|
-
),
|
|
593
|
-
)
|
|
594
|
-
|
|
595
|
-
return to_object
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
def _ListCachedContentsConfig_to_mldev(
|
|
599
|
-
from_object: Union[dict[str, Any], object],
|
|
600
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
601
|
-
) -> dict[str, Any]:
|
|
602
|
-
to_object: dict[str, Any] = {}
|
|
603
|
-
|
|
604
|
-
if getv(from_object, ['page_size']) is not None:
|
|
605
|
-
setv(
|
|
606
|
-
parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
|
|
607
|
-
)
|
|
608
|
-
|
|
609
|
-
if getv(from_object, ['page_token']) is not None:
|
|
610
|
-
setv(
|
|
611
|
-
parent_object,
|
|
612
|
-
['_query', 'pageToken'],
|
|
613
|
-
getv(from_object, ['page_token']),
|
|
614
|
-
)
|
|
615
|
-
|
|
616
|
-
return to_object
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
def _ListCachedContentsParameters_to_mldev(
|
|
620
|
-
from_object: Union[dict[str, Any], object],
|
|
621
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
622
|
-
) -> dict[str, Any]:
|
|
623
|
-
to_object: dict[str, Any] = {}
|
|
624
|
-
if getv(from_object, ['config']) is not None:
|
|
625
|
-
setv(
|
|
626
|
-
to_object,
|
|
627
|
-
['config'],
|
|
628
|
-
_ListCachedContentsConfig_to_mldev(
|
|
629
|
-
getv(from_object, ['config']), to_object
|
|
630
|
-
),
|
|
631
|
-
)
|
|
632
|
-
|
|
633
|
-
return to_object
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
def _VideoMetadata_to_vertex(
|
|
637
|
-
from_object: Union[dict[str, Any], object],
|
|
638
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
639
|
-
) -> dict[str, Any]:
|
|
640
|
-
to_object: dict[str, Any] = {}
|
|
641
|
-
if getv(from_object, ['fps']) is not None:
|
|
642
|
-
setv(to_object, ['fps'], getv(from_object, ['fps']))
|
|
643
|
-
|
|
644
|
-
if getv(from_object, ['end_offset']) is not None:
|
|
645
|
-
setv(to_object, ['endOffset'], getv(from_object, ['end_offset']))
|
|
646
|
-
|
|
647
|
-
if getv(from_object, ['start_offset']) is not None:
|
|
648
|
-
setv(to_object, ['startOffset'], getv(from_object, ['start_offset']))
|
|
649
|
-
|
|
650
|
-
return to_object
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
def _Blob_to_vertex(
|
|
654
|
-
from_object: Union[dict[str, Any], object],
|
|
655
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
656
|
-
) -> dict[str, Any]:
|
|
657
|
-
to_object: dict[str, Any] = {}
|
|
658
|
-
if getv(from_object, ['display_name']) is not None:
|
|
659
|
-
setv(to_object, ['displayName'], getv(from_object, ['display_name']))
|
|
660
|
-
|
|
661
|
-
if getv(from_object, ['data']) is not None:
|
|
662
|
-
setv(to_object, ['data'], getv(from_object, ['data']))
|
|
663
|
-
|
|
664
|
-
if getv(from_object, ['mime_type']) is not None:
|
|
665
|
-
setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
|
|
666
|
-
|
|
667
|
-
return to_object
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
def _FileData_to_vertex(
|
|
671
|
-
from_object: Union[dict[str, Any], object],
|
|
672
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
673
|
-
) -> dict[str, Any]:
|
|
674
|
-
to_object: dict[str, Any] = {}
|
|
675
|
-
if getv(from_object, ['display_name']) is not None:
|
|
676
|
-
setv(to_object, ['displayName'], getv(from_object, ['display_name']))
|
|
677
|
-
|
|
678
|
-
if getv(from_object, ['file_uri']) is not None:
|
|
679
|
-
setv(to_object, ['fileUri'], getv(from_object, ['file_uri']))
|
|
680
|
-
|
|
681
|
-
if getv(from_object, ['mime_type']) is not None:
|
|
682
|
-
setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
|
|
683
|
-
|
|
684
|
-
return to_object
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
def _Part_to_vertex(
|
|
688
|
-
from_object: Union[dict[str, Any], object],
|
|
689
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
690
|
-
) -> dict[str, Any]:
|
|
691
|
-
to_object: dict[str, Any] = {}
|
|
692
|
-
if getv(from_object, ['video_metadata']) is not None:
|
|
693
|
-
setv(
|
|
694
|
-
to_object,
|
|
695
|
-
['videoMetadata'],
|
|
696
|
-
_VideoMetadata_to_vertex(
|
|
697
|
-
getv(from_object, ['video_metadata']), to_object
|
|
698
|
-
),
|
|
699
|
-
)
|
|
700
|
-
|
|
701
|
-
if getv(from_object, ['thought']) is not None:
|
|
702
|
-
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
|
703
|
-
|
|
704
|
-
if getv(from_object, ['inline_data']) is not None:
|
|
705
|
-
setv(
|
|
706
|
-
to_object,
|
|
707
|
-
['inlineData'],
|
|
708
|
-
_Blob_to_vertex(getv(from_object, ['inline_data']), to_object),
|
|
709
|
-
)
|
|
710
|
-
|
|
711
|
-
if getv(from_object, ['file_data']) is not None:
|
|
712
|
-
setv(
|
|
713
|
-
to_object,
|
|
714
|
-
['fileData'],
|
|
715
|
-
_FileData_to_vertex(getv(from_object, ['file_data']), to_object),
|
|
716
|
-
)
|
|
717
|
-
|
|
718
|
-
if getv(from_object, ['thought_signature']) is not None:
|
|
719
|
-
setv(
|
|
720
|
-
to_object,
|
|
721
|
-
['thoughtSignature'],
|
|
722
|
-
getv(from_object, ['thought_signature']),
|
|
723
|
-
)
|
|
724
|
-
|
|
725
|
-
if getv(from_object, ['code_execution_result']) is not None:
|
|
726
|
-
setv(
|
|
727
|
-
to_object,
|
|
728
|
-
['codeExecutionResult'],
|
|
729
|
-
getv(from_object, ['code_execution_result']),
|
|
730
|
-
)
|
|
731
|
-
|
|
732
|
-
if getv(from_object, ['executable_code']) is not None:
|
|
733
|
-
setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
|
|
734
|
-
|
|
735
|
-
if getv(from_object, ['function_call']) is not None:
|
|
736
|
-
setv(to_object, ['functionCall'], getv(from_object, ['function_call']))
|
|
737
|
-
|
|
738
|
-
if getv(from_object, ['function_response']) is not None:
|
|
739
|
-
setv(
|
|
740
|
-
to_object,
|
|
741
|
-
['functionResponse'],
|
|
742
|
-
getv(from_object, ['function_response']),
|
|
743
|
-
)
|
|
744
|
-
|
|
745
|
-
if getv(from_object, ['text']) is not None:
|
|
746
|
-
setv(to_object, ['text'], getv(from_object, ['text']))
|
|
747
|
-
|
|
748
|
-
return to_object
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
def _Content_to_vertex(
|
|
752
|
-
from_object: Union[dict[str, Any], object],
|
|
753
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
754
|
-
) -> dict[str, Any]:
|
|
755
|
-
to_object: dict[str, Any] = {}
|
|
756
|
-
if getv(from_object, ['parts']) is not None:
|
|
757
|
-
setv(
|
|
758
|
-
to_object,
|
|
759
|
-
['parts'],
|
|
760
|
-
[
|
|
761
|
-
_Part_to_vertex(item, to_object)
|
|
762
|
-
for item in getv(from_object, ['parts'])
|
|
763
|
-
],
|
|
764
|
-
)
|
|
765
|
-
|
|
766
|
-
if getv(from_object, ['role']) is not None:
|
|
767
|
-
setv(to_object, ['role'], getv(from_object, ['role']))
|
|
768
|
-
|
|
769
|
-
return to_object
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
def _FunctionDeclaration_to_vertex(
|
|
773
|
-
from_object: Union[dict[str, Any], object],
|
|
774
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
775
|
-
) -> dict[str, Any]:
|
|
776
|
-
to_object: dict[str, Any] = {}
|
|
777
|
-
if getv(from_object, ['behavior']) is not None:
|
|
778
|
-
raise ValueError('behavior parameter is not supported in Vertex AI.')
|
|
779
|
-
|
|
780
|
-
if getv(from_object, ['description']) is not None:
|
|
781
|
-
setv(to_object, ['description'], getv(from_object, ['description']))
|
|
782
|
-
|
|
783
|
-
if getv(from_object, ['name']) is not None:
|
|
784
|
-
setv(to_object, ['name'], getv(from_object, ['name']))
|
|
785
|
-
|
|
786
|
-
if getv(from_object, ['parameters']) is not None:
|
|
787
|
-
setv(to_object, ['parameters'], getv(from_object, ['parameters']))
|
|
788
|
-
|
|
789
|
-
if getv(from_object, ['parameters_json_schema']) is not None:
|
|
790
|
-
setv(
|
|
791
|
-
to_object,
|
|
792
|
-
['parametersJsonSchema'],
|
|
793
|
-
getv(from_object, ['parameters_json_schema']),
|
|
794
|
-
)
|
|
795
|
-
|
|
796
|
-
if getv(from_object, ['response']) is not None:
|
|
797
|
-
setv(to_object, ['response'], getv(from_object, ['response']))
|
|
798
|
-
|
|
799
|
-
if getv(from_object, ['response_json_schema']) is not None:
|
|
800
|
-
setv(
|
|
801
|
-
to_object,
|
|
802
|
-
['responseJsonSchema'],
|
|
803
|
-
getv(from_object, ['response_json_schema']),
|
|
804
|
-
)
|
|
805
|
-
|
|
806
|
-
return to_object
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
def _Interval_to_vertex(
|
|
810
|
-
from_object: Union[dict[str, Any], object],
|
|
811
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
812
|
-
) -> dict[str, Any]:
|
|
813
|
-
to_object: dict[str, Any] = {}
|
|
814
|
-
if getv(from_object, ['start_time']) is not None:
|
|
815
|
-
setv(to_object, ['startTime'], getv(from_object, ['start_time']))
|
|
816
|
-
|
|
817
|
-
if getv(from_object, ['end_time']) is not None:
|
|
818
|
-
setv(to_object, ['endTime'], getv(from_object, ['end_time']))
|
|
819
|
-
|
|
820
|
-
return to_object
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
def _GoogleSearch_to_vertex(
|
|
824
|
-
from_object: Union[dict[str, Any], object],
|
|
825
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
826
|
-
) -> dict[str, Any]:
|
|
827
|
-
to_object: dict[str, Any] = {}
|
|
828
|
-
if getv(from_object, ['time_range_filter']) is not None:
|
|
829
|
-
setv(
|
|
830
|
-
to_object,
|
|
831
|
-
['timeRangeFilter'],
|
|
832
|
-
_Interval_to_vertex(
|
|
833
|
-
getv(from_object, ['time_range_filter']), to_object
|
|
834
|
-
),
|
|
835
|
-
)
|
|
836
|
-
|
|
837
|
-
if getv(from_object, ['exclude_domains']) is not None:
|
|
838
|
-
setv(to_object, ['excludeDomains'], getv(from_object, ['exclude_domains']))
|
|
839
|
-
|
|
840
|
-
return to_object
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
def _DynamicRetrievalConfig_to_vertex(
|
|
844
|
-
from_object: Union[dict[str, Any], object],
|
|
845
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
846
|
-
) -> dict[str, Any]:
|
|
847
|
-
to_object: dict[str, Any] = {}
|
|
848
|
-
if getv(from_object, ['mode']) is not None:
|
|
849
|
-
setv(to_object, ['mode'], getv(from_object, ['mode']))
|
|
850
|
-
|
|
851
|
-
if getv(from_object, ['dynamic_threshold']) is not None:
|
|
852
|
-
setv(
|
|
853
|
-
to_object,
|
|
854
|
-
['dynamicThreshold'],
|
|
855
|
-
getv(from_object, ['dynamic_threshold']),
|
|
856
|
-
)
|
|
857
|
-
|
|
858
|
-
return to_object
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
def _GoogleSearchRetrieval_to_vertex(
|
|
862
|
-
from_object: Union[dict[str, Any], object],
|
|
863
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
864
|
-
) -> dict[str, Any]:
|
|
865
|
-
to_object: dict[str, Any] = {}
|
|
866
|
-
if getv(from_object, ['dynamic_retrieval_config']) is not None:
|
|
867
|
-
setv(
|
|
868
|
-
to_object,
|
|
869
|
-
['dynamicRetrievalConfig'],
|
|
870
|
-
_DynamicRetrievalConfig_to_vertex(
|
|
871
|
-
getv(from_object, ['dynamic_retrieval_config']), to_object
|
|
872
|
-
),
|
|
873
|
-
)
|
|
291
|
+
if getv(from_object, ['file_uri']) is not None:
|
|
292
|
+
setv(to_object, ['fileUri'], getv(from_object, ['file_uri']))
|
|
293
|
+
|
|
294
|
+
if getv(from_object, ['mime_type']) is not None:
|
|
295
|
+
setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
|
|
874
296
|
|
|
875
297
|
return to_object
|
|
876
298
|
|
|
877
299
|
|
|
878
|
-
def
|
|
300
|
+
def _FunctionCall_to_mldev(
|
|
879
301
|
from_object: Union[dict[str, Any], object],
|
|
880
302
|
parent_object: Optional[dict[str, Any]] = None,
|
|
881
303
|
) -> dict[str, Any]:
|
|
882
304
|
to_object: dict[str, Any] = {}
|
|
883
|
-
if getv(from_object, ['
|
|
884
|
-
setv(to_object, ['
|
|
305
|
+
if getv(from_object, ['id']) is not None:
|
|
306
|
+
setv(to_object, ['id'], getv(from_object, ['id']))
|
|
307
|
+
|
|
308
|
+
if getv(from_object, ['args']) is not None:
|
|
309
|
+
setv(to_object, ['args'], getv(from_object, ['args']))
|
|
310
|
+
|
|
311
|
+
if getv(from_object, ['name']) is not None:
|
|
312
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
|
313
|
+
|
|
314
|
+
if getv(from_object, ['partial_args']) is not None:
|
|
315
|
+
raise ValueError('partial_args parameter is not supported in Gemini API.')
|
|
316
|
+
|
|
317
|
+
if getv(from_object, ['will_continue']) is not None:
|
|
318
|
+
raise ValueError('will_continue parameter is not supported in Gemini API.')
|
|
885
319
|
|
|
886
320
|
return to_object
|
|
887
321
|
|
|
888
322
|
|
|
889
|
-
def
|
|
323
|
+
def _FunctionCallingConfig_to_mldev(
|
|
890
324
|
from_object: Union[dict[str, Any], object],
|
|
891
325
|
parent_object: Optional[dict[str, Any]] = None,
|
|
892
326
|
) -> dict[str, Any]:
|
|
893
327
|
to_object: dict[str, Any] = {}
|
|
894
|
-
if getv(from_object, ['
|
|
895
|
-
setv(to_object, ['
|
|
328
|
+
if getv(from_object, ['mode']) is not None:
|
|
329
|
+
setv(to_object, ['mode'], getv(from_object, ['mode']))
|
|
330
|
+
|
|
331
|
+
if getv(from_object, ['allowed_function_names']) is not None:
|
|
332
|
+
setv(
|
|
333
|
+
to_object,
|
|
334
|
+
['allowedFunctionNames'],
|
|
335
|
+
getv(from_object, ['allowed_function_names']),
|
|
336
|
+
)
|
|
337
|
+
|
|
338
|
+
if getv(from_object, ['stream_function_call_arguments']) is not None:
|
|
339
|
+
raise ValueError(
|
|
340
|
+
'stream_function_call_arguments parameter is not supported in Gemini'
|
|
341
|
+
' API.'
|
|
342
|
+
)
|
|
896
343
|
|
|
897
344
|
return to_object
|
|
898
345
|
|
|
899
346
|
|
|
900
|
-
def
|
|
347
|
+
def _FunctionDeclaration_to_vertex(
|
|
901
348
|
from_object: Union[dict[str, Any], object],
|
|
902
349
|
parent_object: Optional[dict[str, Any]] = None,
|
|
903
350
|
) -> dict[str, Any]:
|
|
904
351
|
to_object: dict[str, Any] = {}
|
|
905
|
-
if getv(from_object, ['
|
|
906
|
-
|
|
907
|
-
to_object,
|
|
908
|
-
['apiKeyConfig'],
|
|
909
|
-
_ApiKeyConfig_to_vertex(
|
|
910
|
-
getv(from_object, ['api_key_config']), to_object
|
|
911
|
-
),
|
|
912
|
-
)
|
|
352
|
+
if getv(from_object, ['behavior']) is not None:
|
|
353
|
+
raise ValueError('behavior parameter is not supported in Vertex AI.')
|
|
913
354
|
|
|
914
|
-
if getv(from_object, ['
|
|
915
|
-
setv(to_object, ['
|
|
355
|
+
if getv(from_object, ['description']) is not None:
|
|
356
|
+
setv(to_object, ['description'], getv(from_object, ['description']))
|
|
357
|
+
|
|
358
|
+
if getv(from_object, ['name']) is not None:
|
|
359
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
|
360
|
+
|
|
361
|
+
if getv(from_object, ['parameters']) is not None:
|
|
362
|
+
setv(to_object, ['parameters'], getv(from_object, ['parameters']))
|
|
916
363
|
|
|
917
|
-
if getv(from_object, ['
|
|
364
|
+
if getv(from_object, ['parameters_json_schema']) is not None:
|
|
918
365
|
setv(
|
|
919
366
|
to_object,
|
|
920
|
-
['
|
|
921
|
-
getv(from_object, ['
|
|
367
|
+
['parametersJsonSchema'],
|
|
368
|
+
getv(from_object, ['parameters_json_schema']),
|
|
922
369
|
)
|
|
923
370
|
|
|
924
|
-
if getv(from_object, ['
|
|
371
|
+
if getv(from_object, ['response']) is not None:
|
|
372
|
+
setv(to_object, ['response'], getv(from_object, ['response']))
|
|
373
|
+
|
|
374
|
+
if getv(from_object, ['response_json_schema']) is not None:
|
|
925
375
|
setv(
|
|
926
376
|
to_object,
|
|
927
|
-
['
|
|
928
|
-
getv(from_object, ['
|
|
377
|
+
['responseJsonSchema'],
|
|
378
|
+
getv(from_object, ['response_json_schema']),
|
|
929
379
|
)
|
|
930
380
|
|
|
931
|
-
if getv(from_object, ['oauth_config']) is not None:
|
|
932
|
-
setv(to_object, ['oauthConfig'], getv(from_object, ['oauth_config']))
|
|
933
|
-
|
|
934
|
-
if getv(from_object, ['oidc_config']) is not None:
|
|
935
|
-
setv(to_object, ['oidcConfig'], getv(from_object, ['oidc_config']))
|
|
936
|
-
|
|
937
381
|
return to_object
|
|
938
382
|
|
|
939
383
|
|
|
940
|
-
def
|
|
384
|
+
def _GetCachedContentParameters_to_mldev(
|
|
385
|
+
api_client: BaseApiClient,
|
|
941
386
|
from_object: Union[dict[str, Any], object],
|
|
942
387
|
parent_object: Optional[dict[str, Any]] = None,
|
|
943
388
|
) -> dict[str, Any]:
|
|
944
389
|
to_object: dict[str, Any] = {}
|
|
945
|
-
if getv(from_object, ['
|
|
390
|
+
if getv(from_object, ['name']) is not None:
|
|
946
391
|
setv(
|
|
947
392
|
to_object,
|
|
948
|
-
['
|
|
949
|
-
|
|
393
|
+
['_url', 'name'],
|
|
394
|
+
t.t_cached_content_name(api_client, getv(from_object, ['name'])),
|
|
950
395
|
)
|
|
951
396
|
|
|
952
397
|
return to_object
|
|
953
398
|
|
|
954
399
|
|
|
955
|
-
def
|
|
400
|
+
def _GetCachedContentParameters_to_vertex(
|
|
401
|
+
api_client: BaseApiClient,
|
|
956
402
|
from_object: Union[dict[str, Any], object],
|
|
957
403
|
parent_object: Optional[dict[str, Any]] = None,
|
|
958
404
|
) -> dict[str, Any]:
|
|
959
405
|
to_object: dict[str, Any] = {}
|
|
406
|
+
if getv(from_object, ['name']) is not None:
|
|
407
|
+
setv(
|
|
408
|
+
to_object,
|
|
409
|
+
['_url', 'name'],
|
|
410
|
+
t.t_cached_content_name(api_client, getv(from_object, ['name'])),
|
|
411
|
+
)
|
|
960
412
|
|
|
961
413
|
return to_object
|
|
962
414
|
|
|
963
415
|
|
|
964
|
-
def
|
|
416
|
+
def _GoogleMaps_to_mldev(
|
|
965
417
|
from_object: Union[dict[str, Any], object],
|
|
966
418
|
parent_object: Optional[dict[str, Any]] = None,
|
|
967
419
|
) -> dict[str, Any]:
|
|
968
420
|
to_object: dict[str, Any] = {}
|
|
969
|
-
if getv(from_object, ['
|
|
970
|
-
|
|
421
|
+
if getv(from_object, ['auth_config']) is not None:
|
|
422
|
+
raise ValueError('auth_config parameter is not supported in Gemini API.')
|
|
423
|
+
|
|
424
|
+
if getv(from_object, ['enable_widget']) is not None:
|
|
425
|
+
setv(to_object, ['enableWidget'], getv(from_object, ['enable_widget']))
|
|
971
426
|
|
|
972
427
|
return to_object
|
|
973
428
|
|
|
974
429
|
|
|
975
|
-
def
|
|
430
|
+
def _GoogleSearch_to_mldev(
|
|
976
431
|
from_object: Union[dict[str, Any], object],
|
|
977
432
|
parent_object: Optional[dict[str, Any]] = None,
|
|
978
433
|
) -> dict[str, Any]:
|
|
979
434
|
to_object: dict[str, Any] = {}
|
|
980
|
-
if getv(from_object, ['
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
['functionDeclarations'],
|
|
984
|
-
[
|
|
985
|
-
_FunctionDeclaration_to_vertex(item, to_object)
|
|
986
|
-
for item in getv(from_object, ['function_declarations'])
|
|
987
|
-
],
|
|
435
|
+
if getv(from_object, ['exclude_domains']) is not None:
|
|
436
|
+
raise ValueError(
|
|
437
|
+
'exclude_domains parameter is not supported in Gemini API.'
|
|
988
438
|
)
|
|
989
439
|
|
|
990
|
-
if getv(from_object, ['
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
if getv(from_object, ['google_search']) is not None:
|
|
994
|
-
setv(
|
|
995
|
-
to_object,
|
|
996
|
-
['googleSearch'],
|
|
997
|
-
_GoogleSearch_to_vertex(
|
|
998
|
-
getv(from_object, ['google_search']), to_object
|
|
999
|
-
),
|
|
440
|
+
if getv(from_object, ['blocking_confidence']) is not None:
|
|
441
|
+
raise ValueError(
|
|
442
|
+
'blocking_confidence parameter is not supported in Gemini API.'
|
|
1000
443
|
)
|
|
1001
444
|
|
|
1002
|
-
if getv(from_object, ['
|
|
445
|
+
if getv(from_object, ['time_range_filter']) is not None:
|
|
1003
446
|
setv(
|
|
1004
|
-
to_object,
|
|
1005
|
-
['googleSearchRetrieval'],
|
|
1006
|
-
_GoogleSearchRetrieval_to_vertex(
|
|
1007
|
-
getv(from_object, ['google_search_retrieval']), to_object
|
|
1008
|
-
),
|
|
447
|
+
to_object, ['timeRangeFilter'], getv(from_object, ['time_range_filter'])
|
|
1009
448
|
)
|
|
1010
449
|
|
|
1011
|
-
|
|
1012
|
-
setv(
|
|
1013
|
-
to_object,
|
|
1014
|
-
['enterpriseWebSearch'],
|
|
1015
|
-
_EnterpriseWebSearch_to_vertex(
|
|
1016
|
-
getv(from_object, ['enterprise_web_search']), to_object
|
|
1017
|
-
),
|
|
1018
|
-
)
|
|
450
|
+
return to_object
|
|
1019
451
|
|
|
1020
|
-
if getv(from_object, ['google_maps']) is not None:
|
|
1021
|
-
setv(
|
|
1022
|
-
to_object,
|
|
1023
|
-
['googleMaps'],
|
|
1024
|
-
_GoogleMaps_to_vertex(getv(from_object, ['google_maps']), to_object),
|
|
1025
|
-
)
|
|
1026
452
|
|
|
1027
|
-
|
|
453
|
+
def _ListCachedContentsConfig_to_mldev(
|
|
454
|
+
from_object: Union[dict[str, Any], object],
|
|
455
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
456
|
+
) -> dict[str, Any]:
|
|
457
|
+
to_object: dict[str, Any] = {}
|
|
458
|
+
|
|
459
|
+
if getv(from_object, ['page_size']) is not None:
|
|
1028
460
|
setv(
|
|
1029
|
-
|
|
1030
|
-
['urlContext'],
|
|
1031
|
-
_UrlContext_to_vertex(getv(from_object, ['url_context']), to_object),
|
|
461
|
+
parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
|
|
1032
462
|
)
|
|
1033
463
|
|
|
1034
|
-
if getv(from_object, ['
|
|
464
|
+
if getv(from_object, ['page_token']) is not None:
|
|
1035
465
|
setv(
|
|
1036
|
-
|
|
1037
|
-
['
|
|
1038
|
-
|
|
1039
|
-
getv(from_object, ['computer_use']), to_object
|
|
1040
|
-
),
|
|
466
|
+
parent_object,
|
|
467
|
+
['_query', 'pageToken'],
|
|
468
|
+
getv(from_object, ['page_token']),
|
|
1041
469
|
)
|
|
1042
470
|
|
|
1043
|
-
if getv(from_object, ['code_execution']) is not None:
|
|
1044
|
-
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
|
1045
|
-
|
|
1046
471
|
return to_object
|
|
1047
472
|
|
|
1048
473
|
|
|
1049
|
-
def
|
|
474
|
+
def _ListCachedContentsConfig_to_vertex(
|
|
1050
475
|
from_object: Union[dict[str, Any], object],
|
|
1051
476
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1052
477
|
) -> dict[str, Any]:
|
|
1053
478
|
to_object: dict[str, Any] = {}
|
|
1054
|
-
if getv(from_object, ['mode']) is not None:
|
|
1055
|
-
setv(to_object, ['mode'], getv(from_object, ['mode']))
|
|
1056
479
|
|
|
1057
|
-
if getv(from_object, ['
|
|
480
|
+
if getv(from_object, ['page_size']) is not None:
|
|
1058
481
|
setv(
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
482
|
+
parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
|
|
483
|
+
)
|
|
484
|
+
|
|
485
|
+
if getv(from_object, ['page_token']) is not None:
|
|
486
|
+
setv(
|
|
487
|
+
parent_object,
|
|
488
|
+
['_query', 'pageToken'],
|
|
489
|
+
getv(from_object, ['page_token']),
|
|
1062
490
|
)
|
|
1063
491
|
|
|
1064
492
|
return to_object
|
|
1065
493
|
|
|
1066
494
|
|
|
1067
|
-
def
|
|
495
|
+
def _ListCachedContentsParameters_to_mldev(
|
|
1068
496
|
from_object: Union[dict[str, Any], object],
|
|
1069
497
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1070
498
|
) -> dict[str, Any]:
|
|
1071
499
|
to_object: dict[str, Any] = {}
|
|
1072
|
-
if getv(from_object, ['
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
if getv(from_object, ['longitude']) is not None:
|
|
1076
|
-
setv(to_object, ['longitude'], getv(from_object, ['longitude']))
|
|
500
|
+
if getv(from_object, ['config']) is not None:
|
|
501
|
+
_ListCachedContentsConfig_to_mldev(getv(from_object, ['config']), to_object)
|
|
1077
502
|
|
|
1078
503
|
return to_object
|
|
1079
504
|
|
|
1080
505
|
|
|
1081
|
-
def
|
|
506
|
+
def _ListCachedContentsParameters_to_vertex(
|
|
1082
507
|
from_object: Union[dict[str, Any], object],
|
|
1083
508
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1084
509
|
) -> dict[str, Any]:
|
|
1085
510
|
to_object: dict[str, Any] = {}
|
|
1086
|
-
if getv(from_object, ['
|
|
1087
|
-
|
|
1088
|
-
to_object
|
|
1089
|
-
['latLng'],
|
|
1090
|
-
_LatLng_to_vertex(getv(from_object, ['lat_lng']), to_object),
|
|
511
|
+
if getv(from_object, ['config']) is not None:
|
|
512
|
+
_ListCachedContentsConfig_to_vertex(
|
|
513
|
+
getv(from_object, ['config']), to_object
|
|
1091
514
|
)
|
|
1092
515
|
|
|
1093
|
-
if getv(from_object, ['language_code']) is not None:
|
|
1094
|
-
setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
|
|
1095
|
-
|
|
1096
516
|
return to_object
|
|
1097
517
|
|
|
1098
518
|
|
|
1099
|
-
def
|
|
519
|
+
def _ListCachedContentsResponse_from_mldev(
|
|
1100
520
|
from_object: Union[dict[str, Any], object],
|
|
1101
521
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1102
522
|
) -> dict[str, Any]:
|
|
1103
523
|
to_object: dict[str, Any] = {}
|
|
1104
|
-
if getv(from_object, ['
|
|
524
|
+
if getv(from_object, ['sdkHttpResponse']) is not None:
|
|
1105
525
|
setv(
|
|
1106
|
-
to_object,
|
|
1107
|
-
['functionCallingConfig'],
|
|
1108
|
-
_FunctionCallingConfig_to_vertex(
|
|
1109
|
-
getv(from_object, ['function_calling_config']), to_object
|
|
1110
|
-
),
|
|
526
|
+
to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
|
|
1111
527
|
)
|
|
1112
528
|
|
|
1113
|
-
if getv(from_object, ['
|
|
529
|
+
if getv(from_object, ['nextPageToken']) is not None:
|
|
530
|
+
setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
|
|
531
|
+
|
|
532
|
+
if getv(from_object, ['cachedContents']) is not None:
|
|
1114
533
|
setv(
|
|
1115
534
|
to_object,
|
|
1116
|
-
['
|
|
1117
|
-
|
|
1118
|
-
getv(from_object, ['retrieval_config']), to_object
|
|
1119
|
-
),
|
|
535
|
+
['cached_contents'],
|
|
536
|
+
[item for item in getv(from_object, ['cachedContents'])],
|
|
1120
537
|
)
|
|
1121
538
|
|
|
1122
539
|
return to_object
|
|
1123
540
|
|
|
1124
541
|
|
|
1125
|
-
def
|
|
542
|
+
def _ListCachedContentsResponse_from_vertex(
|
|
1126
543
|
from_object: Union[dict[str, Any], object],
|
|
1127
544
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1128
545
|
) -> dict[str, Any]:
|
|
1129
546
|
to_object: dict[str, Any] = {}
|
|
1130
|
-
|
|
1131
|
-
if getv(from_object, ['ttl']) is not None:
|
|
1132
|
-
setv(parent_object, ['ttl'], getv(from_object, ['ttl']))
|
|
1133
|
-
|
|
1134
|
-
if getv(from_object, ['expire_time']) is not None:
|
|
1135
|
-
setv(parent_object, ['expireTime'], getv(from_object, ['expire_time']))
|
|
1136
|
-
|
|
1137
|
-
if getv(from_object, ['display_name']) is not None:
|
|
1138
|
-
setv(parent_object, ['displayName'], getv(from_object, ['display_name']))
|
|
1139
|
-
|
|
1140
|
-
if getv(from_object, ['contents']) is not None:
|
|
1141
|
-
setv(
|
|
1142
|
-
parent_object,
|
|
1143
|
-
['contents'],
|
|
1144
|
-
[
|
|
1145
|
-
_Content_to_vertex(item, to_object)
|
|
1146
|
-
for item in t.t_contents(getv(from_object, ['contents']))
|
|
1147
|
-
],
|
|
1148
|
-
)
|
|
1149
|
-
|
|
1150
|
-
if getv(from_object, ['system_instruction']) is not None:
|
|
1151
|
-
setv(
|
|
1152
|
-
parent_object,
|
|
1153
|
-
['systemInstruction'],
|
|
1154
|
-
_Content_to_vertex(
|
|
1155
|
-
t.t_content(getv(from_object, ['system_instruction'])), to_object
|
|
1156
|
-
),
|
|
1157
|
-
)
|
|
1158
|
-
|
|
1159
|
-
if getv(from_object, ['tools']) is not None:
|
|
547
|
+
if getv(from_object, ['sdkHttpResponse']) is not None:
|
|
1160
548
|
setv(
|
|
1161
|
-
|
|
1162
|
-
['tools'],
|
|
1163
|
-
[
|
|
1164
|
-
_Tool_to_vertex(item, to_object)
|
|
1165
|
-
for item in getv(from_object, ['tools'])
|
|
1166
|
-
],
|
|
549
|
+
to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
|
|
1167
550
|
)
|
|
1168
551
|
|
|
1169
|
-
if getv(from_object, ['
|
|
1170
|
-
setv(
|
|
1171
|
-
parent_object,
|
|
1172
|
-
['toolConfig'],
|
|
1173
|
-
_ToolConfig_to_vertex(getv(from_object, ['tool_config']), to_object),
|
|
1174
|
-
)
|
|
552
|
+
if getv(from_object, ['nextPageToken']) is not None:
|
|
553
|
+
setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
|
|
1175
554
|
|
|
1176
|
-
if getv(from_object, ['
|
|
555
|
+
if getv(from_object, ['cachedContents']) is not None:
|
|
1177
556
|
setv(
|
|
1178
|
-
|
|
1179
|
-
['
|
|
1180
|
-
getv(from_object, ['
|
|
557
|
+
to_object,
|
|
558
|
+
['cached_contents'],
|
|
559
|
+
[item for item in getv(from_object, ['cachedContents'])],
|
|
1181
560
|
)
|
|
1182
561
|
|
|
1183
562
|
return to_object
|
|
1184
563
|
|
|
1185
564
|
|
|
1186
|
-
def
|
|
1187
|
-
api_client: BaseApiClient,
|
|
565
|
+
def _Part_to_mldev(
|
|
1188
566
|
from_object: Union[dict[str, Any], object],
|
|
1189
567
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1190
568
|
) -> dict[str, Any]:
|
|
1191
569
|
to_object: dict[str, Any] = {}
|
|
1192
|
-
if getv(from_object, ['
|
|
570
|
+
if getv(from_object, ['media_resolution']) is not None:
|
|
1193
571
|
setv(
|
|
1194
|
-
to_object,
|
|
1195
|
-
['model'],
|
|
1196
|
-
t.t_caches_model(api_client, getv(from_object, ['model'])),
|
|
572
|
+
to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
|
|
1197
573
|
)
|
|
1198
574
|
|
|
1199
|
-
if getv(from_object, ['
|
|
575
|
+
if getv(from_object, ['code_execution_result']) is not None:
|
|
1200
576
|
setv(
|
|
1201
577
|
to_object,
|
|
1202
|
-
['
|
|
1203
|
-
|
|
1204
|
-
getv(from_object, ['config']), to_object
|
|
1205
|
-
),
|
|
578
|
+
['codeExecutionResult'],
|
|
579
|
+
getv(from_object, ['code_execution_result']),
|
|
1206
580
|
)
|
|
1207
581
|
|
|
1208
|
-
|
|
582
|
+
if getv(from_object, ['executable_code']) is not None:
|
|
583
|
+
setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
|
|
1209
584
|
|
|
585
|
+
if getv(from_object, ['file_data']) is not None:
|
|
586
|
+
setv(
|
|
587
|
+
to_object,
|
|
588
|
+
['fileData'],
|
|
589
|
+
_FileData_to_mldev(getv(from_object, ['file_data']), to_object),
|
|
590
|
+
)
|
|
1210
591
|
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
592
|
+
if getv(from_object, ['function_call']) is not None:
|
|
593
|
+
setv(
|
|
594
|
+
to_object,
|
|
595
|
+
['functionCall'],
|
|
596
|
+
_FunctionCall_to_mldev(getv(from_object, ['function_call']), to_object),
|
|
597
|
+
)
|
|
598
|
+
|
|
599
|
+
if getv(from_object, ['function_response']) is not None:
|
|
600
|
+
setv(
|
|
601
|
+
to_object,
|
|
602
|
+
['functionResponse'],
|
|
603
|
+
getv(from_object, ['function_response']),
|
|
604
|
+
)
|
|
605
|
+
|
|
606
|
+
if getv(from_object, ['inline_data']) is not None:
|
|
1218
607
|
setv(
|
|
1219
608
|
to_object,
|
|
1220
|
-
['
|
|
1221
|
-
|
|
609
|
+
['inlineData'],
|
|
610
|
+
_Blob_to_mldev(getv(from_object, ['inline_data']), to_object),
|
|
1222
611
|
)
|
|
1223
612
|
|
|
1224
|
-
if getv(from_object, ['
|
|
1225
|
-
setv(to_object, ['
|
|
1226
|
-
|
|
1227
|
-
return to_object
|
|
613
|
+
if getv(from_object, ['text']) is not None:
|
|
614
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
|
1228
615
|
|
|
616
|
+
if getv(from_object, ['thought']) is not None:
|
|
617
|
+
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
|
1229
618
|
|
|
1230
|
-
|
|
1231
|
-
api_client: BaseApiClient,
|
|
1232
|
-
from_object: Union[dict[str, Any], object],
|
|
1233
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
1234
|
-
) -> dict[str, Any]:
|
|
1235
|
-
to_object: dict[str, Any] = {}
|
|
1236
|
-
if getv(from_object, ['name']) is not None:
|
|
619
|
+
if getv(from_object, ['thought_signature']) is not None:
|
|
1237
620
|
setv(
|
|
1238
621
|
to_object,
|
|
1239
|
-
['
|
|
1240
|
-
|
|
622
|
+
['thoughtSignature'],
|
|
623
|
+
getv(from_object, ['thought_signature']),
|
|
1241
624
|
)
|
|
1242
625
|
|
|
1243
|
-
if getv(from_object, ['
|
|
1244
|
-
setv(to_object, ['
|
|
626
|
+
if getv(from_object, ['video_metadata']) is not None:
|
|
627
|
+
setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
|
|
1245
628
|
|
|
1246
629
|
return to_object
|
|
1247
630
|
|
|
1248
631
|
|
|
1249
|
-
def
|
|
632
|
+
def _ToolConfig_to_mldev(
|
|
1250
633
|
from_object: Union[dict[str, Any], object],
|
|
1251
634
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1252
635
|
) -> dict[str, Any]:
|
|
1253
636
|
to_object: dict[str, Any] = {}
|
|
637
|
+
if getv(from_object, ['function_calling_config']) is not None:
|
|
638
|
+
setv(
|
|
639
|
+
to_object,
|
|
640
|
+
['functionCallingConfig'],
|
|
641
|
+
_FunctionCallingConfig_to_mldev(
|
|
642
|
+
getv(from_object, ['function_calling_config']), to_object
|
|
643
|
+
),
|
|
644
|
+
)
|
|
1254
645
|
|
|
1255
|
-
if getv(from_object, ['
|
|
1256
|
-
setv(
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
setv(parent_object, ['expireTime'], getv(from_object, ['expire_time']))
|
|
646
|
+
if getv(from_object, ['retrieval_config']) is not None:
|
|
647
|
+
setv(
|
|
648
|
+
to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
|
|
649
|
+
)
|
|
1260
650
|
|
|
1261
651
|
return to_object
|
|
1262
652
|
|
|
1263
653
|
|
|
1264
|
-
def
|
|
1265
|
-
api_client: BaseApiClient,
|
|
654
|
+
def _Tool_to_mldev(
|
|
1266
655
|
from_object: Union[dict[str, Any], object],
|
|
1267
656
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1268
657
|
) -> dict[str, Any]:
|
|
1269
658
|
to_object: dict[str, Any] = {}
|
|
1270
|
-
if getv(from_object, ['
|
|
659
|
+
if getv(from_object, ['function_declarations']) is not None:
|
|
1271
660
|
setv(
|
|
1272
661
|
to_object,
|
|
1273
|
-
['
|
|
1274
|
-
|
|
662
|
+
['functionDeclarations'],
|
|
663
|
+
[item for item in getv(from_object, ['function_declarations'])],
|
|
1275
664
|
)
|
|
1276
665
|
|
|
1277
|
-
if getv(from_object, ['
|
|
666
|
+
if getv(from_object, ['retrieval']) is not None:
|
|
667
|
+
raise ValueError('retrieval parameter is not supported in Gemini API.')
|
|
668
|
+
|
|
669
|
+
if getv(from_object, ['google_search_retrieval']) is not None:
|
|
1278
670
|
setv(
|
|
1279
671
|
to_object,
|
|
1280
|
-
['
|
|
1281
|
-
|
|
1282
|
-
getv(from_object, ['config']), to_object
|
|
1283
|
-
),
|
|
672
|
+
['googleSearchRetrieval'],
|
|
673
|
+
getv(from_object, ['google_search_retrieval']),
|
|
1284
674
|
)
|
|
1285
675
|
|
|
1286
|
-
|
|
676
|
+
if getv(from_object, ['computer_use']) is not None:
|
|
677
|
+
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
|
|
1287
678
|
|
|
679
|
+
if getv(from_object, ['file_search']) is not None:
|
|
680
|
+
setv(to_object, ['fileSearch'], getv(from_object, ['file_search']))
|
|
1288
681
|
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
1292
|
-
) -> dict[str, Any]:
|
|
1293
|
-
to_object: dict[str, Any] = {}
|
|
682
|
+
if getv(from_object, ['code_execution']) is not None:
|
|
683
|
+
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
|
1294
684
|
|
|
1295
|
-
if getv(from_object, ['
|
|
1296
|
-
|
|
1297
|
-
|
|
685
|
+
if getv(from_object, ['enterprise_web_search']) is not None:
|
|
686
|
+
raise ValueError(
|
|
687
|
+
'enterprise_web_search parameter is not supported in Gemini API.'
|
|
1298
688
|
)
|
|
1299
689
|
|
|
1300
|
-
if getv(from_object, ['
|
|
690
|
+
if getv(from_object, ['google_maps']) is not None:
|
|
1301
691
|
setv(
|
|
1302
|
-
|
|
1303
|
-
['
|
|
1304
|
-
getv(from_object, ['
|
|
692
|
+
to_object,
|
|
693
|
+
['googleMaps'],
|
|
694
|
+
_GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
|
|
1305
695
|
)
|
|
1306
696
|
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
def _ListCachedContentsParameters_to_vertex(
|
|
1311
|
-
from_object: Union[dict[str, Any], object],
|
|
1312
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
1313
|
-
) -> dict[str, Any]:
|
|
1314
|
-
to_object: dict[str, Any] = {}
|
|
1315
|
-
if getv(from_object, ['config']) is not None:
|
|
697
|
+
if getv(from_object, ['google_search']) is not None:
|
|
1316
698
|
setv(
|
|
1317
699
|
to_object,
|
|
1318
|
-
['
|
|
1319
|
-
|
|
1320
|
-
getv(from_object, ['config']), to_object
|
|
1321
|
-
),
|
|
700
|
+
['googleSearch'],
|
|
701
|
+
_GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
|
|
1322
702
|
)
|
|
1323
703
|
|
|
1324
|
-
|
|
1325
|
-
|
|
704
|
+
if getv(from_object, ['url_context']) is not None:
|
|
705
|
+
setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
|
|
1326
706
|
|
|
1327
|
-
|
|
1328
|
-
if enum_value in set(['UNSPECIFIED', 'BLOCKING', 'NON_BLOCKING']):
|
|
1329
|
-
raise ValueError(f'{enum_value} enum value is not supported in Vertex AI.')
|
|
707
|
+
return to_object
|
|
1330
708
|
|
|
1331
709
|
|
|
1332
|
-
def
|
|
710
|
+
def _Tool_to_vertex(
|
|
1333
711
|
from_object: Union[dict[str, Any], object],
|
|
1334
712
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1335
713
|
) -> dict[str, Any]:
|
|
1336
714
|
to_object: dict[str, Any] = {}
|
|
1337
|
-
if getv(from_object, ['
|
|
1338
|
-
setv(
|
|
715
|
+
if getv(from_object, ['function_declarations']) is not None:
|
|
716
|
+
setv(
|
|
717
|
+
to_object,
|
|
718
|
+
['functionDeclarations'],
|
|
719
|
+
[
|
|
720
|
+
_FunctionDeclaration_to_vertex(item, to_object)
|
|
721
|
+
for item in getv(from_object, ['function_declarations'])
|
|
722
|
+
],
|
|
723
|
+
)
|
|
1339
724
|
|
|
1340
|
-
if getv(from_object, ['
|
|
1341
|
-
setv(to_object, ['
|
|
725
|
+
if getv(from_object, ['retrieval']) is not None:
|
|
726
|
+
setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
|
|
1342
727
|
|
|
1343
|
-
if getv(from_object, ['
|
|
1344
|
-
setv(
|
|
728
|
+
if getv(from_object, ['google_search_retrieval']) is not None:
|
|
729
|
+
setv(
|
|
730
|
+
to_object,
|
|
731
|
+
['googleSearchRetrieval'],
|
|
732
|
+
getv(from_object, ['google_search_retrieval']),
|
|
733
|
+
)
|
|
1345
734
|
|
|
1346
|
-
if getv(from_object, ['
|
|
1347
|
-
setv(to_object, ['
|
|
735
|
+
if getv(from_object, ['computer_use']) is not None:
|
|
736
|
+
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
|
|
1348
737
|
|
|
1349
|
-
if getv(from_object, ['
|
|
1350
|
-
|
|
738
|
+
if getv(from_object, ['file_search']) is not None:
|
|
739
|
+
raise ValueError('file_search parameter is not supported in Vertex AI.')
|
|
1351
740
|
|
|
1352
|
-
if getv(from_object, ['
|
|
1353
|
-
setv(to_object, ['
|
|
741
|
+
if getv(from_object, ['code_execution']) is not None:
|
|
742
|
+
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
|
1354
743
|
|
|
1355
|
-
if getv(from_object, ['
|
|
1356
|
-
setv(
|
|
744
|
+
if getv(from_object, ['enterprise_web_search']) is not None:
|
|
745
|
+
setv(
|
|
746
|
+
to_object,
|
|
747
|
+
['enterpriseWebSearch'],
|
|
748
|
+
getv(from_object, ['enterprise_web_search']),
|
|
749
|
+
)
|
|
1357
750
|
|
|
1358
|
-
|
|
751
|
+
if getv(from_object, ['google_maps']) is not None:
|
|
752
|
+
setv(to_object, ['googleMaps'], getv(from_object, ['google_maps']))
|
|
1359
753
|
|
|
754
|
+
if getv(from_object, ['google_search']) is not None:
|
|
755
|
+
setv(to_object, ['googleSearch'], getv(from_object, ['google_search']))
|
|
1360
756
|
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
1364
|
-
) -> dict[str, Any]:
|
|
1365
|
-
to_object: dict[str, Any] = {}
|
|
1366
|
-
if getv(from_object, ['sdkHttpResponse']) is not None:
|
|
1367
|
-
setv(
|
|
1368
|
-
to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
|
|
1369
|
-
)
|
|
757
|
+
if getv(from_object, ['url_context']) is not None:
|
|
758
|
+
setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
|
|
1370
759
|
|
|
1371
760
|
return to_object
|
|
1372
761
|
|
|
1373
762
|
|
|
1374
|
-
def
|
|
763
|
+
def _UpdateCachedContentConfig_to_mldev(
|
|
1375
764
|
from_object: Union[dict[str, Any], object],
|
|
1376
765
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1377
766
|
) -> dict[str, Any]:
|
|
1378
767
|
to_object: dict[str, Any] = {}
|
|
1379
|
-
if getv(from_object, ['sdkHttpResponse']) is not None:
|
|
1380
|
-
setv(
|
|
1381
|
-
to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
|
|
1382
|
-
)
|
|
1383
768
|
|
|
1384
|
-
if getv(from_object, ['
|
|
1385
|
-
setv(
|
|
769
|
+
if getv(from_object, ['ttl']) is not None:
|
|
770
|
+
setv(parent_object, ['ttl'], getv(from_object, ['ttl']))
|
|
1386
771
|
|
|
1387
|
-
if getv(from_object, ['
|
|
1388
|
-
setv(
|
|
1389
|
-
to_object,
|
|
1390
|
-
['cached_contents'],
|
|
1391
|
-
[
|
|
1392
|
-
_CachedContent_from_mldev(item, to_object)
|
|
1393
|
-
for item in getv(from_object, ['cachedContents'])
|
|
1394
|
-
],
|
|
1395
|
-
)
|
|
772
|
+
if getv(from_object, ['expire_time']) is not None:
|
|
773
|
+
setv(parent_object, ['expireTime'], getv(from_object, ['expire_time']))
|
|
1396
774
|
|
|
1397
775
|
return to_object
|
|
1398
776
|
|
|
1399
777
|
|
|
1400
|
-
def
|
|
778
|
+
def _UpdateCachedContentConfig_to_vertex(
|
|
1401
779
|
from_object: Union[dict[str, Any], object],
|
|
1402
780
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1403
781
|
) -> dict[str, Any]:
|
|
1404
782
|
to_object: dict[str, Any] = {}
|
|
1405
|
-
if getv(from_object, ['name']) is not None:
|
|
1406
|
-
setv(to_object, ['name'], getv(from_object, ['name']))
|
|
1407
|
-
|
|
1408
|
-
if getv(from_object, ['displayName']) is not None:
|
|
1409
|
-
setv(to_object, ['display_name'], getv(from_object, ['displayName']))
|
|
1410
|
-
|
|
1411
|
-
if getv(from_object, ['model']) is not None:
|
|
1412
|
-
setv(to_object, ['model'], getv(from_object, ['model']))
|
|
1413
|
-
|
|
1414
|
-
if getv(from_object, ['createTime']) is not None:
|
|
1415
|
-
setv(to_object, ['create_time'], getv(from_object, ['createTime']))
|
|
1416
783
|
|
|
1417
|
-
if getv(from_object, ['
|
|
1418
|
-
setv(
|
|
1419
|
-
|
|
1420
|
-
if getv(from_object, ['expireTime']) is not None:
|
|
1421
|
-
setv(to_object, ['expire_time'], getv(from_object, ['expireTime']))
|
|
784
|
+
if getv(from_object, ['ttl']) is not None:
|
|
785
|
+
setv(parent_object, ['ttl'], getv(from_object, ['ttl']))
|
|
1422
786
|
|
|
1423
|
-
if getv(from_object, ['
|
|
1424
|
-
setv(
|
|
787
|
+
if getv(from_object, ['expire_time']) is not None:
|
|
788
|
+
setv(parent_object, ['expireTime'], getv(from_object, ['expire_time']))
|
|
1425
789
|
|
|
1426
790
|
return to_object
|
|
1427
791
|
|
|
1428
792
|
|
|
1429
|
-
def
|
|
793
|
+
def _UpdateCachedContentParameters_to_mldev(
|
|
794
|
+
api_client: BaseApiClient,
|
|
1430
795
|
from_object: Union[dict[str, Any], object],
|
|
1431
796
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1432
797
|
) -> dict[str, Any]:
|
|
1433
798
|
to_object: dict[str, Any] = {}
|
|
1434
|
-
if getv(from_object, ['
|
|
799
|
+
if getv(from_object, ['name']) is not None:
|
|
1435
800
|
setv(
|
|
1436
|
-
to_object,
|
|
801
|
+
to_object,
|
|
802
|
+
['_url', 'name'],
|
|
803
|
+
t.t_cached_content_name(api_client, getv(from_object, ['name'])),
|
|
804
|
+
)
|
|
805
|
+
|
|
806
|
+
if getv(from_object, ['config']) is not None:
|
|
807
|
+
_UpdateCachedContentConfig_to_mldev(
|
|
808
|
+
getv(from_object, ['config']), to_object
|
|
1437
809
|
)
|
|
1438
810
|
|
|
1439
811
|
return to_object
|
|
1440
812
|
|
|
1441
813
|
|
|
1442
|
-
def
|
|
814
|
+
def _UpdateCachedContentParameters_to_vertex(
|
|
815
|
+
api_client: BaseApiClient,
|
|
1443
816
|
from_object: Union[dict[str, Any], object],
|
|
1444
817
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1445
818
|
) -> dict[str, Any]:
|
|
1446
819
|
to_object: dict[str, Any] = {}
|
|
1447
|
-
if getv(from_object, ['
|
|
820
|
+
if getv(from_object, ['name']) is not None:
|
|
1448
821
|
setv(
|
|
1449
|
-
to_object,
|
|
822
|
+
to_object,
|
|
823
|
+
['_url', 'name'],
|
|
824
|
+
t.t_cached_content_name(api_client, getv(from_object, ['name'])),
|
|
1450
825
|
)
|
|
1451
826
|
|
|
1452
|
-
if getv(from_object, ['
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
if getv(from_object, ['cachedContents']) is not None:
|
|
1456
|
-
setv(
|
|
1457
|
-
to_object,
|
|
1458
|
-
['cached_contents'],
|
|
1459
|
-
[
|
|
1460
|
-
_CachedContent_from_vertex(item, to_object)
|
|
1461
|
-
for item in getv(from_object, ['cachedContents'])
|
|
1462
|
-
],
|
|
827
|
+
if getv(from_object, ['config']) is not None:
|
|
828
|
+
_UpdateCachedContentConfig_to_vertex(
|
|
829
|
+
getv(from_object, ['config']), to_object
|
|
1463
830
|
)
|
|
1464
831
|
|
|
1465
832
|
return to_object
|
|
@@ -1536,13 +903,7 @@ class Caches(_api_module.BaseModule):
|
|
|
1536
903
|
'post', path, request_dict, http_options
|
|
1537
904
|
)
|
|
1538
905
|
|
|
1539
|
-
response_dict =
|
|
1540
|
-
|
|
1541
|
-
if self._api_client.vertexai:
|
|
1542
|
-
response_dict = _CachedContent_from_vertex(response_dict)
|
|
1543
|
-
|
|
1544
|
-
else:
|
|
1545
|
-
response_dict = _CachedContent_from_mldev(response_dict)
|
|
906
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1546
907
|
|
|
1547
908
|
return_value = types.CachedContent._from_response(
|
|
1548
909
|
response=response_dict, kwargs=parameter_model.model_dump()
|
|
@@ -1607,13 +968,7 @@ class Caches(_api_module.BaseModule):
|
|
|
1607
968
|
|
|
1608
969
|
response = self._api_client.request('get', path, request_dict, http_options)
|
|
1609
970
|
|
|
1610
|
-
response_dict =
|
|
1611
|
-
|
|
1612
|
-
if self._api_client.vertexai:
|
|
1613
|
-
response_dict = _CachedContent_from_vertex(response_dict)
|
|
1614
|
-
|
|
1615
|
-
else:
|
|
1616
|
-
response_dict = _CachedContent_from_mldev(response_dict)
|
|
971
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1617
972
|
|
|
1618
973
|
return_value = types.CachedContent._from_response(
|
|
1619
974
|
response=response_dict, kwargs=parameter_model.model_dump()
|
|
@@ -1682,12 +1037,12 @@ class Caches(_api_module.BaseModule):
|
|
|
1682
1037
|
'delete', path, request_dict, http_options
|
|
1683
1038
|
)
|
|
1684
1039
|
|
|
1685
|
-
response_dict =
|
|
1040
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1686
1041
|
|
|
1687
1042
|
if self._api_client.vertexai:
|
|
1688
1043
|
response_dict = _DeleteCachedContentResponse_from_vertex(response_dict)
|
|
1689
1044
|
|
|
1690
|
-
|
|
1045
|
+
if not self._api_client.vertexai:
|
|
1691
1046
|
response_dict = _DeleteCachedContentResponse_from_mldev(response_dict)
|
|
1692
1047
|
|
|
1693
1048
|
return_value = types.DeleteCachedContentResponse._from_response(
|
|
@@ -1762,13 +1117,7 @@ class Caches(_api_module.BaseModule):
|
|
|
1762
1117
|
'patch', path, request_dict, http_options
|
|
1763
1118
|
)
|
|
1764
1119
|
|
|
1765
|
-
response_dict =
|
|
1766
|
-
|
|
1767
|
-
if self._api_client.vertexai:
|
|
1768
|
-
response_dict = _CachedContent_from_vertex(response_dict)
|
|
1769
|
-
|
|
1770
|
-
else:
|
|
1771
|
-
response_dict = _CachedContent_from_mldev(response_dict)
|
|
1120
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1772
1121
|
|
|
1773
1122
|
return_value = types.CachedContent._from_response(
|
|
1774
1123
|
response=response_dict, kwargs=parameter_model.model_dump()
|
|
@@ -1780,15 +1129,6 @@ class Caches(_api_module.BaseModule):
|
|
|
1780
1129
|
def _list(
|
|
1781
1130
|
self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
|
|
1782
1131
|
) -> types.ListCachedContentsResponse:
|
|
1783
|
-
"""Lists cached content configurations.
|
|
1784
|
-
|
|
1785
|
-
.. code-block:: python
|
|
1786
|
-
|
|
1787
|
-
cached_contents = client.caches.list(config={'page_size': 2})
|
|
1788
|
-
for cached_content in cached_contents:
|
|
1789
|
-
print(cached_content)
|
|
1790
|
-
"""
|
|
1791
|
-
|
|
1792
1132
|
parameter_model = types._ListCachedContentsParameters(
|
|
1793
1133
|
config=config,
|
|
1794
1134
|
)
|
|
@@ -1827,12 +1167,12 @@ class Caches(_api_module.BaseModule):
|
|
|
1827
1167
|
|
|
1828
1168
|
response = self._api_client.request('get', path, request_dict, http_options)
|
|
1829
1169
|
|
|
1830
|
-
response_dict =
|
|
1170
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1831
1171
|
|
|
1832
1172
|
if self._api_client.vertexai:
|
|
1833
1173
|
response_dict = _ListCachedContentsResponse_from_vertex(response_dict)
|
|
1834
1174
|
|
|
1835
|
-
|
|
1175
|
+
if not self._api_client.vertexai:
|
|
1836
1176
|
response_dict = _ListCachedContentsResponse_from_mldev(response_dict)
|
|
1837
1177
|
|
|
1838
1178
|
return_value = types.ListCachedContentsResponse._from_response(
|
|
@@ -1847,9 +1187,28 @@ class Caches(_api_module.BaseModule):
|
|
|
1847
1187
|
def list(
|
|
1848
1188
|
self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
|
|
1849
1189
|
) -> Pager[types.CachedContent]:
|
|
1190
|
+
"""Lists cached contents.
|
|
1191
|
+
|
|
1192
|
+
Args:
|
|
1193
|
+
config (ListCachedContentsConfig): Optional configuration for the list
|
|
1194
|
+
request.
|
|
1195
|
+
|
|
1196
|
+
Returns:
|
|
1197
|
+
A Pager object that contains one page of cached contents. When iterating
|
|
1198
|
+
over
|
|
1199
|
+
the pager, it automatically fetches the next page if there are more.
|
|
1200
|
+
|
|
1201
|
+
Usage:
|
|
1202
|
+
|
|
1203
|
+
.. code-block:: python
|
|
1204
|
+
for cached_content in client.caches.list():
|
|
1205
|
+
print(cached_content.name)
|
|
1206
|
+
"""
|
|
1207
|
+
|
|
1208
|
+
list_request = self._list
|
|
1850
1209
|
return Pager(
|
|
1851
1210
|
'cached_contents',
|
|
1852
|
-
|
|
1211
|
+
list_request,
|
|
1853
1212
|
self._list(config=config),
|
|
1854
1213
|
config,
|
|
1855
1214
|
)
|
|
@@ -1926,13 +1285,7 @@ class AsyncCaches(_api_module.BaseModule):
|
|
|
1926
1285
|
'post', path, request_dict, http_options
|
|
1927
1286
|
)
|
|
1928
1287
|
|
|
1929
|
-
response_dict =
|
|
1930
|
-
|
|
1931
|
-
if self._api_client.vertexai:
|
|
1932
|
-
response_dict = _CachedContent_from_vertex(response_dict)
|
|
1933
|
-
|
|
1934
|
-
else:
|
|
1935
|
-
response_dict = _CachedContent_from_mldev(response_dict)
|
|
1288
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1936
1289
|
|
|
1937
1290
|
return_value = types.CachedContent._from_response(
|
|
1938
1291
|
response=response_dict, kwargs=parameter_model.model_dump()
|
|
@@ -2000,13 +1353,7 @@ class AsyncCaches(_api_module.BaseModule):
|
|
|
2000
1353
|
'get', path, request_dict, http_options
|
|
2001
1354
|
)
|
|
2002
1355
|
|
|
2003
|
-
response_dict =
|
|
2004
|
-
|
|
2005
|
-
if self._api_client.vertexai:
|
|
2006
|
-
response_dict = _CachedContent_from_vertex(response_dict)
|
|
2007
|
-
|
|
2008
|
-
else:
|
|
2009
|
-
response_dict = _CachedContent_from_mldev(response_dict)
|
|
1356
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
2010
1357
|
|
|
2011
1358
|
return_value = types.CachedContent._from_response(
|
|
2012
1359
|
response=response_dict, kwargs=parameter_model.model_dump()
|
|
@@ -2076,12 +1423,12 @@ class AsyncCaches(_api_module.BaseModule):
|
|
|
2076
1423
|
'delete', path, request_dict, http_options
|
|
2077
1424
|
)
|
|
2078
1425
|
|
|
2079
|
-
response_dict =
|
|
1426
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
2080
1427
|
|
|
2081
1428
|
if self._api_client.vertexai:
|
|
2082
1429
|
response_dict = _DeleteCachedContentResponse_from_vertex(response_dict)
|
|
2083
1430
|
|
|
2084
|
-
|
|
1431
|
+
if not self._api_client.vertexai:
|
|
2085
1432
|
response_dict = _DeleteCachedContentResponse_from_mldev(response_dict)
|
|
2086
1433
|
|
|
2087
1434
|
return_value = types.DeleteCachedContentResponse._from_response(
|
|
@@ -2156,13 +1503,7 @@ class AsyncCaches(_api_module.BaseModule):
|
|
|
2156
1503
|
'patch', path, request_dict, http_options
|
|
2157
1504
|
)
|
|
2158
1505
|
|
|
2159
|
-
response_dict =
|
|
2160
|
-
|
|
2161
|
-
if self._api_client.vertexai:
|
|
2162
|
-
response_dict = _CachedContent_from_vertex(response_dict)
|
|
2163
|
-
|
|
2164
|
-
else:
|
|
2165
|
-
response_dict = _CachedContent_from_mldev(response_dict)
|
|
1506
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
2166
1507
|
|
|
2167
1508
|
return_value = types.CachedContent._from_response(
|
|
2168
1509
|
response=response_dict, kwargs=parameter_model.model_dump()
|
|
@@ -2174,15 +1515,6 @@ class AsyncCaches(_api_module.BaseModule):
|
|
|
2174
1515
|
async def _list(
|
|
2175
1516
|
self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
|
|
2176
1517
|
) -> types.ListCachedContentsResponse:
|
|
2177
|
-
"""Lists cached content configurations.
|
|
2178
|
-
|
|
2179
|
-
.. code-block:: python
|
|
2180
|
-
|
|
2181
|
-
cached_contents = await client.aio.caches.list(config={'page_size': 2})
|
|
2182
|
-
async for cached_content in cached_contents:
|
|
2183
|
-
print(cached_content)
|
|
2184
|
-
"""
|
|
2185
|
-
|
|
2186
1518
|
parameter_model = types._ListCachedContentsParameters(
|
|
2187
1519
|
config=config,
|
|
2188
1520
|
)
|
|
@@ -2223,12 +1555,12 @@ class AsyncCaches(_api_module.BaseModule):
|
|
|
2223
1555
|
'get', path, request_dict, http_options
|
|
2224
1556
|
)
|
|
2225
1557
|
|
|
2226
|
-
response_dict =
|
|
1558
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
2227
1559
|
|
|
2228
1560
|
if self._api_client.vertexai:
|
|
2229
1561
|
response_dict = _ListCachedContentsResponse_from_vertex(response_dict)
|
|
2230
1562
|
|
|
2231
|
-
|
|
1563
|
+
if not self._api_client.vertexai:
|
|
2232
1564
|
response_dict = _ListCachedContentsResponse_from_mldev(response_dict)
|
|
2233
1565
|
|
|
2234
1566
|
return_value = types.ListCachedContentsResponse._from_response(
|
|
@@ -2243,9 +1575,28 @@ class AsyncCaches(_api_module.BaseModule):
|
|
|
2243
1575
|
async def list(
|
|
2244
1576
|
self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
|
|
2245
1577
|
) -> AsyncPager[types.CachedContent]:
|
|
1578
|
+
"""Lists cached contents asynchronously.
|
|
1579
|
+
|
|
1580
|
+
Args:
|
|
1581
|
+
config (ListCachedContentsConfig): Optional configuration for the list
|
|
1582
|
+
request.
|
|
1583
|
+
|
|
1584
|
+
Returns:
|
|
1585
|
+
A Pager object that contains one page of cached contents. When iterating
|
|
1586
|
+
over
|
|
1587
|
+
the pager, it automatically fetches the next page if there are more.
|
|
1588
|
+
|
|
1589
|
+
Usage:
|
|
1590
|
+
|
|
1591
|
+
.. code-block:: python
|
|
1592
|
+
async for cached_content in await client.aio.caches.list():
|
|
1593
|
+
print(cached_content.name)
|
|
1594
|
+
"""
|
|
1595
|
+
|
|
1596
|
+
list_request = self._list
|
|
2246
1597
|
return AsyncPager(
|
|
2247
1598
|
'cached_contents',
|
|
2248
|
-
|
|
1599
|
+
list_request,
|
|
2249
1600
|
await self._list(config=config),
|
|
2250
1601
|
config,
|
|
2251
1602
|
)
|