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/tunings.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
|
@@ -23,7 +24,6 @@ from . import _api_module
|
|
23
24
|
from . import _common
|
24
25
|
from . import _transformers as t
|
25
26
|
from . import types
|
26
|
-
from ._api_client import BaseApiClient
|
27
27
|
from ._common import get_value_by_path as getv
|
28
28
|
from ._common import set_value_by_path as setv
|
29
29
|
from .pagers import AsyncPager, Pager
|
@@ -32,7 +32,6 @@ logger = logging.getLogger('google_genai.tunings')
|
|
32
32
|
|
33
33
|
|
34
34
|
def _GetTuningJobParameters_to_mldev(
|
35
|
-
api_client: BaseApiClient,
|
36
35
|
from_object: Union[dict[str, Any], object],
|
37
36
|
parent_object: Optional[dict[str, Any]] = None,
|
38
37
|
) -> dict[str, Any]:
|
@@ -47,7 +46,6 @@ def _GetTuningJobParameters_to_mldev(
|
|
47
46
|
|
48
47
|
|
49
48
|
def _ListTuningJobsConfig_to_mldev(
|
50
|
-
api_client: BaseApiClient,
|
51
49
|
from_object: Union[dict[str, Any], object],
|
52
50
|
parent_object: Optional[dict[str, Any]] = None,
|
53
51
|
) -> dict[str, Any]:
|
@@ -72,7 +70,6 @@ def _ListTuningJobsConfig_to_mldev(
|
|
72
70
|
|
73
71
|
|
74
72
|
def _ListTuningJobsParameters_to_mldev(
|
75
|
-
api_client: BaseApiClient,
|
76
73
|
from_object: Union[dict[str, Any], object],
|
77
74
|
parent_object: Optional[dict[str, Any]] = None,
|
78
75
|
) -> dict[str, Any]:
|
@@ -82,7 +79,7 @@ def _ListTuningJobsParameters_to_mldev(
|
|
82
79
|
to_object,
|
83
80
|
['config'],
|
84
81
|
_ListTuningJobsConfig_to_mldev(
|
85
|
-
|
82
|
+
getv(from_object, ['config']), to_object
|
86
83
|
),
|
87
84
|
)
|
88
85
|
|
@@ -90,7 +87,6 @@ def _ListTuningJobsParameters_to_mldev(
|
|
90
87
|
|
91
88
|
|
92
89
|
def _TuningExample_to_mldev(
|
93
|
-
api_client: BaseApiClient,
|
94
90
|
from_object: Union[dict[str, Any], object],
|
95
91
|
parent_object: Optional[dict[str, Any]] = None,
|
96
92
|
) -> dict[str, Any]:
|
@@ -105,7 +101,6 @@ def _TuningExample_to_mldev(
|
|
105
101
|
|
106
102
|
|
107
103
|
def _TuningDataset_to_mldev(
|
108
|
-
api_client: BaseApiClient,
|
109
104
|
from_object: Union[dict[str, Any], object],
|
110
105
|
parent_object: Optional[dict[str, Any]] = None,
|
111
106
|
) -> dict[str, Any]:
|
@@ -118,7 +113,7 @@ def _TuningDataset_to_mldev(
|
|
118
113
|
to_object,
|
119
114
|
['examples', 'examples'],
|
120
115
|
[
|
121
|
-
_TuningExample_to_mldev(
|
116
|
+
_TuningExample_to_mldev(item, to_object)
|
122
117
|
for item in getv(from_object, ['examples'])
|
123
118
|
],
|
124
119
|
)
|
@@ -127,7 +122,6 @@ def _TuningDataset_to_mldev(
|
|
127
122
|
|
128
123
|
|
129
124
|
def _TuningValidationDataset_to_mldev(
|
130
|
-
api_client: BaseApiClient,
|
131
125
|
from_object: Union[dict[str, Any], object],
|
132
126
|
parent_object: Optional[dict[str, Any]] = None,
|
133
127
|
) -> dict[str, Any]:
|
@@ -139,7 +133,6 @@ def _TuningValidationDataset_to_mldev(
|
|
139
133
|
|
140
134
|
|
141
135
|
def _CreateTuningJobConfig_to_mldev(
|
142
|
-
api_client: BaseApiClient,
|
143
136
|
from_object: Union[dict[str, Any], object],
|
144
137
|
parent_object: Optional[dict[str, Any]] = None,
|
145
138
|
) -> dict[str, Any]:
|
@@ -200,7 +193,6 @@ def _CreateTuningJobConfig_to_mldev(
|
|
200
193
|
|
201
194
|
|
202
195
|
def _CreateTuningJobParameters_to_mldev(
|
203
|
-
api_client: BaseApiClient,
|
204
196
|
from_object: Union[dict[str, Any], object],
|
205
197
|
parent_object: Optional[dict[str, Any]] = None,
|
206
198
|
) -> dict[str, Any]:
|
@@ -213,7 +205,7 @@ def _CreateTuningJobParameters_to_mldev(
|
|
213
205
|
to_object,
|
214
206
|
['tuningTask', 'trainingData'],
|
215
207
|
_TuningDataset_to_mldev(
|
216
|
-
|
208
|
+
getv(from_object, ['training_dataset']), to_object
|
217
209
|
),
|
218
210
|
)
|
219
211
|
|
@@ -222,7 +214,7 @@ def _CreateTuningJobParameters_to_mldev(
|
|
222
214
|
to_object,
|
223
215
|
['config'],
|
224
216
|
_CreateTuningJobConfig_to_mldev(
|
225
|
-
|
217
|
+
getv(from_object, ['config']), to_object
|
226
218
|
),
|
227
219
|
)
|
228
220
|
|
@@ -230,7 +222,6 @@ def _CreateTuningJobParameters_to_mldev(
|
|
230
222
|
|
231
223
|
|
232
224
|
def _GetTuningJobParameters_to_vertex(
|
233
|
-
api_client: BaseApiClient,
|
234
225
|
from_object: Union[dict[str, Any], object],
|
235
226
|
parent_object: Optional[dict[str, Any]] = None,
|
236
227
|
) -> dict[str, Any]:
|
@@ -245,7 +236,6 @@ def _GetTuningJobParameters_to_vertex(
|
|
245
236
|
|
246
237
|
|
247
238
|
def _ListTuningJobsConfig_to_vertex(
|
248
|
-
api_client: BaseApiClient,
|
249
239
|
from_object: Union[dict[str, Any], object],
|
250
240
|
parent_object: Optional[dict[str, Any]] = None,
|
251
241
|
) -> dict[str, Any]:
|
@@ -270,7 +260,6 @@ def _ListTuningJobsConfig_to_vertex(
|
|
270
260
|
|
271
261
|
|
272
262
|
def _ListTuningJobsParameters_to_vertex(
|
273
|
-
api_client: BaseApiClient,
|
274
263
|
from_object: Union[dict[str, Any], object],
|
275
264
|
parent_object: Optional[dict[str, Any]] = None,
|
276
265
|
) -> dict[str, Any]:
|
@@ -280,7 +269,7 @@ def _ListTuningJobsParameters_to_vertex(
|
|
280
269
|
to_object,
|
281
270
|
['config'],
|
282
271
|
_ListTuningJobsConfig_to_vertex(
|
283
|
-
|
272
|
+
getv(from_object, ['config']), to_object
|
284
273
|
),
|
285
274
|
)
|
286
275
|
|
@@ -288,7 +277,6 @@ def _ListTuningJobsParameters_to_vertex(
|
|
288
277
|
|
289
278
|
|
290
279
|
def _TuningExample_to_vertex(
|
291
|
-
api_client: BaseApiClient,
|
292
280
|
from_object: Union[dict[str, Any], object],
|
293
281
|
parent_object: Optional[dict[str, Any]] = None,
|
294
282
|
) -> dict[str, Any]:
|
@@ -303,7 +291,6 @@ def _TuningExample_to_vertex(
|
|
303
291
|
|
304
292
|
|
305
293
|
def _TuningDataset_to_vertex(
|
306
|
-
api_client: BaseApiClient,
|
307
294
|
from_object: Union[dict[str, Any], object],
|
308
295
|
parent_object: Optional[dict[str, Any]] = None,
|
309
296
|
) -> dict[str, Any]:
|
@@ -322,7 +309,6 @@ def _TuningDataset_to_vertex(
|
|
322
309
|
|
323
310
|
|
324
311
|
def _TuningValidationDataset_to_vertex(
|
325
|
-
api_client: BaseApiClient,
|
326
312
|
from_object: Union[dict[str, Any], object],
|
327
313
|
parent_object: Optional[dict[str, Any]] = None,
|
328
314
|
) -> dict[str, Any]:
|
@@ -334,7 +320,6 @@ def _TuningValidationDataset_to_vertex(
|
|
334
320
|
|
335
321
|
|
336
322
|
def _CreateTuningJobConfig_to_vertex(
|
337
|
-
api_client: BaseApiClient,
|
338
323
|
from_object: Union[dict[str, Any], object],
|
339
324
|
parent_object: Optional[dict[str, Any]] = None,
|
340
325
|
) -> dict[str, Any]:
|
@@ -345,7 +330,7 @@ def _CreateTuningJobConfig_to_vertex(
|
|
345
330
|
parent_object,
|
346
331
|
['supervisedTuningSpec'],
|
347
332
|
_TuningValidationDataset_to_vertex(
|
348
|
-
|
333
|
+
getv(from_object, ['validation_dataset']), to_object
|
349
334
|
),
|
350
335
|
)
|
351
336
|
|
@@ -397,7 +382,6 @@ def _CreateTuningJobConfig_to_vertex(
|
|
397
382
|
|
398
383
|
|
399
384
|
def _CreateTuningJobParameters_to_vertex(
|
400
|
-
api_client: BaseApiClient,
|
401
385
|
from_object: Union[dict[str, Any], object],
|
402
386
|
parent_object: Optional[dict[str, Any]] = None,
|
403
387
|
) -> dict[str, Any]:
|
@@ -410,7 +394,7 @@ def _CreateTuningJobParameters_to_vertex(
|
|
410
394
|
to_object,
|
411
395
|
['supervisedTuningSpec', 'trainingDatasetUri'],
|
412
396
|
_TuningDataset_to_vertex(
|
413
|
-
|
397
|
+
getv(from_object, ['training_dataset']), to_object
|
414
398
|
),
|
415
399
|
)
|
416
400
|
|
@@ -419,7 +403,7 @@ def _CreateTuningJobParameters_to_vertex(
|
|
419
403
|
to_object,
|
420
404
|
['config'],
|
421
405
|
_CreateTuningJobConfig_to_vertex(
|
422
|
-
|
406
|
+
getv(from_object, ['config']), to_object
|
423
407
|
),
|
424
408
|
)
|
425
409
|
|
@@ -427,7 +411,6 @@ def _CreateTuningJobParameters_to_vertex(
|
|
427
411
|
|
428
412
|
|
429
413
|
def _TunedModelCheckpoint_from_mldev(
|
430
|
-
api_client: BaseApiClient,
|
431
414
|
from_object: Union[dict[str, Any], object],
|
432
415
|
parent_object: Optional[dict[str, Any]] = None,
|
433
416
|
) -> dict[str, Any]:
|
@@ -437,7 +420,6 @@ def _TunedModelCheckpoint_from_mldev(
|
|
437
420
|
|
438
421
|
|
439
422
|
def _TunedModel_from_mldev(
|
440
|
-
api_client: BaseApiClient,
|
441
423
|
from_object: Union[dict[str, Any], object],
|
442
424
|
parent_object: Optional[dict[str, Any]] = None,
|
443
425
|
) -> dict[str, Any]:
|
@@ -452,7 +434,6 @@ def _TunedModel_from_mldev(
|
|
452
434
|
|
453
435
|
|
454
436
|
def _TuningJob_from_mldev(
|
455
|
-
api_client: BaseApiClient,
|
456
437
|
from_object: Union[dict[str, Any], object],
|
457
438
|
parent_object: Optional[dict[str, Any]] = None,
|
458
439
|
) -> dict[str, Any]:
|
@@ -464,7 +445,7 @@ def _TuningJob_from_mldev(
|
|
464
445
|
setv(
|
465
446
|
to_object,
|
466
447
|
['state'],
|
467
|
-
t.t_tuning_job_status(
|
448
|
+
t.t_tuning_job_status(getv(from_object, ['state'])),
|
468
449
|
)
|
469
450
|
|
470
451
|
if getv(from_object, ['createTime']) is not None:
|
@@ -497,9 +478,7 @@ def _TuningJob_from_mldev(
|
|
497
478
|
setv(
|
498
479
|
to_object,
|
499
480
|
['tuned_model'],
|
500
|
-
_TunedModel_from_mldev(
|
501
|
-
api_client, getv(from_object, ['_self']), to_object
|
502
|
-
),
|
481
|
+
_TunedModel_from_mldev(getv(from_object, ['_self']), to_object),
|
503
482
|
)
|
504
483
|
|
505
484
|
if getv(from_object, ['distillationSpec']) is not None:
|
@@ -532,7 +511,6 @@ def _TuningJob_from_mldev(
|
|
532
511
|
|
533
512
|
|
534
513
|
def _ListTuningJobsResponse_from_mldev(
|
535
|
-
api_client: BaseApiClient,
|
536
514
|
from_object: Union[dict[str, Any], object],
|
537
515
|
parent_object: Optional[dict[str, Any]] = None,
|
538
516
|
) -> dict[str, Any]:
|
@@ -545,7 +523,7 @@ def _ListTuningJobsResponse_from_mldev(
|
|
545
523
|
to_object,
|
546
524
|
['tuning_jobs'],
|
547
525
|
[
|
548
|
-
_TuningJob_from_mldev(
|
526
|
+
_TuningJob_from_mldev(item, to_object)
|
549
527
|
for item in getv(from_object, ['tunedModels'])
|
550
528
|
],
|
551
529
|
)
|
@@ -554,7 +532,6 @@ def _ListTuningJobsResponse_from_mldev(
|
|
554
532
|
|
555
533
|
|
556
534
|
def _Operation_from_mldev(
|
557
|
-
api_client: BaseApiClient,
|
558
535
|
from_object: Union[dict[str, Any], object],
|
559
536
|
parent_object: Optional[dict[str, Any]] = None,
|
560
537
|
) -> dict[str, Any]:
|
@@ -575,7 +552,6 @@ def _Operation_from_mldev(
|
|
575
552
|
|
576
553
|
|
577
554
|
def _TunedModelCheckpoint_from_vertex(
|
578
|
-
api_client: BaseApiClient,
|
579
555
|
from_object: Union[dict[str, Any], object],
|
580
556
|
parent_object: Optional[dict[str, Any]] = None,
|
581
557
|
) -> dict[str, Any]:
|
@@ -596,7 +572,6 @@ def _TunedModelCheckpoint_from_vertex(
|
|
596
572
|
|
597
573
|
|
598
574
|
def _TunedModel_from_vertex(
|
599
|
-
api_client: BaseApiClient,
|
600
575
|
from_object: Union[dict[str, Any], object],
|
601
576
|
parent_object: Optional[dict[str, Any]] = None,
|
602
577
|
) -> dict[str, Any]:
|
@@ -612,7 +587,7 @@ def _TunedModel_from_vertex(
|
|
612
587
|
to_object,
|
613
588
|
['checkpoints'],
|
614
589
|
[
|
615
|
-
_TunedModelCheckpoint_from_vertex(
|
590
|
+
_TunedModelCheckpoint_from_vertex(item, to_object)
|
616
591
|
for item in getv(from_object, ['checkpoints'])
|
617
592
|
],
|
618
593
|
)
|
@@ -621,7 +596,6 @@ def _TunedModel_from_vertex(
|
|
621
596
|
|
622
597
|
|
623
598
|
def _TuningJob_from_vertex(
|
624
|
-
api_client: BaseApiClient,
|
625
599
|
from_object: Union[dict[str, Any], object],
|
626
600
|
parent_object: Optional[dict[str, Any]] = None,
|
627
601
|
) -> dict[str, Any]:
|
@@ -633,7 +607,7 @@ def _TuningJob_from_vertex(
|
|
633
607
|
setv(
|
634
608
|
to_object,
|
635
609
|
['state'],
|
636
|
-
t.t_tuning_job_status(
|
610
|
+
t.t_tuning_job_status(getv(from_object, ['state'])),
|
637
611
|
)
|
638
612
|
|
639
613
|
if getv(from_object, ['createTime']) is not None:
|
@@ -661,9 +635,7 @@ def _TuningJob_from_vertex(
|
|
661
635
|
setv(
|
662
636
|
to_object,
|
663
637
|
['tuned_model'],
|
664
|
-
_TunedModel_from_vertex(
|
665
|
-
api_client, getv(from_object, ['tunedModel']), to_object
|
666
|
-
),
|
638
|
+
_TunedModel_from_vertex(getv(from_object, ['tunedModel']), to_object),
|
667
639
|
)
|
668
640
|
|
669
641
|
if getv(from_object, ['supervisedTuningSpec']) is not None:
|
@@ -718,7 +690,6 @@ def _TuningJob_from_vertex(
|
|
718
690
|
|
719
691
|
|
720
692
|
def _ListTuningJobsResponse_from_vertex(
|
721
|
-
api_client: BaseApiClient,
|
722
693
|
from_object: Union[dict[str, Any], object],
|
723
694
|
parent_object: Optional[dict[str, Any]] = None,
|
724
695
|
) -> dict[str, Any]:
|
@@ -731,7 +702,7 @@ def _ListTuningJobsResponse_from_vertex(
|
|
731
702
|
to_object,
|
732
703
|
['tuning_jobs'],
|
733
704
|
[
|
734
|
-
_TuningJob_from_vertex(
|
705
|
+
_TuningJob_from_vertex(item, to_object)
|
735
706
|
for item in getv(from_object, ['tuningJobs'])
|
736
707
|
],
|
737
708
|
)
|
@@ -764,18 +735,14 @@ class Tunings(_api_module.BaseModule):
|
|
764
735
|
request_url_dict: Optional[dict[str, str]]
|
765
736
|
|
766
737
|
if self._api_client.vertexai:
|
767
|
-
request_dict = _GetTuningJobParameters_to_vertex(
|
768
|
-
self._api_client, parameter_model
|
769
|
-
)
|
738
|
+
request_dict = _GetTuningJobParameters_to_vertex(parameter_model)
|
770
739
|
request_url_dict = request_dict.get('_url')
|
771
740
|
if request_url_dict:
|
772
741
|
path = '{name}'.format_map(request_url_dict)
|
773
742
|
else:
|
774
743
|
path = '{name}'
|
775
744
|
else:
|
776
|
-
request_dict = _GetTuningJobParameters_to_mldev(
|
777
|
-
self._api_client, parameter_model
|
778
|
-
)
|
745
|
+
request_dict = _GetTuningJobParameters_to_mldev(parameter_model)
|
779
746
|
request_url_dict = request_dict.get('_url')
|
780
747
|
if request_url_dict:
|
781
748
|
path = '{name}'.format_map(request_url_dict)
|
@@ -797,15 +764,15 @@ class Tunings(_api_module.BaseModule):
|
|
797
764
|
request_dict = _common.convert_to_dict(request_dict)
|
798
765
|
request_dict = _common.encode_unserializable_types(request_dict)
|
799
766
|
|
800
|
-
|
801
|
-
|
802
|
-
)
|
767
|
+
response = self._api_client.request('get', path, request_dict, http_options)
|
768
|
+
|
769
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
803
770
|
|
804
771
|
if self._api_client.vertexai:
|
805
|
-
response_dict = _TuningJob_from_vertex(
|
772
|
+
response_dict = _TuningJob_from_vertex(response_dict)
|
806
773
|
|
807
774
|
else:
|
808
|
-
response_dict = _TuningJob_from_mldev(
|
775
|
+
response_dict = _TuningJob_from_mldev(response_dict)
|
809
776
|
|
810
777
|
return_value = types.TuningJob._from_response(
|
811
778
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -832,18 +799,14 @@ class Tunings(_api_module.BaseModule):
|
|
832
799
|
request_url_dict: Optional[dict[str, str]]
|
833
800
|
|
834
801
|
if self._api_client.vertexai:
|
835
|
-
request_dict = _ListTuningJobsParameters_to_vertex(
|
836
|
-
self._api_client, parameter_model
|
837
|
-
)
|
802
|
+
request_dict = _ListTuningJobsParameters_to_vertex(parameter_model)
|
838
803
|
request_url_dict = request_dict.get('_url')
|
839
804
|
if request_url_dict:
|
840
805
|
path = 'tuningJobs'.format_map(request_url_dict)
|
841
806
|
else:
|
842
807
|
path = 'tuningJobs'
|
843
808
|
else:
|
844
|
-
request_dict = _ListTuningJobsParameters_to_mldev(
|
845
|
-
self._api_client, parameter_model
|
846
|
-
)
|
809
|
+
request_dict = _ListTuningJobsParameters_to_mldev(parameter_model)
|
847
810
|
request_url_dict = request_dict.get('_url')
|
848
811
|
if request_url_dict:
|
849
812
|
path = 'tunedModels'.format_map(request_url_dict)
|
@@ -865,19 +828,15 @@ class Tunings(_api_module.BaseModule):
|
|
865
828
|
request_dict = _common.convert_to_dict(request_dict)
|
866
829
|
request_dict = _common.encode_unserializable_types(request_dict)
|
867
830
|
|
868
|
-
|
869
|
-
|
870
|
-
)
|
831
|
+
response = self._api_client.request('get', path, request_dict, http_options)
|
832
|
+
|
833
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
871
834
|
|
872
835
|
if self._api_client.vertexai:
|
873
|
-
response_dict = _ListTuningJobsResponse_from_vertex(
|
874
|
-
self._api_client, response_dict
|
875
|
-
)
|
836
|
+
response_dict = _ListTuningJobsResponse_from_vertex(response_dict)
|
876
837
|
|
877
838
|
else:
|
878
|
-
response_dict = _ListTuningJobsResponse_from_mldev(
|
879
|
-
self._api_client, response_dict
|
880
|
-
)
|
839
|
+
response_dict = _ListTuningJobsResponse_from_mldev(response_dict)
|
881
840
|
|
882
841
|
return_value = types.ListTuningJobsResponse._from_response(
|
883
842
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -913,9 +872,7 @@ class Tunings(_api_module.BaseModule):
|
|
913
872
|
if not self._api_client.vertexai:
|
914
873
|
raise ValueError('This method is only supported in the Vertex AI client.')
|
915
874
|
else:
|
916
|
-
request_dict = _CreateTuningJobParameters_to_vertex(
|
917
|
-
self._api_client, parameter_model
|
918
|
-
)
|
875
|
+
request_dict = _CreateTuningJobParameters_to_vertex(parameter_model)
|
919
876
|
request_url_dict = request_dict.get('_url')
|
920
877
|
if request_url_dict:
|
921
878
|
path = 'tuningJobs'.format_map(request_url_dict)
|
@@ -938,12 +895,14 @@ class Tunings(_api_module.BaseModule):
|
|
938
895
|
request_dict = _common.convert_to_dict(request_dict)
|
939
896
|
request_dict = _common.encode_unserializable_types(request_dict)
|
940
897
|
|
941
|
-
|
898
|
+
response = self._api_client.request(
|
942
899
|
'post', path, request_dict, http_options
|
943
900
|
)
|
944
901
|
|
902
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
903
|
+
|
945
904
|
if self._api_client.vertexai:
|
946
|
-
response_dict = _TuningJob_from_vertex(
|
905
|
+
response_dict = _TuningJob_from_vertex(response_dict)
|
947
906
|
|
948
907
|
return_value = types.TuningJob._from_response(
|
949
908
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -981,9 +940,7 @@ class Tunings(_api_module.BaseModule):
|
|
981
940
|
'This method is only supported in the Gemini Developer client.'
|
982
941
|
)
|
983
942
|
else:
|
984
|
-
request_dict = _CreateTuningJobParameters_to_mldev(
|
985
|
-
self._api_client, parameter_model
|
986
|
-
)
|
943
|
+
request_dict = _CreateTuningJobParameters_to_mldev(parameter_model)
|
987
944
|
request_url_dict = request_dict.get('_url')
|
988
945
|
if request_url_dict:
|
989
946
|
path = 'tunedModels'.format_map(request_url_dict)
|
@@ -1006,12 +963,14 @@ class Tunings(_api_module.BaseModule):
|
|
1006
963
|
request_dict = _common.convert_to_dict(request_dict)
|
1007
964
|
request_dict = _common.encode_unserializable_types(request_dict)
|
1008
965
|
|
1009
|
-
|
966
|
+
response = self._api_client.request(
|
1010
967
|
'post', path, request_dict, http_options
|
1011
968
|
)
|
1012
969
|
|
970
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
971
|
+
|
1013
972
|
if not self._api_client.vertexai:
|
1014
|
-
response_dict = _Operation_from_mldev(
|
973
|
+
response_dict = _Operation_from_mldev(response_dict)
|
1015
974
|
|
1016
975
|
return_value = types.Operation._from_response(
|
1017
976
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -1112,18 +1071,14 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1112
1071
|
request_url_dict: Optional[dict[str, str]]
|
1113
1072
|
|
1114
1073
|
if self._api_client.vertexai:
|
1115
|
-
request_dict = _GetTuningJobParameters_to_vertex(
|
1116
|
-
self._api_client, parameter_model
|
1117
|
-
)
|
1074
|
+
request_dict = _GetTuningJobParameters_to_vertex(parameter_model)
|
1118
1075
|
request_url_dict = request_dict.get('_url')
|
1119
1076
|
if request_url_dict:
|
1120
1077
|
path = '{name}'.format_map(request_url_dict)
|
1121
1078
|
else:
|
1122
1079
|
path = '{name}'
|
1123
1080
|
else:
|
1124
|
-
request_dict = _GetTuningJobParameters_to_mldev(
|
1125
|
-
self._api_client, parameter_model
|
1126
|
-
)
|
1081
|
+
request_dict = _GetTuningJobParameters_to_mldev(parameter_model)
|
1127
1082
|
request_url_dict = request_dict.get('_url')
|
1128
1083
|
if request_url_dict:
|
1129
1084
|
path = '{name}'.format_map(request_url_dict)
|
@@ -1145,15 +1100,17 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1145
1100
|
request_dict = _common.convert_to_dict(request_dict)
|
1146
1101
|
request_dict = _common.encode_unserializable_types(request_dict)
|
1147
1102
|
|
1148
|
-
|
1103
|
+
response = await self._api_client.async_request(
|
1149
1104
|
'get', path, request_dict, http_options
|
1150
1105
|
)
|
1151
1106
|
|
1107
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
1108
|
+
|
1152
1109
|
if self._api_client.vertexai:
|
1153
|
-
response_dict = _TuningJob_from_vertex(
|
1110
|
+
response_dict = _TuningJob_from_vertex(response_dict)
|
1154
1111
|
|
1155
1112
|
else:
|
1156
|
-
response_dict = _TuningJob_from_mldev(
|
1113
|
+
response_dict = _TuningJob_from_mldev(response_dict)
|
1157
1114
|
|
1158
1115
|
return_value = types.TuningJob._from_response(
|
1159
1116
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -1180,18 +1137,14 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1180
1137
|
request_url_dict: Optional[dict[str, str]]
|
1181
1138
|
|
1182
1139
|
if self._api_client.vertexai:
|
1183
|
-
request_dict = _ListTuningJobsParameters_to_vertex(
|
1184
|
-
self._api_client, parameter_model
|
1185
|
-
)
|
1140
|
+
request_dict = _ListTuningJobsParameters_to_vertex(parameter_model)
|
1186
1141
|
request_url_dict = request_dict.get('_url')
|
1187
1142
|
if request_url_dict:
|
1188
1143
|
path = 'tuningJobs'.format_map(request_url_dict)
|
1189
1144
|
else:
|
1190
1145
|
path = 'tuningJobs'
|
1191
1146
|
else:
|
1192
|
-
request_dict = _ListTuningJobsParameters_to_mldev(
|
1193
|
-
self._api_client, parameter_model
|
1194
|
-
)
|
1147
|
+
request_dict = _ListTuningJobsParameters_to_mldev(parameter_model)
|
1195
1148
|
request_url_dict = request_dict.get('_url')
|
1196
1149
|
if request_url_dict:
|
1197
1150
|
path = 'tunedModels'.format_map(request_url_dict)
|
@@ -1213,19 +1166,17 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1213
1166
|
request_dict = _common.convert_to_dict(request_dict)
|
1214
1167
|
request_dict = _common.encode_unserializable_types(request_dict)
|
1215
1168
|
|
1216
|
-
|
1169
|
+
response = await self._api_client.async_request(
|
1217
1170
|
'get', path, request_dict, http_options
|
1218
1171
|
)
|
1219
1172
|
|
1173
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
1174
|
+
|
1220
1175
|
if self._api_client.vertexai:
|
1221
|
-
response_dict = _ListTuningJobsResponse_from_vertex(
|
1222
|
-
self._api_client, response_dict
|
1223
|
-
)
|
1176
|
+
response_dict = _ListTuningJobsResponse_from_vertex(response_dict)
|
1224
1177
|
|
1225
1178
|
else:
|
1226
|
-
response_dict = _ListTuningJobsResponse_from_mldev(
|
1227
|
-
self._api_client, response_dict
|
1228
|
-
)
|
1179
|
+
response_dict = _ListTuningJobsResponse_from_mldev(response_dict)
|
1229
1180
|
|
1230
1181
|
return_value = types.ListTuningJobsResponse._from_response(
|
1231
1182
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -1261,9 +1212,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1261
1212
|
if not self._api_client.vertexai:
|
1262
1213
|
raise ValueError('This method is only supported in the Vertex AI client.')
|
1263
1214
|
else:
|
1264
|
-
request_dict = _CreateTuningJobParameters_to_vertex(
|
1265
|
-
self._api_client, parameter_model
|
1266
|
-
)
|
1215
|
+
request_dict = _CreateTuningJobParameters_to_vertex(parameter_model)
|
1267
1216
|
request_url_dict = request_dict.get('_url')
|
1268
1217
|
if request_url_dict:
|
1269
1218
|
path = 'tuningJobs'.format_map(request_url_dict)
|
@@ -1286,12 +1235,14 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1286
1235
|
request_dict = _common.convert_to_dict(request_dict)
|
1287
1236
|
request_dict = _common.encode_unserializable_types(request_dict)
|
1288
1237
|
|
1289
|
-
|
1238
|
+
response = await self._api_client.async_request(
|
1290
1239
|
'post', path, request_dict, http_options
|
1291
1240
|
)
|
1292
1241
|
|
1242
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
1243
|
+
|
1293
1244
|
if self._api_client.vertexai:
|
1294
|
-
response_dict = _TuningJob_from_vertex(
|
1245
|
+
response_dict = _TuningJob_from_vertex(response_dict)
|
1295
1246
|
|
1296
1247
|
return_value = types.TuningJob._from_response(
|
1297
1248
|
response=response_dict, kwargs=parameter_model.model_dump()
|
@@ -1329,9 +1280,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1329
1280
|
'This method is only supported in the Gemini Developer client.'
|
1330
1281
|
)
|
1331
1282
|
else:
|
1332
|
-
request_dict = _CreateTuningJobParameters_to_mldev(
|
1333
|
-
self._api_client, parameter_model
|
1334
|
-
)
|
1283
|
+
request_dict = _CreateTuningJobParameters_to_mldev(parameter_model)
|
1335
1284
|
request_url_dict = request_dict.get('_url')
|
1336
1285
|
if request_url_dict:
|
1337
1286
|
path = 'tunedModels'.format_map(request_url_dict)
|
@@ -1354,12 +1303,14 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1354
1303
|
request_dict = _common.convert_to_dict(request_dict)
|
1355
1304
|
request_dict = _common.encode_unserializable_types(request_dict)
|
1356
1305
|
|
1357
|
-
|
1306
|
+
response = await self._api_client.async_request(
|
1358
1307
|
'post', path, request_dict, http_options
|
1359
1308
|
)
|
1360
1309
|
|
1310
|
+
response_dict = '' if not response.body else json.loads(response.body)
|
1311
|
+
|
1361
1312
|
if not self._api_client.vertexai:
|
1362
|
-
response_dict = _Operation_from_mldev(
|
1313
|
+
response_dict = _Operation_from_mldev(response_dict)
|
1363
1314
|
|
1364
1315
|
return_value = types.Operation._from_response(
|
1365
1316
|
response=response_dict, kwargs=parameter_model.model_dump()
|