google-genai 0.3.0__py3-none-any.whl → 0.5.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/__init__.py +2 -1
- google/genai/_api_client.py +161 -52
- google/genai/_automatic_function_calling_util.py +14 -14
- google/genai/_common.py +14 -29
- google/genai/_replay_api_client.py +13 -54
- google/genai/_transformers.py +38 -0
- google/genai/batches.py +80 -78
- google/genai/caches.py +112 -98
- google/genai/chats.py +7 -10
- google/genai/client.py +6 -3
- google/genai/files.py +91 -90
- google/genai/live.py +65 -34
- google/genai/models.py +374 -297
- google/genai/tunings.py +87 -85
- google/genai/types.py +167 -82
- google/genai/version.py +16 -0
- {google_genai-0.3.0.dist-info → google_genai-0.5.0.dist-info}/METADATA +57 -17
- google_genai-0.5.0.dist-info/RECORD +25 -0
- {google_genai-0.3.0.dist-info → google_genai-0.5.0.dist-info}/WHEEL +1 -1
- google_genai-0.3.0.dist-info/RECORD +0 -24
- {google_genai-0.3.0.dist-info → google_genai-0.5.0.dist-info}/LICENSE +0 -0
- {google_genai-0.3.0.dist-info → google_genai-0.5.0.dist-info}/top_level.txt +0 -0
google/genai/tunings.py
CHANGED
@@ -13,6 +13,8 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
#
|
15
15
|
|
16
|
+
# Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
17
|
+
|
16
18
|
from typing import Optional, Union
|
17
19
|
from urllib.parse import urlencode
|
18
20
|
from . import _common
|
@@ -195,10 +197,10 @@ def _TuningExample_to_vertex(
|
|
195
197
|
parent_object: dict = None,
|
196
198
|
) -> dict:
|
197
199
|
to_object = {}
|
198
|
-
if getv(from_object, ['text_input']):
|
200
|
+
if getv(from_object, ['text_input']) is not None:
|
199
201
|
raise ValueError('text_input parameter is not supported in Vertex AI.')
|
200
202
|
|
201
|
-
if getv(from_object, ['output']):
|
203
|
+
if getv(from_object, ['output']) is not None:
|
202
204
|
raise ValueError('output parameter is not supported in Vertex AI.')
|
203
205
|
|
204
206
|
return to_object
|
@@ -210,7 +212,7 @@ def _TuningDataset_to_mldev(
|
|
210
212
|
parent_object: dict = None,
|
211
213
|
) -> dict:
|
212
214
|
to_object = {}
|
213
|
-
if getv(from_object, ['gcs_uri']):
|
215
|
+
if getv(from_object, ['gcs_uri']) is not None:
|
214
216
|
raise ValueError('gcs_uri parameter is not supported in Google AI.')
|
215
217
|
|
216
218
|
if getv(from_object, ['examples']) is not None:
|
@@ -239,7 +241,7 @@ def _TuningDataset_to_vertex(
|
|
239
241
|
getv(from_object, ['gcs_uri']),
|
240
242
|
)
|
241
243
|
|
242
|
-
if getv(from_object, ['examples']):
|
244
|
+
if getv(from_object, ['examples']) is not None:
|
243
245
|
raise ValueError('examples parameter is not supported in Vertex AI.')
|
244
246
|
|
245
247
|
return to_object
|
@@ -251,7 +253,7 @@ def _TuningValidationDataset_to_mldev(
|
|
251
253
|
parent_object: dict = None,
|
252
254
|
) -> dict:
|
253
255
|
to_object = {}
|
254
|
-
if getv(from_object, ['gcs_uri']):
|
256
|
+
if getv(from_object, ['gcs_uri']) is not None:
|
255
257
|
raise ValueError('gcs_uri parameter is not supported in Google AI.')
|
256
258
|
|
257
259
|
return to_object
|
@@ -278,7 +280,7 @@ def _CreateTuningJobConfig_to_mldev(
|
|
278
280
|
if getv(from_object, ['http_options']) is not None:
|
279
281
|
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
280
282
|
|
281
|
-
if getv(from_object, ['validation_dataset']):
|
283
|
+
if getv(from_object, ['validation_dataset']) is not None:
|
282
284
|
raise ValueError(
|
283
285
|
'validation_dataset parameter is not supported in Google AI.'
|
284
286
|
)
|
@@ -290,7 +292,7 @@ def _CreateTuningJobConfig_to_mldev(
|
|
290
292
|
getv(from_object, ['tuned_model_display_name']),
|
291
293
|
)
|
292
294
|
|
293
|
-
if getv(from_object, ['description']):
|
295
|
+
if getv(from_object, ['description']) is not None:
|
294
296
|
raise ValueError('description parameter is not supported in Google AI.')
|
295
297
|
|
296
298
|
if getv(from_object, ['epoch_count']) is not None:
|
@@ -307,7 +309,7 @@ def _CreateTuningJobConfig_to_mldev(
|
|
307
309
|
getv(from_object, ['learning_rate_multiplier']),
|
308
310
|
)
|
309
311
|
|
310
|
-
if getv(from_object, ['adapter_size']):
|
312
|
+
if getv(from_object, ['adapter_size']) is not None:
|
311
313
|
raise ValueError('adapter_size parameter is not supported in Google AI.')
|
312
314
|
|
313
315
|
if getv(from_object, ['batch_size']) is not None:
|
@@ -376,10 +378,10 @@ def _CreateTuningJobConfig_to_vertex(
|
|
376
378
|
getv(from_object, ['adapter_size']),
|
377
379
|
)
|
378
380
|
|
379
|
-
if getv(from_object, ['batch_size']):
|
381
|
+
if getv(from_object, ['batch_size']) is not None:
|
380
382
|
raise ValueError('batch_size parameter is not supported in Vertex AI.')
|
381
383
|
|
382
|
-
if getv(from_object, ['learning_rate']):
|
384
|
+
if getv(from_object, ['learning_rate']) is not None:
|
383
385
|
raise ValueError('learning_rate parameter is not supported in Vertex AI.')
|
384
386
|
|
385
387
|
return to_object
|
@@ -451,7 +453,7 @@ def _DistillationDataset_to_mldev(
|
|
451
453
|
parent_object: dict = None,
|
452
454
|
) -> dict:
|
453
455
|
to_object = {}
|
454
|
-
if getv(from_object, ['gcs_uri']):
|
456
|
+
if getv(from_object, ['gcs_uri']) is not None:
|
455
457
|
raise ValueError('gcs_uri parameter is not supported in Google AI.')
|
456
458
|
|
457
459
|
return to_object
|
@@ -479,7 +481,7 @@ def _DistillationValidationDataset_to_mldev(
|
|
479
481
|
parent_object: dict = None,
|
480
482
|
) -> dict:
|
481
483
|
to_object = {}
|
482
|
-
if getv(from_object, ['gcs_uri']):
|
484
|
+
if getv(from_object, ['gcs_uri']) is not None:
|
483
485
|
raise ValueError('gcs_uri parameter is not supported in Google AI.')
|
484
486
|
|
485
487
|
return to_object
|
@@ -506,7 +508,7 @@ def _CreateDistillationJobConfig_to_mldev(
|
|
506
508
|
if getv(from_object, ['http_options']) is not None:
|
507
509
|
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
508
510
|
|
509
|
-
if getv(from_object, ['validation_dataset']):
|
511
|
+
if getv(from_object, ['validation_dataset']) is not None:
|
510
512
|
raise ValueError(
|
511
513
|
'validation_dataset parameter is not supported in Google AI.'
|
512
514
|
)
|
@@ -532,10 +534,10 @@ def _CreateDistillationJobConfig_to_mldev(
|
|
532
534
|
getv(from_object, ['learning_rate_multiplier']),
|
533
535
|
)
|
534
536
|
|
535
|
-
if getv(from_object, ['adapter_size']):
|
537
|
+
if getv(from_object, ['adapter_size']) is not None:
|
536
538
|
raise ValueError('adapter_size parameter is not supported in Google AI.')
|
537
539
|
|
538
|
-
if getv(from_object, ['pipeline_root_directory']):
|
540
|
+
if getv(from_object, ['pipeline_root_directory']) is not None:
|
539
541
|
raise ValueError(
|
540
542
|
'pipeline_root_directory parameter is not supported in Google AI.'
|
541
543
|
)
|
@@ -605,10 +607,10 @@ def _CreateDistillationJobParameters_to_mldev(
|
|
605
607
|
parent_object: dict = None,
|
606
608
|
) -> dict:
|
607
609
|
to_object = {}
|
608
|
-
if getv(from_object, ['student_model']):
|
610
|
+
if getv(from_object, ['student_model']) is not None:
|
609
611
|
raise ValueError('student_model parameter is not supported in Google AI.')
|
610
612
|
|
611
|
-
if getv(from_object, ['teacher_model']):
|
613
|
+
if getv(from_object, ['teacher_model']) is not None:
|
612
614
|
raise ValueError('teacher_model parameter is not supported in Google AI.')
|
613
615
|
|
614
616
|
if getv(from_object, ['training_dataset']) is not None:
|
@@ -970,14 +972,14 @@ class Tunings(_common.BaseModule):
|
|
970
972
|
config=config,
|
971
973
|
)
|
972
974
|
|
973
|
-
if self.
|
975
|
+
if self._api_client.vertexai:
|
974
976
|
request_dict = _GetTuningJobParameters_to_vertex(
|
975
|
-
self.
|
977
|
+
self._api_client, parameter_model
|
976
978
|
)
|
977
979
|
path = '{name}'.format_map(request_dict.get('_url'))
|
978
980
|
else:
|
979
981
|
request_dict = _GetTuningJobParameters_to_mldev(
|
980
|
-
self.
|
982
|
+
self._api_client, parameter_model
|
981
983
|
)
|
982
984
|
path = '{name}'.format_map(request_dict.get('_url'))
|
983
985
|
query_params = request_dict.get('_query')
|
@@ -989,19 +991,19 @@ class Tunings(_common.BaseModule):
|
|
989
991
|
request_dict = _common.convert_to_dict(request_dict)
|
990
992
|
request_dict = _common.apply_base64_encoding(request_dict)
|
991
993
|
|
992
|
-
response_dict = self.
|
994
|
+
response_dict = self._api_client.request(
|
993
995
|
'get', path, request_dict, http_options
|
994
996
|
)
|
995
997
|
|
996
|
-
if self.
|
997
|
-
response_dict = _TuningJob_from_vertex(self.
|
998
|
+
if self._api_client.vertexai:
|
999
|
+
response_dict = _TuningJob_from_vertex(self._api_client, response_dict)
|
998
1000
|
else:
|
999
|
-
response_dict = _TuningJob_from_mldev(self.
|
1001
|
+
response_dict = _TuningJob_from_mldev(self._api_client, response_dict)
|
1000
1002
|
|
1001
1003
|
return_value = types.TuningJob._from_response(
|
1002
1004
|
response_dict, parameter_model
|
1003
1005
|
)
|
1004
|
-
self.
|
1006
|
+
self._api_client._verify_response(return_value)
|
1005
1007
|
return return_value
|
1006
1008
|
|
1007
1009
|
def _list(
|
@@ -1020,14 +1022,14 @@ class Tunings(_common.BaseModule):
|
|
1020
1022
|
config=config,
|
1021
1023
|
)
|
1022
1024
|
|
1023
|
-
if self.
|
1025
|
+
if self._api_client.vertexai:
|
1024
1026
|
request_dict = _ListTuningJobsParameters_to_vertex(
|
1025
|
-
self.
|
1027
|
+
self._api_client, parameter_model
|
1026
1028
|
)
|
1027
1029
|
path = 'tuningJobs'.format_map(request_dict.get('_url'))
|
1028
1030
|
else:
|
1029
1031
|
request_dict = _ListTuningJobsParameters_to_mldev(
|
1030
|
-
self.
|
1032
|
+
self._api_client, parameter_model
|
1031
1033
|
)
|
1032
1034
|
path = 'tunedModels'.format_map(request_dict.get('_url'))
|
1033
1035
|
query_params = request_dict.get('_query')
|
@@ -1039,23 +1041,23 @@ class Tunings(_common.BaseModule):
|
|
1039
1041
|
request_dict = _common.convert_to_dict(request_dict)
|
1040
1042
|
request_dict = _common.apply_base64_encoding(request_dict)
|
1041
1043
|
|
1042
|
-
response_dict = self.
|
1044
|
+
response_dict = self._api_client.request(
|
1043
1045
|
'get', path, request_dict, http_options
|
1044
1046
|
)
|
1045
1047
|
|
1046
|
-
if self.
|
1048
|
+
if self._api_client.vertexai:
|
1047
1049
|
response_dict = _ListTuningJobsResponse_from_vertex(
|
1048
|
-
self.
|
1050
|
+
self._api_client, response_dict
|
1049
1051
|
)
|
1050
1052
|
else:
|
1051
1053
|
response_dict = _ListTuningJobsResponse_from_mldev(
|
1052
|
-
self.
|
1054
|
+
self._api_client, response_dict
|
1053
1055
|
)
|
1054
1056
|
|
1055
1057
|
return_value = types.ListTuningJobsResponse._from_response(
|
1056
1058
|
response_dict, parameter_model
|
1057
1059
|
)
|
1058
|
-
self.
|
1060
|
+
self._api_client._verify_response(return_value)
|
1059
1061
|
return return_value
|
1060
1062
|
|
1061
1063
|
def _tune(
|
@@ -1082,14 +1084,14 @@ class Tunings(_common.BaseModule):
|
|
1082
1084
|
config=config,
|
1083
1085
|
)
|
1084
1086
|
|
1085
|
-
if self.
|
1087
|
+
if self._api_client.vertexai:
|
1086
1088
|
request_dict = _CreateTuningJobParameters_to_vertex(
|
1087
|
-
self.
|
1089
|
+
self._api_client, parameter_model
|
1088
1090
|
)
|
1089
1091
|
path = 'tuningJobs'.format_map(request_dict.get('_url'))
|
1090
1092
|
else:
|
1091
1093
|
request_dict = _CreateTuningJobParameters_to_mldev(
|
1092
|
-
self.
|
1094
|
+
self._api_client, parameter_model
|
1093
1095
|
)
|
1094
1096
|
path = 'tunedModels'.format_map(request_dict.get('_url'))
|
1095
1097
|
query_params = request_dict.get('_query')
|
@@ -1101,23 +1103,23 @@ class Tunings(_common.BaseModule):
|
|
1101
1103
|
request_dict = _common.convert_to_dict(request_dict)
|
1102
1104
|
request_dict = _common.apply_base64_encoding(request_dict)
|
1103
1105
|
|
1104
|
-
response_dict = self.
|
1106
|
+
response_dict = self._api_client.request(
|
1105
1107
|
'post', path, request_dict, http_options
|
1106
1108
|
)
|
1107
1109
|
|
1108
|
-
if self.
|
1110
|
+
if self._api_client.vertexai:
|
1109
1111
|
response_dict = _TuningJobOrOperation_from_vertex(
|
1110
|
-
self.
|
1112
|
+
self._api_client, response_dict
|
1111
1113
|
)
|
1112
1114
|
else:
|
1113
1115
|
response_dict = _TuningJobOrOperation_from_mldev(
|
1114
|
-
self.
|
1116
|
+
self._api_client, response_dict
|
1115
1117
|
)
|
1116
1118
|
|
1117
1119
|
return_value = types.TuningJobOrOperation._from_response(
|
1118
1120
|
response_dict, parameter_model
|
1119
1121
|
).tuning_job
|
1120
|
-
self.
|
1122
|
+
self._api_client._verify_response(return_value)
|
1121
1123
|
return return_value
|
1122
1124
|
|
1123
1125
|
def distill(
|
@@ -1147,11 +1149,11 @@ class Tunings(_common.BaseModule):
|
|
1147
1149
|
config=config,
|
1148
1150
|
)
|
1149
1151
|
|
1150
|
-
if not self.
|
1152
|
+
if not self._api_client.vertexai:
|
1151
1153
|
raise ValueError('This method is only supported in the Vertex AI client.')
|
1152
1154
|
else:
|
1153
1155
|
request_dict = _CreateDistillationJobParameters_to_vertex(
|
1154
|
-
self.
|
1156
|
+
self._api_client, parameter_model
|
1155
1157
|
)
|
1156
1158
|
path = 'tuningJobs'.format_map(request_dict.get('_url'))
|
1157
1159
|
|
@@ -1164,19 +1166,19 @@ class Tunings(_common.BaseModule):
|
|
1164
1166
|
request_dict = _common.convert_to_dict(request_dict)
|
1165
1167
|
request_dict = _common.apply_base64_encoding(request_dict)
|
1166
1168
|
|
1167
|
-
response_dict = self.
|
1169
|
+
response_dict = self._api_client.request(
|
1168
1170
|
'post', path, request_dict, http_options
|
1169
1171
|
)
|
1170
1172
|
|
1171
|
-
if self.
|
1172
|
-
response_dict = _TuningJob_from_vertex(self.
|
1173
|
+
if self._api_client.vertexai:
|
1174
|
+
response_dict = _TuningJob_from_vertex(self._api_client, response_dict)
|
1173
1175
|
else:
|
1174
|
-
response_dict = _TuningJob_from_mldev(self.
|
1176
|
+
response_dict = _TuningJob_from_mldev(self._api_client, response_dict)
|
1175
1177
|
|
1176
1178
|
return_value = types.TuningJob._from_response(
|
1177
1179
|
response_dict, parameter_model
|
1178
1180
|
)
|
1179
|
-
self.
|
1181
|
+
self._api_client._verify_response(return_value)
|
1180
1182
|
return return_value
|
1181
1183
|
|
1182
1184
|
def list(
|
@@ -1196,10 +1198,10 @@ class Tunings(_common.BaseModule):
|
|
1196
1198
|
config: Optional[types.GetTuningJobConfigOrDict] = None,
|
1197
1199
|
) -> types.TuningJob:
|
1198
1200
|
job = self._get(name=name, config=config)
|
1199
|
-
if job.experiment and self.
|
1201
|
+
if job.experiment and self._api_client.vertexai:
|
1200
1202
|
_IpythonUtils.display_experiment_button(
|
1201
1203
|
experiment=job.experiment,
|
1202
|
-
project=self.
|
1204
|
+
project=self._api_client.project,
|
1203
1205
|
)
|
1204
1206
|
return job
|
1205
1207
|
|
@@ -1215,7 +1217,7 @@ class Tunings(_common.BaseModule):
|
|
1215
1217
|
training_dataset=training_dataset,
|
1216
1218
|
config=config,
|
1217
1219
|
)
|
1218
|
-
if result.name and self.
|
1220
|
+
if result.name and self._api_client.vertexai:
|
1219
1221
|
_IpythonUtils.display_model_tuning_button(tuning_job_resource=result.name)
|
1220
1222
|
return result
|
1221
1223
|
|
@@ -1242,14 +1244,14 @@ class AsyncTunings(_common.BaseModule):
|
|
1242
1244
|
config=config,
|
1243
1245
|
)
|
1244
1246
|
|
1245
|
-
if self.
|
1247
|
+
if self._api_client.vertexai:
|
1246
1248
|
request_dict = _GetTuningJobParameters_to_vertex(
|
1247
|
-
self.
|
1249
|
+
self._api_client, parameter_model
|
1248
1250
|
)
|
1249
1251
|
path = '{name}'.format_map(request_dict.get('_url'))
|
1250
1252
|
else:
|
1251
1253
|
request_dict = _GetTuningJobParameters_to_mldev(
|
1252
|
-
self.
|
1254
|
+
self._api_client, parameter_model
|
1253
1255
|
)
|
1254
1256
|
path = '{name}'.format_map(request_dict.get('_url'))
|
1255
1257
|
query_params = request_dict.get('_query')
|
@@ -1261,19 +1263,19 @@ class AsyncTunings(_common.BaseModule):
|
|
1261
1263
|
request_dict = _common.convert_to_dict(request_dict)
|
1262
1264
|
request_dict = _common.apply_base64_encoding(request_dict)
|
1263
1265
|
|
1264
|
-
response_dict = await self.
|
1266
|
+
response_dict = await self._api_client.async_request(
|
1265
1267
|
'get', path, request_dict, http_options
|
1266
1268
|
)
|
1267
1269
|
|
1268
|
-
if self.
|
1269
|
-
response_dict = _TuningJob_from_vertex(self.
|
1270
|
+
if self._api_client.vertexai:
|
1271
|
+
response_dict = _TuningJob_from_vertex(self._api_client, response_dict)
|
1270
1272
|
else:
|
1271
|
-
response_dict = _TuningJob_from_mldev(self.
|
1273
|
+
response_dict = _TuningJob_from_mldev(self._api_client, response_dict)
|
1272
1274
|
|
1273
1275
|
return_value = types.TuningJob._from_response(
|
1274
1276
|
response_dict, parameter_model
|
1275
1277
|
)
|
1276
|
-
self.
|
1278
|
+
self._api_client._verify_response(return_value)
|
1277
1279
|
return return_value
|
1278
1280
|
|
1279
1281
|
async def _list(
|
@@ -1292,14 +1294,14 @@ class AsyncTunings(_common.BaseModule):
|
|
1292
1294
|
config=config,
|
1293
1295
|
)
|
1294
1296
|
|
1295
|
-
if self.
|
1297
|
+
if self._api_client.vertexai:
|
1296
1298
|
request_dict = _ListTuningJobsParameters_to_vertex(
|
1297
|
-
self.
|
1299
|
+
self._api_client, parameter_model
|
1298
1300
|
)
|
1299
1301
|
path = 'tuningJobs'.format_map(request_dict.get('_url'))
|
1300
1302
|
else:
|
1301
1303
|
request_dict = _ListTuningJobsParameters_to_mldev(
|
1302
|
-
self.
|
1304
|
+
self._api_client, parameter_model
|
1303
1305
|
)
|
1304
1306
|
path = 'tunedModels'.format_map(request_dict.get('_url'))
|
1305
1307
|
query_params = request_dict.get('_query')
|
@@ -1311,23 +1313,23 @@ class AsyncTunings(_common.BaseModule):
|
|
1311
1313
|
request_dict = _common.convert_to_dict(request_dict)
|
1312
1314
|
request_dict = _common.apply_base64_encoding(request_dict)
|
1313
1315
|
|
1314
|
-
response_dict = await self.
|
1316
|
+
response_dict = await self._api_client.async_request(
|
1315
1317
|
'get', path, request_dict, http_options
|
1316
1318
|
)
|
1317
1319
|
|
1318
|
-
if self.
|
1320
|
+
if self._api_client.vertexai:
|
1319
1321
|
response_dict = _ListTuningJobsResponse_from_vertex(
|
1320
|
-
self.
|
1322
|
+
self._api_client, response_dict
|
1321
1323
|
)
|
1322
1324
|
else:
|
1323
1325
|
response_dict = _ListTuningJobsResponse_from_mldev(
|
1324
|
-
self.
|
1326
|
+
self._api_client, response_dict
|
1325
1327
|
)
|
1326
1328
|
|
1327
1329
|
return_value = types.ListTuningJobsResponse._from_response(
|
1328
1330
|
response_dict, parameter_model
|
1329
1331
|
)
|
1330
|
-
self.
|
1332
|
+
self._api_client._verify_response(return_value)
|
1331
1333
|
return return_value
|
1332
1334
|
|
1333
1335
|
async def _tune(
|
@@ -1354,14 +1356,14 @@ class AsyncTunings(_common.BaseModule):
|
|
1354
1356
|
config=config,
|
1355
1357
|
)
|
1356
1358
|
|
1357
|
-
if self.
|
1359
|
+
if self._api_client.vertexai:
|
1358
1360
|
request_dict = _CreateTuningJobParameters_to_vertex(
|
1359
|
-
self.
|
1361
|
+
self._api_client, parameter_model
|
1360
1362
|
)
|
1361
1363
|
path = 'tuningJobs'.format_map(request_dict.get('_url'))
|
1362
1364
|
else:
|
1363
1365
|
request_dict = _CreateTuningJobParameters_to_mldev(
|
1364
|
-
self.
|
1366
|
+
self._api_client, parameter_model
|
1365
1367
|
)
|
1366
1368
|
path = 'tunedModels'.format_map(request_dict.get('_url'))
|
1367
1369
|
query_params = request_dict.get('_query')
|
@@ -1373,23 +1375,23 @@ class AsyncTunings(_common.BaseModule):
|
|
1373
1375
|
request_dict = _common.convert_to_dict(request_dict)
|
1374
1376
|
request_dict = _common.apply_base64_encoding(request_dict)
|
1375
1377
|
|
1376
|
-
response_dict = await self.
|
1378
|
+
response_dict = await self._api_client.async_request(
|
1377
1379
|
'post', path, request_dict, http_options
|
1378
1380
|
)
|
1379
1381
|
|
1380
|
-
if self.
|
1382
|
+
if self._api_client.vertexai:
|
1381
1383
|
response_dict = _TuningJobOrOperation_from_vertex(
|
1382
|
-
self.
|
1384
|
+
self._api_client, response_dict
|
1383
1385
|
)
|
1384
1386
|
else:
|
1385
1387
|
response_dict = _TuningJobOrOperation_from_mldev(
|
1386
|
-
self.
|
1388
|
+
self._api_client, response_dict
|
1387
1389
|
)
|
1388
1390
|
|
1389
1391
|
return_value = types.TuningJobOrOperation._from_response(
|
1390
1392
|
response_dict, parameter_model
|
1391
1393
|
).tuning_job
|
1392
|
-
self.
|
1394
|
+
self._api_client._verify_response(return_value)
|
1393
1395
|
return return_value
|
1394
1396
|
|
1395
1397
|
async def distill(
|
@@ -1419,11 +1421,11 @@ class AsyncTunings(_common.BaseModule):
|
|
1419
1421
|
config=config,
|
1420
1422
|
)
|
1421
1423
|
|
1422
|
-
if not self.
|
1424
|
+
if not self._api_client.vertexai:
|
1423
1425
|
raise ValueError('This method is only supported in the Vertex AI client.')
|
1424
1426
|
else:
|
1425
1427
|
request_dict = _CreateDistillationJobParameters_to_vertex(
|
1426
|
-
self.
|
1428
|
+
self._api_client, parameter_model
|
1427
1429
|
)
|
1428
1430
|
path = 'tuningJobs'.format_map(request_dict.get('_url'))
|
1429
1431
|
|
@@ -1436,19 +1438,19 @@ class AsyncTunings(_common.BaseModule):
|
|
1436
1438
|
request_dict = _common.convert_to_dict(request_dict)
|
1437
1439
|
request_dict = _common.apply_base64_encoding(request_dict)
|
1438
1440
|
|
1439
|
-
response_dict = await self.
|
1441
|
+
response_dict = await self._api_client.async_request(
|
1440
1442
|
'post', path, request_dict, http_options
|
1441
1443
|
)
|
1442
1444
|
|
1443
|
-
if self.
|
1444
|
-
response_dict = _TuningJob_from_vertex(self.
|
1445
|
+
if self._api_client.vertexai:
|
1446
|
+
response_dict = _TuningJob_from_vertex(self._api_client, response_dict)
|
1445
1447
|
else:
|
1446
|
-
response_dict = _TuningJob_from_mldev(self.
|
1448
|
+
response_dict = _TuningJob_from_mldev(self._api_client, response_dict)
|
1447
1449
|
|
1448
1450
|
return_value = types.TuningJob._from_response(
|
1449
1451
|
response_dict, parameter_model
|
1450
1452
|
)
|
1451
|
-
self.
|
1453
|
+
self._api_client._verify_response(return_value)
|
1452
1454
|
return return_value
|
1453
1455
|
|
1454
1456
|
async def list(
|
@@ -1468,10 +1470,10 @@ class AsyncTunings(_common.BaseModule):
|
|
1468
1470
|
config: Optional[types.GetTuningJobConfigOrDict] = None,
|
1469
1471
|
) -> types.TuningJob:
|
1470
1472
|
job = await self._get(name=name, config=config)
|
1471
|
-
if job.experiment and self.
|
1473
|
+
if job.experiment and self._api_client.vertexai:
|
1472
1474
|
_IpythonUtils.display_experiment_button(
|
1473
1475
|
experiment=job.experiment,
|
1474
|
-
project=self.
|
1476
|
+
project=self._api_client.project,
|
1475
1477
|
)
|
1476
1478
|
return job
|
1477
1479
|
|
@@ -1487,7 +1489,7 @@ class AsyncTunings(_common.BaseModule):
|
|
1487
1489
|
training_dataset=training_dataset,
|
1488
1490
|
config=config,
|
1489
1491
|
)
|
1490
|
-
if result.name and self.
|
1492
|
+
if result.name and self._api_client.vertexai:
|
1491
1493
|
_IpythonUtils.display_model_tuning_button(tuning_job_resource=result.name)
|
1492
1494
|
return result
|
1493
1495
|
|