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/tunings.py
CHANGED
@@ -16,13 +16,13 @@
|
|
16
16
|
# Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
17
17
|
|
18
18
|
import logging
|
19
|
-
from typing import Optional, Union
|
19
|
+
from typing import Any, Optional, Union
|
20
20
|
from urllib.parse import urlencode
|
21
21
|
from . import _api_module
|
22
22
|
from . import _common
|
23
23
|
from . import _transformers as t
|
24
24
|
from . import types
|
25
|
-
from ._api_client import
|
25
|
+
from ._api_client import BaseApiClient
|
26
26
|
from ._common import get_value_by_path as getv
|
27
27
|
from ._common import set_value_by_path as setv
|
28
28
|
from .pagers import AsyncPager, Pager
|
@@ -31,11 +31,11 @@ logger = logging.getLogger('google_genai.tunings')
|
|
31
31
|
|
32
32
|
|
33
33
|
def _GetTuningJobParameters_to_mldev(
|
34
|
-
api_client:
|
34
|
+
api_client: BaseApiClient,
|
35
35
|
from_object: Union[dict, object],
|
36
|
-
parent_object: dict = None,
|
36
|
+
parent_object: Optional[dict] = None,
|
37
37
|
) -> dict:
|
38
|
-
to_object = {}
|
38
|
+
to_object: dict[str, Any] = {}
|
39
39
|
if getv(from_object, ['name']) is not None:
|
40
40
|
setv(to_object, ['_url', 'name'], getv(from_object, ['name']))
|
41
41
|
|
@@ -46,11 +46,11 @@ def _GetTuningJobParameters_to_mldev(
|
|
46
46
|
|
47
47
|
|
48
48
|
def _GetTuningJobParameters_to_vertex(
|
49
|
-
api_client:
|
49
|
+
api_client: BaseApiClient,
|
50
50
|
from_object: Union[dict, object],
|
51
|
-
parent_object: dict = None,
|
51
|
+
parent_object: Optional[dict] = None,
|
52
52
|
) -> dict:
|
53
|
-
to_object = {}
|
53
|
+
to_object: dict[str, Any] = {}
|
54
54
|
if getv(from_object, ['name']) is not None:
|
55
55
|
setv(to_object, ['_url', 'name'], getv(from_object, ['name']))
|
56
56
|
|
@@ -61,11 +61,11 @@ def _GetTuningJobParameters_to_vertex(
|
|
61
61
|
|
62
62
|
|
63
63
|
def _ListTuningJobsConfig_to_mldev(
|
64
|
-
api_client:
|
64
|
+
api_client: BaseApiClient,
|
65
65
|
from_object: Union[dict, object],
|
66
|
-
parent_object: dict = None,
|
66
|
+
parent_object: Optional[dict] = None,
|
67
67
|
) -> dict:
|
68
|
-
to_object = {}
|
68
|
+
to_object: dict[str, Any] = {}
|
69
69
|
|
70
70
|
if getv(from_object, ['page_size']) is not None:
|
71
71
|
setv(
|
@@ -86,11 +86,11 @@ def _ListTuningJobsConfig_to_mldev(
|
|
86
86
|
|
87
87
|
|
88
88
|
def _ListTuningJobsConfig_to_vertex(
|
89
|
-
api_client:
|
89
|
+
api_client: BaseApiClient,
|
90
90
|
from_object: Union[dict, object],
|
91
|
-
parent_object: dict = None,
|
91
|
+
parent_object: Optional[dict] = None,
|
92
92
|
) -> dict:
|
93
|
-
to_object = {}
|
93
|
+
to_object: dict[str, Any] = {}
|
94
94
|
|
95
95
|
if getv(from_object, ['page_size']) is not None:
|
96
96
|
setv(
|
@@ -111,11 +111,11 @@ def _ListTuningJobsConfig_to_vertex(
|
|
111
111
|
|
112
112
|
|
113
113
|
def _ListTuningJobsParameters_to_mldev(
|
114
|
-
api_client:
|
114
|
+
api_client: BaseApiClient,
|
115
115
|
from_object: Union[dict, object],
|
116
|
-
parent_object: dict = None,
|
116
|
+
parent_object: Optional[dict] = None,
|
117
117
|
) -> dict:
|
118
|
-
to_object = {}
|
118
|
+
to_object: dict[str, Any] = {}
|
119
119
|
if getv(from_object, ['config']) is not None:
|
120
120
|
setv(
|
121
121
|
to_object,
|
@@ -129,11 +129,11 @@ def _ListTuningJobsParameters_to_mldev(
|
|
129
129
|
|
130
130
|
|
131
131
|
def _ListTuningJobsParameters_to_vertex(
|
132
|
-
api_client:
|
132
|
+
api_client: BaseApiClient,
|
133
133
|
from_object: Union[dict, object],
|
134
|
-
parent_object: dict = None,
|
134
|
+
parent_object: Optional[dict] = None,
|
135
135
|
) -> dict:
|
136
|
-
to_object = {}
|
136
|
+
to_object: dict[str, Any] = {}
|
137
137
|
if getv(from_object, ['config']) is not None:
|
138
138
|
setv(
|
139
139
|
to_object,
|
@@ -147,11 +147,11 @@ def _ListTuningJobsParameters_to_vertex(
|
|
147
147
|
|
148
148
|
|
149
149
|
def _TuningExample_to_mldev(
|
150
|
-
api_client:
|
150
|
+
api_client: BaseApiClient,
|
151
151
|
from_object: Union[dict, object],
|
152
|
-
parent_object: dict = None,
|
152
|
+
parent_object: Optional[dict] = None,
|
153
153
|
) -> dict:
|
154
|
-
to_object = {}
|
154
|
+
to_object: dict[str, Any] = {}
|
155
155
|
if getv(from_object, ['text_input']) is not None:
|
156
156
|
setv(to_object, ['textInput'], getv(from_object, ['text_input']))
|
157
157
|
|
@@ -162,11 +162,11 @@ def _TuningExample_to_mldev(
|
|
162
162
|
|
163
163
|
|
164
164
|
def _TuningExample_to_vertex(
|
165
|
-
api_client:
|
165
|
+
api_client: BaseApiClient,
|
166
166
|
from_object: Union[dict, object],
|
167
|
-
parent_object: dict = None,
|
167
|
+
parent_object: Optional[dict] = None,
|
168
168
|
) -> dict:
|
169
|
-
to_object = {}
|
169
|
+
to_object: dict[str, Any] = {}
|
170
170
|
if getv(from_object, ['text_input']) is not None:
|
171
171
|
raise ValueError('text_input parameter is not supported in Vertex AI.')
|
172
172
|
|
@@ -177,11 +177,11 @@ def _TuningExample_to_vertex(
|
|
177
177
|
|
178
178
|
|
179
179
|
def _TuningDataset_to_mldev(
|
180
|
-
api_client:
|
180
|
+
api_client: BaseApiClient,
|
181
181
|
from_object: Union[dict, object],
|
182
|
-
parent_object: dict = None,
|
182
|
+
parent_object: Optional[dict] = None,
|
183
183
|
) -> dict:
|
184
|
-
to_object = {}
|
184
|
+
to_object: dict[str, Any] = {}
|
185
185
|
if getv(from_object, ['gcs_uri']) is not None:
|
186
186
|
raise ValueError('gcs_uri parameter is not supported in Gemini API.')
|
187
187
|
|
@@ -199,11 +199,11 @@ def _TuningDataset_to_mldev(
|
|
199
199
|
|
200
200
|
|
201
201
|
def _TuningDataset_to_vertex(
|
202
|
-
api_client:
|
202
|
+
api_client: BaseApiClient,
|
203
203
|
from_object: Union[dict, object],
|
204
|
-
parent_object: dict = None,
|
204
|
+
parent_object: Optional[dict] = None,
|
205
205
|
) -> dict:
|
206
|
-
to_object = {}
|
206
|
+
to_object: dict[str, Any] = {}
|
207
207
|
if getv(from_object, ['gcs_uri']) is not None:
|
208
208
|
setv(
|
209
209
|
parent_object,
|
@@ -218,11 +218,11 @@ def _TuningDataset_to_vertex(
|
|
218
218
|
|
219
219
|
|
220
220
|
def _TuningValidationDataset_to_mldev(
|
221
|
-
api_client:
|
221
|
+
api_client: BaseApiClient,
|
222
222
|
from_object: Union[dict, object],
|
223
|
-
parent_object: dict = None,
|
223
|
+
parent_object: Optional[dict] = None,
|
224
224
|
) -> dict:
|
225
|
-
to_object = {}
|
225
|
+
to_object: dict[str, Any] = {}
|
226
226
|
if getv(from_object, ['gcs_uri']) is not None:
|
227
227
|
raise ValueError('gcs_uri parameter is not supported in Gemini API.')
|
228
228
|
|
@@ -230,11 +230,11 @@ def _TuningValidationDataset_to_mldev(
|
|
230
230
|
|
231
231
|
|
232
232
|
def _TuningValidationDataset_to_vertex(
|
233
|
-
api_client:
|
233
|
+
api_client: BaseApiClient,
|
234
234
|
from_object: Union[dict, object],
|
235
|
-
parent_object: dict = None,
|
235
|
+
parent_object: Optional[dict] = None,
|
236
236
|
) -> dict:
|
237
|
-
to_object = {}
|
237
|
+
to_object: dict[str, Any] = {}
|
238
238
|
if getv(from_object, ['gcs_uri']) is not None:
|
239
239
|
setv(to_object, ['validationDatasetUri'], getv(from_object, ['gcs_uri']))
|
240
240
|
|
@@ -242,11 +242,11 @@ def _TuningValidationDataset_to_vertex(
|
|
242
242
|
|
243
243
|
|
244
244
|
def _CreateTuningJobConfig_to_mldev(
|
245
|
-
api_client:
|
245
|
+
api_client: BaseApiClient,
|
246
246
|
from_object: Union[dict, object],
|
247
|
-
parent_object: dict = None,
|
247
|
+
parent_object: Optional[dict] = None,
|
248
248
|
) -> dict:
|
249
|
-
to_object = {}
|
249
|
+
to_object: dict[str, Any] = {}
|
250
250
|
|
251
251
|
if getv(from_object, ['validation_dataset']) is not None:
|
252
252
|
raise ValueError(
|
@@ -298,11 +298,11 @@ def _CreateTuningJobConfig_to_mldev(
|
|
298
298
|
|
299
299
|
|
300
300
|
def _CreateTuningJobConfig_to_vertex(
|
301
|
-
api_client:
|
301
|
+
api_client: BaseApiClient,
|
302
302
|
from_object: Union[dict, object],
|
303
|
-
parent_object: dict = None,
|
303
|
+
parent_object: Optional[dict] = None,
|
304
304
|
) -> dict:
|
305
|
-
to_object = {}
|
305
|
+
to_object: dict[str, Any] = {}
|
306
306
|
|
307
307
|
if getv(from_object, ['validation_dataset']) is not None:
|
308
308
|
setv(
|
@@ -354,11 +354,11 @@ def _CreateTuningJobConfig_to_vertex(
|
|
354
354
|
|
355
355
|
|
356
356
|
def _CreateTuningJobParameters_to_mldev(
|
357
|
-
api_client:
|
357
|
+
api_client: BaseApiClient,
|
358
358
|
from_object: Union[dict, object],
|
359
|
-
parent_object: dict = None,
|
359
|
+
parent_object: Optional[dict] = None,
|
360
360
|
) -> dict:
|
361
|
-
to_object = {}
|
361
|
+
to_object: dict[str, Any] = {}
|
362
362
|
if getv(from_object, ['base_model']) is not None:
|
363
363
|
setv(to_object, ['baseModel'], getv(from_object, ['base_model']))
|
364
364
|
|
@@ -384,11 +384,11 @@ def _CreateTuningJobParameters_to_mldev(
|
|
384
384
|
|
385
385
|
|
386
386
|
def _CreateTuningJobParameters_to_vertex(
|
387
|
-
api_client:
|
387
|
+
api_client: BaseApiClient,
|
388
388
|
from_object: Union[dict, object],
|
389
|
-
parent_object: dict = None,
|
389
|
+
parent_object: Optional[dict] = None,
|
390
390
|
) -> dict:
|
391
|
-
to_object = {}
|
391
|
+
to_object: dict[str, Any] = {}
|
392
392
|
if getv(from_object, ['base_model']) is not None:
|
393
393
|
setv(to_object, ['baseModel'], getv(from_object, ['base_model']))
|
394
394
|
|
@@ -414,11 +414,11 @@ def _CreateTuningJobParameters_to_vertex(
|
|
414
414
|
|
415
415
|
|
416
416
|
def _TunedModel_from_mldev(
|
417
|
-
api_client:
|
417
|
+
api_client: BaseApiClient,
|
418
418
|
from_object: Union[dict, object],
|
419
|
-
parent_object: dict = None,
|
419
|
+
parent_object: Optional[dict] = None,
|
420
420
|
) -> dict:
|
421
|
-
to_object = {}
|
421
|
+
to_object: dict[str, Any] = {}
|
422
422
|
if getv(from_object, ['name']) is not None:
|
423
423
|
setv(to_object, ['model'], getv(from_object, ['name']))
|
424
424
|
|
@@ -429,11 +429,11 @@ def _TunedModel_from_mldev(
|
|
429
429
|
|
430
430
|
|
431
431
|
def _TunedModel_from_vertex(
|
432
|
-
api_client:
|
432
|
+
api_client: BaseApiClient,
|
433
433
|
from_object: Union[dict, object],
|
434
|
-
parent_object: dict = None,
|
434
|
+
parent_object: Optional[dict] = None,
|
435
435
|
) -> dict:
|
436
|
-
to_object = {}
|
436
|
+
to_object: dict[str, Any] = {}
|
437
437
|
if getv(from_object, ['model']) is not None:
|
438
438
|
setv(to_object, ['model'], getv(from_object, ['model']))
|
439
439
|
|
@@ -444,11 +444,11 @@ def _TunedModel_from_vertex(
|
|
444
444
|
|
445
445
|
|
446
446
|
def _TuningJob_from_mldev(
|
447
|
-
api_client:
|
447
|
+
api_client: BaseApiClient,
|
448
448
|
from_object: Union[dict, object],
|
449
|
-
parent_object: dict = None,
|
449
|
+
parent_object: Optional[dict] = None,
|
450
450
|
) -> dict:
|
451
|
-
to_object = {}
|
451
|
+
to_object: dict[str, Any] = {}
|
452
452
|
if getv(from_object, ['name']) is not None:
|
453
453
|
setv(to_object, ['name'], getv(from_object, ['name']))
|
454
454
|
|
@@ -521,11 +521,11 @@ def _TuningJob_from_mldev(
|
|
521
521
|
|
522
522
|
|
523
523
|
def _TuningJob_from_vertex(
|
524
|
-
api_client:
|
524
|
+
api_client: BaseApiClient,
|
525
525
|
from_object: Union[dict, object],
|
526
|
-
parent_object: dict = None,
|
526
|
+
parent_object: Optional[dict] = None,
|
527
527
|
) -> dict:
|
528
|
-
to_object = {}
|
528
|
+
to_object: dict[str, Any] = {}
|
529
529
|
if getv(from_object, ['name']) is not None:
|
530
530
|
setv(to_object, ['name'], getv(from_object, ['name']))
|
531
531
|
|
@@ -615,11 +615,11 @@ def _TuningJob_from_vertex(
|
|
615
615
|
|
616
616
|
|
617
617
|
def _ListTuningJobsResponse_from_mldev(
|
618
|
-
api_client:
|
618
|
+
api_client: BaseApiClient,
|
619
619
|
from_object: Union[dict, object],
|
620
|
-
parent_object: dict = None,
|
620
|
+
parent_object: Optional[dict] = None,
|
621
621
|
) -> dict:
|
622
|
-
to_object = {}
|
622
|
+
to_object: dict[str, Any] = {}
|
623
623
|
if getv(from_object, ['nextPageToken']) is not None:
|
624
624
|
setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
|
625
625
|
|
@@ -637,11 +637,11 @@ def _ListTuningJobsResponse_from_mldev(
|
|
637
637
|
|
638
638
|
|
639
639
|
def _ListTuningJobsResponse_from_vertex(
|
640
|
-
api_client:
|
640
|
+
api_client: BaseApiClient,
|
641
641
|
from_object: Union[dict, object],
|
642
|
-
parent_object: dict = None,
|
642
|
+
parent_object: Optional[dict] = None,
|
643
643
|
) -> dict:
|
644
|
-
to_object = {}
|
644
|
+
to_object: dict[str, Any] = {}
|
645
645
|
if getv(from_object, ['nextPageToken']) is not None:
|
646
646
|
setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
|
647
647
|
|
@@ -659,11 +659,11 @@ def _ListTuningJobsResponse_from_vertex(
|
|
659
659
|
|
660
660
|
|
661
661
|
def _Operation_from_mldev(
|
662
|
-
api_client:
|
662
|
+
api_client: BaseApiClient,
|
663
663
|
from_object: Union[dict, object],
|
664
|
-
parent_object: dict = None,
|
664
|
+
parent_object: Optional[dict] = None,
|
665
665
|
) -> dict:
|
666
|
-
to_object = {}
|
666
|
+
to_object: dict[str, Any] = {}
|
667
667
|
if getv(from_object, ['name']) is not None:
|
668
668
|
setv(to_object, ['name'], getv(from_object, ['name']))
|
669
669
|
|
@@ -683,11 +683,11 @@ def _Operation_from_mldev(
|
|
683
683
|
|
684
684
|
|
685
685
|
def _Operation_from_vertex(
|
686
|
-
api_client:
|
686
|
+
api_client: BaseApiClient,
|
687
687
|
from_object: Union[dict, object],
|
688
|
-
parent_object: dict = None,
|
688
|
+
parent_object: Optional[dict] = None,
|
689
689
|
) -> dict:
|
690
|
-
to_object = {}
|
690
|
+
to_object: dict[str, Any] = {}
|
691
691
|
if getv(from_object, ['name']) is not None:
|
692
692
|
setv(to_object, ['name'], getv(from_object, ['name']))
|
693
693
|
|
@@ -728,23 +728,33 @@ class Tunings(_api_module.BaseModule):
|
|
728
728
|
config=config,
|
729
729
|
)
|
730
730
|
|
731
|
+
request_url_dict: Optional[dict[str, str]]
|
732
|
+
|
731
733
|
if self._api_client.vertexai:
|
732
734
|
request_dict = _GetTuningJobParameters_to_vertex(
|
733
735
|
self._api_client, parameter_model
|
734
736
|
)
|
735
|
-
|
737
|
+
request_url_dict = request_dict.get('_url')
|
738
|
+
if request_url_dict:
|
739
|
+
path = '{name}'.format_map(request_url_dict)
|
740
|
+
else:
|
741
|
+
path = '{name}'
|
736
742
|
else:
|
737
743
|
request_dict = _GetTuningJobParameters_to_mldev(
|
738
744
|
self._api_client, parameter_model
|
739
745
|
)
|
740
|
-
|
746
|
+
request_url_dict = request_dict.get('_url')
|
747
|
+
if request_url_dict:
|
748
|
+
path = '{name}'.format_map(request_url_dict)
|
749
|
+
else:
|
750
|
+
path = '{name}'
|
741
751
|
query_params = request_dict.get('_query')
|
742
752
|
if query_params:
|
743
753
|
path = f'{path}?{urlencode(query_params)}'
|
744
754
|
# TODO: remove the hack that pops config.
|
745
755
|
request_dict.pop('config', None)
|
746
756
|
|
747
|
-
http_options = None
|
757
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
748
758
|
if isinstance(config, dict):
|
749
759
|
http_options = config.get('http_options', None)
|
750
760
|
elif hasattr(config, 'http_options'):
|
@@ -763,7 +773,7 @@ class Tunings(_api_module.BaseModule):
|
|
763
773
|
response_dict = _TuningJob_from_mldev(self._api_client, response_dict)
|
764
774
|
|
765
775
|
return_value = types.TuningJob._from_response(
|
766
|
-
response=response_dict, kwargs=parameter_model
|
776
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
767
777
|
)
|
768
778
|
self._api_client._verify_response(return_value)
|
769
779
|
return return_value
|
@@ -784,23 +794,33 @@ class Tunings(_api_module.BaseModule):
|
|
784
794
|
config=config,
|
785
795
|
)
|
786
796
|
|
797
|
+
request_url_dict: Optional[dict[str, str]]
|
798
|
+
|
787
799
|
if self._api_client.vertexai:
|
788
800
|
request_dict = _ListTuningJobsParameters_to_vertex(
|
789
801
|
self._api_client, parameter_model
|
790
802
|
)
|
791
|
-
|
803
|
+
request_url_dict = request_dict.get('_url')
|
804
|
+
if request_url_dict:
|
805
|
+
path = 'tuningJobs'.format_map(request_url_dict)
|
806
|
+
else:
|
807
|
+
path = 'tuningJobs'
|
792
808
|
else:
|
793
809
|
request_dict = _ListTuningJobsParameters_to_mldev(
|
794
810
|
self._api_client, parameter_model
|
795
811
|
)
|
796
|
-
|
812
|
+
request_url_dict = request_dict.get('_url')
|
813
|
+
if request_url_dict:
|
814
|
+
path = 'tunedModels'.format_map(request_url_dict)
|
815
|
+
else:
|
816
|
+
path = 'tunedModels'
|
797
817
|
query_params = request_dict.get('_query')
|
798
818
|
if query_params:
|
799
819
|
path = f'{path}?{urlencode(query_params)}'
|
800
820
|
# TODO: remove the hack that pops config.
|
801
821
|
request_dict.pop('config', None)
|
802
822
|
|
803
|
-
http_options = None
|
823
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
804
824
|
if isinstance(config, dict):
|
805
825
|
http_options = config.get('http_options', None)
|
806
826
|
elif hasattr(config, 'http_options'):
|
@@ -823,7 +843,7 @@ class Tunings(_api_module.BaseModule):
|
|
823
843
|
)
|
824
844
|
|
825
845
|
return_value = types.ListTuningJobsResponse._from_response(
|
826
|
-
response=response_dict, kwargs=parameter_model
|
846
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
827
847
|
)
|
828
848
|
self._api_client._verify_response(return_value)
|
829
849
|
return return_value
|
@@ -852,13 +872,18 @@ class Tunings(_api_module.BaseModule):
|
|
852
872
|
config=config,
|
853
873
|
)
|
854
874
|
|
875
|
+
request_url_dict: Optional[dict[str, str]]
|
855
876
|
if not self._api_client.vertexai:
|
856
877
|
raise ValueError('This method is only supported in the Vertex AI client.')
|
857
878
|
else:
|
858
879
|
request_dict = _CreateTuningJobParameters_to_vertex(
|
859
880
|
self._api_client, parameter_model
|
860
881
|
)
|
861
|
-
|
882
|
+
request_url_dict = request_dict.get('_url')
|
883
|
+
if request_url_dict:
|
884
|
+
path = 'tuningJobs'.format_map(request_url_dict)
|
885
|
+
else:
|
886
|
+
path = 'tuningJobs'
|
862
887
|
|
863
888
|
query_params = request_dict.get('_query')
|
864
889
|
if query_params:
|
@@ -866,7 +891,7 @@ class Tunings(_api_module.BaseModule):
|
|
866
891
|
# TODO: remove the hack that pops config.
|
867
892
|
request_dict.pop('config', None)
|
868
893
|
|
869
|
-
http_options = None
|
894
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
870
895
|
if isinstance(config, dict):
|
871
896
|
http_options = config.get('http_options', None)
|
872
897
|
elif hasattr(config, 'http_options'):
|
@@ -885,7 +910,7 @@ class Tunings(_api_module.BaseModule):
|
|
885
910
|
response_dict = _TuningJob_from_mldev(self._api_client, response_dict)
|
886
911
|
|
887
912
|
return_value = types.TuningJob._from_response(
|
888
|
-
response=response_dict, kwargs=parameter_model
|
913
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
889
914
|
)
|
890
915
|
self._api_client._verify_response(return_value)
|
891
916
|
return return_value
|
@@ -914,13 +939,18 @@ class Tunings(_api_module.BaseModule):
|
|
914
939
|
config=config,
|
915
940
|
)
|
916
941
|
|
942
|
+
request_url_dict: Optional[dict[str, str]]
|
917
943
|
if self._api_client.vertexai:
|
918
944
|
raise ValueError('This method is only supported in the default client.')
|
919
945
|
else:
|
920
946
|
request_dict = _CreateTuningJobParameters_to_mldev(
|
921
947
|
self._api_client, parameter_model
|
922
948
|
)
|
923
|
-
|
949
|
+
request_url_dict = request_dict.get('_url')
|
950
|
+
if request_url_dict:
|
951
|
+
path = 'tunedModels'.format_map(request_url_dict)
|
952
|
+
else:
|
953
|
+
path = 'tunedModels'
|
924
954
|
|
925
955
|
query_params = request_dict.get('_query')
|
926
956
|
if query_params:
|
@@ -928,7 +958,7 @@ class Tunings(_api_module.BaseModule):
|
|
928
958
|
# TODO: remove the hack that pops config.
|
929
959
|
request_dict.pop('config', None)
|
930
960
|
|
931
|
-
http_options = None
|
961
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
932
962
|
if isinstance(config, dict):
|
933
963
|
http_options = config.get('http_options', None)
|
934
964
|
elif hasattr(config, 'http_options'):
|
@@ -947,7 +977,7 @@ class Tunings(_api_module.BaseModule):
|
|
947
977
|
response_dict = _Operation_from_mldev(self._api_client, response_dict)
|
948
978
|
|
949
979
|
return_value = types.Operation._from_response(
|
950
|
-
response=response_dict, kwargs=parameter_model
|
980
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
951
981
|
)
|
952
982
|
self._api_client._verify_response(return_value)
|
953
983
|
return return_value
|
@@ -1037,23 +1067,33 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1037
1067
|
config=config,
|
1038
1068
|
)
|
1039
1069
|
|
1070
|
+
request_url_dict: Optional[dict[str, str]]
|
1071
|
+
|
1040
1072
|
if self._api_client.vertexai:
|
1041
1073
|
request_dict = _GetTuningJobParameters_to_vertex(
|
1042
1074
|
self._api_client, parameter_model
|
1043
1075
|
)
|
1044
|
-
|
1076
|
+
request_url_dict = request_dict.get('_url')
|
1077
|
+
if request_url_dict:
|
1078
|
+
path = '{name}'.format_map(request_url_dict)
|
1079
|
+
else:
|
1080
|
+
path = '{name}'
|
1045
1081
|
else:
|
1046
1082
|
request_dict = _GetTuningJobParameters_to_mldev(
|
1047
1083
|
self._api_client, parameter_model
|
1048
1084
|
)
|
1049
|
-
|
1085
|
+
request_url_dict = request_dict.get('_url')
|
1086
|
+
if request_url_dict:
|
1087
|
+
path = '{name}'.format_map(request_url_dict)
|
1088
|
+
else:
|
1089
|
+
path = '{name}'
|
1050
1090
|
query_params = request_dict.get('_query')
|
1051
1091
|
if query_params:
|
1052
1092
|
path = f'{path}?{urlencode(query_params)}'
|
1053
1093
|
# TODO: remove the hack that pops config.
|
1054
1094
|
request_dict.pop('config', None)
|
1055
1095
|
|
1056
|
-
http_options = None
|
1096
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
1057
1097
|
if isinstance(config, dict):
|
1058
1098
|
http_options = config.get('http_options', None)
|
1059
1099
|
elif hasattr(config, 'http_options'):
|
@@ -1072,7 +1112,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1072
1112
|
response_dict = _TuningJob_from_mldev(self._api_client, response_dict)
|
1073
1113
|
|
1074
1114
|
return_value = types.TuningJob._from_response(
|
1075
|
-
response=response_dict, kwargs=parameter_model
|
1115
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
1076
1116
|
)
|
1077
1117
|
self._api_client._verify_response(return_value)
|
1078
1118
|
return return_value
|
@@ -1093,23 +1133,33 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1093
1133
|
config=config,
|
1094
1134
|
)
|
1095
1135
|
|
1136
|
+
request_url_dict: Optional[dict[str, str]]
|
1137
|
+
|
1096
1138
|
if self._api_client.vertexai:
|
1097
1139
|
request_dict = _ListTuningJobsParameters_to_vertex(
|
1098
1140
|
self._api_client, parameter_model
|
1099
1141
|
)
|
1100
|
-
|
1142
|
+
request_url_dict = request_dict.get('_url')
|
1143
|
+
if request_url_dict:
|
1144
|
+
path = 'tuningJobs'.format_map(request_url_dict)
|
1145
|
+
else:
|
1146
|
+
path = 'tuningJobs'
|
1101
1147
|
else:
|
1102
1148
|
request_dict = _ListTuningJobsParameters_to_mldev(
|
1103
1149
|
self._api_client, parameter_model
|
1104
1150
|
)
|
1105
|
-
|
1151
|
+
request_url_dict = request_dict.get('_url')
|
1152
|
+
if request_url_dict:
|
1153
|
+
path = 'tunedModels'.format_map(request_url_dict)
|
1154
|
+
else:
|
1155
|
+
path = 'tunedModels'
|
1106
1156
|
query_params = request_dict.get('_query')
|
1107
1157
|
if query_params:
|
1108
1158
|
path = f'{path}?{urlencode(query_params)}'
|
1109
1159
|
# TODO: remove the hack that pops config.
|
1110
1160
|
request_dict.pop('config', None)
|
1111
1161
|
|
1112
|
-
http_options = None
|
1162
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
1113
1163
|
if isinstance(config, dict):
|
1114
1164
|
http_options = config.get('http_options', None)
|
1115
1165
|
elif hasattr(config, 'http_options'):
|
@@ -1132,7 +1182,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1132
1182
|
)
|
1133
1183
|
|
1134
1184
|
return_value = types.ListTuningJobsResponse._from_response(
|
1135
|
-
response=response_dict, kwargs=parameter_model
|
1185
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
1136
1186
|
)
|
1137
1187
|
self._api_client._verify_response(return_value)
|
1138
1188
|
return return_value
|
@@ -1161,13 +1211,18 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1161
1211
|
config=config,
|
1162
1212
|
)
|
1163
1213
|
|
1214
|
+
request_url_dict: Optional[dict[str, str]]
|
1164
1215
|
if not self._api_client.vertexai:
|
1165
1216
|
raise ValueError('This method is only supported in the Vertex AI client.')
|
1166
1217
|
else:
|
1167
1218
|
request_dict = _CreateTuningJobParameters_to_vertex(
|
1168
1219
|
self._api_client, parameter_model
|
1169
1220
|
)
|
1170
|
-
|
1221
|
+
request_url_dict = request_dict.get('_url')
|
1222
|
+
if request_url_dict:
|
1223
|
+
path = 'tuningJobs'.format_map(request_url_dict)
|
1224
|
+
else:
|
1225
|
+
path = 'tuningJobs'
|
1171
1226
|
|
1172
1227
|
query_params = request_dict.get('_query')
|
1173
1228
|
if query_params:
|
@@ -1175,7 +1230,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1175
1230
|
# TODO: remove the hack that pops config.
|
1176
1231
|
request_dict.pop('config', None)
|
1177
1232
|
|
1178
|
-
http_options = None
|
1233
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
1179
1234
|
if isinstance(config, dict):
|
1180
1235
|
http_options = config.get('http_options', None)
|
1181
1236
|
elif hasattr(config, 'http_options'):
|
@@ -1194,7 +1249,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1194
1249
|
response_dict = _TuningJob_from_mldev(self._api_client, response_dict)
|
1195
1250
|
|
1196
1251
|
return_value = types.TuningJob._from_response(
|
1197
|
-
response=response_dict, kwargs=parameter_model
|
1252
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
1198
1253
|
)
|
1199
1254
|
self._api_client._verify_response(return_value)
|
1200
1255
|
return return_value
|
@@ -1223,13 +1278,18 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1223
1278
|
config=config,
|
1224
1279
|
)
|
1225
1280
|
|
1281
|
+
request_url_dict: Optional[dict[str, str]]
|
1226
1282
|
if self._api_client.vertexai:
|
1227
1283
|
raise ValueError('This method is only supported in the default client.')
|
1228
1284
|
else:
|
1229
1285
|
request_dict = _CreateTuningJobParameters_to_mldev(
|
1230
1286
|
self._api_client, parameter_model
|
1231
1287
|
)
|
1232
|
-
|
1288
|
+
request_url_dict = request_dict.get('_url')
|
1289
|
+
if request_url_dict:
|
1290
|
+
path = 'tunedModels'.format_map(request_url_dict)
|
1291
|
+
else:
|
1292
|
+
path = 'tunedModels'
|
1233
1293
|
|
1234
1294
|
query_params = request_dict.get('_query')
|
1235
1295
|
if query_params:
|
@@ -1237,7 +1297,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1237
1297
|
# TODO: remove the hack that pops config.
|
1238
1298
|
request_dict.pop('config', None)
|
1239
1299
|
|
1240
|
-
http_options = None
|
1300
|
+
http_options: Optional[types.HttpOptionsOrDict] = None
|
1241
1301
|
if isinstance(config, dict):
|
1242
1302
|
http_options = config.get('http_options', None)
|
1243
1303
|
elif hasattr(config, 'http_options'):
|
@@ -1256,7 +1316,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1256
1316
|
response_dict = _Operation_from_mldev(self._api_client, response_dict)
|
1257
1317
|
|
1258
1318
|
return_value = types.Operation._from_response(
|
1259
|
-
response=response_dict, kwargs=parameter_model
|
1319
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
1260
1320
|
)
|
1261
1321
|
self._api_client._verify_response(return_value)
|
1262
1322
|
return return_value
|
@@ -1327,7 +1387,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1327
1387
|
class _IpythonUtils:
|
1328
1388
|
"""Temporary class to hold the IPython related functions."""
|
1329
1389
|
|
1330
|
-
displayed_experiments = set()
|
1390
|
+
displayed_experiments: set[str] = set()
|
1331
1391
|
|
1332
1392
|
@staticmethod
|
1333
1393
|
def _get_ipython_shell_name() -> str:
|