google-genai 1.7.0__py3-none-any.whl → 1.9.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- google/genai/_api_client.py +93 -78
- google/genai/_replay_api_client.py +22 -14
- google/genai/_transformers.py +81 -16
- google/genai/batches.py +61 -295
- google/genai/caches.py +546 -526
- google/genai/chats.py +15 -8
- google/genai/client.py +5 -3
- google/genai/errors.py +47 -24
- google/genai/files.py +89 -305
- google/genai/live.py +466 -12
- google/genai/models.py +1992 -2291
- google/genai/operations.py +104 -124
- google/genai/tunings.py +256 -272
- google/genai/types.py +394 -98
- google/genai/version.py +1 -1
- {google_genai-1.7.0.dist-info → google_genai-1.9.0.dist-info}/METADATA +3 -2
- google_genai-1.9.0.dist-info/RECORD +27 -0
- {google_genai-1.7.0.dist-info → google_genai-1.9.0.dist-info}/WHEEL +1 -1
- google_genai-1.7.0.dist-info/RECORD +0 -27
- {google_genai-1.7.0.dist-info → google_genai-1.9.0.dist-info/licenses}/LICENSE +0 -0
- {google_genai-1.7.0.dist-info → google_genai-1.9.0.dist-info}/top_level.txt +0 -0
google/genai/operations.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2025 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -67,24 +67,6 @@ def _GetOperationParameters_to_vertex(
|
|
67
67
|
return to_object
|
68
68
|
|
69
69
|
|
70
|
-
def _FetchPredictOperationParameters_to_mldev(
|
71
|
-
api_client: BaseApiClient,
|
72
|
-
from_object: Union[dict, object],
|
73
|
-
parent_object: Optional[dict] = None,
|
74
|
-
) -> dict:
|
75
|
-
to_object: dict[str, Any] = {}
|
76
|
-
if getv(from_object, ['operation_name']) is not None:
|
77
|
-
raise ValueError('operation_name parameter is not supported in Gemini API.')
|
78
|
-
|
79
|
-
if getv(from_object, ['resource_name']) is not None:
|
80
|
-
raise ValueError('resource_name parameter is not supported in Gemini API.')
|
81
|
-
|
82
|
-
if getv(from_object, ['config']) is not None:
|
83
|
-
raise ValueError('config parameter is not supported in Gemini API.')
|
84
|
-
|
85
|
-
return to_object
|
86
|
-
|
87
|
-
|
88
70
|
def _FetchPredictOperationParameters_to_vertex(
|
89
71
|
api_client: BaseApiClient,
|
90
72
|
from_object: Union[dict, object],
|
@@ -129,88 +111,123 @@ def _Video_from_mldev(
|
|
129
111
|
return to_object
|
130
112
|
|
131
113
|
|
132
|
-
def
|
114
|
+
def _GeneratedVideo_from_mldev(
|
133
115
|
api_client: BaseApiClient,
|
134
116
|
from_object: Union[dict, object],
|
135
117
|
parent_object: Optional[dict] = None,
|
136
118
|
) -> dict:
|
137
119
|
to_object: dict[str, Any] = {}
|
138
|
-
if getv(from_object, ['
|
139
|
-
setv(to_object, ['uri'], getv(from_object, ['gcsUri']))
|
140
|
-
|
141
|
-
if getv(from_object, ['bytesBase64Encoded']) is not None:
|
120
|
+
if getv(from_object, ['_self']) is not None:
|
142
121
|
setv(
|
143
122
|
to_object,
|
144
|
-
['
|
145
|
-
|
123
|
+
['video'],
|
124
|
+
_Video_from_mldev(api_client, getv(from_object, ['_self']), to_object),
|
146
125
|
)
|
147
126
|
|
148
|
-
if getv(from_object, ['mimeType']) is not None:
|
149
|
-
setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
|
150
|
-
|
151
127
|
return to_object
|
152
128
|
|
153
129
|
|
154
|
-
def
|
130
|
+
def _GenerateVideosResponse_from_mldev(
|
155
131
|
api_client: BaseApiClient,
|
156
132
|
from_object: Union[dict, object],
|
157
133
|
parent_object: Optional[dict] = None,
|
158
134
|
) -> dict:
|
159
135
|
to_object: dict[str, Any] = {}
|
160
|
-
if getv(from_object, ['
|
136
|
+
if getv(from_object, ['generatedSamples']) is not None:
|
161
137
|
setv(
|
162
138
|
to_object,
|
163
|
-
['
|
164
|
-
|
139
|
+
['generated_videos'],
|
140
|
+
[
|
141
|
+
_GeneratedVideo_from_mldev(api_client, item, to_object)
|
142
|
+
for item in getv(from_object, ['generatedSamples'])
|
143
|
+
],
|
144
|
+
)
|
145
|
+
|
146
|
+
if getv(from_object, ['raiMediaFilteredCount']) is not None:
|
147
|
+
setv(
|
148
|
+
to_object,
|
149
|
+
['rai_media_filtered_count'],
|
150
|
+
getv(from_object, ['raiMediaFilteredCount']),
|
151
|
+
)
|
152
|
+
|
153
|
+
if getv(from_object, ['raiMediaFilteredReasons']) is not None:
|
154
|
+
setv(
|
155
|
+
to_object,
|
156
|
+
['rai_media_filtered_reasons'],
|
157
|
+
getv(from_object, ['raiMediaFilteredReasons']),
|
165
158
|
)
|
166
159
|
|
167
160
|
return to_object
|
168
161
|
|
169
162
|
|
170
|
-
def
|
163
|
+
def _GenerateVideosOperation_from_mldev(
|
171
164
|
api_client: BaseApiClient,
|
172
165
|
from_object: Union[dict, object],
|
173
166
|
parent_object: Optional[dict] = None,
|
174
167
|
) -> dict:
|
175
168
|
to_object: dict[str, Any] = {}
|
176
|
-
if getv(from_object, ['
|
169
|
+
if getv(from_object, ['name']) is not None:
|
170
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
171
|
+
|
172
|
+
if getv(from_object, ['metadata']) is not None:
|
173
|
+
setv(to_object, ['metadata'], getv(from_object, ['metadata']))
|
174
|
+
|
175
|
+
if getv(from_object, ['done']) is not None:
|
176
|
+
setv(to_object, ['done'], getv(from_object, ['done']))
|
177
|
+
|
178
|
+
if getv(from_object, ['error']) is not None:
|
179
|
+
setv(to_object, ['error'], getv(from_object, ['error']))
|
180
|
+
|
181
|
+
if getv(from_object, ['response']) is not None:
|
182
|
+
setv(to_object, ['response'], getv(from_object, ['response']))
|
183
|
+
|
184
|
+
if getv(from_object, ['response', 'generateVideoResponse']) is not None:
|
177
185
|
setv(
|
178
186
|
to_object,
|
179
|
-
['
|
180
|
-
|
187
|
+
['result'],
|
188
|
+
_GenerateVideosResponse_from_mldev(
|
189
|
+
api_client,
|
190
|
+
getv(from_object, ['response', 'generateVideoResponse']),
|
191
|
+
to_object,
|
192
|
+
),
|
181
193
|
)
|
182
194
|
|
183
195
|
return to_object
|
184
196
|
|
185
197
|
|
186
|
-
def
|
198
|
+
def _Video_from_vertex(
|
187
199
|
api_client: BaseApiClient,
|
188
200
|
from_object: Union[dict, object],
|
189
201
|
parent_object: Optional[dict] = None,
|
190
202
|
) -> dict:
|
191
203
|
to_object: dict[str, Any] = {}
|
192
|
-
if getv(from_object, ['
|
193
|
-
setv(
|
194
|
-
to_object,
|
195
|
-
['generated_videos'],
|
196
|
-
[
|
197
|
-
_GeneratedVideo_from_mldev(api_client, item, to_object)
|
198
|
-
for item in getv(from_object, ['generatedSamples'])
|
199
|
-
],
|
200
|
-
)
|
204
|
+
if getv(from_object, ['gcsUri']) is not None:
|
205
|
+
setv(to_object, ['uri'], getv(from_object, ['gcsUri']))
|
201
206
|
|
202
|
-
if getv(from_object, ['
|
207
|
+
if getv(from_object, ['bytesBase64Encoded']) is not None:
|
203
208
|
setv(
|
204
209
|
to_object,
|
205
|
-
['
|
206
|
-
getv(from_object, ['
|
210
|
+
['video_bytes'],
|
211
|
+
t.t_bytes(api_client, getv(from_object, ['bytesBase64Encoded'])),
|
207
212
|
)
|
208
213
|
|
209
|
-
if getv(from_object, ['
|
214
|
+
if getv(from_object, ['mimeType']) is not None:
|
215
|
+
setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
|
216
|
+
|
217
|
+
return to_object
|
218
|
+
|
219
|
+
|
220
|
+
def _GeneratedVideo_from_vertex(
|
221
|
+
api_client: BaseApiClient,
|
222
|
+
from_object: Union[dict, object],
|
223
|
+
parent_object: Optional[dict] = None,
|
224
|
+
) -> dict:
|
225
|
+
to_object: dict[str, Any] = {}
|
226
|
+
if getv(from_object, ['_self']) is not None:
|
210
227
|
setv(
|
211
228
|
to_object,
|
212
|
-
['
|
213
|
-
getv(from_object, ['
|
229
|
+
['video'],
|
230
|
+
_Video_from_vertex(api_client, getv(from_object, ['_self']), to_object),
|
214
231
|
)
|
215
232
|
|
216
233
|
return to_object
|
@@ -249,41 +266,6 @@ def _GenerateVideosResponse_from_vertex(
|
|
249
266
|
return to_object
|
250
267
|
|
251
268
|
|
252
|
-
def _GenerateVideosOperation_from_mldev(
|
253
|
-
api_client: BaseApiClient,
|
254
|
-
from_object: Union[dict, object],
|
255
|
-
parent_object: Optional[dict] = None,
|
256
|
-
) -> dict:
|
257
|
-
to_object: dict[str, Any] = {}
|
258
|
-
if getv(from_object, ['name']) is not None:
|
259
|
-
setv(to_object, ['name'], getv(from_object, ['name']))
|
260
|
-
|
261
|
-
if getv(from_object, ['metadata']) is not None:
|
262
|
-
setv(to_object, ['metadata'], getv(from_object, ['metadata']))
|
263
|
-
|
264
|
-
if getv(from_object, ['done']) is not None:
|
265
|
-
setv(to_object, ['done'], getv(from_object, ['done']))
|
266
|
-
|
267
|
-
if getv(from_object, ['error']) is not None:
|
268
|
-
setv(to_object, ['error'], getv(from_object, ['error']))
|
269
|
-
|
270
|
-
if getv(from_object, ['response']) is not None:
|
271
|
-
setv(to_object, ['response'], getv(from_object, ['response']))
|
272
|
-
|
273
|
-
if getv(from_object, ['response', 'generateVideoResponse']) is not None:
|
274
|
-
setv(
|
275
|
-
to_object,
|
276
|
-
['result'],
|
277
|
-
_GenerateVideosResponse_from_mldev(
|
278
|
-
api_client,
|
279
|
-
getv(from_object, ['response', 'generateVideoResponse']),
|
280
|
-
to_object,
|
281
|
-
),
|
282
|
-
)
|
283
|
-
|
284
|
-
return to_object
|
285
|
-
|
286
|
-
|
287
269
|
def _GenerateVideosOperation_from_vertex(
|
288
270
|
api_client: BaseApiClient,
|
289
271
|
from_object: Union[dict, object],
|
@@ -319,7 +301,7 @@ def _GenerateVideosOperation_from_vertex(
|
|
319
301
|
|
320
302
|
class Operations(_api_module.BaseModule):
|
321
303
|
|
322
|
-
def
|
304
|
+
def _get_videos_operation(
|
323
305
|
self,
|
324
306
|
*,
|
325
307
|
operation_name: str,
|
@@ -356,11 +338,12 @@ class Operations(_api_module.BaseModule):
|
|
356
338
|
# TODO: remove the hack that pops config.
|
357
339
|
request_dict.pop('config', None)
|
358
340
|
|
359
|
-
http_options: Optional[types.
|
360
|
-
if
|
361
|
-
|
362
|
-
|
363
|
-
|
341
|
+
http_options: Optional[types.HttpOptions] = None
|
342
|
+
if (
|
343
|
+
parameter_model.config is not None
|
344
|
+
and parameter_model.config.http_options is not None
|
345
|
+
):
|
346
|
+
http_options = parameter_model.config.http_options
|
364
347
|
|
365
348
|
request_dict = _common.convert_to_dict(request_dict)
|
366
349
|
request_dict = _common.encode_unserializable_types(request_dict)
|
@@ -373,6 +356,7 @@ class Operations(_api_module.BaseModule):
|
|
373
356
|
response_dict = _GenerateVideosOperation_from_vertex(
|
374
357
|
self._api_client, response_dict
|
375
358
|
)
|
359
|
+
|
376
360
|
else:
|
377
361
|
response_dict = _GenerateVideosOperation_from_mldev(
|
378
362
|
self._api_client, response_dict
|
@@ -384,7 +368,7 @@ class Operations(_api_module.BaseModule):
|
|
384
368
|
self._api_client._verify_response(return_value)
|
385
369
|
return return_value
|
386
370
|
|
387
|
-
def
|
371
|
+
def _fetch_predict_videos_operation(
|
388
372
|
self,
|
389
373
|
*,
|
390
374
|
operation_name: str,
|
@@ -418,11 +402,12 @@ class Operations(_api_module.BaseModule):
|
|
418
402
|
# TODO: remove the hack that pops config.
|
419
403
|
request_dict.pop('config', None)
|
420
404
|
|
421
|
-
http_options: Optional[types.
|
422
|
-
if
|
423
|
-
|
424
|
-
|
425
|
-
|
405
|
+
http_options: Optional[types.HttpOptions] = None
|
406
|
+
if (
|
407
|
+
parameter_model.config is not None
|
408
|
+
and parameter_model.config.http_options is not None
|
409
|
+
):
|
410
|
+
http_options = parameter_model.config.http_options
|
426
411
|
|
427
412
|
request_dict = _common.convert_to_dict(request_dict)
|
428
413
|
request_dict = _common.encode_unserializable_types(request_dict)
|
@@ -435,10 +420,6 @@ class Operations(_api_module.BaseModule):
|
|
435
420
|
response_dict = _GenerateVideosOperation_from_vertex(
|
436
421
|
self._api_client, response_dict
|
437
422
|
)
|
438
|
-
else:
|
439
|
-
response_dict = _GenerateVideosOperation_from_mldev(
|
440
|
-
self._api_client, response_dict
|
441
|
-
)
|
442
423
|
|
443
424
|
return_value = types.GenerateVideosOperation._from_response(
|
444
425
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -479,13 +460,13 @@ class Operations(_api_module.BaseModule):
|
|
479
460
|
fetch_operation_config = types.FetchPredictOperationConfig(
|
480
461
|
http_options=http_options
|
481
462
|
)
|
482
|
-
return self.
|
463
|
+
return self._fetch_predict_videos_operation(
|
483
464
|
operation_name=operation_name,
|
484
465
|
resource_name=resource_name,
|
485
466
|
config=fetch_operation_config,
|
486
467
|
)
|
487
468
|
else:
|
488
|
-
return self.
|
469
|
+
return self._get_videos_operation(
|
489
470
|
operation_name=operation_name,
|
490
471
|
config=config,
|
491
472
|
)
|
@@ -493,7 +474,7 @@ class Operations(_api_module.BaseModule):
|
|
493
474
|
|
494
475
|
class AsyncOperations(_api_module.BaseModule):
|
495
476
|
|
496
|
-
async def
|
477
|
+
async def _get_videos_operation(
|
497
478
|
self,
|
498
479
|
*,
|
499
480
|
operation_name: str,
|
@@ -530,11 +511,12 @@ class AsyncOperations(_api_module.BaseModule):
|
|
530
511
|
# TODO: remove the hack that pops config.
|
531
512
|
request_dict.pop('config', None)
|
532
513
|
|
533
|
-
http_options: Optional[types.
|
534
|
-
if
|
535
|
-
|
536
|
-
|
537
|
-
|
514
|
+
http_options: Optional[types.HttpOptions] = None
|
515
|
+
if (
|
516
|
+
parameter_model.config is not None
|
517
|
+
and parameter_model.config.http_options is not None
|
518
|
+
):
|
519
|
+
http_options = parameter_model.config.http_options
|
538
520
|
|
539
521
|
request_dict = _common.convert_to_dict(request_dict)
|
540
522
|
request_dict = _common.encode_unserializable_types(request_dict)
|
@@ -547,6 +529,7 @@ class AsyncOperations(_api_module.BaseModule):
|
|
547
529
|
response_dict = _GenerateVideosOperation_from_vertex(
|
548
530
|
self._api_client, response_dict
|
549
531
|
)
|
532
|
+
|
550
533
|
else:
|
551
534
|
response_dict = _GenerateVideosOperation_from_mldev(
|
552
535
|
self._api_client, response_dict
|
@@ -558,7 +541,7 @@ class AsyncOperations(_api_module.BaseModule):
|
|
558
541
|
self._api_client._verify_response(return_value)
|
559
542
|
return return_value
|
560
543
|
|
561
|
-
async def
|
544
|
+
async def _fetch_predict_videos_operation(
|
562
545
|
self,
|
563
546
|
*,
|
564
547
|
operation_name: str,
|
@@ -592,11 +575,12 @@ class AsyncOperations(_api_module.BaseModule):
|
|
592
575
|
# TODO: remove the hack that pops config.
|
593
576
|
request_dict.pop('config', None)
|
594
577
|
|
595
|
-
http_options: Optional[types.
|
596
|
-
if
|
597
|
-
|
598
|
-
|
599
|
-
|
578
|
+
http_options: Optional[types.HttpOptions] = None
|
579
|
+
if (
|
580
|
+
parameter_model.config is not None
|
581
|
+
and parameter_model.config.http_options is not None
|
582
|
+
):
|
583
|
+
http_options = parameter_model.config.http_options
|
600
584
|
|
601
585
|
request_dict = _common.convert_to_dict(request_dict)
|
602
586
|
request_dict = _common.encode_unserializable_types(request_dict)
|
@@ -609,10 +593,6 @@ class AsyncOperations(_api_module.BaseModule):
|
|
609
593
|
response_dict = _GenerateVideosOperation_from_vertex(
|
610
594
|
self._api_client, response_dict
|
611
595
|
)
|
612
|
-
else:
|
613
|
-
response_dict = _GenerateVideosOperation_from_mldev(
|
614
|
-
self._api_client, response_dict
|
615
|
-
)
|
616
596
|
|
617
597
|
return_value = types.GenerateVideosOperation._from_response(
|
618
598
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -651,13 +631,13 @@ class AsyncOperations(_api_module.BaseModule):
|
|
651
631
|
fetch_operation_config = types.FetchPredictOperationConfig(
|
652
632
|
http_options=http_options
|
653
633
|
)
|
654
|
-
return await self.
|
634
|
+
return await self._fetch_predict_videos_operation(
|
655
635
|
operation_name=operation_name,
|
656
636
|
resource_name=resource_name,
|
657
637
|
config=fetch_operation_config,
|
658
638
|
)
|
659
639
|
else:
|
660
|
-
return await self.
|
640
|
+
return await self._get_videos_operation(
|
661
641
|
operation_name=operation_name,
|
662
642
|
config=config,
|
663
643
|
)
|