google-genai 1.3.0__py3-none-any.whl → 1.4.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 +30 -26
- google/genai/_api_module.py +1 -1
- google/genai/_automatic_function_calling_util.py +12 -12
- google/genai/_common.py +2 -2
- google/genai/_extra_utils.py +7 -6
- google/genai/_replay_api_client.py +3 -2
- google/genai/_test_api_client.py +8 -8
- google/genai/_transformers.py +158 -47
- google/genai/batches.py +170 -124
- google/genai/caches.py +306 -206
- google/genai/chats.py +179 -35
- google/genai/client.py +3 -3
- google/genai/errors.py +1 -2
- google/genai/files.py +153 -110
- google/genai/live.py +73 -64
- google/genai/models.py +828 -591
- google/genai/operations.py +86 -56
- google/genai/pagers.py +5 -5
- google/genai/tunings.py +163 -103
- google/genai/types.py +174 -157
- google/genai/version.py +1 -1
- {google_genai-1.3.0.dist-info → google_genai-1.4.0.dist-info}/METADATA +7 -1
- google_genai-1.4.0.dist-info/RECORD +27 -0
- {google_genai-1.3.0.dist-info → google_genai-1.4.0.dist-info}/WHEEL +1 -1
- google_genai-1.3.0.dist-info/RECORD +0 -27
- {google_genai-1.3.0.dist-info → google_genai-1.4.0.dist-info}/LICENSE +0 -0
- {google_genai-1.3.0.dist-info → google_genai-1.4.0.dist-info}/top_level.txt +0 -0
google/genai/files.py
CHANGED
@@ -26,7 +26,7 @@ from . import _api_module
|
|
26
26
|
from . import _common
|
27
27
|
from . import _transformers as t
|
28
28
|
from . import types
|
29
|
-
from ._api_client import
|
29
|
+
from ._api_client import BaseApiClient
|
30
30
|
from ._common import get_value_by_path as getv
|
31
31
|
from ._common import set_value_by_path as setv
|
32
32
|
from .pagers import AsyncPager, Pager
|
@@ -35,11 +35,11 @@ logger = logging.getLogger('google_genai.files')
|
|
35
35
|
|
36
36
|
|
37
37
|
def _ListFilesConfig_to_mldev(
|
38
|
-
api_client:
|
38
|
+
api_client: BaseApiClient,
|
39
39
|
from_object: Union[dict, object],
|
40
|
-
parent_object: dict = None,
|
40
|
+
parent_object: Optional[dict] = None,
|
41
41
|
) -> dict:
|
42
|
-
to_object = {}
|
42
|
+
to_object: dict[str, Any] = {}
|
43
43
|
|
44
44
|
if getv(from_object, ['page_size']) is not None:
|
45
45
|
setv(
|
@@ -57,11 +57,11 @@ def _ListFilesConfig_to_mldev(
|
|
57
57
|
|
58
58
|
|
59
59
|
def _ListFilesConfig_to_vertex(
|
60
|
-
api_client:
|
60
|
+
api_client: BaseApiClient,
|
61
61
|
from_object: Union[dict, object],
|
62
|
-
parent_object: dict = None,
|
62
|
+
parent_object: Optional[dict] = None,
|
63
63
|
) -> dict:
|
64
|
-
to_object = {}
|
64
|
+
to_object: dict[str, Any] = {}
|
65
65
|
|
66
66
|
if getv(from_object, ['page_size']) is not None:
|
67
67
|
setv(
|
@@ -79,11 +79,11 @@ def _ListFilesConfig_to_vertex(
|
|
79
79
|
|
80
80
|
|
81
81
|
def _ListFilesParameters_to_mldev(
|
82
|
-
api_client:
|
82
|
+
api_client: BaseApiClient,
|
83
83
|
from_object: Union[dict, object],
|
84
|
-
parent_object: dict = None,
|
84
|
+
parent_object: Optional[dict] = None,
|
85
85
|
) -> dict:
|
86
|
-
to_object = {}
|
86
|
+
to_object: dict[str, Any] = {}
|
87
87
|
if getv(from_object, ['config']) is not None:
|
88
88
|
setv(
|
89
89
|
to_object,
|
@@ -97,11 +97,11 @@ def _ListFilesParameters_to_mldev(
|
|
97
97
|
|
98
98
|
|
99
99
|
def _ListFilesParameters_to_vertex(
|
100
|
-
api_client:
|
100
|
+
api_client: BaseApiClient,
|
101
101
|
from_object: Union[dict, object],
|
102
|
-
parent_object: dict = None,
|
102
|
+
parent_object: Optional[dict] = None,
|
103
103
|
) -> dict:
|
104
|
-
to_object = {}
|
104
|
+
to_object: dict[str, Any] = {}
|
105
105
|
if getv(from_object, ['config']) is not None:
|
106
106
|
raise ValueError('config parameter is not supported in Vertex AI.')
|
107
107
|
|
@@ -109,11 +109,11 @@ def _ListFilesParameters_to_vertex(
|
|
109
109
|
|
110
110
|
|
111
111
|
def _FileStatus_to_mldev(
|
112
|
-
api_client:
|
112
|
+
api_client: BaseApiClient,
|
113
113
|
from_object: Union[dict, object],
|
114
|
-
parent_object: dict = None,
|
114
|
+
parent_object: Optional[dict] = None,
|
115
115
|
) -> dict:
|
116
|
-
to_object = {}
|
116
|
+
to_object: dict[str, Any] = {}
|
117
117
|
if getv(from_object, ['details']) is not None:
|
118
118
|
setv(to_object, ['details'], getv(from_object, ['details']))
|
119
119
|
|
@@ -127,11 +127,11 @@ def _FileStatus_to_mldev(
|
|
127
127
|
|
128
128
|
|
129
129
|
def _FileStatus_to_vertex(
|
130
|
-
api_client:
|
130
|
+
api_client: BaseApiClient,
|
131
131
|
from_object: Union[dict, object],
|
132
|
-
parent_object: dict = None,
|
132
|
+
parent_object: Optional[dict] = None,
|
133
133
|
) -> dict:
|
134
|
-
to_object = {}
|
134
|
+
to_object: dict[str, Any] = {}
|
135
135
|
if getv(from_object, ['details']) is not None:
|
136
136
|
raise ValueError('details parameter is not supported in Vertex AI.')
|
137
137
|
|
@@ -145,11 +145,11 @@ def _FileStatus_to_vertex(
|
|
145
145
|
|
146
146
|
|
147
147
|
def _File_to_mldev(
|
148
|
-
api_client:
|
148
|
+
api_client: BaseApiClient,
|
149
149
|
from_object: Union[dict, object],
|
150
|
-
parent_object: dict = None,
|
150
|
+
parent_object: Optional[dict] = None,
|
151
151
|
) -> dict:
|
152
|
-
to_object = {}
|
152
|
+
to_object: dict[str, Any] = {}
|
153
153
|
if getv(from_object, ['name']) is not None:
|
154
154
|
setv(to_object, ['name'], getv(from_object, ['name']))
|
155
155
|
|
@@ -202,11 +202,11 @@ def _File_to_mldev(
|
|
202
202
|
|
203
203
|
|
204
204
|
def _File_to_vertex(
|
205
|
-
api_client:
|
205
|
+
api_client: BaseApiClient,
|
206
206
|
from_object: Union[dict, object],
|
207
|
-
parent_object: dict = None,
|
207
|
+
parent_object: Optional[dict] = None,
|
208
208
|
) -> dict:
|
209
|
-
to_object = {}
|
209
|
+
to_object: dict[str, Any] = {}
|
210
210
|
if getv(from_object, ['name']) is not None:
|
211
211
|
raise ValueError('name parameter is not supported in Vertex AI.')
|
212
212
|
|
@@ -253,11 +253,11 @@ def _File_to_vertex(
|
|
253
253
|
|
254
254
|
|
255
255
|
def _CreateFileParameters_to_mldev(
|
256
|
-
api_client:
|
256
|
+
api_client: BaseApiClient,
|
257
257
|
from_object: Union[dict, object],
|
258
|
-
parent_object: dict = None,
|
258
|
+
parent_object: Optional[dict] = None,
|
259
259
|
) -> dict:
|
260
|
-
to_object = {}
|
260
|
+
to_object: dict[str, Any] = {}
|
261
261
|
if getv(from_object, ['file']) is not None:
|
262
262
|
setv(
|
263
263
|
to_object,
|
@@ -272,11 +272,11 @@ def _CreateFileParameters_to_mldev(
|
|
272
272
|
|
273
273
|
|
274
274
|
def _CreateFileParameters_to_vertex(
|
275
|
-
api_client:
|
275
|
+
api_client: BaseApiClient,
|
276
276
|
from_object: Union[dict, object],
|
277
|
-
parent_object: dict = None,
|
277
|
+
parent_object: Optional[dict] = None,
|
278
278
|
) -> dict:
|
279
|
-
to_object = {}
|
279
|
+
to_object: dict[str, Any] = {}
|
280
280
|
if getv(from_object, ['file']) is not None:
|
281
281
|
raise ValueError('file parameter is not supported in Vertex AI.')
|
282
282
|
|
@@ -287,11 +287,11 @@ def _CreateFileParameters_to_vertex(
|
|
287
287
|
|
288
288
|
|
289
289
|
def _GetFileParameters_to_mldev(
|
290
|
-
api_client:
|
290
|
+
api_client: BaseApiClient,
|
291
291
|
from_object: Union[dict, object],
|
292
|
-
parent_object: dict = None,
|
292
|
+
parent_object: Optional[dict] = None,
|
293
293
|
) -> dict:
|
294
|
-
to_object = {}
|
294
|
+
to_object: dict[str, Any] = {}
|
295
295
|
if getv(from_object, ['name']) is not None:
|
296
296
|
setv(
|
297
297
|
to_object,
|
@@ -306,11 +306,11 @@ def _GetFileParameters_to_mldev(
|
|
306
306
|
|
307
307
|
|
308
308
|
def _GetFileParameters_to_vertex(
|
309
|
-
api_client:
|
309
|
+
api_client: BaseApiClient,
|
310
310
|
from_object: Union[dict, object],
|
311
|
-
parent_object: dict = None,
|
311
|
+
parent_object: Optional[dict] = None,
|
312
312
|
) -> dict:
|
313
|
-
to_object = {}
|
313
|
+
to_object: dict[str, Any] = {}
|
314
314
|
if getv(from_object, ['name']) is not None:
|
315
315
|
raise ValueError('name parameter is not supported in Vertex AI.')
|
316
316
|
|
@@ -321,11 +321,11 @@ def _GetFileParameters_to_vertex(
|
|
321
321
|
|
322
322
|
|
323
323
|
def _DeleteFileParameters_to_mldev(
|
324
|
-
api_client:
|
324
|
+
api_client: BaseApiClient,
|
325
325
|
from_object: Union[dict, object],
|
326
|
-
parent_object: dict = None,
|
326
|
+
parent_object: Optional[dict] = None,
|
327
327
|
) -> dict:
|
328
|
-
to_object = {}
|
328
|
+
to_object: dict[str, Any] = {}
|
329
329
|
if getv(from_object, ['name']) is not None:
|
330
330
|
setv(
|
331
331
|
to_object,
|
@@ -340,11 +340,11 @@ def _DeleteFileParameters_to_mldev(
|
|
340
340
|
|
341
341
|
|
342
342
|
def _DeleteFileParameters_to_vertex(
|
343
|
-
api_client:
|
343
|
+
api_client: BaseApiClient,
|
344
344
|
from_object: Union[dict, object],
|
345
|
-
parent_object: dict = None,
|
345
|
+
parent_object: Optional[dict] = None,
|
346
346
|
) -> dict:
|
347
|
-
to_object = {}
|
347
|
+
to_object: dict[str, Any] = {}
|
348
348
|
if getv(from_object, ['name']) is not None:
|
349
349
|
raise ValueError('name parameter is not supported in Vertex AI.')
|
350
350
|
|
@@ -365,11 +365,11 @@ def _FileSource_to_vertex_enum_validate(enum_value: Any):
|
|
365
365
|
|
366
366
|
|
367
367
|
def _FileStatus_from_mldev(
|
368
|
-
api_client:
|
368
|
+
api_client: BaseApiClient,
|
369
369
|
from_object: Union[dict, object],
|
370
|
-
parent_object: dict = None,
|
370
|
+
parent_object: Optional[dict] = None,
|
371
371
|
) -> dict:
|
372
|
-
to_object = {}
|
372
|
+
to_object: dict[str, Any] = {}
|
373
373
|
if getv(from_object, ['details']) is not None:
|
374
374
|
setv(to_object, ['details'], getv(from_object, ['details']))
|
375
375
|
|
@@ -383,21 +383,21 @@ def _FileStatus_from_mldev(
|
|
383
383
|
|
384
384
|
|
385
385
|
def _FileStatus_from_vertex(
|
386
|
-
api_client:
|
386
|
+
api_client: BaseApiClient,
|
387
387
|
from_object: Union[dict, object],
|
388
|
-
parent_object: dict = None,
|
388
|
+
parent_object: Optional[dict] = None,
|
389
389
|
) -> dict:
|
390
|
-
to_object = {}
|
390
|
+
to_object: dict[str, Any] = {}
|
391
391
|
|
392
392
|
return to_object
|
393
393
|
|
394
394
|
|
395
395
|
def _File_from_mldev(
|
396
|
-
api_client:
|
396
|
+
api_client: BaseApiClient,
|
397
397
|
from_object: Union[dict, object],
|
398
|
-
parent_object: dict = None,
|
398
|
+
parent_object: Optional[dict] = None,
|
399
399
|
) -> dict:
|
400
|
-
to_object = {}
|
400
|
+
to_object: dict[str, Any] = {}
|
401
401
|
if getv(from_object, ['name']) is not None:
|
402
402
|
setv(to_object, ['name'], getv(from_object, ['name']))
|
403
403
|
|
@@ -450,21 +450,21 @@ def _File_from_mldev(
|
|
450
450
|
|
451
451
|
|
452
452
|
def _File_from_vertex(
|
453
|
-
api_client:
|
453
|
+
api_client: BaseApiClient,
|
454
454
|
from_object: Union[dict, object],
|
455
|
-
parent_object: dict = None,
|
455
|
+
parent_object: Optional[dict] = None,
|
456
456
|
) -> dict:
|
457
|
-
to_object = {}
|
457
|
+
to_object: dict[str, Any] = {}
|
458
458
|
|
459
459
|
return to_object
|
460
460
|
|
461
461
|
|
462
462
|
def _ListFilesResponse_from_mldev(
|
463
|
-
api_client:
|
463
|
+
api_client: BaseApiClient,
|
464
464
|
from_object: Union[dict, object],
|
465
|
-
parent_object: dict = None,
|
465
|
+
parent_object: Optional[dict] = None,
|
466
466
|
) -> dict:
|
467
|
-
to_object = {}
|
467
|
+
to_object: dict[str, Any] = {}
|
468
468
|
if getv(from_object, ['nextPageToken']) is not None:
|
469
469
|
setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
|
470
470
|
|
@@ -482,21 +482,21 @@ def _ListFilesResponse_from_mldev(
|
|
482
482
|
|
483
483
|
|
484
484
|
def _ListFilesResponse_from_vertex(
|
485
|
-
api_client:
|
485
|
+
api_client: BaseApiClient,
|
486
486
|
from_object: Union[dict, object],
|
487
|
-
parent_object: dict = None,
|
487
|
+
parent_object: Optional[dict] = None,
|
488
488
|
) -> dict:
|
489
|
-
to_object = {}
|
489
|
+
to_object: dict[str, Any] = {}
|
490
490
|
|
491
491
|
return to_object
|
492
492
|
|
493
493
|
|
494
494
|
def _CreateFileResponse_from_mldev(
|
495
|
-
api_client:
|
495
|
+
api_client: BaseApiClient,
|
496
496
|
from_object: Union[dict, object],
|
497
|
-
parent_object: dict = None,
|
497
|
+
parent_object: Optional[dict] = None,
|
498
498
|
) -> dict:
|
499
|
-
to_object = {}
|
499
|
+
to_object: dict[str, Any] = {}
|
500
500
|
if getv(from_object, ['httpHeaders']) is not None:
|
501
501
|
setv(to_object, ['http_headers'], getv(from_object, ['httpHeaders']))
|
502
502
|
|
@@ -504,11 +504,11 @@ def _CreateFileResponse_from_mldev(
|
|
504
504
|
|
505
505
|
|
506
506
|
def _CreateFileResponse_from_vertex(
|
507
|
-
api_client:
|
507
|
+
api_client: BaseApiClient,
|
508
508
|
from_object: Union[dict, object],
|
509
|
-
parent_object: dict = None,
|
509
|
+
parent_object: Optional[dict] = None,
|
510
510
|
) -> dict:
|
511
|
-
to_object = {}
|
511
|
+
to_object: dict[str, Any] = {}
|
512
512
|
if getv(from_object, ['httpHeaders']) is not None:
|
513
513
|
setv(to_object, ['http_headers'], getv(from_object, ['httpHeaders']))
|
514
514
|
|
@@ -516,21 +516,21 @@ def _CreateFileResponse_from_vertex(
|
|
516
516
|
|
517
517
|
|
518
518
|
def _DeleteFileResponse_from_mldev(
|
519
|
-
api_client:
|
519
|
+
api_client: BaseApiClient,
|
520
520
|
from_object: Union[dict, object],
|
521
|
-
parent_object: dict = None,
|
521
|
+
parent_object: Optional[dict] = None,
|
522
522
|
) -> dict:
|
523
|
-
to_object = {}
|
523
|
+
to_object: dict[str, Any] = {}
|
524
524
|
|
525
525
|
return to_object
|
526
526
|
|
527
527
|
|
528
528
|
def _DeleteFileResponse_from_vertex(
|
529
|
-
api_client:
|
529
|
+
api_client: BaseApiClient,
|
530
530
|
from_object: Union[dict, object],
|
531
|
-
parent_object: dict = None,
|
531
|
+
parent_object: Optional[dict] = None,
|
532
532
|
) -> dict:
|
533
|
-
to_object = {}
|
533
|
+
to_object: dict[str, Any] = {}
|
534
534
|
|
535
535
|
return to_object
|
536
536
|
|
@@ -561,13 +561,18 @@ class Files(_api_module.BaseModule):
|
|
561
561
|
config=config,
|
562
562
|
)
|
563
563
|
|
564
|
+
request_url_dict: Optional[dict[str, str]]
|
564
565
|
if self._api_client.vertexai:
|
565
566
|
raise ValueError('This method is only supported in the default client.')
|
566
567
|
else:
|
567
568
|
request_dict = _ListFilesParameters_to_mldev(
|
568
569
|
self._api_client, parameter_model
|
569
570
|
)
|
570
|
-
|
571
|
+
request_url_dict = request_dict.get('_url')
|
572
|
+
if request_url_dict:
|
573
|
+
path = 'files'.format_map(request_url_dict)
|
574
|
+
else:
|
575
|
+
path = 'files'
|
571
576
|
|
572
577
|
query_params = request_dict.get('_query')
|
573
578
|
if query_params:
|
@@ -575,7 +580,7 @@ class Files(_api_module.BaseModule):
|
|
575
580
|
# TODO: remove the hack that pops config.
|
576
581
|
request_dict.pop('config', None)
|
577
582
|
|
578
|
-
http_options = None
|
583
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
579
584
|
if isinstance(config, dict):
|
580
585
|
http_options = config.get('http_options', None)
|
581
586
|
elif hasattr(config, 'http_options'):
|
@@ -598,7 +603,7 @@ class Files(_api_module.BaseModule):
|
|
598
603
|
)
|
599
604
|
|
600
605
|
return_value = types.ListFilesResponse._from_response(
|
601
|
-
response=response_dict, kwargs=parameter_model
|
606
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
602
607
|
)
|
603
608
|
self._api_client._verify_response(return_value)
|
604
609
|
return return_value
|
@@ -614,13 +619,18 @@ class Files(_api_module.BaseModule):
|
|
614
619
|
config=config,
|
615
620
|
)
|
616
621
|
|
622
|
+
request_url_dict: Optional[dict[str, str]]
|
617
623
|
if self._api_client.vertexai:
|
618
624
|
raise ValueError('This method is only supported in the default client.')
|
619
625
|
else:
|
620
626
|
request_dict = _CreateFileParameters_to_mldev(
|
621
627
|
self._api_client, parameter_model
|
622
628
|
)
|
623
|
-
|
629
|
+
request_url_dict = request_dict.get('_url')
|
630
|
+
if request_url_dict:
|
631
|
+
path = 'upload/v1beta/files'.format_map(request_url_dict)
|
632
|
+
else:
|
633
|
+
path = 'upload/v1beta/files'
|
624
634
|
|
625
635
|
query_params = request_dict.get('_query')
|
626
636
|
if query_params:
|
@@ -628,7 +638,7 @@ class Files(_api_module.BaseModule):
|
|
628
638
|
# TODO: remove the hack that pops config.
|
629
639
|
request_dict.pop('config', None)
|
630
640
|
|
631
|
-
http_options = None
|
641
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
632
642
|
if isinstance(config, dict):
|
633
643
|
http_options = config.get('http_options', None)
|
634
644
|
elif hasattr(config, 'http_options'):
|
@@ -651,7 +661,7 @@ class Files(_api_module.BaseModule):
|
|
651
661
|
)
|
652
662
|
|
653
663
|
return_value = types.CreateFileResponse._from_response(
|
654
|
-
response=response_dict, kwargs=parameter_model
|
664
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
655
665
|
)
|
656
666
|
self._api_client._verify_response(return_value)
|
657
667
|
return return_value
|
@@ -681,13 +691,18 @@ class Files(_api_module.BaseModule):
|
|
681
691
|
config=config,
|
682
692
|
)
|
683
693
|
|
694
|
+
request_url_dict: Optional[dict[str, str]]
|
684
695
|
if self._api_client.vertexai:
|
685
696
|
raise ValueError('This method is only supported in the default client.')
|
686
697
|
else:
|
687
698
|
request_dict = _GetFileParameters_to_mldev(
|
688
699
|
self._api_client, parameter_model
|
689
700
|
)
|
690
|
-
|
701
|
+
request_url_dict = request_dict.get('_url')
|
702
|
+
if request_url_dict:
|
703
|
+
path = 'files/{file}'.format_map(request_url_dict)
|
704
|
+
else:
|
705
|
+
path = 'files/{file}'
|
691
706
|
|
692
707
|
query_params = request_dict.get('_query')
|
693
708
|
if query_params:
|
@@ -695,7 +710,7 @@ class Files(_api_module.BaseModule):
|
|
695
710
|
# TODO: remove the hack that pops config.
|
696
711
|
request_dict.pop('config', None)
|
697
712
|
|
698
|
-
http_options = None
|
713
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
699
714
|
if isinstance(config, dict):
|
700
715
|
http_options = config.get('http_options', None)
|
701
716
|
elif hasattr(config, 'http_options'):
|
@@ -714,7 +729,7 @@ class Files(_api_module.BaseModule):
|
|
714
729
|
response_dict = _File_from_mldev(self._api_client, response_dict)
|
715
730
|
|
716
731
|
return_value = types.File._from_response(
|
717
|
-
response=response_dict, kwargs=parameter_model
|
732
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
718
733
|
)
|
719
734
|
self._api_client._verify_response(return_value)
|
720
735
|
return return_value
|
@@ -743,13 +758,18 @@ class Files(_api_module.BaseModule):
|
|
743
758
|
config=config,
|
744
759
|
)
|
745
760
|
|
761
|
+
request_url_dict: Optional[dict[str, str]]
|
746
762
|
if self._api_client.vertexai:
|
747
763
|
raise ValueError('This method is only supported in the default client.')
|
748
764
|
else:
|
749
765
|
request_dict = _DeleteFileParameters_to_mldev(
|
750
766
|
self._api_client, parameter_model
|
751
767
|
)
|
752
|
-
|
768
|
+
request_url_dict = request_dict.get('_url')
|
769
|
+
if request_url_dict:
|
770
|
+
path = 'files/{file}'.format_map(request_url_dict)
|
771
|
+
else:
|
772
|
+
path = 'files/{file}'
|
753
773
|
|
754
774
|
query_params = request_dict.get('_query')
|
755
775
|
if query_params:
|
@@ -757,7 +777,7 @@ class Files(_api_module.BaseModule):
|
|
757
777
|
# TODO: remove the hack that pops config.
|
758
778
|
request_dict.pop('config', None)
|
759
779
|
|
760
|
-
http_options = None
|
780
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
761
781
|
if isinstance(config, dict):
|
762
782
|
http_options = config.get('http_options', None)
|
763
783
|
elif hasattr(config, 'http_options'):
|
@@ -780,7 +800,7 @@ class Files(_api_module.BaseModule):
|
|
780
800
|
)
|
781
801
|
|
782
802
|
return_value = types.DeleteFileResponse._from_response(
|
783
|
-
response=response_dict, kwargs=parameter_model
|
803
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
784
804
|
)
|
785
805
|
self._api_client._verify_response(return_value)
|
786
806
|
return return_value
|
@@ -848,21 +868,22 @@ class Files(_api_module.BaseModule):
|
|
848
868
|
' file\n please set the `mime_type` argument'
|
849
869
|
)
|
850
870
|
|
871
|
+
http_options: types.HttpOptions
|
851
872
|
if config_model and config_model.http_options:
|
852
873
|
http_options = config_model.http_options
|
853
874
|
else:
|
854
|
-
http_options =
|
855
|
-
|
856
|
-
|
875
|
+
http_options = types.HttpOptions(
|
876
|
+
api_version='',
|
877
|
+
headers={
|
857
878
|
'Content-Type': 'application/json',
|
858
879
|
'X-Goog-Upload-Protocol': 'resumable',
|
859
880
|
'X-Goog-Upload-Command': 'start',
|
860
881
|
'X-Goog-Upload-Header-Content-Length': f'{file_obj.size_bytes}',
|
861
882
|
'X-Goog-Upload-Header-Content-Type': f'{file_obj.mime_type}',
|
862
883
|
},
|
863
|
-
|
884
|
+
)
|
864
885
|
response = self._create(
|
865
|
-
file=file_obj, config=
|
886
|
+
file=file_obj, config=types.CreateFileConfig(http_options=http_options)
|
866
887
|
)
|
867
888
|
|
868
889
|
if (
|
@@ -885,7 +906,8 @@ class Files(_api_module.BaseModule):
|
|
885
906
|
)
|
886
907
|
|
887
908
|
return types.File._from_response(
|
888
|
-
_File_from_mldev(self._api_client, return_file['file']),
|
909
|
+
response=_File_from_mldev(self._api_client, return_file['file']),
|
910
|
+
kwargs=None,
|
889
911
|
)
|
890
912
|
|
891
913
|
def list(
|
@@ -993,13 +1015,18 @@ class AsyncFiles(_api_module.BaseModule):
|
|
993
1015
|
config=config,
|
994
1016
|
)
|
995
1017
|
|
1018
|
+
request_url_dict: Optional[dict[str, str]]
|
996
1019
|
if self._api_client.vertexai:
|
997
1020
|
raise ValueError('This method is only supported in the default client.')
|
998
1021
|
else:
|
999
1022
|
request_dict = _ListFilesParameters_to_mldev(
|
1000
1023
|
self._api_client, parameter_model
|
1001
1024
|
)
|
1002
|
-
|
1025
|
+
request_url_dict = request_dict.get('_url')
|
1026
|
+
if request_url_dict:
|
1027
|
+
path = 'files'.format_map(request_url_dict)
|
1028
|
+
else:
|
1029
|
+
path = 'files'
|
1003
1030
|
|
1004
1031
|
query_params = request_dict.get('_query')
|
1005
1032
|
if query_params:
|
@@ -1007,7 +1034,7 @@ class AsyncFiles(_api_module.BaseModule):
|
|
1007
1034
|
# TODO: remove the hack that pops config.
|
1008
1035
|
request_dict.pop('config', None)
|
1009
1036
|
|
1010
|
-
http_options = None
|
1037
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
1011
1038
|
if isinstance(config, dict):
|
1012
1039
|
http_options = config.get('http_options', None)
|
1013
1040
|
elif hasattr(config, 'http_options'):
|
@@ -1030,7 +1057,7 @@ class AsyncFiles(_api_module.BaseModule):
|
|
1030
1057
|
)
|
1031
1058
|
|
1032
1059
|
return_value = types.ListFilesResponse._from_response(
|
1033
|
-
response=response_dict, kwargs=parameter_model
|
1060
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
1034
1061
|
)
|
1035
1062
|
self._api_client._verify_response(return_value)
|
1036
1063
|
return return_value
|
@@ -1046,13 +1073,18 @@ class AsyncFiles(_api_module.BaseModule):
|
|
1046
1073
|
config=config,
|
1047
1074
|
)
|
1048
1075
|
|
1076
|
+
request_url_dict: Optional[dict[str, str]]
|
1049
1077
|
if self._api_client.vertexai:
|
1050
1078
|
raise ValueError('This method is only supported in the default client.')
|
1051
1079
|
else:
|
1052
1080
|
request_dict = _CreateFileParameters_to_mldev(
|
1053
1081
|
self._api_client, parameter_model
|
1054
1082
|
)
|
1055
|
-
|
1083
|
+
request_url_dict = request_dict.get('_url')
|
1084
|
+
if request_url_dict:
|
1085
|
+
path = 'upload/v1beta/files'.format_map(request_url_dict)
|
1086
|
+
else:
|
1087
|
+
path = 'upload/v1beta/files'
|
1056
1088
|
|
1057
1089
|
query_params = request_dict.get('_query')
|
1058
1090
|
if query_params:
|
@@ -1060,7 +1092,7 @@ class AsyncFiles(_api_module.BaseModule):
|
|
1060
1092
|
# TODO: remove the hack that pops config.
|
1061
1093
|
request_dict.pop('config', None)
|
1062
1094
|
|
1063
|
-
http_options = None
|
1095
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
1064
1096
|
if isinstance(config, dict):
|
1065
1097
|
http_options = config.get('http_options', None)
|
1066
1098
|
elif hasattr(config, 'http_options'):
|
@@ -1083,7 +1115,7 @@ class AsyncFiles(_api_module.BaseModule):
|
|
1083
1115
|
)
|
1084
1116
|
|
1085
1117
|
return_value = types.CreateFileResponse._from_response(
|
1086
|
-
response=response_dict, kwargs=parameter_model
|
1118
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
1087
1119
|
)
|
1088
1120
|
self._api_client._verify_response(return_value)
|
1089
1121
|
return return_value
|
@@ -1113,13 +1145,18 @@ class AsyncFiles(_api_module.BaseModule):
|
|
1113
1145
|
config=config,
|
1114
1146
|
)
|
1115
1147
|
|
1148
|
+
request_url_dict: Optional[dict[str, str]]
|
1116
1149
|
if self._api_client.vertexai:
|
1117
1150
|
raise ValueError('This method is only supported in the default client.')
|
1118
1151
|
else:
|
1119
1152
|
request_dict = _GetFileParameters_to_mldev(
|
1120
1153
|
self._api_client, parameter_model
|
1121
1154
|
)
|
1122
|
-
|
1155
|
+
request_url_dict = request_dict.get('_url')
|
1156
|
+
if request_url_dict:
|
1157
|
+
path = 'files/{file}'.format_map(request_url_dict)
|
1158
|
+
else:
|
1159
|
+
path = 'files/{file}'
|
1123
1160
|
|
1124
1161
|
query_params = request_dict.get('_query')
|
1125
1162
|
if query_params:
|
@@ -1127,7 +1164,7 @@ class AsyncFiles(_api_module.BaseModule):
|
|
1127
1164
|
# TODO: remove the hack that pops config.
|
1128
1165
|
request_dict.pop('config', None)
|
1129
1166
|
|
1130
|
-
http_options = None
|
1167
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
1131
1168
|
if isinstance(config, dict):
|
1132
1169
|
http_options = config.get('http_options', None)
|
1133
1170
|
elif hasattr(config, 'http_options'):
|
@@ -1146,7 +1183,7 @@ class AsyncFiles(_api_module.BaseModule):
|
|
1146
1183
|
response_dict = _File_from_mldev(self._api_client, response_dict)
|
1147
1184
|
|
1148
1185
|
return_value = types.File._from_response(
|
1149
|
-
response=response_dict, kwargs=parameter_model
|
1186
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
1150
1187
|
)
|
1151
1188
|
self._api_client._verify_response(return_value)
|
1152
1189
|
return return_value
|
@@ -1175,13 +1212,18 @@ class AsyncFiles(_api_module.BaseModule):
|
|
1175
1212
|
config=config,
|
1176
1213
|
)
|
1177
1214
|
|
1215
|
+
request_url_dict: Optional[dict[str, str]]
|
1178
1216
|
if self._api_client.vertexai:
|
1179
1217
|
raise ValueError('This method is only supported in the default client.')
|
1180
1218
|
else:
|
1181
1219
|
request_dict = _DeleteFileParameters_to_mldev(
|
1182
1220
|
self._api_client, parameter_model
|
1183
1221
|
)
|
1184
|
-
|
1222
|
+
request_url_dict = request_dict.get('_url')
|
1223
|
+
if request_url_dict:
|
1224
|
+
path = 'files/{file}'.format_map(request_url_dict)
|
1225
|
+
else:
|
1226
|
+
path = 'files/{file}'
|
1185
1227
|
|
1186
1228
|
query_params = request_dict.get('_query')
|
1187
1229
|
if query_params:
|
@@ -1189,7 +1231,7 @@ class AsyncFiles(_api_module.BaseModule):
|
|
1189
1231
|
# TODO: remove the hack that pops config.
|
1190
1232
|
request_dict.pop('config', None)
|
1191
1233
|
|
1192
|
-
http_options = None
|
1234
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
1193
1235
|
if isinstance(config, dict):
|
1194
1236
|
http_options = config.get('http_options', None)
|
1195
1237
|
elif hasattr(config, 'http_options'):
|
@@ -1212,7 +1254,7 @@ class AsyncFiles(_api_module.BaseModule):
|
|
1212
1254
|
)
|
1213
1255
|
|
1214
1256
|
return_value = types.DeleteFileResponse._from_response(
|
1215
|
-
response=response_dict, kwargs=parameter_model
|
1257
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
1216
1258
|
)
|
1217
1259
|
self._api_client._verify_response(return_value)
|
1218
1260
|
return return_value
|
@@ -1280,23 +1322,23 @@ class AsyncFiles(_api_module.BaseModule):
|
|
1280
1322
|
' file\n please set the `mime_type` argument'
|
1281
1323
|
)
|
1282
1324
|
|
1325
|
+
http_options: types.HttpOptions
|
1283
1326
|
if config_model and config_model.http_options:
|
1284
1327
|
http_options = config_model.http_options
|
1285
1328
|
else:
|
1286
|
-
http_options =
|
1287
|
-
|
1288
|
-
|
1329
|
+
http_options = types.HttpOptions(
|
1330
|
+
api_version='',
|
1331
|
+
headers={
|
1289
1332
|
'Content-Type': 'application/json',
|
1290
1333
|
'X-Goog-Upload-Protocol': 'resumable',
|
1291
1334
|
'X-Goog-Upload-Command': 'start',
|
1292
1335
|
'X-Goog-Upload-Header-Content-Length': f'{file_obj.size_bytes}',
|
1293
1336
|
'X-Goog-Upload-Header-Content-Type': f'{file_obj.mime_type}',
|
1294
1337
|
},
|
1295
|
-
|
1338
|
+
)
|
1296
1339
|
response = await self._create(
|
1297
|
-
file=file_obj, config=
|
1340
|
+
file=file_obj, config=types.CreateFileConfig(http_options=http_options)
|
1298
1341
|
)
|
1299
|
-
|
1300
1342
|
if (
|
1301
1343
|
response.http_headers is None
|
1302
1344
|
or 'x-goog-upload-url' not in response.http_headers
|
@@ -1317,7 +1359,8 @@ class AsyncFiles(_api_module.BaseModule):
|
|
1317
1359
|
)
|
1318
1360
|
|
1319
1361
|
return types.File._from_response(
|
1320
|
-
_File_from_mldev(self._api_client, return_file['file']),
|
1362
|
+
response=_File_from_mldev(self._api_client, return_file['file']),
|
1363
|
+
kwargs=None,
|
1321
1364
|
)
|
1322
1365
|
|
1323
1366
|
async def list(
|