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