google-genai 1.20.0__py3-none-any.whl → 1.21.1__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 +170 -103
- google/genai/_common.py +73 -0
- google/genai/_live_converters.py +174 -414
- google/genai/_replay_api_client.py +9 -3
- google/genai/_tokens_converters.py +81 -176
- google/genai/_transformers.py +19 -40
- google/genai/batches.py +46 -64
- google/genai/caches.py +131 -222
- google/genai/chats.py +4 -4
- google/genai/client.py +1 -1
- google/genai/files.py +88 -106
- google/genai/live.py +15 -20
- google/genai/live_music.py +4 -5
- google/genai/models.py +317 -560
- google/genai/operations.py +35 -68
- google/genai/tokens.py +11 -6
- google/genai/tunings.py +64 -113
- google/genai/types.py +132 -9
- google/genai/version.py +1 -1
- {google_genai-1.20.0.dist-info → google_genai-1.21.1.dist-info}/METADATA +45 -1
- google_genai-1.21.1.dist-info/RECORD +35 -0
- google_genai-1.20.0.dist-info/RECORD +0 -35
- {google_genai-1.20.0.dist-info → google_genai-1.21.1.dist-info}/WHEEL +0 -0
- {google_genai-1.20.0.dist-info → google_genai-1.21.1.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.20.0.dist-info → google_genai-1.21.1.dist-info}/top_level.txt +0 -0
google/genai/_transformers.py
CHANGED
@@ -195,7 +195,6 @@ def t_models_url(
|
|
195
195
|
|
196
196
|
|
197
197
|
def t_extract_models(
|
198
|
-
api_client: _api_client.BaseApiClient,
|
199
198
|
response: dict[str, Any],
|
200
199
|
) -> list[dict[str, Any]]:
|
201
200
|
if not response:
|
@@ -299,18 +298,15 @@ def t_function_responses(
|
|
299
298
|
|
300
299
|
|
301
300
|
def t_blobs(
|
302
|
-
api_client: _api_client.BaseApiClient,
|
303
301
|
blobs: Union[types.BlobImageUnionDict, list[types.BlobImageUnionDict]],
|
304
302
|
) -> list[types.Blob]:
|
305
303
|
if isinstance(blobs, list):
|
306
|
-
return [t_blob(
|
304
|
+
return [t_blob(blob) for blob in blobs]
|
307
305
|
else:
|
308
|
-
return [t_blob(
|
306
|
+
return [t_blob(blobs)]
|
309
307
|
|
310
308
|
|
311
|
-
def t_blob(
|
312
|
-
api_client: _api_client.BaseApiClient, blob: types.BlobImageUnionDict
|
313
|
-
) -> types.Blob:
|
309
|
+
def t_blob(blob: types.BlobImageUnionDict) -> types.Blob:
|
314
310
|
try:
|
315
311
|
import PIL.Image
|
316
312
|
|
@@ -335,19 +331,15 @@ def t_blob(
|
|
335
331
|
)
|
336
332
|
|
337
333
|
|
338
|
-
def t_image_blob(
|
339
|
-
|
340
|
-
) -> types.Blob:
|
341
|
-
blob = t_blob(api_client, blob)
|
334
|
+
def t_image_blob(blob: types.BlobImageUnionDict) -> types.Blob:
|
335
|
+
blob = t_blob(blob)
|
342
336
|
if blob.mime_type and blob.mime_type.startswith('image/'):
|
343
337
|
return blob
|
344
338
|
raise ValueError(f'Unsupported mime type: {blob.mime_type!r}')
|
345
339
|
|
346
340
|
|
347
|
-
def t_audio_blob(
|
348
|
-
|
349
|
-
) -> types.Blob:
|
350
|
-
blob = t_blob(api_client, blob)
|
341
|
+
def t_audio_blob(blob: types.BlobOrDict) -> types.Blob:
|
342
|
+
blob = t_blob(blob)
|
351
343
|
if blob.mime_type and blob.mime_type.startswith('audio/'):
|
352
344
|
return blob
|
353
345
|
raise ValueError(f'Unsupported mime type: {blob.mime_type!r}')
|
@@ -393,7 +385,6 @@ def t_parts(
|
|
393
385
|
|
394
386
|
|
395
387
|
def t_image_predictions(
|
396
|
-
client: _api_client.BaseApiClient,
|
397
388
|
predictions: Optional[Iterable[Mapping[str, Any]]],
|
398
389
|
) -> Optional[list[types.GeneratedImage]]:
|
399
390
|
if not predictions:
|
@@ -416,7 +407,6 @@ ContentType = Union[types.Content, types.ContentDict, types.PartUnionDict]
|
|
416
407
|
|
417
408
|
|
418
409
|
def t_content(
|
419
|
-
client: _api_client.BaseApiClient,
|
420
410
|
content: Optional[ContentType],
|
421
411
|
) -> types.Content:
|
422
412
|
if content is None:
|
@@ -447,9 +437,9 @@ def t_contents_for_embed(
|
|
447
437
|
contents: Union[list[types.Content], list[types.ContentDict], ContentType],
|
448
438
|
) -> Union[list[str], list[types.Content]]:
|
449
439
|
if isinstance(contents, list):
|
450
|
-
transformed_contents = [t_content(
|
440
|
+
transformed_contents = [t_content(content) for content in contents]
|
451
441
|
else:
|
452
|
-
transformed_contents = [t_content(
|
442
|
+
transformed_contents = [t_content(contents)]
|
453
443
|
|
454
444
|
if client.vertexai:
|
455
445
|
text_parts = []
|
@@ -469,7 +459,6 @@ def t_contents_for_embed(
|
|
469
459
|
|
470
460
|
|
471
461
|
def t_contents(
|
472
|
-
client: _api_client.BaseApiClient,
|
473
462
|
contents: Optional[
|
474
463
|
Union[types.ContentListUnion, types.ContentListUnionDict, types.Content]
|
475
464
|
],
|
@@ -477,7 +466,7 @@ def t_contents(
|
|
477
466
|
if contents is None or (isinstance(contents, list) and not contents):
|
478
467
|
raise ValueError('contents are required.')
|
479
468
|
if not isinstance(contents, list):
|
480
|
-
return [t_content(
|
469
|
+
return [t_content(contents)]
|
481
470
|
|
482
471
|
try:
|
483
472
|
import PIL.Image
|
@@ -635,14 +624,13 @@ def _raise_for_unsupported_schema_type(origin: Any) -> None:
|
|
635
624
|
raise ValueError(f'Unsupported schema type: {origin}')
|
636
625
|
|
637
626
|
|
638
|
-
def _raise_for_unsupported_mldev_properties(
|
627
|
+
def _raise_for_unsupported_mldev_properties(
|
628
|
+
schema: Any, client: _api_client.BaseApiClient
|
629
|
+
) -> None:
|
639
630
|
if not client.vertexai and (
|
640
|
-
schema.get('additionalProperties')
|
641
|
-
or schema.get('additional_properties')
|
631
|
+
schema.get('additionalProperties') or schema.get('additional_properties')
|
642
632
|
):
|
643
|
-
raise ValueError(
|
644
|
-
'additionalProperties is not supported in the Gemini API.'
|
645
|
-
)
|
633
|
+
raise ValueError('additionalProperties is not supported in the Gemini API.')
|
646
634
|
|
647
635
|
|
648
636
|
def process_schema(
|
@@ -872,7 +860,6 @@ def t_schema(
|
|
872
860
|
|
873
861
|
|
874
862
|
def t_speech_config(
|
875
|
-
_: _api_client.BaseApiClient,
|
876
863
|
origin: Union[types.SpeechConfigUnionDict, Any],
|
877
864
|
) -> Optional[types.SpeechConfig]:
|
878
865
|
if not origin:
|
@@ -892,7 +879,6 @@ def t_speech_config(
|
|
892
879
|
|
893
880
|
|
894
881
|
def t_live_speech_config(
|
895
|
-
client: _api_client.BaseApiClient,
|
896
882
|
origin: types.SpeechConfigOrDict,
|
897
883
|
) -> Optional[types.SpeechConfig]:
|
898
884
|
if isinstance(origin, types.SpeechConfig):
|
@@ -958,9 +944,7 @@ def t_cached_content_name(client: _api_client.BaseApiClient, name: str) -> str:
|
|
958
944
|
return _resource_name(client, name, collection_identifier='cachedContents')
|
959
945
|
|
960
946
|
|
961
|
-
def t_batch_job_source(
|
962
|
-
client: _api_client.BaseApiClient, src: str
|
963
|
-
) -> types.BatchJobSource:
|
947
|
+
def t_batch_job_source(src: str) -> types.BatchJobSource:
|
964
948
|
if src.startswith('gs://'):
|
965
949
|
return types.BatchJobSource(
|
966
950
|
format='jsonl',
|
@@ -975,9 +959,7 @@ def t_batch_job_source(
|
|
975
959
|
raise ValueError(f'Unsupported source: {src}')
|
976
960
|
|
977
961
|
|
978
|
-
def t_batch_job_destination(
|
979
|
-
client: _api_client.BaseApiClient, dest: str
|
980
|
-
) -> types.BatchJobDestination:
|
962
|
+
def t_batch_job_destination(dest: str) -> types.BatchJobDestination:
|
981
963
|
if dest.startswith('gs://'):
|
982
964
|
return types.BatchJobDestination(
|
983
965
|
format='jsonl',
|
@@ -1042,7 +1024,6 @@ def t_resolve_operation(
|
|
1042
1024
|
|
1043
1025
|
|
1044
1026
|
def t_file_name(
|
1045
|
-
api_client: _api_client.BaseApiClient,
|
1046
1027
|
name: Optional[Union[str, types.File, types.Video, types.GeneratedVideo]],
|
1047
1028
|
) -> str:
|
1048
1029
|
# Remove the files/ prefix since it's added to the url path.
|
@@ -1076,9 +1057,7 @@ def t_file_name(
|
|
1076
1057
|
return name
|
1077
1058
|
|
1078
1059
|
|
1079
|
-
def t_tuning_job_status(
|
1080
|
-
api_client: _api_client.BaseApiClient, status: str
|
1081
|
-
) -> Union[types.JobState, str]:
|
1060
|
+
def t_tuning_job_status(status: str) -> Union[types.JobState, str]:
|
1082
1061
|
if status == 'STATE_UNSPECIFIED':
|
1083
1062
|
return types.JobState.JOB_STATE_UNSPECIFIED
|
1084
1063
|
elif status == 'CREATING':
|
@@ -1098,7 +1077,7 @@ def t_tuning_job_status(
|
|
1098
1077
|
# We shouldn't use this transformer if the backend adhere to Cloud Type
|
1099
1078
|
# format https://cloud.google.com/docs/discovery/type-format.
|
1100
1079
|
# TODO(b/389133914,b/390320301): Remove the hack after backend fix the issue.
|
1101
|
-
def t_bytes(
|
1080
|
+
def t_bytes(data: bytes) -> str:
|
1102
1081
|
if not isinstance(data, bytes):
|
1103
1082
|
return data
|
1104
1083
|
return base64.b64encode(data).decode('ascii')
|
google/genai/batches.py
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
|
16
16
|
# Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
17
17
|
|
18
|
+
import json
|
18
19
|
import logging
|
19
20
|
from typing import Any, Optional, Union
|
20
21
|
from urllib.parse import urlencode
|
@@ -33,7 +34,6 @@ logger = logging.getLogger('google_genai.batches')
|
|
33
34
|
|
34
35
|
|
35
36
|
def _BatchJobSource_to_vertex(
|
36
|
-
api_client: BaseApiClient,
|
37
37
|
from_object: Union[dict[str, Any], object],
|
38
38
|
parent_object: Optional[dict[str, Any]] = None,
|
39
39
|
) -> dict[str, Any]:
|
@@ -55,7 +55,6 @@ def _BatchJobSource_to_vertex(
|
|
55
55
|
|
56
56
|
|
57
57
|
def _BatchJobDestination_to_vertex(
|
58
|
-
api_client: BaseApiClient,
|
59
58
|
from_object: Union[dict[str, Any], object],
|
60
59
|
parent_object: Optional[dict[str, Any]] = None,
|
61
60
|
) -> dict[str, Any]:
|
@@ -81,7 +80,6 @@ def _BatchJobDestination_to_vertex(
|
|
81
80
|
|
82
81
|
|
83
82
|
def _CreateBatchJobConfig_to_vertex(
|
84
|
-
api_client: BaseApiClient,
|
85
83
|
from_object: Union[dict[str, Any], object],
|
86
84
|
parent_object: Optional[dict[str, Any]] = None,
|
87
85
|
) -> dict[str, Any]:
|
@@ -95,9 +93,7 @@ def _CreateBatchJobConfig_to_vertex(
|
|
95
93
|
parent_object,
|
96
94
|
['outputConfig'],
|
97
95
|
_BatchJobDestination_to_vertex(
|
98
|
-
|
99
|
-
t.t_batch_job_destination(api_client, getv(from_object, ['dest'])),
|
100
|
-
to_object,
|
96
|
+
t.t_batch_job_destination(getv(from_object, ['dest'])), to_object
|
101
97
|
),
|
102
98
|
)
|
103
99
|
|
@@ -122,9 +118,7 @@ def _CreateBatchJobParameters_to_vertex(
|
|
122
118
|
to_object,
|
123
119
|
['inputConfig'],
|
124
120
|
_BatchJobSource_to_vertex(
|
125
|
-
|
126
|
-
t.t_batch_job_source(api_client, getv(from_object, ['src'])),
|
127
|
-
to_object,
|
121
|
+
t.t_batch_job_source(getv(from_object, ['src'])), to_object
|
128
122
|
),
|
129
123
|
)
|
130
124
|
|
@@ -133,7 +127,7 @@ def _CreateBatchJobParameters_to_vertex(
|
|
133
127
|
to_object,
|
134
128
|
['config'],
|
135
129
|
_CreateBatchJobConfig_to_vertex(
|
136
|
-
|
130
|
+
getv(from_object, ['config']), to_object
|
137
131
|
),
|
138
132
|
)
|
139
133
|
|
@@ -179,7 +173,6 @@ def _CancelBatchJobParameters_to_vertex(
|
|
179
173
|
|
180
174
|
|
181
175
|
def _ListBatchJobsConfig_to_vertex(
|
182
|
-
api_client: BaseApiClient,
|
183
176
|
from_object: Union[dict[str, Any], object],
|
184
177
|
parent_object: Optional[dict[str, Any]] = None,
|
185
178
|
) -> dict[str, Any]:
|
@@ -204,7 +197,6 @@ def _ListBatchJobsConfig_to_vertex(
|
|
204
197
|
|
205
198
|
|
206
199
|
def _ListBatchJobsParameters_to_vertex(
|
207
|
-
api_client: BaseApiClient,
|
208
200
|
from_object: Union[dict[str, Any], object],
|
209
201
|
parent_object: Optional[dict[str, Any]] = None,
|
210
202
|
) -> dict[str, Any]:
|
@@ -214,7 +206,7 @@ def _ListBatchJobsParameters_to_vertex(
|
|
214
206
|
to_object,
|
215
207
|
['config'],
|
216
208
|
_ListBatchJobsConfig_to_vertex(
|
217
|
-
|
209
|
+
getv(from_object, ['config']), to_object
|
218
210
|
),
|
219
211
|
)
|
220
212
|
|
@@ -241,7 +233,6 @@ def _DeleteBatchJobParameters_to_vertex(
|
|
241
233
|
|
242
234
|
|
243
235
|
def _JobError_from_vertex(
|
244
|
-
api_client: BaseApiClient,
|
245
236
|
from_object: Union[dict[str, Any], object],
|
246
237
|
parent_object: Optional[dict[str, Any]] = None,
|
247
238
|
) -> dict[str, Any]:
|
@@ -259,7 +250,6 @@ def _JobError_from_vertex(
|
|
259
250
|
|
260
251
|
|
261
252
|
def _BatchJobSource_from_vertex(
|
262
|
-
api_client: BaseApiClient,
|
263
253
|
from_object: Union[dict[str, Any], object],
|
264
254
|
parent_object: Optional[dict[str, Any]] = None,
|
265
255
|
) -> dict[str, Any]:
|
@@ -281,7 +271,6 @@ def _BatchJobSource_from_vertex(
|
|
281
271
|
|
282
272
|
|
283
273
|
def _BatchJobDestination_from_vertex(
|
284
|
-
api_client: BaseApiClient,
|
285
274
|
from_object: Union[dict[str, Any], object],
|
286
275
|
parent_object: Optional[dict[str, Any]] = None,
|
287
276
|
) -> dict[str, Any]:
|
@@ -307,7 +296,6 @@ def _BatchJobDestination_from_vertex(
|
|
307
296
|
|
308
297
|
|
309
298
|
def _BatchJob_from_vertex(
|
310
|
-
api_client: BaseApiClient,
|
311
299
|
from_object: Union[dict[str, Any], object],
|
312
300
|
parent_object: Optional[dict[str, Any]] = None,
|
313
301
|
) -> dict[str, Any]:
|
@@ -325,9 +313,7 @@ def _BatchJob_from_vertex(
|
|
325
313
|
setv(
|
326
314
|
to_object,
|
327
315
|
['error'],
|
328
|
-
_JobError_from_vertex(
|
329
|
-
api_client, getv(from_object, ['error']), to_object
|
330
|
-
),
|
316
|
+
_JobError_from_vertex(getv(from_object, ['error']), to_object),
|
331
317
|
)
|
332
318
|
|
333
319
|
if getv(from_object, ['createTime']) is not None:
|
@@ -350,7 +336,7 @@ def _BatchJob_from_vertex(
|
|
350
336
|
to_object,
|
351
337
|
['src'],
|
352
338
|
_BatchJobSource_from_vertex(
|
353
|
-
|
339
|
+
getv(from_object, ['inputConfig']), to_object
|
354
340
|
),
|
355
341
|
)
|
356
342
|
|
@@ -359,7 +345,7 @@ def _BatchJob_from_vertex(
|
|
359
345
|
to_object,
|
360
346
|
['dest'],
|
361
347
|
_BatchJobDestination_from_vertex(
|
362
|
-
|
348
|
+
getv(from_object, ['outputConfig']), to_object
|
363
349
|
),
|
364
350
|
)
|
365
351
|
|
@@ -367,7 +353,6 @@ def _BatchJob_from_vertex(
|
|
367
353
|
|
368
354
|
|
369
355
|
def _ListBatchJobsResponse_from_vertex(
|
370
|
-
api_client: BaseApiClient,
|
371
356
|
from_object: Union[dict[str, Any], object],
|
372
357
|
parent_object: Optional[dict[str, Any]] = None,
|
373
358
|
) -> dict[str, Any]:
|
@@ -380,7 +365,7 @@ def _ListBatchJobsResponse_from_vertex(
|
|
380
365
|
to_object,
|
381
366
|
['batch_jobs'],
|
382
367
|
[
|
383
|
-
_BatchJob_from_vertex(
|
368
|
+
_BatchJob_from_vertex(item, to_object)
|
384
369
|
for item in getv(from_object, ['batchPredictionJobs'])
|
385
370
|
],
|
386
371
|
)
|
@@ -389,7 +374,6 @@ def _ListBatchJobsResponse_from_vertex(
|
|
389
374
|
|
390
375
|
|
391
376
|
def _DeleteResourceJob_from_vertex(
|
392
|
-
api_client: BaseApiClient,
|
393
377
|
from_object: Union[dict[str, Any], object],
|
394
378
|
parent_object: Optional[dict[str, Any]] = None,
|
395
379
|
) -> dict[str, Any]:
|
@@ -404,9 +388,7 @@ def _DeleteResourceJob_from_vertex(
|
|
404
388
|
setv(
|
405
389
|
to_object,
|
406
390
|
['error'],
|
407
|
-
_JobError_from_vertex(
|
408
|
-
api_client, getv(from_object, ['error']), to_object
|
409
|
-
),
|
391
|
+
_JobError_from_vertex(getv(from_object, ['error']), to_object),
|
410
392
|
)
|
411
393
|
|
412
394
|
return to_object
|
@@ -456,12 +438,14 @@ class Batches(_api_module.BaseModule):
|
|
456
438
|
request_dict = _common.convert_to_dict(request_dict)
|
457
439
|
request_dict = _common.encode_unserializable_types(request_dict)
|
458
440
|
|
459
|
-
|
441
|
+
response = self._api_client.request(
|
460
442
|
'post', path, request_dict, http_options
|
461
443
|
)
|
462
444
|
|
445
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
446
|
+
|
463
447
|
if self._api_client.vertexai:
|
464
|
-
response_dict = _BatchJob_from_vertex(
|
448
|
+
response_dict = _BatchJob_from_vertex(response_dict)
|
465
449
|
|
466
450
|
return_value = types.BatchJob._from_response(
|
467
451
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -524,12 +508,12 @@ class Batches(_api_module.BaseModule):
|
|
524
508
|
request_dict = _common.convert_to_dict(request_dict)
|
525
509
|
request_dict = _common.encode_unserializable_types(request_dict)
|
526
510
|
|
527
|
-
|
528
|
-
|
529
|
-
)
|
511
|
+
response = self._api_client.request('get', path, request_dict, http_options)
|
512
|
+
|
513
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
530
514
|
|
531
515
|
if self._api_client.vertexai:
|
532
|
-
response_dict = _BatchJob_from_vertex(
|
516
|
+
response_dict = _BatchJob_from_vertex(response_dict)
|
533
517
|
|
534
518
|
return_value = types.BatchJob._from_response(
|
535
519
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -593,7 +577,7 @@ class Batches(_api_module.BaseModule):
|
|
593
577
|
request_dict = _common.convert_to_dict(request_dict)
|
594
578
|
request_dict = _common.encode_unserializable_types(request_dict)
|
595
579
|
|
596
|
-
|
580
|
+
response = self._api_client.request(
|
597
581
|
'post', path, request_dict, http_options
|
598
582
|
)
|
599
583
|
|
@@ -608,9 +592,7 @@ class Batches(_api_module.BaseModule):
|
|
608
592
|
if not self._api_client.vertexai:
|
609
593
|
raise ValueError('This method is only supported in the Vertex AI client.')
|
610
594
|
else:
|
611
|
-
request_dict = _ListBatchJobsParameters_to_vertex(
|
612
|
-
self._api_client, parameter_model
|
613
|
-
)
|
595
|
+
request_dict = _ListBatchJobsParameters_to_vertex(parameter_model)
|
614
596
|
request_url_dict = request_dict.get('_url')
|
615
597
|
if request_url_dict:
|
616
598
|
path = 'batchPredictionJobs'.format_map(request_url_dict)
|
@@ -633,14 +615,12 @@ class Batches(_api_module.BaseModule):
|
|
633
615
|
request_dict = _common.convert_to_dict(request_dict)
|
634
616
|
request_dict = _common.encode_unserializable_types(request_dict)
|
635
617
|
|
636
|
-
|
637
|
-
|
638
|
-
)
|
618
|
+
response = self._api_client.request('get', path, request_dict, http_options)
|
619
|
+
|
620
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
639
621
|
|
640
622
|
if self._api_client.vertexai:
|
641
|
-
response_dict = _ListBatchJobsResponse_from_vertex(
|
642
|
-
self._api_client, response_dict
|
643
|
-
)
|
623
|
+
response_dict = _ListBatchJobsResponse_from_vertex(response_dict)
|
644
624
|
|
645
625
|
return_value = types.ListBatchJobsResponse._from_response(
|
646
626
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -705,14 +685,14 @@ class Batches(_api_module.BaseModule):
|
|
705
685
|
request_dict = _common.convert_to_dict(request_dict)
|
706
686
|
request_dict = _common.encode_unserializable_types(request_dict)
|
707
687
|
|
708
|
-
|
688
|
+
response = self._api_client.request(
|
709
689
|
'delete', path, request_dict, http_options
|
710
690
|
)
|
711
691
|
|
692
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
693
|
+
|
712
694
|
if self._api_client.vertexai:
|
713
|
-
response_dict = _DeleteResourceJob_from_vertex(
|
714
|
-
self._api_client, response_dict
|
715
|
-
)
|
695
|
+
response_dict = _DeleteResourceJob_from_vertex(response_dict)
|
716
696
|
|
717
697
|
return_value = types.DeleteResourceJob._from_response(
|
718
698
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -826,12 +806,14 @@ class AsyncBatches(_api_module.BaseModule):
|
|
826
806
|
request_dict = _common.convert_to_dict(request_dict)
|
827
807
|
request_dict = _common.encode_unserializable_types(request_dict)
|
828
808
|
|
829
|
-
|
809
|
+
response = await self._api_client.async_request(
|
830
810
|
'post', path, request_dict, http_options
|
831
811
|
)
|
832
812
|
|
813
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
814
|
+
|
833
815
|
if self._api_client.vertexai:
|
834
|
-
response_dict = _BatchJob_from_vertex(
|
816
|
+
response_dict = _BatchJob_from_vertex(response_dict)
|
835
817
|
|
836
818
|
return_value = types.BatchJob._from_response(
|
837
819
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -894,12 +876,14 @@ class AsyncBatches(_api_module.BaseModule):
|
|
894
876
|
request_dict = _common.convert_to_dict(request_dict)
|
895
877
|
request_dict = _common.encode_unserializable_types(request_dict)
|
896
878
|
|
897
|
-
|
879
|
+
response = await self._api_client.async_request(
|
898
880
|
'get', path, request_dict, http_options
|
899
881
|
)
|
900
882
|
|
883
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
884
|
+
|
901
885
|
if self._api_client.vertexai:
|
902
|
-
response_dict = _BatchJob_from_vertex(
|
886
|
+
response_dict = _BatchJob_from_vertex(response_dict)
|
903
887
|
|
904
888
|
return_value = types.BatchJob._from_response(
|
905
889
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -963,7 +947,7 @@ class AsyncBatches(_api_module.BaseModule):
|
|
963
947
|
request_dict = _common.convert_to_dict(request_dict)
|
964
948
|
request_dict = _common.encode_unserializable_types(request_dict)
|
965
949
|
|
966
|
-
|
950
|
+
response = await self._api_client.async_request(
|
967
951
|
'post', path, request_dict, http_options
|
968
952
|
)
|
969
953
|
|
@@ -978,9 +962,7 @@ class AsyncBatches(_api_module.BaseModule):
|
|
978
962
|
if not self._api_client.vertexai:
|
979
963
|
raise ValueError('This method is only supported in the Vertex AI client.')
|
980
964
|
else:
|
981
|
-
request_dict = _ListBatchJobsParameters_to_vertex(
|
982
|
-
self._api_client, parameter_model
|
983
|
-
)
|
965
|
+
request_dict = _ListBatchJobsParameters_to_vertex(parameter_model)
|
984
966
|
request_url_dict = request_dict.get('_url')
|
985
967
|
if request_url_dict:
|
986
968
|
path = 'batchPredictionJobs'.format_map(request_url_dict)
|
@@ -1003,14 +985,14 @@ class AsyncBatches(_api_module.BaseModule):
|
|
1003
985
|
request_dict = _common.convert_to_dict(request_dict)
|
1004
986
|
request_dict = _common.encode_unserializable_types(request_dict)
|
1005
987
|
|
1006
|
-
|
988
|
+
response = await self._api_client.async_request(
|
1007
989
|
'get', path, request_dict, http_options
|
1008
990
|
)
|
1009
991
|
|
992
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
993
|
+
|
1010
994
|
if self._api_client.vertexai:
|
1011
|
-
response_dict = _ListBatchJobsResponse_from_vertex(
|
1012
|
-
self._api_client, response_dict
|
1013
|
-
)
|
995
|
+
response_dict = _ListBatchJobsResponse_from_vertex(response_dict)
|
1014
996
|
|
1015
997
|
return_value = types.ListBatchJobsResponse._from_response(
|
1016
998
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -1075,14 +1057,14 @@ class AsyncBatches(_api_module.BaseModule):
|
|
1075
1057
|
request_dict = _common.convert_to_dict(request_dict)
|
1076
1058
|
request_dict = _common.encode_unserializable_types(request_dict)
|
1077
1059
|
|
1078
|
-
|
1060
|
+
response = await self._api_client.async_request(
|
1079
1061
|
'delete', path, request_dict, http_options
|
1080
1062
|
)
|
1081
1063
|
|
1064
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
1065
|
+
|
1082
1066
|
if self._api_client.vertexai:
|
1083
|
-
response_dict = _DeleteResourceJob_from_vertex(
|
1084
|
-
self._api_client, response_dict
|
1085
|
-
)
|
1067
|
+
response_dict = _DeleteResourceJob_from_vertex(response_dict)
|
1086
1068
|
|
1087
1069
|
return_value = types.DeleteResourceJob._from_response(
|
1088
1070
|
response=response_dict, kwargs=parameter_model.model_dump()
|