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/batches.py CHANGED
@@ -27,6 +27,7 @@ from . import _transformers as t
27
27
  from . import types
28
28
  from ._api_client import BaseApiClient
29
29
  from ._common import get_value_by_path as getv
30
+ from ._common import move_value_by_path as movev
30
31
  from ._common import set_value_by_path as setv
31
32
  from .pagers import AsyncPager, Pager
32
33
 
@@ -34,873 +35,485 @@ from .pagers import AsyncPager, Pager
34
35
  logger = logging.getLogger('google_genai.batches')
35
36
 
36
37
 
37
- def _VideoMetadata_to_mldev(
38
+ def _BatchJobDestination_from_mldev(
38
39
  from_object: Union[dict[str, Any], object],
39
40
  parent_object: Optional[dict[str, Any]] = None,
40
41
  ) -> dict[str, Any]:
41
42
  to_object: dict[str, Any] = {}
42
- if getv(from_object, ['fps']) is not None:
43
- setv(to_object, ['fps'], getv(from_object, ['fps']))
44
-
45
- if getv(from_object, ['end_offset']) is not None:
46
- setv(to_object, ['endOffset'], getv(from_object, ['end_offset']))
47
-
48
- if getv(from_object, ['start_offset']) is not None:
49
- setv(to_object, ['startOffset'], getv(from_object, ['start_offset']))
50
-
51
- return to_object
52
-
53
43
 
54
- def _Blob_to_mldev(
55
- from_object: Union[dict[str, Any], object],
56
- parent_object: Optional[dict[str, Any]] = None,
57
- ) -> dict[str, Any]:
58
- to_object: dict[str, Any] = {}
59
- if getv(from_object, ['display_name']) is not None:
60
- raise ValueError('display_name parameter is not supported in Gemini API.')
44
+ if getv(from_object, ['responsesFile']) is not None:
45
+ setv(to_object, ['file_name'], getv(from_object, ['responsesFile']))
61
46
 
62
- if getv(from_object, ['data']) is not None:
63
- setv(to_object, ['data'], getv(from_object, ['data']))
47
+ if getv(from_object, ['inlinedResponses', 'inlinedResponses']) is not None:
48
+ setv(
49
+ to_object,
50
+ ['inlined_responses'],
51
+ [
52
+ _InlinedResponse_from_mldev(item, to_object)
53
+ for item in getv(
54
+ from_object, ['inlinedResponses', 'inlinedResponses']
55
+ )
56
+ ],
57
+ )
64
58
 
65
- if getv(from_object, ['mime_type']) is not None:
66
- setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
59
+ if (
60
+ getv(from_object, ['inlinedEmbedContentResponses', 'inlinedResponses'])
61
+ is not None
62
+ ):
63
+ setv(
64
+ to_object,
65
+ ['inlined_embed_content_responses'],
66
+ [
67
+ item
68
+ for item in getv(
69
+ from_object,
70
+ ['inlinedEmbedContentResponses', 'inlinedResponses'],
71
+ )
72
+ ],
73
+ )
67
74
 
68
75
  return to_object
69
76
 
70
77
 
71
- def _FileData_to_mldev(
78
+ def _BatchJobDestination_from_vertex(
72
79
  from_object: Union[dict[str, Any], object],
73
80
  parent_object: Optional[dict[str, Any]] = None,
74
81
  ) -> dict[str, Any]:
75
82
  to_object: dict[str, Any] = {}
76
- if getv(from_object, ['display_name']) is not None:
77
- raise ValueError('display_name parameter is not supported in Gemini API.')
83
+ if getv(from_object, ['predictionsFormat']) is not None:
84
+ setv(to_object, ['format'], getv(from_object, ['predictionsFormat']))
78
85
 
79
- if getv(from_object, ['file_uri']) is not None:
80
- setv(to_object, ['fileUri'], getv(from_object, ['file_uri']))
86
+ if getv(from_object, ['gcsDestination', 'outputUriPrefix']) is not None:
87
+ setv(
88
+ to_object,
89
+ ['gcs_uri'],
90
+ getv(from_object, ['gcsDestination', 'outputUriPrefix']),
91
+ )
81
92
 
82
- if getv(from_object, ['mime_type']) is not None:
83
- setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
93
+ if getv(from_object, ['bigqueryDestination', 'outputUri']) is not None:
94
+ setv(
95
+ to_object,
96
+ ['bigquery_uri'],
97
+ getv(from_object, ['bigqueryDestination', 'outputUri']),
98
+ )
84
99
 
85
100
  return to_object
86
101
 
87
102
 
88
- def _Part_to_mldev(
103
+ def _BatchJobDestination_to_vertex(
89
104
  from_object: Union[dict[str, Any], object],
90
105
  parent_object: Optional[dict[str, Any]] = None,
91
106
  ) -> dict[str, Any]:
92
107
  to_object: dict[str, Any] = {}
93
- if getv(from_object, ['video_metadata']) is not None:
94
- setv(
95
- to_object,
96
- ['videoMetadata'],
97
- _VideoMetadata_to_mldev(
98
- getv(from_object, ['video_metadata']), to_object
99
- ),
100
- )
101
-
102
- if getv(from_object, ['thought']) is not None:
103
- setv(to_object, ['thought'], getv(from_object, ['thought']))
108
+ if getv(from_object, ['format']) is not None:
109
+ setv(to_object, ['predictionsFormat'], getv(from_object, ['format']))
104
110
 
105
- if getv(from_object, ['inline_data']) is not None:
111
+ if getv(from_object, ['gcs_uri']) is not None:
106
112
  setv(
107
113
  to_object,
108
- ['inlineData'],
109
- _Blob_to_mldev(getv(from_object, ['inline_data']), to_object),
114
+ ['gcsDestination', 'outputUriPrefix'],
115
+ getv(from_object, ['gcs_uri']),
110
116
  )
111
117
 
112
- if getv(from_object, ['file_data']) is not None:
118
+ if getv(from_object, ['bigquery_uri']) is not None:
113
119
  setv(
114
120
  to_object,
115
- ['fileData'],
116
- _FileData_to_mldev(getv(from_object, ['file_data']), to_object),
121
+ ['bigqueryDestination', 'outputUri'],
122
+ getv(from_object, ['bigquery_uri']),
117
123
  )
118
124
 
119
- if getv(from_object, ['thought_signature']) is not None:
120
- setv(
121
- to_object,
122
- ['thoughtSignature'],
123
- getv(from_object, ['thought_signature']),
124
- )
125
+ if getv(from_object, ['file_name']) is not None:
126
+ raise ValueError('file_name parameter is not supported in Vertex AI.')
125
127
 
126
- if getv(from_object, ['code_execution_result']) is not None:
127
- setv(
128
- to_object,
129
- ['codeExecutionResult'],
130
- getv(from_object, ['code_execution_result']),
128
+ if getv(from_object, ['inlined_responses']) is not None:
129
+ raise ValueError(
130
+ 'inlined_responses parameter is not supported in Vertex AI.'
131
131
  )
132
132
 
133
- if getv(from_object, ['executable_code']) is not None:
134
- setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
135
-
136
- if getv(from_object, ['function_call']) is not None:
137
- setv(to_object, ['functionCall'], getv(from_object, ['function_call']))
138
-
139
- if getv(from_object, ['function_response']) is not None:
140
- setv(
141
- to_object,
142
- ['functionResponse'],
143
- getv(from_object, ['function_response']),
133
+ if getv(from_object, ['inlined_embed_content_responses']) is not None:
134
+ raise ValueError(
135
+ 'inlined_embed_content_responses parameter is not supported in'
136
+ ' Vertex AI.'
144
137
  )
145
138
 
146
- if getv(from_object, ['text']) is not None:
147
- setv(to_object, ['text'], getv(from_object, ['text']))
148
-
149
139
  return to_object
150
140
 
151
141
 
152
- def _Content_to_mldev(
142
+ def _BatchJobSource_from_vertex(
153
143
  from_object: Union[dict[str, Any], object],
154
144
  parent_object: Optional[dict[str, Any]] = None,
155
145
  ) -> dict[str, Any]:
156
146
  to_object: dict[str, Any] = {}
157
- if getv(from_object, ['parts']) is not None:
147
+ if getv(from_object, ['instancesFormat']) is not None:
148
+ setv(to_object, ['format'], getv(from_object, ['instancesFormat']))
149
+
150
+ if getv(from_object, ['gcsSource', 'uris']) is not None:
151
+ setv(to_object, ['gcs_uri'], getv(from_object, ['gcsSource', 'uris']))
152
+
153
+ if getv(from_object, ['bigquerySource', 'inputUri']) is not None:
158
154
  setv(
159
155
  to_object,
160
- ['parts'],
161
- [
162
- _Part_to_mldev(item, to_object)
163
- for item in getv(from_object, ['parts'])
164
- ],
156
+ ['bigquery_uri'],
157
+ getv(from_object, ['bigquerySource', 'inputUri']),
165
158
  )
166
159
 
167
- if getv(from_object, ['role']) is not None:
168
- setv(to_object, ['role'], getv(from_object, ['role']))
169
-
170
160
  return to_object
171
161
 
172
162
 
173
- def _Schema_to_mldev(
163
+ def _BatchJobSource_to_mldev(
164
+ api_client: BaseApiClient,
174
165
  from_object: Union[dict[str, Any], object],
175
166
  parent_object: Optional[dict[str, Any]] = None,
176
167
  ) -> dict[str, Any]:
177
168
  to_object: dict[str, Any] = {}
178
- if getv(from_object, ['additional_properties']) is not None:
179
- raise ValueError(
180
- 'additional_properties parameter is not supported in Gemini API.'
181
- )
182
-
183
- if getv(from_object, ['defs']) is not None:
184
- raise ValueError('defs parameter is not supported in Gemini API.')
185
-
186
- if getv(from_object, ['ref']) is not None:
187
- raise ValueError('ref parameter is not supported in Gemini API.')
188
-
189
- if getv(from_object, ['any_of']) is not None:
190
- setv(to_object, ['anyOf'], getv(from_object, ['any_of']))
191
-
192
- if getv(from_object, ['default']) is not None:
193
- setv(to_object, ['default'], getv(from_object, ['default']))
194
-
195
- if getv(from_object, ['description']) is not None:
196
- setv(to_object, ['description'], getv(from_object, ['description']))
197
-
198
- if getv(from_object, ['enum']) is not None:
199
- setv(to_object, ['enum'], getv(from_object, ['enum']))
200
-
201
- if getv(from_object, ['example']) is not None:
202
- setv(to_object, ['example'], getv(from_object, ['example']))
203
-
204
169
  if getv(from_object, ['format']) is not None:
205
- setv(to_object, ['format'], getv(from_object, ['format']))
206
-
207
- if getv(from_object, ['items']) is not None:
208
- setv(to_object, ['items'], getv(from_object, ['items']))
209
-
210
- if getv(from_object, ['max_items']) is not None:
211
- setv(to_object, ['maxItems'], getv(from_object, ['max_items']))
212
-
213
- if getv(from_object, ['max_length']) is not None:
214
- setv(to_object, ['maxLength'], getv(from_object, ['max_length']))
215
-
216
- if getv(from_object, ['max_properties']) is not None:
217
- setv(to_object, ['maxProperties'], getv(from_object, ['max_properties']))
218
-
219
- if getv(from_object, ['maximum']) is not None:
220
- setv(to_object, ['maximum'], getv(from_object, ['maximum']))
221
-
222
- if getv(from_object, ['min_items']) is not None:
223
- setv(to_object, ['minItems'], getv(from_object, ['min_items']))
224
-
225
- if getv(from_object, ['min_length']) is not None:
226
- setv(to_object, ['minLength'], getv(from_object, ['min_length']))
227
-
228
- if getv(from_object, ['min_properties']) is not None:
229
- setv(to_object, ['minProperties'], getv(from_object, ['min_properties']))
230
-
231
- if getv(from_object, ['minimum']) is not None:
232
- setv(to_object, ['minimum'], getv(from_object, ['minimum']))
170
+ raise ValueError('format parameter is not supported in Gemini API.')
233
171
 
234
- if getv(from_object, ['nullable']) is not None:
235
- setv(to_object, ['nullable'], getv(from_object, ['nullable']))
172
+ if getv(from_object, ['gcs_uri']) is not None:
173
+ raise ValueError('gcs_uri parameter is not supported in Gemini API.')
236
174
 
237
- if getv(from_object, ['pattern']) is not None:
238
- setv(to_object, ['pattern'], getv(from_object, ['pattern']))
175
+ if getv(from_object, ['bigquery_uri']) is not None:
176
+ raise ValueError('bigquery_uri parameter is not supported in Gemini API.')
239
177
 
240
- if getv(from_object, ['properties']) is not None:
241
- setv(to_object, ['properties'], getv(from_object, ['properties']))
178
+ if getv(from_object, ['file_name']) is not None:
179
+ setv(to_object, ['fileName'], getv(from_object, ['file_name']))
242
180
 
243
- if getv(from_object, ['property_ordering']) is not None:
181
+ if getv(from_object, ['inlined_requests']) is not None:
244
182
  setv(
245
183
  to_object,
246
- ['propertyOrdering'],
247
- getv(from_object, ['property_ordering']),
184
+ ['requests', 'requests'],
185
+ [
186
+ _InlinedRequest_to_mldev(api_client, item, to_object)
187
+ for item in getv(from_object, ['inlined_requests'])
188
+ ],
248
189
  )
249
190
 
250
- if getv(from_object, ['required']) is not None:
251
- setv(to_object, ['required'], getv(from_object, ['required']))
252
-
253
- if getv(from_object, ['title']) is not None:
254
- setv(to_object, ['title'], getv(from_object, ['title']))
255
-
256
- if getv(from_object, ['type']) is not None:
257
- setv(to_object, ['type'], getv(from_object, ['type']))
258
-
259
191
  return to_object
260
192
 
261
193
 
262
- def _SafetySetting_to_mldev(
194
+ def _BatchJobSource_to_vertex(
263
195
  from_object: Union[dict[str, Any], object],
264
196
  parent_object: Optional[dict[str, Any]] = None,
265
197
  ) -> dict[str, Any]:
266
198
  to_object: dict[str, Any] = {}
267
- if getv(from_object, ['method']) is not None:
268
- raise ValueError('method parameter is not supported in Gemini API.')
199
+ if getv(from_object, ['format']) is not None:
200
+ setv(to_object, ['instancesFormat'], getv(from_object, ['format']))
269
201
 
270
- if getv(from_object, ['category']) is not None:
271
- setv(to_object, ['category'], getv(from_object, ['category']))
202
+ if getv(from_object, ['gcs_uri']) is not None:
203
+ setv(to_object, ['gcsSource', 'uris'], getv(from_object, ['gcs_uri']))
272
204
 
273
- if getv(from_object, ['threshold']) is not None:
274
- setv(to_object, ['threshold'], getv(from_object, ['threshold']))
205
+ if getv(from_object, ['bigquery_uri']) is not None:
206
+ setv(
207
+ to_object,
208
+ ['bigquerySource', 'inputUri'],
209
+ getv(from_object, ['bigquery_uri']),
210
+ )
211
+
212
+ if getv(from_object, ['file_name']) is not None:
213
+ raise ValueError('file_name parameter is not supported in Vertex AI.')
214
+
215
+ if getv(from_object, ['inlined_requests']) is not None:
216
+ raise ValueError(
217
+ 'inlined_requests parameter is not supported in Vertex AI.'
218
+ )
275
219
 
276
220
  return to_object
277
221
 
278
222
 
279
- def _FunctionDeclaration_to_mldev(
223
+ def _BatchJob_from_mldev(
280
224
  from_object: Union[dict[str, Any], object],
281
225
  parent_object: Optional[dict[str, Any]] = None,
282
226
  ) -> dict[str, Any]:
283
227
  to_object: dict[str, Any] = {}
284
- if getv(from_object, ['behavior']) is not None:
285
- setv(to_object, ['behavior'], getv(from_object, ['behavior']))
286
-
287
- if getv(from_object, ['description']) is not None:
288
- setv(to_object, ['description'], getv(from_object, ['description']))
289
-
290
228
  if getv(from_object, ['name']) is not None:
291
229
  setv(to_object, ['name'], getv(from_object, ['name']))
292
230
 
293
- if getv(from_object, ['parameters']) is not None:
294
- setv(to_object, ['parameters'], getv(from_object, ['parameters']))
295
-
296
- if getv(from_object, ['parameters_json_schema']) is not None:
231
+ if getv(from_object, ['metadata', 'displayName']) is not None:
297
232
  setv(
298
233
  to_object,
299
- ['parametersJsonSchema'],
300
- getv(from_object, ['parameters_json_schema']),
234
+ ['display_name'],
235
+ getv(from_object, ['metadata', 'displayName']),
301
236
  )
302
237
 
303
- if getv(from_object, ['response']) is not None:
304
- setv(to_object, ['response'], getv(from_object, ['response']))
305
-
306
- if getv(from_object, ['response_json_schema']) is not None:
238
+ if getv(from_object, ['metadata', 'state']) is not None:
307
239
  setv(
308
240
  to_object,
309
- ['responseJsonSchema'],
310
- getv(from_object, ['response_json_schema']),
241
+ ['state'],
242
+ t.t_job_state(getv(from_object, ['metadata', 'state'])),
311
243
  )
312
244
 
313
- return to_object
314
-
315
-
316
- def _Interval_to_mldev(
317
- from_object: Union[dict[str, Any], object],
318
- parent_object: Optional[dict[str, Any]] = None,
319
- ) -> dict[str, Any]:
320
- to_object: dict[str, Any] = {}
321
- if getv(from_object, ['start_time']) is not None:
322
- setv(to_object, ['startTime'], getv(from_object, ['start_time']))
323
-
324
- if getv(from_object, ['end_time']) is not None:
325
- setv(to_object, ['endTime'], getv(from_object, ['end_time']))
326
-
327
- return to_object
245
+ if getv(from_object, ['metadata', 'createTime']) is not None:
246
+ setv(
247
+ to_object,
248
+ ['create_time'],
249
+ getv(from_object, ['metadata', 'createTime']),
250
+ )
328
251
 
252
+ if getv(from_object, ['metadata', 'endTime']) is not None:
253
+ setv(to_object, ['end_time'], getv(from_object, ['metadata', 'endTime']))
329
254
 
330
- def _GoogleSearch_to_mldev(
331
- from_object: Union[dict[str, Any], object],
332
- parent_object: Optional[dict[str, Any]] = None,
333
- ) -> dict[str, Any]:
334
- to_object: dict[str, Any] = {}
335
- if getv(from_object, ['time_range_filter']) is not None:
255
+ if getv(from_object, ['metadata', 'updateTime']) is not None:
336
256
  setv(
337
257
  to_object,
338
- ['timeRangeFilter'],
339
- _Interval_to_mldev(getv(from_object, ['time_range_filter']), to_object),
258
+ ['update_time'],
259
+ getv(from_object, ['metadata', 'updateTime']),
340
260
  )
341
261
 
342
- if getv(from_object, ['exclude_domains']) is not None:
343
- raise ValueError(
344
- 'exclude_domains parameter is not supported in Gemini API.'
262
+ if getv(from_object, ['metadata', 'model']) is not None:
263
+ setv(to_object, ['model'], getv(from_object, ['metadata', 'model']))
264
+
265
+ if getv(from_object, ['metadata', 'output']) is not None:
266
+ setv(
267
+ to_object,
268
+ ['dest'],
269
+ _BatchJobDestination_from_mldev(
270
+ t.t_recv_batch_job_destination(
271
+ getv(from_object, ['metadata', 'output'])
272
+ ),
273
+ to_object,
274
+ ),
345
275
  )
346
276
 
347
277
  return to_object
348
278
 
349
279
 
350
- def _DynamicRetrievalConfig_to_mldev(
351
- from_object: Union[dict[str, Any], object],
352
- parent_object: Optional[dict[str, Any]] = None,
353
- ) -> dict[str, Any]:
354
- to_object: dict[str, Any] = {}
355
- if getv(from_object, ['mode']) is not None:
356
- setv(to_object, ['mode'], getv(from_object, ['mode']))
357
-
358
- if getv(from_object, ['dynamic_threshold']) is not None:
359
- setv(
360
- to_object,
361
- ['dynamicThreshold'],
362
- getv(from_object, ['dynamic_threshold']),
363
- )
364
-
365
- return to_object
366
-
367
-
368
- def _GoogleSearchRetrieval_to_mldev(
369
- from_object: Union[dict[str, Any], object],
370
- parent_object: Optional[dict[str, Any]] = None,
371
- ) -> dict[str, Any]:
372
- to_object: dict[str, Any] = {}
373
- if getv(from_object, ['dynamic_retrieval_config']) is not None:
374
- setv(
375
- to_object,
376
- ['dynamicRetrievalConfig'],
377
- _DynamicRetrievalConfig_to_mldev(
378
- getv(from_object, ['dynamic_retrieval_config']), to_object
379
- ),
380
- )
381
-
382
- return to_object
383
-
384
-
385
- def _UrlContext_to_mldev(
280
+ def _BatchJob_from_vertex(
386
281
  from_object: Union[dict[str, Any], object],
387
282
  parent_object: Optional[dict[str, Any]] = None,
388
283
  ) -> dict[str, Any]:
389
284
  to_object: dict[str, Any] = {}
285
+ if getv(from_object, ['name']) is not None:
286
+ setv(to_object, ['name'], getv(from_object, ['name']))
390
287
 
391
- return to_object
288
+ if getv(from_object, ['displayName']) is not None:
289
+ setv(to_object, ['display_name'], getv(from_object, ['displayName']))
392
290
 
291
+ if getv(from_object, ['state']) is not None:
292
+ setv(to_object, ['state'], t.t_job_state(getv(from_object, ['state'])))
393
293
 
394
- def _ToolComputerUse_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, ['environment']) is not None:
400
- setv(to_object, ['environment'], getv(from_object, ['environment']))
294
+ if getv(from_object, ['error']) is not None:
295
+ setv(to_object, ['error'], getv(from_object, ['error']))
401
296
 
402
- return to_object
297
+ if getv(from_object, ['createTime']) is not None:
298
+ setv(to_object, ['create_time'], getv(from_object, ['createTime']))
403
299
 
300
+ if getv(from_object, ['startTime']) is not None:
301
+ setv(to_object, ['start_time'], getv(from_object, ['startTime']))
404
302
 
405
- def _Tool_to_mldev(
406
- from_object: Union[dict[str, Any], object],
407
- parent_object: Optional[dict[str, Any]] = None,
408
- ) -> dict[str, Any]:
409
- to_object: dict[str, Any] = {}
410
- if getv(from_object, ['function_declarations']) is not None:
411
- setv(
412
- to_object,
413
- ['functionDeclarations'],
414
- [
415
- _FunctionDeclaration_to_mldev(item, to_object)
416
- for item in getv(from_object, ['function_declarations'])
417
- ],
418
- )
303
+ if getv(from_object, ['endTime']) is not None:
304
+ setv(to_object, ['end_time'], getv(from_object, ['endTime']))
419
305
 
420
- if getv(from_object, ['retrieval']) is not None:
421
- raise ValueError('retrieval parameter is not supported in Gemini API.')
306
+ if getv(from_object, ['updateTime']) is not None:
307
+ setv(to_object, ['update_time'], getv(from_object, ['updateTime']))
422
308
 
423
- if getv(from_object, ['google_search']) is not None:
424
- setv(
425
- to_object,
426
- ['googleSearch'],
427
- _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
428
- )
309
+ if getv(from_object, ['model']) is not None:
310
+ setv(to_object, ['model'], getv(from_object, ['model']))
429
311
 
430
- if getv(from_object, ['google_search_retrieval']) is not None:
312
+ if getv(from_object, ['inputConfig']) is not None:
431
313
  setv(
432
314
  to_object,
433
- ['googleSearchRetrieval'],
434
- _GoogleSearchRetrieval_to_mldev(
435
- getv(from_object, ['google_search_retrieval']), to_object
315
+ ['src'],
316
+ _BatchJobSource_from_vertex(
317
+ getv(from_object, ['inputConfig']), to_object
436
318
  ),
437
319
  )
438
320
 
439
- if getv(from_object, ['enterprise_web_search']) is not None:
440
- raise ValueError(
441
- 'enterprise_web_search parameter is not supported in Gemini API.'
442
- )
443
-
444
- if getv(from_object, ['google_maps']) is not None:
445
- raise ValueError('google_maps parameter is not supported in Gemini API.')
446
-
447
- if getv(from_object, ['url_context']) is not None:
448
- setv(
449
- to_object,
450
- ['urlContext'],
451
- _UrlContext_to_mldev(getv(from_object, ['url_context']), to_object),
452
- )
453
-
454
- if getv(from_object, ['computer_use']) is not None:
321
+ if getv(from_object, ['outputConfig']) is not None:
455
322
  setv(
456
323
  to_object,
457
- ['computerUse'],
458
- _ToolComputerUse_to_mldev(
459
- getv(from_object, ['computer_use']), to_object
324
+ ['dest'],
325
+ _BatchJobDestination_from_vertex(
326
+ t.t_recv_batch_job_destination(getv(from_object, ['outputConfig'])),
327
+ to_object,
460
328
  ),
461
329
  )
462
330
 
463
- if getv(from_object, ['code_execution']) is not None:
464
- setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
465
-
466
- return to_object
467
-
468
-
469
- def _FunctionCallingConfig_to_mldev(
470
- from_object: Union[dict[str, Any], object],
471
- parent_object: Optional[dict[str, Any]] = None,
472
- ) -> dict[str, Any]:
473
- to_object: dict[str, Any] = {}
474
- if getv(from_object, ['mode']) is not None:
475
- setv(to_object, ['mode'], getv(from_object, ['mode']))
476
-
477
- if getv(from_object, ['allowed_function_names']) is not None:
331
+ if getv(from_object, ['completionStats']) is not None:
478
332
  setv(
479
- to_object,
480
- ['allowedFunctionNames'],
481
- getv(from_object, ['allowed_function_names']),
333
+ to_object, ['completion_stats'], getv(from_object, ['completionStats'])
482
334
  )
483
335
 
484
336
  return to_object
485
337
 
486
338
 
487
- def _LatLng_to_mldev(
339
+ def _Blob_to_mldev(
488
340
  from_object: Union[dict[str, Any], object],
489
341
  parent_object: Optional[dict[str, Any]] = None,
490
342
  ) -> dict[str, Any]:
491
343
  to_object: dict[str, Any] = {}
492
- if getv(from_object, ['latitude']) is not None:
493
- setv(to_object, ['latitude'], getv(from_object, ['latitude']))
344
+ if getv(from_object, ['data']) is not None:
345
+ setv(to_object, ['data'], getv(from_object, ['data']))
346
+
347
+ if getv(from_object, ['display_name']) is not None:
348
+ raise ValueError('display_name parameter is not supported in Gemini API.')
494
349
 
495
- if getv(from_object, ['longitude']) is not None:
496
- setv(to_object, ['longitude'], getv(from_object, ['longitude']))
350
+ if getv(from_object, ['mime_type']) is not None:
351
+ setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
497
352
 
498
353
  return to_object
499
354
 
500
355
 
501
- def _RetrievalConfig_to_mldev(
356
+ def _CancelBatchJobParameters_to_mldev(
357
+ api_client: BaseApiClient,
502
358
  from_object: Union[dict[str, Any], object],
503
359
  parent_object: Optional[dict[str, Any]] = None,
504
360
  ) -> dict[str, Any]:
505
361
  to_object: dict[str, Any] = {}
506
- if getv(from_object, ['lat_lng']) is not None:
362
+ if getv(from_object, ['name']) is not None:
507
363
  setv(
508
364
  to_object,
509
- ['latLng'],
510
- _LatLng_to_mldev(getv(from_object, ['lat_lng']), to_object),
365
+ ['_url', 'name'],
366
+ t.t_batch_job_name(api_client, getv(from_object, ['name'])),
511
367
  )
512
368
 
513
- if getv(from_object, ['language_code']) is not None:
514
- setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
515
-
516
369
  return to_object
517
370
 
518
371
 
519
- def _ToolConfig_to_mldev(
372
+ def _CancelBatchJobParameters_to_vertex(
373
+ api_client: BaseApiClient,
520
374
  from_object: Union[dict[str, Any], object],
521
375
  parent_object: Optional[dict[str, Any]] = None,
522
376
  ) -> dict[str, Any]:
523
377
  to_object: dict[str, Any] = {}
524
- if getv(from_object, ['function_calling_config']) is not None:
525
- setv(
526
- to_object,
527
- ['functionCallingConfig'],
528
- _FunctionCallingConfig_to_mldev(
529
- getv(from_object, ['function_calling_config']), to_object
530
- ),
531
- )
532
-
533
- if getv(from_object, ['retrieval_config']) is not None:
378
+ if getv(from_object, ['name']) is not None:
534
379
  setv(
535
380
  to_object,
536
- ['retrievalConfig'],
537
- _RetrievalConfig_to_mldev(
538
- getv(from_object, ['retrieval_config']), to_object
539
- ),
381
+ ['_url', 'name'],
382
+ t.t_batch_job_name(api_client, getv(from_object, ['name'])),
540
383
  )
541
384
 
542
385
  return to_object
543
386
 
544
387
 
545
- def _PrebuiltVoiceConfig_to_mldev(
388
+ def _Candidate_from_mldev(
546
389
  from_object: Union[dict[str, Any], object],
547
390
  parent_object: Optional[dict[str, Any]] = None,
548
391
  ) -> dict[str, Any]:
549
392
  to_object: dict[str, Any] = {}
550
- if getv(from_object, ['voice_name']) is not None:
551
- setv(to_object, ['voiceName'], getv(from_object, ['voice_name']))
552
-
553
- return to_object
554
-
393
+ if getv(from_object, ['content']) is not None:
394
+ setv(to_object, ['content'], getv(from_object, ['content']))
555
395
 
556
- def _VoiceConfig_to_mldev(
557
- from_object: Union[dict[str, Any], object],
558
- parent_object: Optional[dict[str, Any]] = None,
559
- ) -> dict[str, Any]:
560
- to_object: dict[str, Any] = {}
561
- if getv(from_object, ['prebuilt_voice_config']) is not None:
396
+ if getv(from_object, ['citationMetadata']) is not None:
562
397
  setv(
563
398
  to_object,
564
- ['prebuiltVoiceConfig'],
565
- _PrebuiltVoiceConfig_to_mldev(
566
- getv(from_object, ['prebuilt_voice_config']), to_object
399
+ ['citation_metadata'],
400
+ _CitationMetadata_from_mldev(
401
+ getv(from_object, ['citationMetadata']), to_object
567
402
  ),
568
403
  )
569
404
 
570
- return to_object
571
-
572
-
573
- def _SpeakerVoiceConfig_to_mldev(
574
- from_object: Union[dict[str, Any], object],
575
- parent_object: Optional[dict[str, Any]] = None,
576
- ) -> dict[str, Any]:
577
- to_object: dict[str, Any] = {}
578
- if getv(from_object, ['speaker']) is not None:
579
- setv(to_object, ['speaker'], getv(from_object, ['speaker']))
580
-
581
- if getv(from_object, ['voice_config']) is not None:
582
- setv(
583
- to_object,
584
- ['voiceConfig'],
585
- _VoiceConfig_to_mldev(getv(from_object, ['voice_config']), to_object),
586
- )
405
+ if getv(from_object, ['tokenCount']) is not None:
406
+ setv(to_object, ['token_count'], getv(from_object, ['tokenCount']))
587
407
 
588
- return to_object
408
+ if getv(from_object, ['finishReason']) is not None:
409
+ setv(to_object, ['finish_reason'], getv(from_object, ['finishReason']))
589
410
 
411
+ if getv(from_object, ['avgLogprobs']) is not None:
412
+ setv(to_object, ['avg_logprobs'], getv(from_object, ['avgLogprobs']))
590
413
 
591
- def _MultiSpeakerVoiceConfig_to_mldev(
592
- from_object: Union[dict[str, Any], object],
593
- parent_object: Optional[dict[str, Any]] = None,
594
- ) -> dict[str, Any]:
595
- to_object: dict[str, Any] = {}
596
- if getv(from_object, ['speaker_voice_configs']) is not None:
414
+ if getv(from_object, ['groundingMetadata']) is not None:
597
415
  setv(
598
416
  to_object,
599
- ['speakerVoiceConfigs'],
600
- [
601
- _SpeakerVoiceConfig_to_mldev(item, to_object)
602
- for item in getv(from_object, ['speaker_voice_configs'])
603
- ],
417
+ ['grounding_metadata'],
418
+ getv(from_object, ['groundingMetadata']),
604
419
  )
605
420
 
606
- return to_object
421
+ if getv(from_object, ['index']) is not None:
422
+ setv(to_object, ['index'], getv(from_object, ['index']))
607
423
 
424
+ if getv(from_object, ['logprobsResult']) is not None:
425
+ setv(to_object, ['logprobs_result'], getv(from_object, ['logprobsResult']))
608
426
 
609
- def _SpeechConfig_to_mldev(
610
- from_object: Union[dict[str, Any], object],
611
- parent_object: Optional[dict[str, Any]] = None,
612
- ) -> dict[str, Any]:
613
- to_object: dict[str, Any] = {}
614
- if getv(from_object, ['voice_config']) is not None:
427
+ if getv(from_object, ['safetyRatings']) is not None:
615
428
  setv(
616
429
  to_object,
617
- ['voiceConfig'],
618
- _VoiceConfig_to_mldev(getv(from_object, ['voice_config']), to_object),
430
+ ['safety_ratings'],
431
+ [item for item in getv(from_object, ['safetyRatings'])],
619
432
  )
620
433
 
621
- if getv(from_object, ['multi_speaker_voice_config']) is not None:
434
+ if getv(from_object, ['urlContextMetadata']) is not None:
622
435
  setv(
623
436
  to_object,
624
- ['multiSpeakerVoiceConfig'],
625
- _MultiSpeakerVoiceConfig_to_mldev(
626
- getv(from_object, ['multi_speaker_voice_config']), to_object
627
- ),
628
- )
629
-
630
- if getv(from_object, ['language_code']) is not None:
631
- setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
632
-
633
- return to_object
634
-
635
-
636
- def _ThinkingConfig_to_mldev(
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, ['include_thoughts']) is not None:
642
- setv(
643
- to_object, ['includeThoughts'], getv(from_object, ['include_thoughts'])
437
+ ['url_context_metadata'],
438
+ getv(from_object, ['urlContextMetadata']),
644
439
  )
645
440
 
646
- if getv(from_object, ['thinking_budget']) is not None:
647
- setv(to_object, ['thinkingBudget'], getv(from_object, ['thinking_budget']))
648
-
649
441
  return to_object
650
442
 
651
443
 
652
- def _GenerateContentConfig_to_mldev(
653
- api_client: BaseApiClient,
444
+ def _CitationMetadata_from_mldev(
654
445
  from_object: Union[dict[str, Any], object],
655
446
  parent_object: Optional[dict[str, Any]] = None,
656
447
  ) -> dict[str, Any]:
657
448
  to_object: dict[str, Any] = {}
658
-
659
- if getv(from_object, ['system_instruction']) is not None:
660
- setv(
661
- parent_object,
662
- ['systemInstruction'],
663
- _Content_to_mldev(
664
- t.t_content(getv(from_object, ['system_instruction'])), to_object
665
- ),
666
- )
667
-
668
- if getv(from_object, ['temperature']) is not None:
669
- setv(to_object, ['temperature'], getv(from_object, ['temperature']))
670
-
671
- if getv(from_object, ['top_p']) is not None:
672
- setv(to_object, ['topP'], getv(from_object, ['top_p']))
673
-
674
- if getv(from_object, ['top_k']) is not None:
675
- setv(to_object, ['topK'], getv(from_object, ['top_k']))
676
-
677
- if getv(from_object, ['candidate_count']) is not None:
678
- setv(to_object, ['candidateCount'], getv(from_object, ['candidate_count']))
679
-
680
- if getv(from_object, ['max_output_tokens']) is not None:
681
- setv(
682
- to_object, ['maxOutputTokens'], getv(from_object, ['max_output_tokens'])
683
- )
684
-
685
- if getv(from_object, ['stop_sequences']) is not None:
686
- setv(to_object, ['stopSequences'], getv(from_object, ['stop_sequences']))
687
-
688
- if getv(from_object, ['response_logprobs']) is not None:
689
- setv(
690
- to_object,
691
- ['responseLogprobs'],
692
- getv(from_object, ['response_logprobs']),
693
- )
694
-
695
- if getv(from_object, ['logprobs']) is not None:
696
- setv(to_object, ['logprobs'], getv(from_object, ['logprobs']))
697
-
698
- if getv(from_object, ['presence_penalty']) is not None:
699
- setv(
700
- to_object, ['presencePenalty'], getv(from_object, ['presence_penalty'])
701
- )
702
-
703
- if getv(from_object, ['frequency_penalty']) is not None:
704
- setv(
705
- to_object,
706
- ['frequencyPenalty'],
707
- getv(from_object, ['frequency_penalty']),
708
- )
709
-
710
- if getv(from_object, ['seed']) is not None:
711
- setv(to_object, ['seed'], getv(from_object, ['seed']))
712
-
713
- if getv(from_object, ['response_mime_type']) is not None:
714
- setv(
715
- to_object,
716
- ['responseMimeType'],
717
- getv(from_object, ['response_mime_type']),
718
- )
719
-
720
- if getv(from_object, ['response_schema']) is not None:
721
- setv(
722
- to_object,
723
- ['responseSchema'],
724
- _Schema_to_mldev(
725
- t.t_schema(api_client, getv(from_object, ['response_schema'])),
726
- to_object,
727
- ),
728
- )
729
-
730
- if getv(from_object, ['response_json_schema']) is not None:
731
- setv(
732
- to_object,
733
- ['responseJsonSchema'],
734
- getv(from_object, ['response_json_schema']),
735
- )
736
-
737
- if getv(from_object, ['routing_config']) is not None:
738
- raise ValueError('routing_config parameter is not supported in Gemini API.')
739
-
740
- if getv(from_object, ['model_selection_config']) is not None:
741
- raise ValueError(
742
- 'model_selection_config parameter is not supported in Gemini API.'
743
- )
744
-
745
- if getv(from_object, ['safety_settings']) is not None:
746
- setv(
747
- parent_object,
748
- ['safetySettings'],
749
- [
750
- _SafetySetting_to_mldev(item, to_object)
751
- for item in getv(from_object, ['safety_settings'])
752
- ],
753
- )
754
-
755
- if getv(from_object, ['tools']) is not None:
756
- setv(
757
- parent_object,
758
- ['tools'],
759
- [
760
- _Tool_to_mldev(t.t_tool(api_client, item), to_object)
761
- for item in t.t_tools(api_client, getv(from_object, ['tools']))
762
- ],
763
- )
764
-
765
- if getv(from_object, ['tool_config']) is not None:
766
- setv(
767
- parent_object,
768
- ['toolConfig'],
769
- _ToolConfig_to_mldev(getv(from_object, ['tool_config']), to_object),
770
- )
771
-
772
- if getv(from_object, ['labels']) is not None:
773
- raise ValueError('labels parameter is not supported in Gemini API.')
774
-
775
- if getv(from_object, ['cached_content']) is not None:
776
- setv(
777
- parent_object,
778
- ['cachedContent'],
779
- t.t_cached_content_name(
780
- api_client, getv(from_object, ['cached_content'])
781
- ),
782
- )
783
-
784
- if getv(from_object, ['response_modalities']) is not None:
785
- setv(
786
- to_object,
787
- ['responseModalities'],
788
- getv(from_object, ['response_modalities']),
789
- )
790
-
791
- if getv(from_object, ['media_resolution']) is not None:
792
- setv(
793
- to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
794
- )
795
-
796
- if getv(from_object, ['speech_config']) is not None:
797
- setv(
798
- to_object,
799
- ['speechConfig'],
800
- _SpeechConfig_to_mldev(
801
- t.t_speech_config(getv(from_object, ['speech_config'])), to_object
802
- ),
803
- )
804
-
805
- if getv(from_object, ['audio_timestamp']) is not None:
806
- raise ValueError(
807
- 'audio_timestamp parameter is not supported in Gemini API.'
808
- )
809
-
810
- if getv(from_object, ['thinking_config']) is not None:
449
+ if getv(from_object, ['citationSources']) is not None:
811
450
  setv(
812
451
  to_object,
813
- ['thinkingConfig'],
814
- _ThinkingConfig_to_mldev(
815
- getv(from_object, ['thinking_config']), to_object
816
- ),
452
+ ['citations'],
453
+ [item for item in getv(from_object, ['citationSources'])],
817
454
  )
818
455
 
819
456
  return to_object
820
457
 
821
458
 
822
- def _InlinedRequest_to_mldev(
823
- api_client: BaseApiClient,
459
+ def _Content_to_mldev(
824
460
  from_object: Union[dict[str, Any], object],
825
461
  parent_object: Optional[dict[str, Any]] = None,
826
462
  ) -> dict[str, Any]:
827
463
  to_object: dict[str, Any] = {}
828
- if getv(from_object, ['model']) is not None:
829
- setv(
830
- to_object,
831
- ['request', 'model'],
832
- t.t_model(api_client, getv(from_object, ['model'])),
833
- )
834
-
835
- if getv(from_object, ['contents']) is not None:
464
+ if getv(from_object, ['parts']) is not None:
836
465
  setv(
837
466
  to_object,
838
- ['request', 'contents'],
467
+ ['parts'],
839
468
  [
840
- _Content_to_mldev(item, to_object)
841
- for item in t.t_contents(getv(from_object, ['contents']))
469
+ _Part_to_mldev(item, to_object)
470
+ for item in getv(from_object, ['parts'])
842
471
  ],
843
472
  )
844
473
 
845
- if getv(from_object, ['config']) is not None:
846
- setv(
847
- to_object,
848
- ['request', 'generationConfig'],
849
- _GenerateContentConfig_to_mldev(
850
- api_client, getv(from_object, ['config']), to_object
851
- ),
852
- )
474
+ if getv(from_object, ['role']) is not None:
475
+ setv(to_object, ['role'], getv(from_object, ['role']))
853
476
 
854
477
  return to_object
855
478
 
856
479
 
857
- def _BatchJobSource_to_mldev(
858
- api_client: BaseApiClient,
480
+ def _CreateBatchJobConfig_to_mldev(
859
481
  from_object: Union[dict[str, Any], object],
860
482
  parent_object: Optional[dict[str, Any]] = None,
861
483
  ) -> dict[str, Any]:
862
484
  to_object: dict[str, Any] = {}
863
- if getv(from_object, ['format']) is not None:
864
- raise ValueError('format parameter is not supported in Gemini API.')
865
-
866
- if getv(from_object, ['gcs_uri']) is not None:
867
- raise ValueError('gcs_uri parameter is not supported in Gemini API.')
868
-
869
- if getv(from_object, ['bigquery_uri']) is not None:
870
- raise ValueError('bigquery_uri parameter is not supported in Gemini API.')
871
485
 
872
- if getv(from_object, ['file_name']) is not None:
873
- setv(to_object, ['fileName'], getv(from_object, ['file_name']))
874
-
875
- if getv(from_object, ['inlined_requests']) is not None:
486
+ if getv(from_object, ['display_name']) is not None:
876
487
  setv(
877
- to_object,
878
- ['requests', 'requests'],
879
- [
880
- _InlinedRequest_to_mldev(api_client, item, to_object)
881
- for item in getv(from_object, ['inlined_requests'])
882
- ],
488
+ parent_object,
489
+ ['batch', 'displayName'],
490
+ getv(from_object, ['display_name']),
883
491
  )
884
492
 
493
+ if getv(from_object, ['dest']) is not None:
494
+ raise ValueError('dest parameter is not supported in Gemini API.')
495
+
885
496
  return to_object
886
497
 
887
498
 
888
- def _CreateBatchJobConfig_to_mldev(
499
+ def _CreateBatchJobConfig_to_vertex(
889
500
  from_object: Union[dict[str, Any], object],
890
501
  parent_object: Optional[dict[str, Any]] = None,
891
502
  ) -> dict[str, Any]:
892
503
  to_object: dict[str, Any] = {}
893
504
 
894
505
  if getv(from_object, ['display_name']) is not None:
506
+ setv(parent_object, ['displayName'], getv(from_object, ['display_name']))
507
+
508
+ if getv(from_object, ['dest']) is not None:
895
509
  setv(
896
510
  parent_object,
897
- ['batch', 'displayName'],
898
- getv(from_object, ['display_name']),
511
+ ['outputConfig'],
512
+ _BatchJobDestination_to_vertex(
513
+ t.t_batch_job_destination(getv(from_object, ['dest'])), to_object
514
+ ),
899
515
  )
900
516
 
901
- if getv(from_object, ['dest']) is not None:
902
- raise ValueError('dest parameter is not supported in Gemini API.')
903
-
904
517
  return to_object
905
518
 
906
519
 
@@ -929,95 +542,103 @@ def _CreateBatchJobParameters_to_mldev(
929
542
  )
930
543
 
931
544
  if getv(from_object, ['config']) is not None:
932
- setv(
933
- to_object,
934
- ['config'],
935
- _CreateBatchJobConfig_to_mldev(
936
- getv(from_object, ['config']), to_object
937
- ),
938
- )
545
+ _CreateBatchJobConfig_to_mldev(getv(from_object, ['config']), to_object)
939
546
 
940
547
  return to_object
941
548
 
942
549
 
943
- def _GetBatchJobParameters_to_mldev(
550
+ def _CreateBatchJobParameters_to_vertex(
944
551
  api_client: BaseApiClient,
945
552
  from_object: Union[dict[str, Any], object],
946
553
  parent_object: Optional[dict[str, Any]] = None,
947
554
  ) -> dict[str, Any]:
948
555
  to_object: dict[str, Any] = {}
949
- if getv(from_object, ['name']) is not None:
556
+ if getv(from_object, ['model']) is not None:
950
557
  setv(
951
558
  to_object,
952
- ['_url', 'name'],
953
- t.t_batch_job_name(api_client, getv(from_object, ['name'])),
559
+ ['model'],
560
+ t.t_model(api_client, getv(from_object, ['model'])),
561
+ )
562
+
563
+ if getv(from_object, ['src']) is not None:
564
+ setv(
565
+ to_object,
566
+ ['inputConfig'],
567
+ _BatchJobSource_to_vertex(
568
+ t.t_batch_job_source(api_client, getv(from_object, ['src'])),
569
+ to_object,
570
+ ),
954
571
  )
955
572
 
956
573
  if getv(from_object, ['config']) is not None:
957
- setv(to_object, ['config'], getv(from_object, ['config']))
574
+ _CreateBatchJobConfig_to_vertex(getv(from_object, ['config']), to_object)
958
575
 
959
576
  return to_object
960
577
 
961
578
 
962
- def _CancelBatchJobParameters_to_mldev(
963
- api_client: BaseApiClient,
579
+ def _CreateEmbeddingsBatchJobConfig_to_mldev(
964
580
  from_object: Union[dict[str, Any], object],
965
581
  parent_object: Optional[dict[str, Any]] = None,
966
582
  ) -> dict[str, Any]:
967
583
  to_object: dict[str, Any] = {}
968
- if getv(from_object, ['name']) is not None:
584
+
585
+ if getv(from_object, ['display_name']) is not None:
969
586
  setv(
970
- to_object,
971
- ['_url', 'name'],
972
- t.t_batch_job_name(api_client, getv(from_object, ['name'])),
587
+ parent_object,
588
+ ['batch', 'displayName'],
589
+ getv(from_object, ['display_name']),
973
590
  )
974
591
 
975
- if getv(from_object, ['config']) is not None:
976
- setv(to_object, ['config'], getv(from_object, ['config']))
977
-
978
592
  return to_object
979
593
 
980
594
 
981
- def _ListBatchJobsConfig_to_mldev(
595
+ def _CreateEmbeddingsBatchJobParameters_to_mldev(
596
+ api_client: BaseApiClient,
982
597
  from_object: Union[dict[str, Any], object],
983
598
  parent_object: Optional[dict[str, Any]] = None,
984
599
  ) -> dict[str, Any]:
985
600
  to_object: dict[str, Any] = {}
986
-
987
- if getv(from_object, ['page_size']) is not None:
601
+ if getv(from_object, ['model']) is not None:
988
602
  setv(
989
- parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
603
+ to_object,
604
+ ['_url', 'model'],
605
+ t.t_model(api_client, getv(from_object, ['model'])),
990
606
  )
991
607
 
992
- if getv(from_object, ['page_token']) is not None:
608
+ if getv(from_object, ['src']) is not None:
993
609
  setv(
994
- parent_object,
995
- ['_query', 'pageToken'],
996
- getv(from_object, ['page_token']),
610
+ to_object,
611
+ ['batch', 'inputConfig'],
612
+ _EmbeddingsBatchJobSource_to_mldev(
613
+ api_client, getv(from_object, ['src']), to_object
614
+ ),
997
615
  )
998
616
 
999
- if getv(from_object, ['filter']) is not None:
1000
- raise ValueError('filter parameter is not supported in Gemini API.')
617
+ if getv(from_object, ['config']) is not None:
618
+ _CreateEmbeddingsBatchJobConfig_to_mldev(
619
+ getv(from_object, ['config']), to_object
620
+ )
1001
621
 
1002
622
  return to_object
1003
623
 
1004
624
 
1005
- def _ListBatchJobsParameters_to_mldev(
625
+ def _DeleteBatchJobParameters_to_mldev(
626
+ api_client: BaseApiClient,
1006
627
  from_object: Union[dict[str, Any], object],
1007
628
  parent_object: Optional[dict[str, Any]] = None,
1008
629
  ) -> dict[str, Any]:
1009
630
  to_object: dict[str, Any] = {}
1010
- if getv(from_object, ['config']) is not None:
631
+ if getv(from_object, ['name']) is not None:
1011
632
  setv(
1012
633
  to_object,
1013
- ['config'],
1014
- _ListBatchJobsConfig_to_mldev(getv(from_object, ['config']), to_object),
634
+ ['_url', 'name'],
635
+ t.t_batch_job_name(api_client, getv(from_object, ['name'])),
1015
636
  )
1016
637
 
1017
638
  return to_object
1018
639
 
1019
640
 
1020
- def _DeleteBatchJobParameters_to_mldev(
641
+ def _DeleteBatchJobParameters_to_vertex(
1021
642
  api_client: BaseApiClient,
1022
643
  from_object: Union[dict[str, Any], object],
1023
644
  parent_object: Optional[dict[str, Any]] = None,
@@ -1030,513 +651,528 @@ def _DeleteBatchJobParameters_to_mldev(
1030
651
  t.t_batch_job_name(api_client, getv(from_object, ['name'])),
1031
652
  )
1032
653
 
1033
- if getv(from_object, ['config']) is not None:
1034
- setv(to_object, ['config'], getv(from_object, ['config']))
1035
-
1036
654
  return to_object
1037
655
 
1038
656
 
1039
- def _BatchJobSource_to_vertex(
657
+ def _DeleteResourceJob_from_mldev(
1040
658
  from_object: Union[dict[str, Any], object],
1041
659
  parent_object: Optional[dict[str, Any]] = None,
1042
660
  ) -> dict[str, Any]:
1043
661
  to_object: dict[str, Any] = {}
1044
- if getv(from_object, ['format']) is not None:
1045
- setv(to_object, ['instancesFormat'], getv(from_object, ['format']))
1046
-
1047
- if getv(from_object, ['gcs_uri']) is not None:
1048
- setv(to_object, ['gcsSource', 'uris'], getv(from_object, ['gcs_uri']))
1049
-
1050
- if getv(from_object, ['bigquery_uri']) is not None:
662
+ if getv(from_object, ['sdkHttpResponse']) is not None:
1051
663
  setv(
1052
- to_object,
1053
- ['bigquerySource', 'inputUri'],
1054
- getv(from_object, ['bigquery_uri']),
664
+ to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
1055
665
  )
1056
666
 
1057
- if getv(from_object, ['file_name']) is not None:
1058
- raise ValueError('file_name parameter is not supported in Vertex AI.')
667
+ if getv(from_object, ['name']) is not None:
668
+ setv(to_object, ['name'], getv(from_object, ['name']))
1059
669
 
1060
- if getv(from_object, ['inlined_requests']) is not None:
1061
- raise ValueError(
1062
- 'inlined_requests parameter is not supported in Vertex AI.'
1063
- )
670
+ if getv(from_object, ['done']) is not None:
671
+ setv(to_object, ['done'], getv(from_object, ['done']))
672
+
673
+ if getv(from_object, ['error']) is not None:
674
+ setv(to_object, ['error'], getv(from_object, ['error']))
1064
675
 
1065
676
  return to_object
1066
677
 
1067
678
 
1068
- def _BatchJobDestination_to_vertex(
679
+ def _DeleteResourceJob_from_vertex(
1069
680
  from_object: Union[dict[str, Any], object],
1070
681
  parent_object: Optional[dict[str, Any]] = None,
1071
682
  ) -> dict[str, Any]:
1072
683
  to_object: dict[str, Any] = {}
1073
- if getv(from_object, ['format']) is not None:
1074
- setv(to_object, ['predictionsFormat'], getv(from_object, ['format']))
1075
-
1076
- if getv(from_object, ['gcs_uri']) is not None:
684
+ if getv(from_object, ['sdkHttpResponse']) is not None:
1077
685
  setv(
1078
- to_object,
1079
- ['gcsDestination', 'outputUriPrefix'],
1080
- getv(from_object, ['gcs_uri']),
686
+ to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
1081
687
  )
1082
688
 
1083
- if getv(from_object, ['bigquery_uri']) is not None:
1084
- setv(
1085
- to_object,
1086
- ['bigqueryDestination', 'outputUri'],
1087
- getv(from_object, ['bigquery_uri']),
1088
- )
689
+ if getv(from_object, ['name']) is not None:
690
+ setv(to_object, ['name'], getv(from_object, ['name']))
1089
691
 
1090
- if getv(from_object, ['file_name']) is not None:
1091
- raise ValueError('file_name parameter is not supported in Vertex AI.')
692
+ if getv(from_object, ['done']) is not None:
693
+ setv(to_object, ['done'], getv(from_object, ['done']))
1092
694
 
1093
- if getv(from_object, ['inlined_responses']) is not None:
1094
- raise ValueError(
1095
- 'inlined_responses parameter is not supported in Vertex AI.'
1096
- )
695
+ if getv(from_object, ['error']) is not None:
696
+ setv(to_object, ['error'], getv(from_object, ['error']))
1097
697
 
1098
698
  return to_object
1099
699
 
1100
700
 
1101
- def _CreateBatchJobConfig_to_vertex(
701
+ def _EmbedContentBatch_to_mldev(
702
+ api_client: BaseApiClient,
1102
703
  from_object: Union[dict[str, Any], object],
1103
704
  parent_object: Optional[dict[str, Any]] = None,
1104
705
  ) -> dict[str, Any]:
1105
706
  to_object: dict[str, Any] = {}
1106
-
1107
- if getv(from_object, ['display_name']) is not None:
1108
- setv(parent_object, ['displayName'], getv(from_object, ['display_name']))
1109
-
1110
- if getv(from_object, ['dest']) is not None:
707
+ if getv(from_object, ['contents']) is not None:
1111
708
  setv(
1112
- parent_object,
1113
- ['outputConfig'],
1114
- _BatchJobDestination_to_vertex(
1115
- t.t_batch_job_destination(getv(from_object, ['dest'])), to_object
1116
- ),
709
+ to_object,
710
+ ['requests[]', 'request', 'content'],
711
+ [
712
+ item
713
+ for item in t.t_contents_for_embed(
714
+ api_client, getv(from_object, ['contents'])
715
+ )
716
+ ],
1117
717
  )
1118
718
 
719
+ if getv(from_object, ['config']) is not None:
720
+ setv(
721
+ to_object,
722
+ ['_self'],
723
+ _EmbedContentConfig_to_mldev(getv(from_object, ['config']), to_object),
724
+ )
725
+ movev(to_object, {'requests[].*': 'requests[].request.*'})
1119
726
  return to_object
1120
727
 
1121
728
 
1122
- def _CreateBatchJobParameters_to_vertex(
1123
- api_client: BaseApiClient,
729
+ def _EmbedContentConfig_to_mldev(
1124
730
  from_object: Union[dict[str, Any], object],
1125
731
  parent_object: Optional[dict[str, Any]] = None,
1126
732
  ) -> dict[str, Any]:
1127
733
  to_object: dict[str, Any] = {}
1128
- if getv(from_object, ['model']) is not None:
1129
- setv(
1130
- to_object,
1131
- ['model'],
1132
- t.t_model(api_client, getv(from_object, ['model'])),
1133
- )
1134
734
 
1135
- if getv(from_object, ['src']) is not None:
735
+ if getv(from_object, ['task_type']) is not None:
1136
736
  setv(
1137
- to_object,
1138
- ['inputConfig'],
1139
- _BatchJobSource_to_vertex(
1140
- t.t_batch_job_source(api_client, getv(from_object, ['src'])),
1141
- to_object,
1142
- ),
737
+ parent_object,
738
+ ['requests[]', 'taskType'],
739
+ getv(from_object, ['task_type']),
1143
740
  )
1144
741
 
1145
- if getv(from_object, ['config']) is not None:
742
+ if getv(from_object, ['title']) is not None:
743
+ setv(parent_object, ['requests[]', 'title'], getv(from_object, ['title']))
744
+
745
+ if getv(from_object, ['output_dimensionality']) is not None:
1146
746
  setv(
1147
- to_object,
1148
- ['config'],
1149
- _CreateBatchJobConfig_to_vertex(
1150
- getv(from_object, ['config']), to_object
1151
- ),
747
+ parent_object,
748
+ ['requests[]', 'outputDimensionality'],
749
+ getv(from_object, ['output_dimensionality']),
1152
750
  )
1153
751
 
752
+ if getv(from_object, ['mime_type']) is not None:
753
+ raise ValueError('mime_type parameter is not supported in Gemini API.')
754
+
755
+ if getv(from_object, ['auto_truncate']) is not None:
756
+ raise ValueError('auto_truncate parameter is not supported in Gemini API.')
757
+
1154
758
  return to_object
1155
759
 
1156
760
 
1157
- def _GetBatchJobParameters_to_vertex(
761
+ def _EmbeddingsBatchJobSource_to_mldev(
1158
762
  api_client: BaseApiClient,
1159
763
  from_object: Union[dict[str, Any], object],
1160
764
  parent_object: Optional[dict[str, Any]] = None,
1161
765
  ) -> dict[str, Any]:
1162
766
  to_object: dict[str, Any] = {}
1163
- if getv(from_object, ['name']) is not None:
767
+ if getv(from_object, ['file_name']) is not None:
768
+ setv(to_object, ['file_name'], getv(from_object, ['file_name']))
769
+
770
+ if getv(from_object, ['inlined_requests']) is not None:
1164
771
  setv(
1165
772
  to_object,
1166
- ['_url', 'name'],
1167
- t.t_batch_job_name(api_client, getv(from_object, ['name'])),
773
+ ['requests'],
774
+ _EmbedContentBatch_to_mldev(
775
+ api_client, getv(from_object, ['inlined_requests']), to_object
776
+ ),
1168
777
  )
1169
778
 
1170
- if getv(from_object, ['config']) is not None:
1171
- setv(to_object, ['config'], getv(from_object, ['config']))
1172
-
1173
779
  return to_object
1174
780
 
1175
781
 
1176
- def _CancelBatchJobParameters_to_vertex(
1177
- api_client: BaseApiClient,
782
+ def _FileData_to_mldev(
1178
783
  from_object: Union[dict[str, Any], object],
1179
784
  parent_object: Optional[dict[str, Any]] = None,
1180
785
  ) -> dict[str, Any]:
1181
786
  to_object: dict[str, Any] = {}
1182
- if getv(from_object, ['name']) is not None:
1183
- setv(
1184
- to_object,
1185
- ['_url', 'name'],
1186
- t.t_batch_job_name(api_client, getv(from_object, ['name'])),
1187
- )
787
+ if getv(from_object, ['display_name']) is not None:
788
+ raise ValueError('display_name parameter is not supported in Gemini API.')
1188
789
 
1189
- if getv(from_object, ['config']) is not None:
1190
- setv(to_object, ['config'], getv(from_object, ['config']))
790
+ if getv(from_object, ['file_uri']) is not None:
791
+ setv(to_object, ['fileUri'], getv(from_object, ['file_uri']))
792
+
793
+ if getv(from_object, ['mime_type']) is not None:
794
+ setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
1191
795
 
1192
796
  return to_object
1193
797
 
1194
798
 
1195
- def _ListBatchJobsConfig_to_vertex(
799
+ def _FunctionCall_to_mldev(
1196
800
  from_object: Union[dict[str, Any], object],
1197
801
  parent_object: Optional[dict[str, Any]] = None,
1198
802
  ) -> dict[str, Any]:
1199
803
  to_object: dict[str, Any] = {}
804
+ if getv(from_object, ['id']) is not None:
805
+ setv(to_object, ['id'], getv(from_object, ['id']))
1200
806
 
1201
- if getv(from_object, ['page_size']) is not None:
1202
- setv(
1203
- parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
1204
- )
807
+ if getv(from_object, ['args']) is not None:
808
+ setv(to_object, ['args'], getv(from_object, ['args']))
1205
809
 
1206
- if getv(from_object, ['page_token']) is not None:
1207
- setv(
1208
- parent_object,
1209
- ['_query', 'pageToken'],
1210
- getv(from_object, ['page_token']),
1211
- )
810
+ if getv(from_object, ['name']) is not None:
811
+ setv(to_object, ['name'], getv(from_object, ['name']))
1212
812
 
1213
- if getv(from_object, ['filter']) is not None:
1214
- setv(parent_object, ['_query', 'filter'], getv(from_object, ['filter']))
813
+ if getv(from_object, ['partial_args']) is not None:
814
+ raise ValueError('partial_args parameter is not supported in Gemini API.')
815
+
816
+ if getv(from_object, ['will_continue']) is not None:
817
+ raise ValueError('will_continue parameter is not supported in Gemini API.')
1215
818
 
1216
819
  return to_object
1217
820
 
1218
821
 
1219
- def _ListBatchJobsParameters_to_vertex(
822
+ def _FunctionCallingConfig_to_mldev(
1220
823
  from_object: Union[dict[str, Any], object],
1221
824
  parent_object: Optional[dict[str, Any]] = None,
1222
825
  ) -> dict[str, Any]:
1223
826
  to_object: dict[str, Any] = {}
1224
- if getv(from_object, ['config']) is not None:
827
+ if getv(from_object, ['mode']) is not None:
828
+ setv(to_object, ['mode'], getv(from_object, ['mode']))
829
+
830
+ if getv(from_object, ['allowed_function_names']) is not None:
1225
831
  setv(
1226
832
  to_object,
1227
- ['config'],
1228
- _ListBatchJobsConfig_to_vertex(
1229
- getv(from_object, ['config']), to_object
1230
- ),
833
+ ['allowedFunctionNames'],
834
+ getv(from_object, ['allowed_function_names']),
835
+ )
836
+
837
+ if getv(from_object, ['stream_function_call_arguments']) is not None:
838
+ raise ValueError(
839
+ 'stream_function_call_arguments parameter is not supported in Gemini'
840
+ ' API.'
1231
841
  )
1232
842
 
1233
843
  return to_object
1234
844
 
1235
845
 
1236
- def _DeleteBatchJobParameters_to_vertex(
846
+ def _GenerateContentConfig_to_mldev(
1237
847
  api_client: BaseApiClient,
1238
848
  from_object: Union[dict[str, Any], object],
1239
849
  parent_object: Optional[dict[str, Any]] = None,
1240
850
  ) -> dict[str, Any]:
1241
851
  to_object: dict[str, Any] = {}
1242
- if getv(from_object, ['name']) is not None:
852
+
853
+ if getv(from_object, ['system_instruction']) is not None:
1243
854
  setv(
1244
- to_object,
1245
- ['_url', 'name'],
1246
- t.t_batch_job_name(api_client, getv(from_object, ['name'])),
855
+ parent_object,
856
+ ['systemInstruction'],
857
+ _Content_to_mldev(
858
+ t.t_content(getv(from_object, ['system_instruction'])), to_object
859
+ ),
1247
860
  )
1248
861
 
1249
- if getv(from_object, ['config']) is not None:
1250
- setv(to_object, ['config'], getv(from_object, ['config']))
862
+ if getv(from_object, ['temperature']) is not None:
863
+ setv(to_object, ['temperature'], getv(from_object, ['temperature']))
1251
864
 
1252
- return to_object
865
+ if getv(from_object, ['top_p']) is not None:
866
+ setv(to_object, ['topP'], getv(from_object, ['top_p']))
1253
867
 
868
+ if getv(from_object, ['top_k']) is not None:
869
+ setv(to_object, ['topK'], getv(from_object, ['top_k']))
1254
870
 
1255
- def _VideoMetadata_from_mldev(
1256
- from_object: Union[dict[str, Any], object],
1257
- parent_object: Optional[dict[str, Any]] = None,
1258
- ) -> dict[str, Any]:
1259
- to_object: dict[str, Any] = {}
1260
- if getv(from_object, ['fps']) is not None:
1261
- setv(to_object, ['fps'], getv(from_object, ['fps']))
871
+ if getv(from_object, ['candidate_count']) is not None:
872
+ setv(to_object, ['candidateCount'], getv(from_object, ['candidate_count']))
1262
873
 
1263
- if getv(from_object, ['endOffset']) is not None:
1264
- setv(to_object, ['end_offset'], getv(from_object, ['endOffset']))
874
+ if getv(from_object, ['max_output_tokens']) is not None:
875
+ setv(
876
+ to_object, ['maxOutputTokens'], getv(from_object, ['max_output_tokens'])
877
+ )
1265
878
 
1266
- if getv(from_object, ['startOffset']) is not None:
1267
- setv(to_object, ['start_offset'], getv(from_object, ['startOffset']))
879
+ if getv(from_object, ['stop_sequences']) is not None:
880
+ setv(to_object, ['stopSequences'], getv(from_object, ['stop_sequences']))
1268
881
 
1269
- return to_object
882
+ if getv(from_object, ['response_logprobs']) is not None:
883
+ setv(
884
+ to_object,
885
+ ['responseLogprobs'],
886
+ getv(from_object, ['response_logprobs']),
887
+ )
1270
888
 
889
+ if getv(from_object, ['logprobs']) is not None:
890
+ setv(to_object, ['logprobs'], getv(from_object, ['logprobs']))
1271
891
 
1272
- def _Blob_from_mldev(
1273
- from_object: Union[dict[str, Any], object],
1274
- parent_object: Optional[dict[str, Any]] = None,
1275
- ) -> dict[str, Any]:
1276
- to_object: dict[str, Any] = {}
892
+ if getv(from_object, ['presence_penalty']) is not None:
893
+ setv(
894
+ to_object, ['presencePenalty'], getv(from_object, ['presence_penalty'])
895
+ )
1277
896
 
1278
- if getv(from_object, ['data']) is not None:
1279
- setv(to_object, ['data'], getv(from_object, ['data']))
897
+ if getv(from_object, ['frequency_penalty']) is not None:
898
+ setv(
899
+ to_object,
900
+ ['frequencyPenalty'],
901
+ getv(from_object, ['frequency_penalty']),
902
+ )
1280
903
 
1281
- if getv(from_object, ['mimeType']) is not None:
1282
- setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
904
+ if getv(from_object, ['seed']) is not None:
905
+ setv(to_object, ['seed'], getv(from_object, ['seed']))
1283
906
 
1284
- return to_object
907
+ if getv(from_object, ['response_mime_type']) is not None:
908
+ setv(
909
+ to_object,
910
+ ['responseMimeType'],
911
+ getv(from_object, ['response_mime_type']),
912
+ )
1285
913
 
914
+ if getv(from_object, ['response_schema']) is not None:
915
+ setv(
916
+ to_object,
917
+ ['responseSchema'],
918
+ t.t_schema(api_client, getv(from_object, ['response_schema'])),
919
+ )
1286
920
 
1287
- def _FileData_from_mldev(
1288
- from_object: Union[dict[str, Any], object],
1289
- parent_object: Optional[dict[str, Any]] = None,
1290
- ) -> dict[str, Any]:
1291
- to_object: dict[str, Any] = {}
921
+ if getv(from_object, ['response_json_schema']) is not None:
922
+ setv(
923
+ to_object,
924
+ ['responseJsonSchema'],
925
+ getv(from_object, ['response_json_schema']),
926
+ )
1292
927
 
1293
- if getv(from_object, ['fileUri']) is not None:
1294
- setv(to_object, ['file_uri'], getv(from_object, ['fileUri']))
928
+ if getv(from_object, ['routing_config']) is not None:
929
+ raise ValueError('routing_config parameter is not supported in Gemini API.')
1295
930
 
1296
- if getv(from_object, ['mimeType']) is not None:
1297
- setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
931
+ if getv(from_object, ['model_selection_config']) is not None:
932
+ raise ValueError(
933
+ 'model_selection_config parameter is not supported in Gemini API.'
934
+ )
1298
935
 
1299
- return to_object
936
+ if getv(from_object, ['safety_settings']) is not None:
937
+ setv(
938
+ parent_object,
939
+ ['safetySettings'],
940
+ [
941
+ _SafetySetting_to_mldev(item, to_object)
942
+ for item in getv(from_object, ['safety_settings'])
943
+ ],
944
+ )
1300
945
 
946
+ if getv(from_object, ['tools']) is not None:
947
+ setv(
948
+ parent_object,
949
+ ['tools'],
950
+ [
951
+ _Tool_to_mldev(t.t_tool(api_client, item), to_object)
952
+ for item in t.t_tools(api_client, getv(from_object, ['tools']))
953
+ ],
954
+ )
1301
955
 
1302
- def _Part_from_mldev(
1303
- from_object: Union[dict[str, Any], object],
1304
- parent_object: Optional[dict[str, Any]] = None,
1305
- ) -> dict[str, Any]:
1306
- to_object: dict[str, Any] = {}
1307
- if getv(from_object, ['videoMetadata']) is not None:
956
+ if getv(from_object, ['tool_config']) is not None:
1308
957
  setv(
1309
- to_object,
1310
- ['video_metadata'],
1311
- _VideoMetadata_from_mldev(
1312
- getv(from_object, ['videoMetadata']), to_object
1313
- ),
958
+ parent_object,
959
+ ['toolConfig'],
960
+ _ToolConfig_to_mldev(getv(from_object, ['tool_config']), to_object),
1314
961
  )
1315
962
 
1316
- if getv(from_object, ['thought']) is not None:
1317
- setv(to_object, ['thought'], getv(from_object, ['thought']))
963
+ if getv(from_object, ['labels']) is not None:
964
+ raise ValueError('labels parameter is not supported in Gemini API.')
1318
965
 
1319
- if getv(from_object, ['inlineData']) is not None:
966
+ if getv(from_object, ['cached_content']) is not None:
1320
967
  setv(
1321
- to_object,
1322
- ['inline_data'],
1323
- _Blob_from_mldev(getv(from_object, ['inlineData']), to_object),
968
+ parent_object,
969
+ ['cachedContent'],
970
+ t.t_cached_content_name(
971
+ api_client, getv(from_object, ['cached_content'])
972
+ ),
1324
973
  )
1325
974
 
1326
- if getv(from_object, ['fileData']) is not None:
975
+ if getv(from_object, ['response_modalities']) is not None:
1327
976
  setv(
1328
977
  to_object,
1329
- ['file_data'],
1330
- _FileData_from_mldev(getv(from_object, ['fileData']), to_object),
978
+ ['responseModalities'],
979
+ getv(from_object, ['response_modalities']),
1331
980
  )
1332
981
 
1333
- if getv(from_object, ['thoughtSignature']) is not None:
982
+ if getv(from_object, ['media_resolution']) is not None:
1334
983
  setv(
1335
- to_object,
1336
- ['thought_signature'],
1337
- getv(from_object, ['thoughtSignature']),
984
+ to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
1338
985
  )
1339
986
 
1340
- if getv(from_object, ['codeExecutionResult']) is not None:
987
+ if getv(from_object, ['speech_config']) is not None:
1341
988
  setv(
1342
989
  to_object,
1343
- ['code_execution_result'],
1344
- getv(from_object, ['codeExecutionResult']),
990
+ ['speechConfig'],
991
+ t.t_speech_config(getv(from_object, ['speech_config'])),
1345
992
  )
1346
993
 
1347
- if getv(from_object, ['executableCode']) is not None:
1348
- setv(to_object, ['executable_code'], getv(from_object, ['executableCode']))
994
+ if getv(from_object, ['audio_timestamp']) is not None:
995
+ raise ValueError(
996
+ 'audio_timestamp parameter is not supported in Gemini API.'
997
+ )
1349
998
 
1350
- if getv(from_object, ['functionCall']) is not None:
1351
- setv(to_object, ['function_call'], getv(from_object, ['functionCall']))
999
+ if getv(from_object, ['thinking_config']) is not None:
1000
+ setv(to_object, ['thinkingConfig'], getv(from_object, ['thinking_config']))
1352
1001
 
1353
- if getv(from_object, ['functionResponse']) is not None:
1002
+ if getv(from_object, ['image_config']) is not None:
1354
1003
  setv(
1355
1004
  to_object,
1356
- ['function_response'],
1357
- getv(from_object, ['functionResponse']),
1005
+ ['imageConfig'],
1006
+ _ImageConfig_to_mldev(getv(from_object, ['image_config']), to_object),
1358
1007
  )
1359
1008
 
1360
- if getv(from_object, ['text']) is not None:
1361
- setv(to_object, ['text'], getv(from_object, ['text']))
1362
-
1363
1009
  return to_object
1364
1010
 
1365
1011
 
1366
- def _Content_from_mldev(
1012
+ def _GenerateContentResponse_from_mldev(
1367
1013
  from_object: Union[dict[str, Any], object],
1368
1014
  parent_object: Optional[dict[str, Any]] = None,
1369
1015
  ) -> dict[str, Any]:
1370
1016
  to_object: dict[str, Any] = {}
1371
- if getv(from_object, ['parts']) is not None:
1017
+ if getv(from_object, ['sdkHttpResponse']) is not None:
1018
+ setv(
1019
+ to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
1020
+ )
1021
+
1022
+ if getv(from_object, ['candidates']) is not None:
1372
1023
  setv(
1373
1024
  to_object,
1374
- ['parts'],
1025
+ ['candidates'],
1375
1026
  [
1376
- _Part_from_mldev(item, to_object)
1377
- for item in getv(from_object, ['parts'])
1027
+ _Candidate_from_mldev(item, to_object)
1028
+ for item in getv(from_object, ['candidates'])
1378
1029
  ],
1379
1030
  )
1380
1031
 
1381
- if getv(from_object, ['role']) is not None:
1382
- setv(to_object, ['role'], getv(from_object, ['role']))
1032
+ if getv(from_object, ['modelVersion']) is not None:
1033
+ setv(to_object, ['model_version'], getv(from_object, ['modelVersion']))
1034
+
1035
+ if getv(from_object, ['promptFeedback']) is not None:
1036
+ setv(to_object, ['prompt_feedback'], getv(from_object, ['promptFeedback']))
1037
+
1038
+ if getv(from_object, ['responseId']) is not None:
1039
+ setv(to_object, ['response_id'], getv(from_object, ['responseId']))
1040
+
1041
+ if getv(from_object, ['usageMetadata']) is not None:
1042
+ setv(to_object, ['usage_metadata'], getv(from_object, ['usageMetadata']))
1383
1043
 
1384
1044
  return to_object
1385
1045
 
1386
1046
 
1387
- def _CitationMetadata_from_mldev(
1047
+ def _GetBatchJobParameters_to_mldev(
1048
+ api_client: BaseApiClient,
1388
1049
  from_object: Union[dict[str, Any], object],
1389
1050
  parent_object: Optional[dict[str, Any]] = None,
1390
1051
  ) -> dict[str, Any]:
1391
1052
  to_object: dict[str, Any] = {}
1392
- if getv(from_object, ['citationSources']) is not None:
1393
- setv(to_object, ['citations'], getv(from_object, ['citationSources']))
1053
+ if getv(from_object, ['name']) is not None:
1054
+ setv(
1055
+ to_object,
1056
+ ['_url', 'name'],
1057
+ t.t_batch_job_name(api_client, getv(from_object, ['name'])),
1058
+ )
1394
1059
 
1395
1060
  return to_object
1396
1061
 
1397
1062
 
1398
- def _UrlMetadata_from_mldev(
1063
+ def _GetBatchJobParameters_to_vertex(
1064
+ api_client: BaseApiClient,
1399
1065
  from_object: Union[dict[str, Any], object],
1400
1066
  parent_object: Optional[dict[str, Any]] = None,
1401
1067
  ) -> dict[str, Any]:
1402
1068
  to_object: dict[str, Any] = {}
1403
- if getv(from_object, ['retrievedUrl']) is not None:
1404
- setv(to_object, ['retrieved_url'], getv(from_object, ['retrievedUrl']))
1405
-
1406
- if getv(from_object, ['urlRetrievalStatus']) is not None:
1069
+ if getv(from_object, ['name']) is not None:
1407
1070
  setv(
1408
1071
  to_object,
1409
- ['url_retrieval_status'],
1410
- getv(from_object, ['urlRetrievalStatus']),
1072
+ ['_url', 'name'],
1073
+ t.t_batch_job_name(api_client, getv(from_object, ['name'])),
1411
1074
  )
1412
1075
 
1413
1076
  return to_object
1414
1077
 
1415
1078
 
1416
- def _UrlContextMetadata_from_mldev(
1079
+ def _GoogleMaps_to_mldev(
1417
1080
  from_object: Union[dict[str, Any], object],
1418
1081
  parent_object: Optional[dict[str, Any]] = None,
1419
1082
  ) -> dict[str, Any]:
1420
1083
  to_object: dict[str, Any] = {}
1421
- if getv(from_object, ['urlMetadata']) is not None:
1422
- setv(
1423
- to_object,
1424
- ['url_metadata'],
1425
- [
1426
- _UrlMetadata_from_mldev(item, to_object)
1427
- for item in getv(from_object, ['urlMetadata'])
1428
- ],
1429
- )
1084
+ if getv(from_object, ['auth_config']) is not None:
1085
+ raise ValueError('auth_config parameter is not supported in Gemini API.')
1086
+
1087
+ if getv(from_object, ['enable_widget']) is not None:
1088
+ setv(to_object, ['enableWidget'], getv(from_object, ['enable_widget']))
1430
1089
 
1431
1090
  return to_object
1432
1091
 
1433
1092
 
1434
- def _Candidate_from_mldev(
1093
+ def _GoogleSearch_to_mldev(
1435
1094
  from_object: Union[dict[str, Any], object],
1436
1095
  parent_object: Optional[dict[str, Any]] = None,
1437
1096
  ) -> dict[str, Any]:
1438
1097
  to_object: dict[str, Any] = {}
1439
- if getv(from_object, ['content']) is not None:
1440
- setv(
1441
- to_object,
1442
- ['content'],
1443
- _Content_from_mldev(getv(from_object, ['content']), to_object),
1098
+ if getv(from_object, ['exclude_domains']) is not None:
1099
+ raise ValueError(
1100
+ 'exclude_domains parameter is not supported in Gemini API.'
1444
1101
  )
1445
1102
 
1446
- if getv(from_object, ['citationMetadata']) is not None:
1447
- setv(
1448
- to_object,
1449
- ['citation_metadata'],
1450
- _CitationMetadata_from_mldev(
1451
- getv(from_object, ['citationMetadata']), to_object
1452
- ),
1103
+ if getv(from_object, ['blocking_confidence']) is not None:
1104
+ raise ValueError(
1105
+ 'blocking_confidence parameter is not supported in Gemini API.'
1453
1106
  )
1454
1107
 
1455
- if getv(from_object, ['tokenCount']) is not None:
1456
- setv(to_object, ['token_count'], getv(from_object, ['tokenCount']))
1457
-
1458
- if getv(from_object, ['finishReason']) is not None:
1459
- setv(to_object, ['finish_reason'], getv(from_object, ['finishReason']))
1460
-
1461
- if getv(from_object, ['urlContextMetadata']) is not None:
1108
+ if getv(from_object, ['time_range_filter']) is not None:
1462
1109
  setv(
1463
- to_object,
1464
- ['url_context_metadata'],
1465
- _UrlContextMetadata_from_mldev(
1466
- getv(from_object, ['urlContextMetadata']), to_object
1467
- ),
1110
+ to_object, ['timeRangeFilter'], getv(from_object, ['time_range_filter'])
1468
1111
  )
1469
1112
 
1470
- if getv(from_object, ['avgLogprobs']) is not None:
1471
- setv(to_object, ['avg_logprobs'], getv(from_object, ['avgLogprobs']))
1113
+ return to_object
1472
1114
 
1473
- if getv(from_object, ['groundingMetadata']) is not None:
1474
- setv(
1475
- to_object,
1476
- ['grounding_metadata'],
1477
- getv(from_object, ['groundingMetadata']),
1478
- )
1479
1115
 
1480
- if getv(from_object, ['index']) is not None:
1481
- setv(to_object, ['index'], getv(from_object, ['index']))
1116
+ def _ImageConfig_to_mldev(
1117
+ from_object: Union[dict[str, Any], object],
1118
+ parent_object: Optional[dict[str, Any]] = None,
1119
+ ) -> dict[str, Any]:
1120
+ to_object: dict[str, Any] = {}
1121
+ if getv(from_object, ['aspect_ratio']) is not None:
1122
+ setv(to_object, ['aspectRatio'], getv(from_object, ['aspect_ratio']))
1482
1123
 
1483
- if getv(from_object, ['logprobsResult']) is not None:
1484
- setv(to_object, ['logprobs_result'], getv(from_object, ['logprobsResult']))
1124
+ if getv(from_object, ['image_size']) is not None:
1125
+ setv(to_object, ['imageSize'], getv(from_object, ['image_size']))
1485
1126
 
1486
- if getv(from_object, ['safetyRatings']) is not None:
1487
- setv(to_object, ['safety_ratings'], getv(from_object, ['safetyRatings']))
1127
+ if getv(from_object, ['output_mime_type']) is not None:
1128
+ raise ValueError(
1129
+ 'output_mime_type parameter is not supported in Gemini API.'
1130
+ )
1131
+
1132
+ if getv(from_object, ['output_compression_quality']) is not None:
1133
+ raise ValueError(
1134
+ 'output_compression_quality parameter is not supported in Gemini API.'
1135
+ )
1488
1136
 
1489
1137
  return to_object
1490
1138
 
1491
1139
 
1492
- def _GenerateContentResponse_from_mldev(
1140
+ def _InlinedRequest_to_mldev(
1141
+ api_client: BaseApiClient,
1493
1142
  from_object: Union[dict[str, Any], object],
1494
1143
  parent_object: Optional[dict[str, Any]] = None,
1495
1144
  ) -> dict[str, Any]:
1496
1145
  to_object: dict[str, Any] = {}
1497
- if getv(from_object, ['sdkHttpResponse']) is not None:
1146
+ if getv(from_object, ['model']) is not None:
1498
1147
  setv(
1499
- to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
1148
+ to_object,
1149
+ ['request', 'model'],
1150
+ t.t_model(api_client, getv(from_object, ['model'])),
1500
1151
  )
1501
1152
 
1502
- if getv(from_object, ['candidates']) is not None:
1153
+ if getv(from_object, ['contents']) is not None:
1503
1154
  setv(
1504
1155
  to_object,
1505
- ['candidates'],
1156
+ ['request', 'contents'],
1506
1157
  [
1507
- _Candidate_from_mldev(item, to_object)
1508
- for item in getv(from_object, ['candidates'])
1158
+ _Content_to_mldev(item, to_object)
1159
+ for item in t.t_contents(getv(from_object, ['contents']))
1509
1160
  ],
1510
1161
  )
1511
1162
 
1512
- if getv(from_object, ['modelVersion']) is not None:
1513
- setv(to_object, ['model_version'], getv(from_object, ['modelVersion']))
1514
-
1515
- if getv(from_object, ['promptFeedback']) is not None:
1516
- setv(to_object, ['prompt_feedback'], getv(from_object, ['promptFeedback']))
1517
-
1518
- if getv(from_object, ['responseId']) is not None:
1519
- setv(to_object, ['response_id'], getv(from_object, ['responseId']))
1520
-
1521
- if getv(from_object, ['usageMetadata']) is not None:
1522
- setv(to_object, ['usage_metadata'], getv(from_object, ['usageMetadata']))
1523
-
1524
- return to_object
1525
-
1526
-
1527
- def _JobError_from_mldev(
1528
- from_object: Union[dict[str, Any], object],
1529
- parent_object: Optional[dict[str, Any]] = None,
1530
- ) -> dict[str, Any]:
1531
- to_object: dict[str, Any] = {}
1532
- if getv(from_object, ['details']) is not None:
1533
- setv(to_object, ['details'], getv(from_object, ['details']))
1163
+ if getv(from_object, ['metadata']) is not None:
1164
+ setv(to_object, ['metadata'], getv(from_object, ['metadata']))
1534
1165
 
1535
- if getv(from_object, ['code']) is not None:
1536
- setv(to_object, ['code'], getv(from_object, ['code']))
1537
-
1538
- if getv(from_object, ['message']) is not None:
1539
- setv(to_object, ['message'], getv(from_object, ['message']))
1166
+ if getv(from_object, ['config']) is not None:
1167
+ setv(
1168
+ to_object,
1169
+ ['request', 'generationConfig'],
1170
+ _GenerateContentConfig_to_mldev(
1171
+ api_client,
1172
+ getv(from_object, ['config']),
1173
+ getv(to_object, ['request'], default_value={}),
1174
+ ),
1175
+ )
1540
1176
 
1541
1177
  return to_object
1542
1178
 
@@ -1556,89 +1192,77 @@ def _InlinedResponse_from_mldev(
1556
1192
  )
1557
1193
 
1558
1194
  if getv(from_object, ['error']) is not None:
1559
- setv(
1560
- to_object,
1561
- ['error'],
1562
- _JobError_from_mldev(getv(from_object, ['error']), to_object),
1563
- )
1195
+ setv(to_object, ['error'], getv(from_object, ['error']))
1564
1196
 
1565
1197
  return to_object
1566
1198
 
1567
1199
 
1568
- def _BatchJobDestination_from_mldev(
1200
+ def _ListBatchJobsConfig_to_mldev(
1569
1201
  from_object: Union[dict[str, Any], object],
1570
1202
  parent_object: Optional[dict[str, Any]] = None,
1571
1203
  ) -> dict[str, Any]:
1572
1204
  to_object: dict[str, Any] = {}
1573
1205
 
1574
- if getv(from_object, ['responsesFile']) is not None:
1575
- setv(to_object, ['file_name'], getv(from_object, ['responsesFile']))
1206
+ if getv(from_object, ['page_size']) is not None:
1207
+ setv(
1208
+ parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
1209
+ )
1576
1210
 
1577
- if getv(from_object, ['inlinedResponses', 'inlinedResponses']) is not None:
1211
+ if getv(from_object, ['page_token']) is not None:
1578
1212
  setv(
1579
- to_object,
1580
- ['inlined_responses'],
1581
- [
1582
- _InlinedResponse_from_mldev(item, to_object)
1583
- for item in getv(
1584
- from_object, ['inlinedResponses', 'inlinedResponses']
1585
- )
1586
- ],
1213
+ parent_object,
1214
+ ['_query', 'pageToken'],
1215
+ getv(from_object, ['page_token']),
1587
1216
  )
1588
1217
 
1218
+ if getv(from_object, ['filter']) is not None:
1219
+ raise ValueError('filter parameter is not supported in Gemini API.')
1220
+
1589
1221
  return to_object
1590
1222
 
1591
1223
 
1592
- def _BatchJob_from_mldev(
1224
+ def _ListBatchJobsConfig_to_vertex(
1593
1225
  from_object: Union[dict[str, Any], object],
1594
1226
  parent_object: Optional[dict[str, Any]] = None,
1595
1227
  ) -> dict[str, Any]:
1596
1228
  to_object: dict[str, Any] = {}
1597
- if getv(from_object, ['name']) is not None:
1598
- setv(to_object, ['name'], getv(from_object, ['name']))
1599
1229
 
1600
- if getv(from_object, ['metadata', 'displayName']) is not None:
1230
+ if getv(from_object, ['page_size']) is not None:
1601
1231
  setv(
1602
- to_object,
1603
- ['display_name'],
1604
- getv(from_object, ['metadata', 'displayName']),
1232
+ parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
1605
1233
  )
1606
1234
 
1607
- if getv(from_object, ['metadata', 'state']) is not None:
1235
+ if getv(from_object, ['page_token']) is not None:
1608
1236
  setv(
1609
- to_object,
1610
- ['state'],
1611
- t.t_job_state(getv(from_object, ['metadata', 'state'])),
1237
+ parent_object,
1238
+ ['_query', 'pageToken'],
1239
+ getv(from_object, ['page_token']),
1612
1240
  )
1613
1241
 
1614
- if getv(from_object, ['metadata', 'createTime']) is not None:
1615
- setv(
1616
- to_object,
1617
- ['create_time'],
1618
- getv(from_object, ['metadata', 'createTime']),
1619
- )
1242
+ if getv(from_object, ['filter']) is not None:
1243
+ setv(parent_object, ['_query', 'filter'], getv(from_object, ['filter']))
1620
1244
 
1621
- if getv(from_object, ['metadata', 'endTime']) is not None:
1622
- setv(to_object, ['end_time'], getv(from_object, ['metadata', 'endTime']))
1245
+ return to_object
1623
1246
 
1624
- if getv(from_object, ['metadata', 'updateTime']) is not None:
1625
- setv(
1626
- to_object,
1627
- ['update_time'],
1628
- getv(from_object, ['metadata', 'updateTime']),
1629
- )
1630
1247
 
1631
- if getv(from_object, ['metadata', 'model']) is not None:
1632
- setv(to_object, ['model'], getv(from_object, ['metadata', 'model']))
1248
+ def _ListBatchJobsParameters_to_mldev(
1249
+ from_object: Union[dict[str, Any], object],
1250
+ parent_object: Optional[dict[str, Any]] = None,
1251
+ ) -> dict[str, Any]:
1252
+ to_object: dict[str, Any] = {}
1253
+ if getv(from_object, ['config']) is not None:
1254
+ _ListBatchJobsConfig_to_mldev(getv(from_object, ['config']), to_object)
1633
1255
 
1634
- if getv(from_object, ['metadata', 'output']) is not None:
1635
- setv(
1636
- to_object,
1637
- ['dest'],
1638
- _BatchJobDestination_from_mldev(
1639
- getv(from_object, ['metadata', 'output']), to_object
1640
- ),
1641
- )
1256
+ return to_object
1257
+
1258
+
1259
+ def _ListBatchJobsParameters_to_vertex(
1260
+ from_object: Union[dict[str, Any], object],
1261
+ parent_object: Optional[dict[str, Any]] = None,
1262
+ ) -> dict[str, Any]:
1263
+ to_object: dict[str, Any] = {}
1264
+ if getv(from_object, ['config']) is not None:
1265
+ _ListBatchJobsConfig_to_vertex(getv(from_object, ['config']), to_object)
1642
1266
 
1643
1267
  return to_object
1644
1268
 
@@ -1669,7 +1293,7 @@ def _ListBatchJobsResponse_from_mldev(
1669
1293
  return to_object
1670
1294
 
1671
1295
 
1672
- def _DeleteResourceJob_from_mldev(
1296
+ def _ListBatchJobsResponse_from_vertex(
1673
1297
  from_object: Union[dict[str, Any], object],
1674
1298
  parent_object: Optional[dict[str, Any]] = None,
1675
1299
  ) -> dict[str, Any]:
@@ -1679,191 +1303,181 @@ def _DeleteResourceJob_from_mldev(
1679
1303
  to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
1680
1304
  )
1681
1305
 
1682
- if getv(from_object, ['name']) is not None:
1683
- setv(to_object, ['name'], getv(from_object, ['name']))
1684
-
1685
- if getv(from_object, ['done']) is not None:
1686
- setv(to_object, ['done'], getv(from_object, ['done']))
1306
+ if getv(from_object, ['nextPageToken']) is not None:
1307
+ setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
1687
1308
 
1688
- if getv(from_object, ['error']) is not None:
1309
+ if getv(from_object, ['batchPredictionJobs']) is not None:
1689
1310
  setv(
1690
1311
  to_object,
1691
- ['error'],
1692
- _JobError_from_mldev(getv(from_object, ['error']), to_object),
1312
+ ['batch_jobs'],
1313
+ [
1314
+ _BatchJob_from_vertex(item, to_object)
1315
+ for item in getv(from_object, ['batchPredictionJobs'])
1316
+ ],
1693
1317
  )
1694
1318
 
1695
1319
  return to_object
1696
1320
 
1697
1321
 
1698
- def _JobError_from_vertex(
1322
+ def _Part_to_mldev(
1699
1323
  from_object: Union[dict[str, Any], object],
1700
1324
  parent_object: Optional[dict[str, Any]] = None,
1701
1325
  ) -> dict[str, Any]:
1702
1326
  to_object: dict[str, Any] = {}
1703
- if getv(from_object, ['details']) is not None:
1704
- setv(to_object, ['details'], getv(from_object, ['details']))
1705
-
1706
- if getv(from_object, ['code']) is not None:
1707
- setv(to_object, ['code'], getv(from_object, ['code']))
1708
-
1709
- if getv(from_object, ['message']) is not None:
1710
- setv(to_object, ['message'], getv(from_object, ['message']))
1711
-
1712
- return to_object
1713
-
1327
+ if getv(from_object, ['media_resolution']) is not None:
1328
+ setv(
1329
+ to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
1330
+ )
1714
1331
 
1715
- def _BatchJobSource_from_vertex(
1716
- from_object: Union[dict[str, Any], object],
1717
- parent_object: Optional[dict[str, Any]] = None,
1718
- ) -> dict[str, Any]:
1719
- to_object: dict[str, Any] = {}
1720
- if getv(from_object, ['instancesFormat']) is not None:
1721
- setv(to_object, ['format'], getv(from_object, ['instancesFormat']))
1332
+ if getv(from_object, ['code_execution_result']) is not None:
1333
+ setv(
1334
+ to_object,
1335
+ ['codeExecutionResult'],
1336
+ getv(from_object, ['code_execution_result']),
1337
+ )
1722
1338
 
1723
- if getv(from_object, ['gcsSource', 'uris']) is not None:
1724
- setv(to_object, ['gcs_uri'], getv(from_object, ['gcsSource', 'uris']))
1339
+ if getv(from_object, ['executable_code']) is not None:
1340
+ setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
1725
1341
 
1726
- if getv(from_object, ['bigquerySource', 'inputUri']) is not None:
1342
+ if getv(from_object, ['file_data']) is not None:
1727
1343
  setv(
1728
1344
  to_object,
1729
- ['bigquery_uri'],
1730
- getv(from_object, ['bigquerySource', 'inputUri']),
1345
+ ['fileData'],
1346
+ _FileData_to_mldev(getv(from_object, ['file_data']), to_object),
1731
1347
  )
1732
1348
 
1733
- return to_object
1734
-
1349
+ if getv(from_object, ['function_call']) is not None:
1350
+ setv(
1351
+ to_object,
1352
+ ['functionCall'],
1353
+ _FunctionCall_to_mldev(getv(from_object, ['function_call']), to_object),
1354
+ )
1735
1355
 
1736
- def _BatchJobDestination_from_vertex(
1737
- from_object: Union[dict[str, Any], object],
1738
- parent_object: Optional[dict[str, Any]] = None,
1739
- ) -> dict[str, Any]:
1740
- to_object: dict[str, Any] = {}
1741
- if getv(from_object, ['predictionsFormat']) is not None:
1742
- setv(to_object, ['format'], getv(from_object, ['predictionsFormat']))
1356
+ if getv(from_object, ['function_response']) is not None:
1357
+ setv(
1358
+ to_object,
1359
+ ['functionResponse'],
1360
+ getv(from_object, ['function_response']),
1361
+ )
1743
1362
 
1744
- if getv(from_object, ['gcsDestination', 'outputUriPrefix']) is not None:
1363
+ if getv(from_object, ['inline_data']) is not None:
1745
1364
  setv(
1746
1365
  to_object,
1747
- ['gcs_uri'],
1748
- getv(from_object, ['gcsDestination', 'outputUriPrefix']),
1366
+ ['inlineData'],
1367
+ _Blob_to_mldev(getv(from_object, ['inline_data']), to_object),
1749
1368
  )
1750
1369
 
1751
- if getv(from_object, ['bigqueryDestination', 'outputUri']) is not None:
1370
+ if getv(from_object, ['text']) is not None:
1371
+ setv(to_object, ['text'], getv(from_object, ['text']))
1372
+
1373
+ if getv(from_object, ['thought']) is not None:
1374
+ setv(to_object, ['thought'], getv(from_object, ['thought']))
1375
+
1376
+ if getv(from_object, ['thought_signature']) is not None:
1752
1377
  setv(
1753
1378
  to_object,
1754
- ['bigquery_uri'],
1755
- getv(from_object, ['bigqueryDestination', 'outputUri']),
1379
+ ['thoughtSignature'],
1380
+ getv(from_object, ['thought_signature']),
1756
1381
  )
1757
1382
 
1383
+ if getv(from_object, ['video_metadata']) is not None:
1384
+ setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
1385
+
1758
1386
  return to_object
1759
1387
 
1760
1388
 
1761
- def _BatchJob_from_vertex(
1389
+ def _SafetySetting_to_mldev(
1762
1390
  from_object: Union[dict[str, Any], object],
1763
1391
  parent_object: Optional[dict[str, Any]] = None,
1764
1392
  ) -> dict[str, Any]:
1765
1393
  to_object: dict[str, Any] = {}
1766
- if getv(from_object, ['name']) is not None:
1767
- setv(to_object, ['name'], getv(from_object, ['name']))
1768
-
1769
- if getv(from_object, ['displayName']) is not None:
1770
- setv(to_object, ['display_name'], getv(from_object, ['displayName']))
1771
-
1772
- if getv(from_object, ['state']) is not None:
1773
- setv(to_object, ['state'], t.t_job_state(getv(from_object, ['state'])))
1774
-
1775
- if getv(from_object, ['error']) is not None:
1776
- setv(
1777
- to_object,
1778
- ['error'],
1779
- _JobError_from_vertex(getv(from_object, ['error']), to_object),
1780
- )
1781
-
1782
- if getv(from_object, ['createTime']) is not None:
1783
- setv(to_object, ['create_time'], getv(from_object, ['createTime']))
1394
+ if getv(from_object, ['category']) is not None:
1395
+ setv(to_object, ['category'], getv(from_object, ['category']))
1784
1396
 
1785
- if getv(from_object, ['startTime']) is not None:
1786
- setv(to_object, ['start_time'], getv(from_object, ['startTime']))
1397
+ if getv(from_object, ['method']) is not None:
1398
+ raise ValueError('method parameter is not supported in Gemini API.')
1787
1399
 
1788
- if getv(from_object, ['endTime']) is not None:
1789
- setv(to_object, ['end_time'], getv(from_object, ['endTime']))
1400
+ if getv(from_object, ['threshold']) is not None:
1401
+ setv(to_object, ['threshold'], getv(from_object, ['threshold']))
1790
1402
 
1791
- if getv(from_object, ['updateTime']) is not None:
1792
- setv(to_object, ['update_time'], getv(from_object, ['updateTime']))
1403
+ return to_object
1793
1404
 
1794
- if getv(from_object, ['model']) is not None:
1795
- setv(to_object, ['model'], getv(from_object, ['model']))
1796
1405
 
1797
- if getv(from_object, ['inputConfig']) is not None:
1406
+ def _ToolConfig_to_mldev(
1407
+ from_object: Union[dict[str, Any], object],
1408
+ parent_object: Optional[dict[str, Any]] = None,
1409
+ ) -> dict[str, Any]:
1410
+ to_object: dict[str, Any] = {}
1411
+ if getv(from_object, ['function_calling_config']) is not None:
1798
1412
  setv(
1799
1413
  to_object,
1800
- ['src'],
1801
- _BatchJobSource_from_vertex(
1802
- getv(from_object, ['inputConfig']), to_object
1414
+ ['functionCallingConfig'],
1415
+ _FunctionCallingConfig_to_mldev(
1416
+ getv(from_object, ['function_calling_config']), to_object
1803
1417
  ),
1804
1418
  )
1805
1419
 
1806
- if getv(from_object, ['outputConfig']) is not None:
1420
+ if getv(from_object, ['retrieval_config']) is not None:
1807
1421
  setv(
1808
- to_object,
1809
- ['dest'],
1810
- _BatchJobDestination_from_vertex(
1811
- getv(from_object, ['outputConfig']), to_object
1812
- ),
1422
+ to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
1813
1423
  )
1814
1424
 
1815
1425
  return to_object
1816
1426
 
1817
1427
 
1818
- def _ListBatchJobsResponse_from_vertex(
1428
+ def _Tool_to_mldev(
1819
1429
  from_object: Union[dict[str, Any], object],
1820
1430
  parent_object: Optional[dict[str, Any]] = None,
1821
1431
  ) -> dict[str, Any]:
1822
1432
  to_object: dict[str, Any] = {}
1823
- if getv(from_object, ['sdkHttpResponse']) is not None:
1433
+ if getv(from_object, ['function_declarations']) is not None:
1824
1434
  setv(
1825
- to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
1435
+ to_object,
1436
+ ['functionDeclarations'],
1437
+ [item for item in getv(from_object, ['function_declarations'])],
1826
1438
  )
1827
1439
 
1828
- if getv(from_object, ['nextPageToken']) is not None:
1829
- setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
1440
+ if getv(from_object, ['retrieval']) is not None:
1441
+ raise ValueError('retrieval parameter is not supported in Gemini API.')
1830
1442
 
1831
- if getv(from_object, ['batchPredictionJobs']) is not None:
1443
+ if getv(from_object, ['google_search_retrieval']) is not None:
1832
1444
  setv(
1833
1445
  to_object,
1834
- ['batch_jobs'],
1835
- [
1836
- _BatchJob_from_vertex(item, to_object)
1837
- for item in getv(from_object, ['batchPredictionJobs'])
1838
- ],
1446
+ ['googleSearchRetrieval'],
1447
+ getv(from_object, ['google_search_retrieval']),
1839
1448
  )
1840
1449
 
1841
- return to_object
1450
+ if getv(from_object, ['computer_use']) is not None:
1451
+ setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
1452
+
1453
+ if getv(from_object, ['file_search']) is not None:
1454
+ setv(to_object, ['fileSearch'], getv(from_object, ['file_search']))
1455
+
1456
+ if getv(from_object, ['code_execution']) is not None:
1457
+ setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
1842
1458
 
1459
+ if getv(from_object, ['enterprise_web_search']) is not None:
1460
+ raise ValueError(
1461
+ 'enterprise_web_search parameter is not supported in Gemini API.'
1462
+ )
1843
1463
 
1844
- def _DeleteResourceJob_from_vertex(
1845
- from_object: Union[dict[str, Any], object],
1846
- parent_object: Optional[dict[str, Any]] = None,
1847
- ) -> dict[str, Any]:
1848
- to_object: dict[str, Any] = {}
1849
- if getv(from_object, ['sdkHttpResponse']) is not None:
1464
+ if getv(from_object, ['google_maps']) is not None:
1850
1465
  setv(
1851
- to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
1466
+ to_object,
1467
+ ['googleMaps'],
1468
+ _GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
1852
1469
  )
1853
1470
 
1854
- if getv(from_object, ['name']) is not None:
1855
- setv(to_object, ['name'], getv(from_object, ['name']))
1856
-
1857
- if getv(from_object, ['done']) is not None:
1858
- setv(to_object, ['done'], getv(from_object, ['done']))
1859
-
1860
- if getv(from_object, ['error']) is not None:
1471
+ if getv(from_object, ['google_search']) is not None:
1861
1472
  setv(
1862
1473
  to_object,
1863
- ['error'],
1864
- _JobError_from_vertex(getv(from_object, ['error']), to_object),
1474
+ ['googleSearch'],
1475
+ _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
1865
1476
  )
1866
1477
 
1478
+ if getv(from_object, ['url_context']) is not None:
1479
+ setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
1480
+
1867
1481
  return to_object
1868
1482
 
1869
1483
 
@@ -1922,12 +1536,72 @@ class Batches(_api_module.BaseModule):
1922
1536
  'post', path, request_dict, http_options
1923
1537
  )
1924
1538
 
1925
- response_dict = '' if not response.body else json.loads(response.body)
1539
+ response_dict = {} if not response.body else json.loads(response.body)
1926
1540
 
1927
1541
  if self._api_client.vertexai:
1928
1542
  response_dict = _BatchJob_from_vertex(response_dict)
1929
1543
 
1544
+ if not self._api_client.vertexai:
1545
+ response_dict = _BatchJob_from_mldev(response_dict)
1546
+
1547
+ return_value = types.BatchJob._from_response(
1548
+ response=response_dict, kwargs=parameter_model.model_dump()
1549
+ )
1550
+
1551
+ self._api_client._verify_response(return_value)
1552
+ return return_value
1553
+
1554
+ def _create_embeddings(
1555
+ self,
1556
+ *,
1557
+ model: Optional[str] = None,
1558
+ src: types.EmbeddingsBatchJobSourceOrDict,
1559
+ config: Optional[types.CreateEmbeddingsBatchJobConfigOrDict] = None,
1560
+ ) -> types.BatchJob:
1561
+ parameter_model = types._CreateEmbeddingsBatchJobParameters(
1562
+ model=model,
1563
+ src=src,
1564
+ config=config,
1565
+ )
1566
+
1567
+ request_url_dict: Optional[dict[str, str]]
1568
+ if self._api_client.vertexai:
1569
+ raise ValueError(
1570
+ 'This method is only supported in the Gemini Developer client.'
1571
+ )
1930
1572
  else:
1573
+ request_dict = _CreateEmbeddingsBatchJobParameters_to_mldev(
1574
+ self._api_client, parameter_model
1575
+ )
1576
+ request_url_dict = request_dict.get('_url')
1577
+ if request_url_dict:
1578
+ path = '{model}:asyncBatchEmbedContent'.format_map(request_url_dict)
1579
+ else:
1580
+ path = '{model}:asyncBatchEmbedContent'
1581
+
1582
+ query_params = request_dict.get('_query')
1583
+ if query_params:
1584
+ path = f'{path}?{urlencode(query_params)}'
1585
+ # TODO: remove the hack that pops config.
1586
+ request_dict.pop('config', None)
1587
+
1588
+ http_options: Optional[types.HttpOptions] = None
1589
+ if (
1590
+ parameter_model.config is not None
1591
+ and parameter_model.config.http_options is not None
1592
+ ):
1593
+ http_options = parameter_model.config.http_options
1594
+
1595
+ request_dict = _common.convert_to_dict(request_dict)
1596
+ request_dict = _common.encode_unserializable_types(request_dict)
1597
+
1598
+ response = self._api_client.request(
1599
+ 'post', path, request_dict, http_options
1600
+ )
1601
+
1602
+ response_dict = {} if not response.body else json.loads(response.body)
1603
+
1604
+ if not self._api_client.vertexai:
1931
1605
  response_dict = _BatchJob_from_mldev(response_dict)
1932
1606
 
1933
1607
  return_value = types.BatchJob._from_response(
@@ -2002,12 +1676,12 @@ class Batches(_api_module.BaseModule):
2002
1676
 
2003
1677
  response = self._api_client.request('get', path, request_dict, http_options)
2004
1678
 
2005
- response_dict = '' if not response.body else json.loads(response.body)
1679
+ response_dict = {} if not response.body else json.loads(response.body)
2006
1680
 
2007
1681
  if self._api_client.vertexai:
2008
1682
  response_dict = _BatchJob_from_vertex(response_dict)
2009
1683
 
2010
- else:
1684
+ if not self._api_client.vertexai:
2011
1685
  response_dict = _BatchJob_from_mldev(response_dict)
2012
1686
 
2013
1687
  return_value = types.BatchJob._from_response(
@@ -2126,12 +1800,12 @@ class Batches(_api_module.BaseModule):
2126
1800
 
2127
1801
  response = self._api_client.request('get', path, request_dict, http_options)
2128
1802
 
2129
- response_dict = '' if not response.body else json.loads(response.body)
1803
+ response_dict = {} if not response.body else json.loads(response.body)
2130
1804
 
2131
1805
  if self._api_client.vertexai:
2132
1806
  response_dict = _ListBatchJobsResponse_from_vertex(response_dict)
2133
1807
 
2134
- else:
1808
+ if not self._api_client.vertexai:
2135
1809
  response_dict = _ListBatchJobsResponse_from_mldev(response_dict)
2136
1810
 
2137
1811
  return_value = types.ListBatchJobsResponse._from_response(
@@ -2211,12 +1885,12 @@ class Batches(_api_module.BaseModule):
2211
1885
  'delete', path, request_dict, http_options
2212
1886
  )
2213
1887
 
2214
- response_dict = '' if not response.body else json.loads(response.body)
1888
+ response_dict = {} if not response.body else json.loads(response.body)
2215
1889
 
2216
1890
  if self._api_client.vertexai:
2217
1891
  response_dict = _DeleteResourceJob_from_vertex(response_dict)
2218
1892
 
2219
- else:
1893
+ if not self._api_client.vertexai:
2220
1894
  response_dict = _DeleteResourceJob_from_mldev(response_dict)
2221
1895
 
2222
1896
  return_value = types.DeleteResourceJob._from_response(
@@ -2228,11 +1902,39 @@ class Batches(_api_module.BaseModule):
2228
1902
  self._api_client._verify_response(return_value)
2229
1903
  return return_value
2230
1904
 
1905
+ def list(
1906
+ self, *, config: Optional[types.ListBatchJobsConfigOrDict] = None
1907
+ ) -> Pager[types.BatchJob]:
1908
+ """Lists batch jobs.
1909
+
1910
+ Args:
1911
+ config (ListBatchJobsConfig): Optional configuration for the list request.
1912
+
1913
+ Returns:
1914
+ A Pager object that contains one page of batch jobs. When iterating over
1915
+ the pager, it automatically fetches the next page if there are more.
1916
+
1917
+ Usage:
1918
+
1919
+ .. code-block:: python
1920
+ config = {'page_size': 10}
1921
+ for batch_job in client.batches.list(config):
1922
+ print(batch_job.name)
1923
+ """
1924
+
1925
+ list_request = self._list
1926
+ return Pager(
1927
+ 'batch_jobs',
1928
+ list_request,
1929
+ self._list(config=config),
1930
+ config,
1931
+ )
1932
+
2231
1933
  def create(
2232
1934
  self,
2233
1935
  *,
2234
1936
  model: str,
2235
- src: Union[types.BatchJobSourceUnion, types.BatchJobSourceUnionDict],
1937
+ src: types.BatchJobSourceUnionDict,
2236
1938
  config: Optional[types.CreateBatchJobConfigOrDict] = None,
2237
1939
  ) -> types.BatchJob:
2238
1940
  """Creates a batch job.
@@ -2258,114 +1960,70 @@ class Batches(_api_module.BaseModule):
2258
1960
  )
2259
1961
  print(batch_job.state)
2260
1962
  """
1963
+ src = t.t_batch_job_source(self._api_client, src)
1964
+
1965
+ # Convert all dicts to Pydantic objects.
2261
1966
  parameter_model = types._CreateBatchJobParameters(
2262
1967
  model=model,
2263
1968
  src=src,
2264
1969
  config=config,
2265
1970
  )
2266
- http_options: Optional[types.HttpOptions] = None
2267
- if (
2268
- parameter_model.config is not None
2269
- and parameter_model.config.http_options is not None
2270
- ):
2271
- http_options = parameter_model.config.http_options
2272
- if self._api_client.vertexai:
2273
- if isinstance(src, list):
2274
- raise ValueError(
2275
- 'inlined_requests is not supported in Vertex AI. Please use'
2276
- ' Google Cloud Storage URI or BigQuery URI instead.'
2277
- )
2278
1971
 
2279
- config = _extra_utils.format_destination(src, config)
1972
+ if self._api_client.vertexai:
1973
+ config = _extra_utils.format_destination(src, parameter_model.config)
1974
+ return self._create(model=model, src=src, config=config)
2280
1975
  else:
2281
- if isinstance(parameter_model.src, list) or (
2282
- not isinstance(parameter_model.src, str)
2283
- and parameter_model.src
2284
- and parameter_model.src.inlined_requests
2285
- ):
2286
- # Handle system instruction in InlinedRequests.
2287
- request_url_dict: Optional[dict[str, str]]
2288
- request_dict: dict[str, Any] = _CreateBatchJobParameters_to_mldev(
2289
- self._api_client, parameter_model
2290
- )
2291
- request_url_dict = request_dict.get('_url')
2292
- if request_url_dict:
2293
- path = '{model}:batchGenerateContent'.format_map(request_url_dict)
2294
- else:
2295
- path = '{model}:batchGenerateContent'
2296
- query_params = request_dict.get('_query')
2297
- if query_params:
2298
- path = f'{path}?{urlencode(query_params)}'
2299
- request_dict.pop('config', None)
2300
-
2301
- request_dict = _common.convert_to_dict(request_dict)
2302
- request_dict = _common.encode_unserializable_types(request_dict)
2303
- # Move system instruction to 'request':
2304
- # {'systemInstruction': system_instruction}
2305
- requests = []
2306
- batch_dict = request_dict.get('batch')
2307
- if batch_dict and isinstance(batch_dict, dict):
2308
- input_config_dict = batch_dict.get('inputConfig')
2309
- if input_config_dict and isinstance(input_config_dict, dict):
2310
- requests_dict = input_config_dict.get('requests')
2311
- if requests_dict and isinstance(requests_dict, dict):
2312
- requests = requests_dict.get('requests')
2313
- new_requests = []
2314
- if requests:
2315
- for req in requests:
2316
- if req.get('systemInstruction'):
2317
- value = req.pop('systemInstruction')
2318
- req['request'].update({'systemInstruction': value})
2319
- new_requests.append(req)
2320
- request_dict['batch']['inputConfig']['requests'][ # type: ignore
2321
- 'requests'
2322
- ] = new_requests
2323
-
2324
- response = self._api_client.request(
2325
- 'post', path, request_dict, http_options
2326
- )
2327
-
2328
- response_dict = '' if not response.body else json.loads(response.body)
2329
-
2330
- response_dict = _BatchJob_from_mldev(response_dict)
2331
-
2332
- return_value = types.BatchJob._from_response(
2333
- response=response_dict, kwargs=parameter_model.model_dump()
2334
- )
2335
-
2336
- self._api_client._verify_response(return_value)
2337
- return return_value
2338
-
2339
- return self._create(model=model, src=src, config=config)
1976
+ return self._create(model=model, src=src, config=config)
2340
1977
 
2341
- def list(
2342
- self, *, config: Optional[types.ListBatchJobsConfigOrDict] = None
2343
- ) -> Pager[types.BatchJob]:
2344
- """Lists batch jobs.
1978
+ def create_embeddings(
1979
+ self,
1980
+ *,
1981
+ model: str,
1982
+ src: types.EmbeddingsBatchJobSourceOrDict,
1983
+ config: Optional[types.CreateEmbeddingsBatchJobConfigOrDict] = None,
1984
+ ) -> types.BatchJob:
1985
+ """**Experimental** Creates an embedding batch job.
2345
1986
 
2346
1987
  Args:
2347
- config (ListBatchJobsConfig): Optional configuration for the list request.
1988
+ model (str): The model to use for the batch job.
1989
+ src: Gemini Developer API supports List of inlined_request, or file name.
1990
+ Example: "files/file_name".
1991
+ config (CreateBatchJobConfig): Optional configuration for the batch job.
2348
1992
 
2349
1993
  Returns:
2350
- A Pager object that contains one page of batch jobs. When iterating over
2351
- the pager, it automatically fetches the next page if there are more.
1994
+ A BatchJob object that contains details about the batch job.
2352
1995
 
2353
1996
  Usage:
2354
1997
 
2355
1998
  .. code-block:: python
2356
1999
 
2357
- batch_jobs = client.batches.list(config={"page_size": 10})
2358
- for batch_job in batch_jobs:
2359
- print(f"Batch job: {batch_job.name}, state {batch_job.state}")
2000
+ batch_job = client.batches.create_embeddings(
2001
+ model="text-embedding-004",
2002
+ src="files/my_embedding_input",
2003
+ )
2004
+ print(batch_job.state)
2360
2005
  """
2361
- if config is None:
2362
- config = types.ListBatchJobsConfig()
2363
- return Pager(
2364
- 'batch_jobs',
2365
- self._list,
2366
- self._list(config=config),
2367
- config,
2006
+ import warnings
2007
+
2008
+ warnings.warn(
2009
+ 'batches.create_embeddings() is experimental and may change without'
2010
+ ' notice.',
2011
+ category=_common.ExperimentalWarning,
2012
+ stacklevel=2, # This is crucial!
2368
2013
  )
2014
+ src = t.t_embedding_batch_job_source(self._api_client, src)
2015
+
2016
+ # Convert all dicts to Pydantic objects.
2017
+ parameter_model = types._CreateEmbeddingsBatchJobParameters(
2018
+ model=model,
2019
+ src=src,
2020
+ config=config,
2021
+ )
2022
+
2023
+ if self._api_client.vertexai:
2024
+ raise ValueError('Vertex AI does not support batches.create_embeddings.')
2025
+ else:
2026
+ return self._create_embeddings(model=model, src=src, config=config)
2369
2027
 
2370
2028
 
2371
2029
  class AsyncBatches(_api_module.BaseModule):
@@ -2423,12 +2081,72 @@ class AsyncBatches(_api_module.BaseModule):
2423
2081
  'post', path, request_dict, http_options
2424
2082
  )
2425
2083
 
2426
- response_dict = '' if not response.body else json.loads(response.body)
2084
+ response_dict = {} if not response.body else json.loads(response.body)
2427
2085
 
2428
2086
  if self._api_client.vertexai:
2429
2087
  response_dict = _BatchJob_from_vertex(response_dict)
2430
2088
 
2089
+ if not self._api_client.vertexai:
2090
+ response_dict = _BatchJob_from_mldev(response_dict)
2091
+
2092
+ return_value = types.BatchJob._from_response(
2093
+ response=response_dict, kwargs=parameter_model.model_dump()
2094
+ )
2095
+
2096
+ self._api_client._verify_response(return_value)
2097
+ return return_value
2098
+
2099
+ async def _create_embeddings(
2100
+ self,
2101
+ *,
2102
+ model: Optional[str] = None,
2103
+ src: types.EmbeddingsBatchJobSourceOrDict,
2104
+ config: Optional[types.CreateEmbeddingsBatchJobConfigOrDict] = None,
2105
+ ) -> types.BatchJob:
2106
+ parameter_model = types._CreateEmbeddingsBatchJobParameters(
2107
+ model=model,
2108
+ src=src,
2109
+ config=config,
2110
+ )
2111
+
2112
+ request_url_dict: Optional[dict[str, str]]
2113
+ if self._api_client.vertexai:
2114
+ raise ValueError(
2115
+ 'This method is only supported in the Gemini Developer client.'
2116
+ )
2431
2117
  else:
2118
+ request_dict = _CreateEmbeddingsBatchJobParameters_to_mldev(
2119
+ self._api_client, parameter_model
2120
+ )
2121
+ request_url_dict = request_dict.get('_url')
2122
+ if request_url_dict:
2123
+ path = '{model}:asyncBatchEmbedContent'.format_map(request_url_dict)
2124
+ else:
2125
+ path = '{model}:asyncBatchEmbedContent'
2126
+
2127
+ query_params = request_dict.get('_query')
2128
+ if query_params:
2129
+ path = f'{path}?{urlencode(query_params)}'
2130
+ # TODO: remove the hack that pops config.
2131
+ request_dict.pop('config', None)
2132
+
2133
+ http_options: Optional[types.HttpOptions] = None
2134
+ if (
2135
+ parameter_model.config is not None
2136
+ and parameter_model.config.http_options is not None
2137
+ ):
2138
+ http_options = parameter_model.config.http_options
2139
+
2140
+ request_dict = _common.convert_to_dict(request_dict)
2141
+ request_dict = _common.encode_unserializable_types(request_dict)
2142
+
2143
+ response = await self._api_client.async_request(
2144
+ 'post', path, request_dict, http_options
2145
+ )
2146
+
2147
+ response_dict = {} if not response.body else json.loads(response.body)
2148
+
2149
+ if not self._api_client.vertexai:
2432
2150
  response_dict = _BatchJob_from_mldev(response_dict)
2433
2151
 
2434
2152
  return_value = types.BatchJob._from_response(
@@ -2505,12 +2223,12 @@ class AsyncBatches(_api_module.BaseModule):
2505
2223
  'get', path, request_dict, http_options
2506
2224
  )
2507
2225
 
2508
- response_dict = '' if not response.body else json.loads(response.body)
2226
+ response_dict = {} if not response.body else json.loads(response.body)
2509
2227
 
2510
2228
  if self._api_client.vertexai:
2511
2229
  response_dict = _BatchJob_from_vertex(response_dict)
2512
2230
 
2513
- else:
2231
+ if not self._api_client.vertexai:
2514
2232
  response_dict = _BatchJob_from_mldev(response_dict)
2515
2233
 
2516
2234
  return_value = types.BatchJob._from_response(
@@ -2631,12 +2349,12 @@ class AsyncBatches(_api_module.BaseModule):
2631
2349
  'get', path, request_dict, http_options
2632
2350
  )
2633
2351
 
2634
- response_dict = '' if not response.body else json.loads(response.body)
2352
+ response_dict = {} if not response.body else json.loads(response.body)
2635
2353
 
2636
2354
  if self._api_client.vertexai:
2637
2355
  response_dict = _ListBatchJobsResponse_from_vertex(response_dict)
2638
2356
 
2639
- else:
2357
+ if not self._api_client.vertexai:
2640
2358
  response_dict = _ListBatchJobsResponse_from_mldev(response_dict)
2641
2359
 
2642
2360
  return_value = types.ListBatchJobsResponse._from_response(
@@ -2716,12 +2434,12 @@ class AsyncBatches(_api_module.BaseModule):
2716
2434
  'delete', path, request_dict, http_options
2717
2435
  )
2718
2436
 
2719
- response_dict = '' if not response.body else json.loads(response.body)
2437
+ response_dict = {} if not response.body else json.loads(response.body)
2720
2438
 
2721
2439
  if self._api_client.vertexai:
2722
2440
  response_dict = _DeleteResourceJob_from_vertex(response_dict)
2723
2441
 
2724
- else:
2442
+ if not self._api_client.vertexai:
2725
2443
  response_dict = _DeleteResourceJob_from_mldev(response_dict)
2726
2444
 
2727
2445
  return_value = types.DeleteResourceJob._from_response(
@@ -2733,11 +2451,38 @@ class AsyncBatches(_api_module.BaseModule):
2733
2451
  self._api_client._verify_response(return_value)
2734
2452
  return return_value
2735
2453
 
2454
+ async def list(
2455
+ self, *, config: Optional[types.ListBatchJobsConfigOrDict] = None
2456
+ ) -> AsyncPager[types.BatchJob]:
2457
+ """Lists batch jobs asynchronously.
2458
+
2459
+ Args:
2460
+ config (ListBatchJobsConfig): Optional configuration for the list request.
2461
+
2462
+ Returns:
2463
+ A Pager object that contains one page of batch jobs. When iterating over
2464
+ the pager, it automatically fetches the next page if there are more.
2465
+
2466
+ Usage:
2467
+
2468
+ .. code-block:: python
2469
+ async for batch_job in await client.aio.batches.list():
2470
+ print(batch_job.name)
2471
+ """
2472
+
2473
+ list_request = self._list
2474
+ return AsyncPager(
2475
+ 'batch_jobs',
2476
+ list_request,
2477
+ await self._list(config=config),
2478
+ config,
2479
+ )
2480
+
2736
2481
  async def create(
2737
2482
  self,
2738
2483
  *,
2739
2484
  model: str,
2740
- src: Union[types.BatchJobSourceUnion, types.BatchJobSourceUnionDict],
2485
+ src: types.BatchJobSourceUnionDict,
2741
2486
  config: Optional[types.CreateBatchJobConfigOrDict] = None,
2742
2487
  ) -> types.BatchJob:
2743
2488
  """Creates a batch job asynchronously.
@@ -2762,112 +2507,74 @@ class AsyncBatches(_api_module.BaseModule):
2762
2507
  src="gs://path/to/input/data",
2763
2508
  )
2764
2509
  """
2510
+ src = t.t_batch_job_source(self._api_client, src)
2511
+
2512
+ # Convert all dicts to Pydantic objects.
2765
2513
  parameter_model = types._CreateBatchJobParameters(
2766
2514
  model=model,
2767
2515
  src=src,
2768
2516
  config=config,
2769
2517
  )
2770
- http_options: Optional[types.HttpOptions] = None
2771
- if (
2772
- parameter_model.config is not None
2773
- and parameter_model.config.http_options is not None
2774
- ):
2775
- http_options = parameter_model.config.http_options
2776
- if self._api_client.vertexai:
2777
- if isinstance(src, list):
2778
- raise ValueError(
2779
- 'inlined_requests is not supported in Vertex AI. Please use'
2780
- ' Google Cloud Storage URI or BigQuery URI instead.'
2781
- )
2782
2518
 
2783
- config = _extra_utils.format_destination(src, config)
2519
+ if self._api_client.vertexai:
2520
+ config = _extra_utils.format_destination(src, parameter_model.config)
2521
+ return await self._create(model=model, src=src, config=config)
2784
2522
  else:
2785
- if isinstance(parameter_model.src, list) or (
2786
- not isinstance(parameter_model.src, str)
2787
- and parameter_model.src
2788
- and parameter_model.src.inlined_requests
2789
- ):
2790
- # Handle system instruction in InlinedRequests.
2791
- request_url_dict: Optional[dict[str, str]]
2792
- request_dict: dict[str, Any] = _CreateBatchJobParameters_to_mldev(
2793
- self._api_client, parameter_model
2794
- )
2795
- request_url_dict = request_dict.get('_url')
2796
- if request_url_dict:
2797
- path = '{model}:batchGenerateContent'.format_map(request_url_dict)
2798
- else:
2799
- path = '{model}:batchGenerateContent'
2800
- query_params = request_dict.get('_query')
2801
- if query_params:
2802
- path = f'{path}?{urlencode(query_params)}'
2803
- request_dict.pop('config', None)
2804
-
2805
- request_dict = _common.convert_to_dict(request_dict)
2806
- request_dict = _common.encode_unserializable_types(request_dict)
2807
- # Move system instruction to 'request':
2808
- # {'systemInstruction': system_instruction}
2809
- requests = []
2810
- batch_dict = request_dict.get('batch')
2811
- if batch_dict and isinstance(batch_dict, dict):
2812
- input_config_dict = batch_dict.get('inputConfig')
2813
- if input_config_dict and isinstance(input_config_dict, dict):
2814
- requests_dict = input_config_dict.get('requests')
2815
- if requests_dict and isinstance(requests_dict, dict):
2816
- requests = requests_dict.get('requests')
2817
- new_requests = []
2818
- if requests:
2819
- for req in requests:
2820
- if req.get('systemInstruction'):
2821
- value = req.pop('systemInstruction')
2822
- req['request'].update({'systemInstruction': value})
2823
- new_requests.append(req)
2824
- request_dict['batch']['inputConfig']['requests'][ # type: ignore
2825
- 'requests'
2826
- ] = new_requests
2827
-
2828
- response = await self._api_client.async_request(
2829
- 'post', path, request_dict, http_options
2830
- )
2831
-
2832
- response_dict = '' if not response.body else json.loads(response.body)
2833
-
2834
- response_dict = _BatchJob_from_mldev(response_dict)
2835
-
2836
- return_value = types.BatchJob._from_response(
2837
- response=response_dict, kwargs=parameter_model.model_dump()
2838
- )
2839
-
2840
- self._api_client._verify_response(return_value)
2841
- return return_value
2842
-
2843
- return await self._create(model=model, src=src, config=config)
2523
+ return await self._create(model=model, src=src, config=config)
2844
2524
 
2845
- async def list(
2846
- self, *, config: Optional[types.ListBatchJobsConfigOrDict] = None
2847
- ) -> AsyncPager[types.BatchJob]:
2848
- """Lists batch jobs asynchronously.
2525
+ async def create_embeddings(
2526
+ self,
2527
+ *,
2528
+ model: str,
2529
+ src: types.EmbeddingsBatchJobSourceOrDict,
2530
+ config: Optional[types.CreateEmbeddingsBatchJobConfigOrDict] = None,
2531
+ ) -> types.BatchJob:
2532
+ """**Experimental** Creates an asynchronously embedding batch job.
2849
2533
 
2850
2534
  Args:
2851
- config (ListBatchJobsConfig): Optional configuration for the list request.
2535
+ model (str): The model to use for the batch job.
2536
+ src: Gemini Developer API supports inlined_requests, or file name.
2537
+ Example: "files/file_name".
2538
+ config (CreateBatchJobConfig): Optional configuration for the batch job.
2852
2539
 
2853
2540
  Returns:
2854
- A Pager object that contains one page of batch jobs. When iterating over
2855
- the pager, it automatically fetches the next page if there are more.
2541
+ A BatchJob object that contains details about the batch job.
2856
2542
 
2857
2543
  Usage:
2858
2544
 
2859
2545
  .. code-block:: python
2860
2546
 
2861
- batch_jobs = await client.aio.batches.list(config={'page_size': 5})
2862
- print(f"current page: {batch_jobs.page}")
2863
- await batch_jobs_pager.next_page()
2864
- print(f"next page: {batch_jobs_pager.page}")
2547
+ batch_job = await client.aio.batches.create_embeddings(
2548
+ model="text-embedding-004",
2549
+ src="files/my_embedding_input",
2550
+ )
2551
+ print(batch_job.state)
2865
2552
  """
2866
- if config is None:
2867
- config = types.ListBatchJobsConfig()
2868
- return AsyncPager(
2869
- 'batch_jobs',
2870
- self._list,
2871
- await self._list(config=config),
2872
- config,
2553
+ import warnings
2554
+
2555
+ warnings.warn(
2556
+ 'batches.create_embeddings() is experimental and may change without'
2557
+ ' notice.',
2558
+ category=_common.ExperimentalWarning,
2559
+ stacklevel=2, # This is crucial!
2560
+ )
2561
+ src = t.t_embedding_batch_job_source(self._api_client, src)
2562
+
2563
+ # Convert all dicts to Pydantic objects.
2564
+ parameter_model = types._CreateEmbeddingsBatchJobParameters(
2565
+ model=model,
2566
+ src=src,
2567
+ config=config,
2873
2568
  )
2569
+
2570
+ http_options: Optional[types.HttpOptions] = None
2571
+ if (
2572
+ parameter_model.config is not None
2573
+ and parameter_model.config.http_options is not None
2574
+ ):
2575
+ http_options = parameter_model.config.http_options
2576
+
2577
+ if self._api_client.vertexai:
2578
+ raise ValueError('Vertex AI does not support batches.create_embeddings.')
2579
+ else:
2580
+ return await self._create_embeddings(model=model, src=src, config=config)