google-genai 1.33.0__py3-none-any.whl → 1.53.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 +361 -208
- google/genai/_common.py +260 -69
- google/genai/_extra_utils.py +142 -12
- google/genai/_live_converters.py +691 -2746
- google/genai/_local_tokenizer_loader.py +0 -9
- google/genai/_operations_converters.py +186 -99
- google/genai/_replay_api_client.py +48 -51
- google/genai/_tokens_converters.py +169 -489
- google/genai/_transformers.py +193 -90
- google/genai/batches.py +1014 -1307
- google/genai/caches.py +458 -1107
- google/genai/client.py +101 -0
- google/genai/documents.py +532 -0
- google/genai/errors.py +58 -4
- google/genai/file_search_stores.py +1296 -0
- google/genai/files.py +108 -358
- google/genai/live.py +90 -32
- google/genai/live_music.py +24 -27
- google/genai/local_tokenizer.py +36 -3
- google/genai/models.py +2308 -3375
- google/genai/operations.py +129 -21
- google/genai/pagers.py +7 -1
- google/genai/tokens.py +2 -12
- google/genai/tunings.py +770 -436
- google/genai/types.py +4341 -1218
- google/genai/version.py +1 -1
- {google_genai-1.33.0.dist-info → google_genai-1.53.0.dist-info}/METADATA +359 -201
- google_genai-1.53.0.dist-info/RECORD +41 -0
- google_genai-1.33.0.dist-info/RECORD +0 -39
- {google_genai-1.33.0.dist-info → google_genai-1.53.0.dist-info}/WHEEL +0 -0
- {google_genai-1.33.0.dist-info → google_genai-1.53.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.33.0.dist-info → google_genai-1.53.0.dist-info}/top_level.txt +0 -0
google/genai/tunings.py
CHANGED
|
@@ -32,110 +32,107 @@ from .pagers import AsyncPager, Pager
|
|
|
32
32
|
logger = logging.getLogger('google_genai.tunings')
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
def
|
|
35
|
+
def _AutoraterConfig_from_vertex(
|
|
36
36
|
from_object: Union[dict[str, Any], object],
|
|
37
37
|
parent_object: Optional[dict[str, Any]] = None,
|
|
38
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
38
39
|
) -> dict[str, Any]:
|
|
39
40
|
to_object: dict[str, Any] = {}
|
|
40
|
-
if getv(from_object, ['
|
|
41
|
-
setv(to_object, ['
|
|
41
|
+
if getv(from_object, ['samplingCount']) is not None:
|
|
42
|
+
setv(to_object, ['sampling_count'], getv(from_object, ['samplingCount']))
|
|
42
43
|
|
|
43
|
-
if getv(from_object, ['
|
|
44
|
-
setv(to_object, ['
|
|
44
|
+
if getv(from_object, ['flipEnabled']) is not None:
|
|
45
|
+
setv(to_object, ['flip_enabled'], getv(from_object, ['flipEnabled']))
|
|
46
|
+
|
|
47
|
+
if getv(from_object, ['autoraterModel']) is not None:
|
|
48
|
+
setv(to_object, ['autorater_model'], getv(from_object, ['autoraterModel']))
|
|
49
|
+
|
|
50
|
+
if getv(from_object, ['generationConfig']) is not None:
|
|
51
|
+
setv(
|
|
52
|
+
to_object,
|
|
53
|
+
['generation_config'],
|
|
54
|
+
_GenerationConfig_from_vertex(
|
|
55
|
+
getv(from_object, ['generationConfig']), to_object, root_object
|
|
56
|
+
),
|
|
57
|
+
)
|
|
45
58
|
|
|
46
59
|
return to_object
|
|
47
60
|
|
|
48
61
|
|
|
49
|
-
def
|
|
62
|
+
def _AutoraterConfig_to_vertex(
|
|
50
63
|
from_object: Union[dict[str, Any], object],
|
|
51
64
|
parent_object: Optional[dict[str, Any]] = None,
|
|
65
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
52
66
|
) -> dict[str, Any]:
|
|
53
67
|
to_object: dict[str, Any] = {}
|
|
68
|
+
if getv(from_object, ['sampling_count']) is not None:
|
|
69
|
+
setv(to_object, ['samplingCount'], getv(from_object, ['sampling_count']))
|
|
54
70
|
|
|
55
|
-
if getv(from_object, ['
|
|
56
|
-
setv(
|
|
57
|
-
parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
|
|
58
|
-
)
|
|
71
|
+
if getv(from_object, ['flip_enabled']) is not None:
|
|
72
|
+
setv(to_object, ['flipEnabled'], getv(from_object, ['flip_enabled']))
|
|
59
73
|
|
|
60
|
-
if getv(from_object, ['
|
|
74
|
+
if getv(from_object, ['autorater_model']) is not None:
|
|
75
|
+
setv(to_object, ['autoraterModel'], getv(from_object, ['autorater_model']))
|
|
76
|
+
|
|
77
|
+
if getv(from_object, ['generation_config']) is not None:
|
|
61
78
|
setv(
|
|
62
|
-
|
|
63
|
-
['
|
|
64
|
-
|
|
79
|
+
to_object,
|
|
80
|
+
['generationConfig'],
|
|
81
|
+
_GenerationConfig_to_vertex(
|
|
82
|
+
getv(from_object, ['generation_config']), to_object, root_object
|
|
83
|
+
),
|
|
65
84
|
)
|
|
66
85
|
|
|
67
|
-
if getv(from_object, ['filter']) is not None:
|
|
68
|
-
setv(parent_object, ['_query', 'filter'], getv(from_object, ['filter']))
|
|
69
|
-
|
|
70
86
|
return to_object
|
|
71
87
|
|
|
72
88
|
|
|
73
|
-
def
|
|
89
|
+
def _CancelTuningJobParameters_to_mldev(
|
|
74
90
|
from_object: Union[dict[str, Any], object],
|
|
75
91
|
parent_object: Optional[dict[str, Any]] = None,
|
|
92
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
76
93
|
) -> dict[str, Any]:
|
|
77
94
|
to_object: dict[str, Any] = {}
|
|
78
|
-
if getv(from_object, ['
|
|
79
|
-
setv(
|
|
80
|
-
to_object,
|
|
81
|
-
['config'],
|
|
82
|
-
_ListTuningJobsConfig_to_mldev(
|
|
83
|
-
getv(from_object, ['config']), to_object
|
|
84
|
-
),
|
|
85
|
-
)
|
|
95
|
+
if getv(from_object, ['name']) is not None:
|
|
96
|
+
setv(to_object, ['_url', 'name'], getv(from_object, ['name']))
|
|
86
97
|
|
|
87
98
|
return to_object
|
|
88
99
|
|
|
89
100
|
|
|
90
|
-
def
|
|
101
|
+
def _CancelTuningJobParameters_to_vertex(
|
|
91
102
|
from_object: Union[dict[str, Any], object],
|
|
92
103
|
parent_object: Optional[dict[str, Any]] = None,
|
|
104
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
93
105
|
) -> dict[str, Any]:
|
|
94
106
|
to_object: dict[str, Any] = {}
|
|
95
107
|
if getv(from_object, ['name']) is not None:
|
|
96
108
|
setv(to_object, ['_url', 'name'], getv(from_object, ['name']))
|
|
97
109
|
|
|
98
|
-
if getv(from_object, ['config']) is not None:
|
|
99
|
-
setv(to_object, ['config'], getv(from_object, ['config']))
|
|
100
|
-
|
|
101
110
|
return to_object
|
|
102
111
|
|
|
103
112
|
|
|
104
|
-
def
|
|
113
|
+
def _CancelTuningJobResponse_from_mldev(
|
|
105
114
|
from_object: Union[dict[str, Any], object],
|
|
106
115
|
parent_object: Optional[dict[str, Any]] = None,
|
|
116
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
107
117
|
) -> dict[str, Any]:
|
|
108
118
|
to_object: dict[str, Any] = {}
|
|
109
|
-
if getv(from_object, ['
|
|
110
|
-
setv(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
setv(to_object, ['output'], getv(from_object, ['output']))
|
|
119
|
+
if getv(from_object, ['sdkHttpResponse']) is not None:
|
|
120
|
+
setv(
|
|
121
|
+
to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
|
|
122
|
+
)
|
|
114
123
|
|
|
115
124
|
return to_object
|
|
116
125
|
|
|
117
126
|
|
|
118
|
-
def
|
|
127
|
+
def _CancelTuningJobResponse_from_vertex(
|
|
119
128
|
from_object: Union[dict[str, Any], object],
|
|
120
129
|
parent_object: Optional[dict[str, Any]] = None,
|
|
130
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
121
131
|
) -> dict[str, Any]:
|
|
122
132
|
to_object: dict[str, Any] = {}
|
|
123
|
-
if getv(from_object, ['
|
|
124
|
-
raise ValueError('gcs_uri parameter is not supported in Gemini API.')
|
|
125
|
-
|
|
126
|
-
if getv(from_object, ['vertex_dataset_resource']) is not None:
|
|
127
|
-
raise ValueError(
|
|
128
|
-
'vertex_dataset_resource parameter is not supported in Gemini API.'
|
|
129
|
-
)
|
|
130
|
-
|
|
131
|
-
if getv(from_object, ['examples']) is not None:
|
|
133
|
+
if getv(from_object, ['sdkHttpResponse']) is not None:
|
|
132
134
|
setv(
|
|
133
|
-
to_object,
|
|
134
|
-
['examples', 'examples'],
|
|
135
|
-
[
|
|
136
|
-
_TuningExample_to_mldev(item, to_object)
|
|
137
|
-
for item in getv(from_object, ['examples'])
|
|
138
|
-
],
|
|
135
|
+
to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
|
|
139
136
|
)
|
|
140
137
|
|
|
141
138
|
return to_object
|
|
@@ -144,6 +141,7 @@ def _TuningDataset_to_mldev(
|
|
|
144
141
|
def _CreateTuningJobConfig_to_mldev(
|
|
145
142
|
from_object: Union[dict[str, Any], object],
|
|
146
143
|
parent_object: Optional[dict[str, Any]] = None,
|
|
144
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
147
145
|
) -> dict[str, Any]:
|
|
148
146
|
to_object: dict[str, Any] = {}
|
|
149
147
|
|
|
@@ -209,431 +207,601 @@ def _CreateTuningJobConfig_to_mldev(
|
|
|
209
207
|
'evaluation_config parameter is not supported in Gemini API.'
|
|
210
208
|
)
|
|
211
209
|
|
|
210
|
+
if getv(from_object, ['labels']) is not None:
|
|
211
|
+
raise ValueError('labels parameter is not supported in Gemini API.')
|
|
212
|
+
|
|
213
|
+
if getv(from_object, ['beta']) is not None:
|
|
214
|
+
raise ValueError('beta parameter is not supported in Gemini API.')
|
|
215
|
+
|
|
212
216
|
return to_object
|
|
213
217
|
|
|
214
218
|
|
|
215
|
-
def
|
|
219
|
+
def _CreateTuningJobConfig_to_vertex(
|
|
216
220
|
from_object: Union[dict[str, Any], object],
|
|
217
221
|
parent_object: Optional[dict[str, Any]] = None,
|
|
222
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
218
223
|
) -> dict[str, Any]:
|
|
219
224
|
to_object: dict[str, Any] = {}
|
|
220
|
-
if getv(from_object, ['base_model']) is not None:
|
|
221
|
-
setv(to_object, ['baseModel'], getv(from_object, ['base_model']))
|
|
222
225
|
|
|
223
|
-
|
|
224
|
-
|
|
226
|
+
discriminator = getv(root_object, ['config', 'method'])
|
|
227
|
+
if discriminator is None:
|
|
228
|
+
discriminator = 'SUPERVISED_FINE_TUNING'
|
|
229
|
+
if discriminator == 'SUPERVISED_FINE_TUNING':
|
|
230
|
+
if getv(from_object, ['validation_dataset']) is not None:
|
|
231
|
+
setv(
|
|
232
|
+
parent_object,
|
|
233
|
+
['supervisedTuningSpec'],
|
|
234
|
+
_TuningValidationDataset_to_vertex(
|
|
235
|
+
getv(from_object, ['validation_dataset']), to_object, root_object
|
|
236
|
+
),
|
|
237
|
+
)
|
|
225
238
|
|
|
226
|
-
|
|
239
|
+
elif discriminator == 'PREFERENCE_TUNING':
|
|
240
|
+
if getv(from_object, ['validation_dataset']) is not None:
|
|
241
|
+
setv(
|
|
242
|
+
parent_object,
|
|
243
|
+
['preferenceOptimizationSpec'],
|
|
244
|
+
_TuningValidationDataset_to_vertex(
|
|
245
|
+
getv(from_object, ['validation_dataset']), to_object, root_object
|
|
246
|
+
),
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
if getv(from_object, ['tuned_model_display_name']) is not None:
|
|
227
250
|
setv(
|
|
228
|
-
|
|
229
|
-
['
|
|
230
|
-
|
|
231
|
-
getv(from_object, ['training_dataset']), to_object
|
|
232
|
-
),
|
|
251
|
+
parent_object,
|
|
252
|
+
['tunedModelDisplayName'],
|
|
253
|
+
getv(from_object, ['tuned_model_display_name']),
|
|
233
254
|
)
|
|
234
255
|
|
|
235
|
-
if getv(from_object, ['
|
|
256
|
+
if getv(from_object, ['description']) is not None:
|
|
257
|
+
setv(parent_object, ['description'], getv(from_object, ['description']))
|
|
258
|
+
|
|
259
|
+
discriminator = getv(root_object, ['config', 'method'])
|
|
260
|
+
if discriminator is None:
|
|
261
|
+
discriminator = 'SUPERVISED_FINE_TUNING'
|
|
262
|
+
if discriminator == 'SUPERVISED_FINE_TUNING':
|
|
263
|
+
if getv(from_object, ['epoch_count']) is not None:
|
|
264
|
+
setv(
|
|
265
|
+
parent_object,
|
|
266
|
+
['supervisedTuningSpec', 'hyperParameters', 'epochCount'],
|
|
267
|
+
getv(from_object, ['epoch_count']),
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
elif discriminator == 'PREFERENCE_TUNING':
|
|
271
|
+
if getv(from_object, ['epoch_count']) is not None:
|
|
272
|
+
setv(
|
|
273
|
+
parent_object,
|
|
274
|
+
['preferenceOptimizationSpec', 'hyperParameters', 'epochCount'],
|
|
275
|
+
getv(from_object, ['epoch_count']),
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
discriminator = getv(root_object, ['config', 'method'])
|
|
279
|
+
if discriminator is None:
|
|
280
|
+
discriminator = 'SUPERVISED_FINE_TUNING'
|
|
281
|
+
if discriminator == 'SUPERVISED_FINE_TUNING':
|
|
282
|
+
if getv(from_object, ['learning_rate_multiplier']) is not None:
|
|
283
|
+
setv(
|
|
284
|
+
parent_object,
|
|
285
|
+
['supervisedTuningSpec', 'hyperParameters', 'learningRateMultiplier'],
|
|
286
|
+
getv(from_object, ['learning_rate_multiplier']),
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
elif discriminator == 'PREFERENCE_TUNING':
|
|
290
|
+
if getv(from_object, ['learning_rate_multiplier']) is not None:
|
|
291
|
+
setv(
|
|
292
|
+
parent_object,
|
|
293
|
+
[
|
|
294
|
+
'preferenceOptimizationSpec',
|
|
295
|
+
'hyperParameters',
|
|
296
|
+
'learningRateMultiplier',
|
|
297
|
+
],
|
|
298
|
+
getv(from_object, ['learning_rate_multiplier']),
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
discriminator = getv(root_object, ['config', 'method'])
|
|
302
|
+
if discriminator is None:
|
|
303
|
+
discriminator = 'SUPERVISED_FINE_TUNING'
|
|
304
|
+
if discriminator == 'SUPERVISED_FINE_TUNING':
|
|
305
|
+
if getv(from_object, ['export_last_checkpoint_only']) is not None:
|
|
306
|
+
setv(
|
|
307
|
+
parent_object,
|
|
308
|
+
['supervisedTuningSpec', 'exportLastCheckpointOnly'],
|
|
309
|
+
getv(from_object, ['export_last_checkpoint_only']),
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
elif discriminator == 'PREFERENCE_TUNING':
|
|
313
|
+
if getv(from_object, ['export_last_checkpoint_only']) is not None:
|
|
314
|
+
setv(
|
|
315
|
+
parent_object,
|
|
316
|
+
['preferenceOptimizationSpec', 'exportLastCheckpointOnly'],
|
|
317
|
+
getv(from_object, ['export_last_checkpoint_only']),
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
discriminator = getv(root_object, ['config', 'method'])
|
|
321
|
+
if discriminator is None:
|
|
322
|
+
discriminator = 'SUPERVISED_FINE_TUNING'
|
|
323
|
+
if discriminator == 'SUPERVISED_FINE_TUNING':
|
|
324
|
+
if getv(from_object, ['adapter_size']) is not None:
|
|
325
|
+
setv(
|
|
326
|
+
parent_object,
|
|
327
|
+
['supervisedTuningSpec', 'hyperParameters', 'adapterSize'],
|
|
328
|
+
getv(from_object, ['adapter_size']),
|
|
329
|
+
)
|
|
330
|
+
|
|
331
|
+
elif discriminator == 'PREFERENCE_TUNING':
|
|
332
|
+
if getv(from_object, ['adapter_size']) is not None:
|
|
333
|
+
setv(
|
|
334
|
+
parent_object,
|
|
335
|
+
['preferenceOptimizationSpec', 'hyperParameters', 'adapterSize'],
|
|
336
|
+
getv(from_object, ['adapter_size']),
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
if getv(from_object, ['batch_size']) is not None:
|
|
340
|
+
raise ValueError('batch_size parameter is not supported in Vertex AI.')
|
|
341
|
+
|
|
342
|
+
if getv(from_object, ['learning_rate']) is not None:
|
|
343
|
+
raise ValueError('learning_rate parameter is not supported in Vertex AI.')
|
|
344
|
+
|
|
345
|
+
discriminator = getv(root_object, ['config', 'method'])
|
|
346
|
+
if discriminator is None:
|
|
347
|
+
discriminator = 'SUPERVISED_FINE_TUNING'
|
|
348
|
+
if discriminator == 'SUPERVISED_FINE_TUNING':
|
|
349
|
+
if getv(from_object, ['evaluation_config']) is not None:
|
|
350
|
+
setv(
|
|
351
|
+
parent_object,
|
|
352
|
+
['supervisedTuningSpec', 'evaluationConfig'],
|
|
353
|
+
_EvaluationConfig_to_vertex(
|
|
354
|
+
getv(from_object, ['evaluation_config']), to_object, root_object
|
|
355
|
+
),
|
|
356
|
+
)
|
|
357
|
+
|
|
358
|
+
elif discriminator == 'PREFERENCE_TUNING':
|
|
359
|
+
if getv(from_object, ['evaluation_config']) is not None:
|
|
360
|
+
setv(
|
|
361
|
+
parent_object,
|
|
362
|
+
['preferenceOptimizationSpec', 'evaluationConfig'],
|
|
363
|
+
_EvaluationConfig_to_vertex(
|
|
364
|
+
getv(from_object, ['evaluation_config']), to_object, root_object
|
|
365
|
+
),
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
if getv(from_object, ['labels']) is not None:
|
|
369
|
+
setv(parent_object, ['labels'], getv(from_object, ['labels']))
|
|
370
|
+
|
|
371
|
+
if getv(from_object, ['beta']) is not None:
|
|
236
372
|
setv(
|
|
237
|
-
|
|
238
|
-
['
|
|
239
|
-
|
|
240
|
-
getv(from_object, ['config']), to_object
|
|
241
|
-
),
|
|
373
|
+
parent_object,
|
|
374
|
+
['preferenceOptimizationSpec', 'hyperParameters', 'beta'],
|
|
375
|
+
getv(from_object, ['beta']),
|
|
242
376
|
)
|
|
243
377
|
|
|
244
378
|
return to_object
|
|
245
379
|
|
|
246
380
|
|
|
247
|
-
def
|
|
381
|
+
def _CreateTuningJobParametersPrivate_to_mldev(
|
|
248
382
|
from_object: Union[dict[str, Any], object],
|
|
249
383
|
parent_object: Optional[dict[str, Any]] = None,
|
|
384
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
250
385
|
) -> dict[str, Any]:
|
|
251
386
|
to_object: dict[str, Any] = {}
|
|
252
|
-
if getv(from_object, ['
|
|
253
|
-
setv(to_object, ['
|
|
387
|
+
if getv(from_object, ['base_model']) is not None:
|
|
388
|
+
setv(to_object, ['baseModel'], getv(from_object, ['base_model']))
|
|
389
|
+
|
|
390
|
+
if getv(from_object, ['pre_tuned_model']) is not None:
|
|
391
|
+
setv(to_object, ['preTunedModel'], getv(from_object, ['pre_tuned_model']))
|
|
392
|
+
|
|
393
|
+
if getv(from_object, ['training_dataset']) is not None:
|
|
394
|
+
_TuningDataset_to_mldev(
|
|
395
|
+
getv(from_object, ['training_dataset']), to_object, root_object
|
|
396
|
+
)
|
|
254
397
|
|
|
255
398
|
if getv(from_object, ['config']) is not None:
|
|
256
|
-
|
|
399
|
+
_CreateTuningJobConfig_to_mldev(
|
|
400
|
+
getv(from_object, ['config']), to_object, root_object
|
|
401
|
+
)
|
|
257
402
|
|
|
258
403
|
return to_object
|
|
259
404
|
|
|
260
405
|
|
|
261
|
-
def
|
|
406
|
+
def _CreateTuningJobParametersPrivate_to_vertex(
|
|
262
407
|
from_object: Union[dict[str, Any], object],
|
|
263
408
|
parent_object: Optional[dict[str, Any]] = None,
|
|
409
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
264
410
|
) -> dict[str, Any]:
|
|
265
411
|
to_object: dict[str, Any] = {}
|
|
412
|
+
if getv(from_object, ['base_model']) is not None:
|
|
413
|
+
setv(to_object, ['baseModel'], getv(from_object, ['base_model']))
|
|
266
414
|
|
|
267
|
-
if getv(from_object, ['
|
|
268
|
-
setv(
|
|
269
|
-
parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
|
|
270
|
-
)
|
|
415
|
+
if getv(from_object, ['pre_tuned_model']) is not None:
|
|
416
|
+
setv(to_object, ['preTunedModel'], getv(from_object, ['pre_tuned_model']))
|
|
271
417
|
|
|
272
|
-
if getv(from_object, ['
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
['_query', 'pageToken'],
|
|
276
|
-
getv(from_object, ['page_token']),
|
|
418
|
+
if getv(from_object, ['training_dataset']) is not None:
|
|
419
|
+
_TuningDataset_to_vertex(
|
|
420
|
+
getv(from_object, ['training_dataset']), to_object, root_object
|
|
277
421
|
)
|
|
278
422
|
|
|
279
|
-
if getv(from_object, ['
|
|
280
|
-
|
|
423
|
+
if getv(from_object, ['config']) is not None:
|
|
424
|
+
_CreateTuningJobConfig_to_vertex(
|
|
425
|
+
getv(from_object, ['config']), to_object, root_object
|
|
426
|
+
)
|
|
281
427
|
|
|
282
428
|
return to_object
|
|
283
429
|
|
|
284
430
|
|
|
285
|
-
def
|
|
431
|
+
def _EvaluationConfig_from_vertex(
|
|
286
432
|
from_object: Union[dict[str, Any], object],
|
|
287
433
|
parent_object: Optional[dict[str, Any]] = None,
|
|
434
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
288
435
|
) -> dict[str, Any]:
|
|
289
436
|
to_object: dict[str, Any] = {}
|
|
290
|
-
if getv(from_object, ['
|
|
437
|
+
if getv(from_object, ['metrics']) is not None:
|
|
438
|
+
setv(to_object, ['metrics'], t.t_metrics(getv(from_object, ['metrics'])))
|
|
439
|
+
|
|
440
|
+
if getv(from_object, ['outputConfig']) is not None:
|
|
441
|
+
setv(to_object, ['output_config'], getv(from_object, ['outputConfig']))
|
|
442
|
+
|
|
443
|
+
if getv(from_object, ['autoraterConfig']) is not None:
|
|
291
444
|
setv(
|
|
292
445
|
to_object,
|
|
293
|
-
['
|
|
294
|
-
|
|
295
|
-
getv(from_object, ['
|
|
446
|
+
['autorater_config'],
|
|
447
|
+
_AutoraterConfig_from_vertex(
|
|
448
|
+
getv(from_object, ['autoraterConfig']), to_object, root_object
|
|
296
449
|
),
|
|
297
450
|
)
|
|
298
451
|
|
|
299
452
|
return to_object
|
|
300
453
|
|
|
301
454
|
|
|
302
|
-
def
|
|
455
|
+
def _EvaluationConfig_to_vertex(
|
|
303
456
|
from_object: Union[dict[str, Any], object],
|
|
304
457
|
parent_object: Optional[dict[str, Any]] = None,
|
|
458
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
305
459
|
) -> dict[str, Any]:
|
|
306
460
|
to_object: dict[str, Any] = {}
|
|
307
|
-
if getv(from_object, ['
|
|
308
|
-
setv(to_object, ['
|
|
461
|
+
if getv(from_object, ['metrics']) is not None:
|
|
462
|
+
setv(to_object, ['metrics'], t.t_metrics(getv(from_object, ['metrics'])))
|
|
309
463
|
|
|
310
|
-
if getv(from_object, ['
|
|
311
|
-
setv(to_object, ['
|
|
464
|
+
if getv(from_object, ['output_config']) is not None:
|
|
465
|
+
setv(to_object, ['outputConfig'], getv(from_object, ['output_config']))
|
|
466
|
+
|
|
467
|
+
if getv(from_object, ['autorater_config']) is not None:
|
|
468
|
+
setv(
|
|
469
|
+
to_object,
|
|
470
|
+
['autoraterConfig'],
|
|
471
|
+
_AutoraterConfig_to_vertex(
|
|
472
|
+
getv(from_object, ['autorater_config']), to_object, root_object
|
|
473
|
+
),
|
|
474
|
+
)
|
|
312
475
|
|
|
313
476
|
return to_object
|
|
314
477
|
|
|
315
478
|
|
|
316
|
-
def
|
|
479
|
+
def _GenerationConfig_from_vertex(
|
|
317
480
|
from_object: Union[dict[str, Any], object],
|
|
318
481
|
parent_object: Optional[dict[str, Any]] = None,
|
|
482
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
319
483
|
) -> dict[str, Any]:
|
|
320
484
|
to_object: dict[str, Any] = {}
|
|
321
|
-
if getv(from_object, ['
|
|
485
|
+
if getv(from_object, ['modelConfig']) is not None:
|
|
322
486
|
setv(
|
|
323
|
-
|
|
324
|
-
['
|
|
325
|
-
getv(from_object, ['
|
|
487
|
+
to_object,
|
|
488
|
+
['model_selection_config'],
|
|
489
|
+
getv(from_object, ['modelConfig']),
|
|
326
490
|
)
|
|
327
491
|
|
|
328
|
-
if getv(from_object, ['
|
|
492
|
+
if getv(from_object, ['responseJsonSchema']) is not None:
|
|
329
493
|
setv(
|
|
330
|
-
|
|
331
|
-
['
|
|
332
|
-
getv(from_object, ['
|
|
494
|
+
to_object,
|
|
495
|
+
['response_json_schema'],
|
|
496
|
+
getv(from_object, ['responseJsonSchema']),
|
|
333
497
|
)
|
|
334
498
|
|
|
335
|
-
if getv(from_object, ['
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
return to_object
|
|
499
|
+
if getv(from_object, ['audioTimestamp']) is not None:
|
|
500
|
+
setv(to_object, ['audio_timestamp'], getv(from_object, ['audioTimestamp']))
|
|
339
501
|
|
|
502
|
+
if getv(from_object, ['candidateCount']) is not None:
|
|
503
|
+
setv(to_object, ['candidate_count'], getv(from_object, ['candidateCount']))
|
|
340
504
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
setv(to_object, ['validationDatasetUri'], getv(from_object, ['gcs_uri']))
|
|
505
|
+
if getv(from_object, ['enableAffectiveDialog']) is not None:
|
|
506
|
+
setv(
|
|
507
|
+
to_object,
|
|
508
|
+
['enable_affective_dialog'],
|
|
509
|
+
getv(from_object, ['enableAffectiveDialog']),
|
|
510
|
+
)
|
|
348
511
|
|
|
349
|
-
if getv(from_object, ['
|
|
512
|
+
if getv(from_object, ['frequencyPenalty']) is not None:
|
|
350
513
|
setv(
|
|
351
|
-
|
|
352
|
-
['
|
|
353
|
-
getv(from_object, ['
|
|
514
|
+
to_object,
|
|
515
|
+
['frequency_penalty'],
|
|
516
|
+
getv(from_object, ['frequencyPenalty']),
|
|
354
517
|
)
|
|
355
518
|
|
|
356
|
-
|
|
519
|
+
if getv(from_object, ['logprobs']) is not None:
|
|
520
|
+
setv(to_object, ['logprobs'], getv(from_object, ['logprobs']))
|
|
357
521
|
|
|
522
|
+
if getv(from_object, ['maxOutputTokens']) is not None:
|
|
523
|
+
setv(
|
|
524
|
+
to_object, ['max_output_tokens'], getv(from_object, ['maxOutputTokens'])
|
|
525
|
+
)
|
|
358
526
|
|
|
359
|
-
|
|
360
|
-
from_object: Union[dict[str, Any], object],
|
|
361
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
362
|
-
) -> dict[str, Any]:
|
|
363
|
-
to_object: dict[str, Any] = {}
|
|
364
|
-
if getv(from_object, ['output_uri_prefix']) is not None:
|
|
527
|
+
if getv(from_object, ['mediaResolution']) is not None:
|
|
365
528
|
setv(
|
|
366
|
-
to_object, ['
|
|
529
|
+
to_object, ['media_resolution'], getv(from_object, ['mediaResolution'])
|
|
367
530
|
)
|
|
368
531
|
|
|
369
|
-
|
|
532
|
+
if getv(from_object, ['presencePenalty']) is not None:
|
|
533
|
+
setv(
|
|
534
|
+
to_object, ['presence_penalty'], getv(from_object, ['presencePenalty'])
|
|
535
|
+
)
|
|
370
536
|
|
|
537
|
+
if getv(from_object, ['responseLogprobs']) is not None:
|
|
538
|
+
setv(
|
|
539
|
+
to_object,
|
|
540
|
+
['response_logprobs'],
|
|
541
|
+
getv(from_object, ['responseLogprobs']),
|
|
542
|
+
)
|
|
371
543
|
|
|
372
|
-
|
|
373
|
-
from_object: Union[dict[str, Any], object],
|
|
374
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
375
|
-
) -> dict[str, Any]:
|
|
376
|
-
to_object: dict[str, Any] = {}
|
|
377
|
-
if getv(from_object, ['gcs_destination']) is not None:
|
|
544
|
+
if getv(from_object, ['responseMimeType']) is not None:
|
|
378
545
|
setv(
|
|
379
546
|
to_object,
|
|
380
|
-
['
|
|
381
|
-
|
|
382
|
-
getv(from_object, ['gcs_destination']), to_object
|
|
383
|
-
),
|
|
547
|
+
['response_mime_type'],
|
|
548
|
+
getv(from_object, ['responseMimeType']),
|
|
384
549
|
)
|
|
385
550
|
|
|
386
|
-
|
|
551
|
+
if getv(from_object, ['responseModalities']) is not None:
|
|
552
|
+
setv(
|
|
553
|
+
to_object,
|
|
554
|
+
['response_modalities'],
|
|
555
|
+
getv(from_object, ['responseModalities']),
|
|
556
|
+
)
|
|
387
557
|
|
|
558
|
+
if getv(from_object, ['responseSchema']) is not None:
|
|
559
|
+
setv(to_object, ['response_schema'], getv(from_object, ['responseSchema']))
|
|
388
560
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
392
|
-
) -> dict[str, Any]:
|
|
393
|
-
to_object: dict[str, Any] = {}
|
|
394
|
-
if getv(from_object, ['sampling_count']) is not None:
|
|
395
|
-
setv(to_object, ['samplingCount'], getv(from_object, ['sampling_count']))
|
|
561
|
+
if getv(from_object, ['routingConfig']) is not None:
|
|
562
|
+
setv(to_object, ['routing_config'], getv(from_object, ['routingConfig']))
|
|
396
563
|
|
|
397
|
-
if getv(from_object, ['
|
|
398
|
-
setv(to_object, ['
|
|
564
|
+
if getv(from_object, ['seed']) is not None:
|
|
565
|
+
setv(to_object, ['seed'], getv(from_object, ['seed']))
|
|
399
566
|
|
|
400
|
-
if getv(from_object, ['
|
|
401
|
-
setv(to_object, ['
|
|
567
|
+
if getv(from_object, ['speechConfig']) is not None:
|
|
568
|
+
setv(to_object, ['speech_config'], getv(from_object, ['speechConfig']))
|
|
569
|
+
|
|
570
|
+
if getv(from_object, ['stopSequences']) is not None:
|
|
571
|
+
setv(to_object, ['stop_sequences'], getv(from_object, ['stopSequences']))
|
|
572
|
+
|
|
573
|
+
if getv(from_object, ['temperature']) is not None:
|
|
574
|
+
setv(to_object, ['temperature'], getv(from_object, ['temperature']))
|
|
575
|
+
|
|
576
|
+
if getv(from_object, ['thinkingConfig']) is not None:
|
|
577
|
+
setv(to_object, ['thinking_config'], getv(from_object, ['thinkingConfig']))
|
|
578
|
+
|
|
579
|
+
if getv(from_object, ['topK']) is not None:
|
|
580
|
+
setv(to_object, ['top_k'], getv(from_object, ['topK']))
|
|
581
|
+
|
|
582
|
+
if getv(from_object, ['topP']) is not None:
|
|
583
|
+
setv(to_object, ['top_p'], getv(from_object, ['topP']))
|
|
402
584
|
|
|
403
585
|
return to_object
|
|
404
586
|
|
|
405
587
|
|
|
406
|
-
def
|
|
588
|
+
def _GenerationConfig_to_vertex(
|
|
407
589
|
from_object: Union[dict[str, Any], object],
|
|
408
590
|
parent_object: Optional[dict[str, Any]] = None,
|
|
591
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
409
592
|
) -> dict[str, Any]:
|
|
410
593
|
to_object: dict[str, Any] = {}
|
|
411
|
-
if getv(from_object, ['
|
|
412
|
-
setv(to_object, ['metrics'], t.t_metrics(getv(from_object, ['metrics'])))
|
|
413
|
-
|
|
414
|
-
if getv(from_object, ['output_config']) is not None:
|
|
594
|
+
if getv(from_object, ['model_selection_config']) is not None:
|
|
415
595
|
setv(
|
|
416
596
|
to_object,
|
|
417
|
-
['
|
|
418
|
-
|
|
419
|
-
getv(from_object, ['output_config']), to_object
|
|
420
|
-
),
|
|
597
|
+
['modelConfig'],
|
|
598
|
+
getv(from_object, ['model_selection_config']),
|
|
421
599
|
)
|
|
422
600
|
|
|
423
|
-
if getv(from_object, ['
|
|
601
|
+
if getv(from_object, ['response_json_schema']) is not None:
|
|
424
602
|
setv(
|
|
425
603
|
to_object,
|
|
426
|
-
['
|
|
427
|
-
|
|
428
|
-
getv(from_object, ['autorater_config']), to_object
|
|
429
|
-
),
|
|
604
|
+
['responseJsonSchema'],
|
|
605
|
+
getv(from_object, ['response_json_schema']),
|
|
430
606
|
)
|
|
431
607
|
|
|
432
|
-
|
|
608
|
+
if getv(from_object, ['audio_timestamp']) is not None:
|
|
609
|
+
setv(to_object, ['audioTimestamp'], getv(from_object, ['audio_timestamp']))
|
|
433
610
|
|
|
611
|
+
if getv(from_object, ['candidate_count']) is not None:
|
|
612
|
+
setv(to_object, ['candidateCount'], getv(from_object, ['candidate_count']))
|
|
434
613
|
|
|
435
|
-
|
|
436
|
-
from_object: Union[dict[str, Any], object],
|
|
437
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
438
|
-
) -> dict[str, Any]:
|
|
439
|
-
to_object: dict[str, Any] = {}
|
|
440
|
-
|
|
441
|
-
if getv(from_object, ['validation_dataset']) is not None:
|
|
614
|
+
if getv(from_object, ['enable_affective_dialog']) is not None:
|
|
442
615
|
setv(
|
|
443
|
-
|
|
444
|
-
['
|
|
445
|
-
|
|
446
|
-
getv(from_object, ['validation_dataset']), to_object
|
|
447
|
-
),
|
|
616
|
+
to_object,
|
|
617
|
+
['enableAffectiveDialog'],
|
|
618
|
+
getv(from_object, ['enable_affective_dialog']),
|
|
448
619
|
)
|
|
449
620
|
|
|
450
|
-
if getv(from_object, ['
|
|
621
|
+
if getv(from_object, ['frequency_penalty']) is not None:
|
|
451
622
|
setv(
|
|
452
|
-
|
|
453
|
-
['
|
|
454
|
-
getv(from_object, ['
|
|
623
|
+
to_object,
|
|
624
|
+
['frequencyPenalty'],
|
|
625
|
+
getv(from_object, ['frequency_penalty']),
|
|
455
626
|
)
|
|
456
627
|
|
|
457
|
-
if getv(from_object, ['
|
|
458
|
-
setv(
|
|
628
|
+
if getv(from_object, ['logprobs']) is not None:
|
|
629
|
+
setv(to_object, ['logprobs'], getv(from_object, ['logprobs']))
|
|
459
630
|
|
|
460
|
-
if getv(from_object, ['
|
|
631
|
+
if getv(from_object, ['max_output_tokens']) is not None:
|
|
461
632
|
setv(
|
|
462
|
-
|
|
463
|
-
['supervisedTuningSpec', 'hyperParameters', 'epochCount'],
|
|
464
|
-
getv(from_object, ['epoch_count']),
|
|
633
|
+
to_object, ['maxOutputTokens'], getv(from_object, ['max_output_tokens'])
|
|
465
634
|
)
|
|
466
635
|
|
|
467
|
-
if getv(from_object, ['
|
|
636
|
+
if getv(from_object, ['media_resolution']) is not None:
|
|
468
637
|
setv(
|
|
469
|
-
|
|
470
|
-
['supervisedTuningSpec', 'hyperParameters', 'learningRateMultiplier'],
|
|
471
|
-
getv(from_object, ['learning_rate_multiplier']),
|
|
638
|
+
to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
|
|
472
639
|
)
|
|
473
640
|
|
|
474
|
-
if getv(from_object, ['
|
|
641
|
+
if getv(from_object, ['presence_penalty']) is not None:
|
|
475
642
|
setv(
|
|
476
|
-
|
|
477
|
-
['supervisedTuningSpec', 'exportLastCheckpointOnly'],
|
|
478
|
-
getv(from_object, ['export_last_checkpoint_only']),
|
|
643
|
+
to_object, ['presencePenalty'], getv(from_object, ['presence_penalty'])
|
|
479
644
|
)
|
|
480
645
|
|
|
481
|
-
if getv(from_object, ['
|
|
646
|
+
if getv(from_object, ['response_logprobs']) is not None:
|
|
482
647
|
setv(
|
|
483
648
|
to_object,
|
|
484
|
-
['
|
|
485
|
-
getv(from_object, ['
|
|
649
|
+
['responseLogprobs'],
|
|
650
|
+
getv(from_object, ['response_logprobs']),
|
|
486
651
|
)
|
|
487
652
|
|
|
488
|
-
if getv(from_object, ['
|
|
653
|
+
if getv(from_object, ['response_mime_type']) is not None:
|
|
489
654
|
setv(
|
|
490
|
-
|
|
491
|
-
['
|
|
492
|
-
getv(from_object, ['
|
|
655
|
+
to_object,
|
|
656
|
+
['responseMimeType'],
|
|
657
|
+
getv(from_object, ['response_mime_type']),
|
|
493
658
|
)
|
|
494
659
|
|
|
495
|
-
if getv(from_object, ['
|
|
496
|
-
raise ValueError('batch_size parameter is not supported in Vertex AI.')
|
|
497
|
-
|
|
498
|
-
if getv(from_object, ['learning_rate']) is not None:
|
|
499
|
-
raise ValueError('learning_rate parameter is not supported in Vertex AI.')
|
|
500
|
-
|
|
501
|
-
if getv(from_object, ['evaluation_config']) is not None:
|
|
660
|
+
if getv(from_object, ['response_modalities']) is not None:
|
|
502
661
|
setv(
|
|
503
|
-
|
|
504
|
-
['
|
|
505
|
-
|
|
506
|
-
getv(from_object, ['evaluation_config']), to_object
|
|
507
|
-
),
|
|
662
|
+
to_object,
|
|
663
|
+
['responseModalities'],
|
|
664
|
+
getv(from_object, ['response_modalities']),
|
|
508
665
|
)
|
|
509
666
|
|
|
510
|
-
|
|
511
|
-
|
|
667
|
+
if getv(from_object, ['response_schema']) is not None:
|
|
668
|
+
setv(to_object, ['responseSchema'], getv(from_object, ['response_schema']))
|
|
512
669
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
516
|
-
) -> dict[str, Any]:
|
|
517
|
-
to_object: dict[str, Any] = {}
|
|
518
|
-
if getv(from_object, ['base_model']) is not None:
|
|
519
|
-
setv(to_object, ['baseModel'], getv(from_object, ['base_model']))
|
|
670
|
+
if getv(from_object, ['routing_config']) is not None:
|
|
671
|
+
setv(to_object, ['routingConfig'], getv(from_object, ['routing_config']))
|
|
520
672
|
|
|
521
|
-
if getv(from_object, ['
|
|
522
|
-
setv(to_object, ['
|
|
673
|
+
if getv(from_object, ['seed']) is not None:
|
|
674
|
+
setv(to_object, ['seed'], getv(from_object, ['seed']))
|
|
523
675
|
|
|
524
|
-
if getv(from_object, ['
|
|
676
|
+
if getv(from_object, ['speech_config']) is not None:
|
|
525
677
|
setv(
|
|
526
678
|
to_object,
|
|
527
|
-
['
|
|
528
|
-
|
|
529
|
-
getv(from_object, ['
|
|
679
|
+
['speechConfig'],
|
|
680
|
+
_SpeechConfig_to_vertex(
|
|
681
|
+
getv(from_object, ['speech_config']), to_object, root_object
|
|
530
682
|
),
|
|
531
683
|
)
|
|
532
684
|
|
|
533
|
-
if getv(from_object, ['
|
|
534
|
-
setv(
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
685
|
+
if getv(from_object, ['stop_sequences']) is not None:
|
|
686
|
+
setv(to_object, ['stopSequences'], getv(from_object, ['stop_sequences']))
|
|
687
|
+
|
|
688
|
+
if getv(from_object, ['temperature']) is not None:
|
|
689
|
+
setv(to_object, ['temperature'], getv(from_object, ['temperature']))
|
|
690
|
+
|
|
691
|
+
if getv(from_object, ['thinking_config']) is not None:
|
|
692
|
+
setv(to_object, ['thinkingConfig'], getv(from_object, ['thinking_config']))
|
|
693
|
+
|
|
694
|
+
if getv(from_object, ['top_k']) is not None:
|
|
695
|
+
setv(to_object, ['topK'], getv(from_object, ['top_k']))
|
|
696
|
+
|
|
697
|
+
if getv(from_object, ['top_p']) is not None:
|
|
698
|
+
setv(to_object, ['topP'], getv(from_object, ['top_p']))
|
|
699
|
+
|
|
700
|
+
if getv(from_object, ['enable_enhanced_civic_answers']) is not None:
|
|
701
|
+
raise ValueError(
|
|
702
|
+
'enable_enhanced_civic_answers parameter is not supported in Vertex AI.'
|
|
540
703
|
)
|
|
541
704
|
|
|
542
705
|
return to_object
|
|
543
706
|
|
|
544
707
|
|
|
545
|
-
def
|
|
708
|
+
def _GetTuningJobParameters_to_mldev(
|
|
546
709
|
from_object: Union[dict[str, Any], object],
|
|
547
710
|
parent_object: Optional[dict[str, Any]] = None,
|
|
711
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
548
712
|
) -> dict[str, Any]:
|
|
549
713
|
to_object: dict[str, Any] = {}
|
|
550
714
|
if getv(from_object, ['name']) is not None:
|
|
551
|
-
setv(to_object, ['
|
|
552
|
-
|
|
553
|
-
if getv(from_object, ['name']) is not None:
|
|
554
|
-
setv(to_object, ['endpoint'], getv(from_object, ['name']))
|
|
715
|
+
setv(to_object, ['_url', 'name'], getv(from_object, ['name']))
|
|
555
716
|
|
|
556
717
|
return to_object
|
|
557
718
|
|
|
558
719
|
|
|
559
|
-
def
|
|
720
|
+
def _GetTuningJobParameters_to_vertex(
|
|
560
721
|
from_object: Union[dict[str, Any], object],
|
|
561
722
|
parent_object: Optional[dict[str, Any]] = None,
|
|
723
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
562
724
|
) -> dict[str, Any]:
|
|
563
725
|
to_object: dict[str, Any] = {}
|
|
564
|
-
if getv(from_object, ['sdkHttpResponse']) is not None:
|
|
565
|
-
setv(
|
|
566
|
-
to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
|
|
567
|
-
)
|
|
568
|
-
|
|
569
726
|
if getv(from_object, ['name']) is not None:
|
|
570
|
-
setv(to_object, ['name'], getv(from_object, ['name']))
|
|
727
|
+
setv(to_object, ['_url', 'name'], getv(from_object, ['name']))
|
|
571
728
|
|
|
572
|
-
|
|
573
|
-
setv(
|
|
574
|
-
to_object,
|
|
575
|
-
['state'],
|
|
576
|
-
t.t_tuning_job_status(getv(from_object, ['state'])),
|
|
577
|
-
)
|
|
729
|
+
return to_object
|
|
578
730
|
|
|
579
|
-
if getv(from_object, ['createTime']) is not None:
|
|
580
|
-
setv(to_object, ['create_time'], getv(from_object, ['createTime']))
|
|
581
731
|
|
|
582
|
-
|
|
732
|
+
def _ListTuningJobsConfig_to_mldev(
|
|
733
|
+
from_object: Union[dict[str, Any], object],
|
|
734
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
735
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
736
|
+
) -> dict[str, Any]:
|
|
737
|
+
to_object: dict[str, Any] = {}
|
|
738
|
+
|
|
739
|
+
if getv(from_object, ['page_size']) is not None:
|
|
583
740
|
setv(
|
|
584
|
-
|
|
585
|
-
['start_time'],
|
|
586
|
-
getv(from_object, ['tuningTask', 'startTime']),
|
|
741
|
+
parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
|
|
587
742
|
)
|
|
588
743
|
|
|
589
|
-
if getv(from_object, ['
|
|
744
|
+
if getv(from_object, ['page_token']) is not None:
|
|
590
745
|
setv(
|
|
591
|
-
|
|
592
|
-
['
|
|
593
|
-
getv(from_object, ['
|
|
746
|
+
parent_object,
|
|
747
|
+
['_query', 'pageToken'],
|
|
748
|
+
getv(from_object, ['page_token']),
|
|
594
749
|
)
|
|
595
750
|
|
|
596
|
-
if getv(from_object, ['
|
|
597
|
-
setv(
|
|
751
|
+
if getv(from_object, ['filter']) is not None:
|
|
752
|
+
setv(parent_object, ['_query', 'filter'], getv(from_object, ['filter']))
|
|
598
753
|
|
|
599
|
-
|
|
600
|
-
setv(to_object, ['description'], getv(from_object, ['description']))
|
|
754
|
+
return to_object
|
|
601
755
|
|
|
602
|
-
if getv(from_object, ['baseModel']) is not None:
|
|
603
|
-
setv(to_object, ['base_model'], getv(from_object, ['baseModel']))
|
|
604
756
|
|
|
605
|
-
|
|
757
|
+
def _ListTuningJobsConfig_to_vertex(
|
|
758
|
+
from_object: Union[dict[str, Any], object],
|
|
759
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
760
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
761
|
+
) -> dict[str, Any]:
|
|
762
|
+
to_object: dict[str, Any] = {}
|
|
763
|
+
|
|
764
|
+
if getv(from_object, ['page_size']) is not None:
|
|
606
765
|
setv(
|
|
607
|
-
|
|
608
|
-
['tuned_model'],
|
|
609
|
-
_TunedModel_from_mldev(getv(from_object, ['_self']), to_object),
|
|
766
|
+
parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
|
|
610
767
|
)
|
|
611
768
|
|
|
612
|
-
if getv(from_object, ['
|
|
769
|
+
if getv(from_object, ['page_token']) is not None:
|
|
613
770
|
setv(
|
|
614
|
-
|
|
771
|
+
parent_object,
|
|
772
|
+
['_query', 'pageToken'],
|
|
773
|
+
getv(from_object, ['page_token']),
|
|
615
774
|
)
|
|
616
775
|
|
|
617
|
-
if getv(from_object, ['
|
|
618
|
-
setv(
|
|
619
|
-
|
|
620
|
-
if getv(from_object, ['labels']) is not None:
|
|
621
|
-
setv(to_object, ['labels'], getv(from_object, ['labels']))
|
|
776
|
+
if getv(from_object, ['filter']) is not None:
|
|
777
|
+
setv(parent_object, ['_query', 'filter'], getv(from_object, ['filter']))
|
|
622
778
|
|
|
623
|
-
|
|
624
|
-
setv(to_object, ['output_uri'], getv(from_object, ['outputUri']))
|
|
779
|
+
return to_object
|
|
625
780
|
|
|
626
|
-
if getv(from_object, ['pipelineJob']) is not None:
|
|
627
|
-
setv(to_object, ['pipeline_job'], getv(from_object, ['pipelineJob']))
|
|
628
781
|
|
|
629
|
-
|
|
630
|
-
|
|
782
|
+
def _ListTuningJobsParameters_to_mldev(
|
|
783
|
+
from_object: Union[dict[str, Any], object],
|
|
784
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
785
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
786
|
+
) -> dict[str, Any]:
|
|
787
|
+
to_object: dict[str, Any] = {}
|
|
788
|
+
if getv(from_object, ['config']) is not None:
|
|
789
|
+
_ListTuningJobsConfig_to_mldev(
|
|
790
|
+
getv(from_object, ['config']), to_object, root_object
|
|
791
|
+
)
|
|
631
792
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
793
|
+
return to_object
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
def _ListTuningJobsParameters_to_vertex(
|
|
797
|
+
from_object: Union[dict[str, Any], object],
|
|
798
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
799
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
800
|
+
) -> dict[str, Any]:
|
|
801
|
+
to_object: dict[str, Any] = {}
|
|
802
|
+
if getv(from_object, ['config']) is not None:
|
|
803
|
+
_ListTuningJobsConfig_to_vertex(
|
|
804
|
+
getv(from_object, ['config']), to_object, root_object
|
|
637
805
|
)
|
|
638
806
|
|
|
639
807
|
return to_object
|
|
@@ -642,6 +810,7 @@ def _TuningJob_from_mldev(
|
|
|
642
810
|
def _ListTuningJobsResponse_from_mldev(
|
|
643
811
|
from_object: Union[dict[str, Any], object],
|
|
644
812
|
parent_object: Optional[dict[str, Any]] = None,
|
|
813
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
645
814
|
) -> dict[str, Any]:
|
|
646
815
|
to_object: dict[str, Any] = {}
|
|
647
816
|
if getv(from_object, ['sdkHttpResponse']) is not None:
|
|
@@ -657,7 +826,7 @@ def _ListTuningJobsResponse_from_mldev(
|
|
|
657
826
|
to_object,
|
|
658
827
|
['tuning_jobs'],
|
|
659
828
|
[
|
|
660
|
-
_TuningJob_from_mldev(item, to_object)
|
|
829
|
+
_TuningJob_from_mldev(item, to_object, root_object)
|
|
661
830
|
for item in getv(from_object, ['tunedModels'])
|
|
662
831
|
],
|
|
663
832
|
)
|
|
@@ -665,9 +834,10 @@ def _ListTuningJobsResponse_from_mldev(
|
|
|
665
834
|
return to_object
|
|
666
835
|
|
|
667
836
|
|
|
668
|
-
def
|
|
837
|
+
def _ListTuningJobsResponse_from_vertex(
|
|
669
838
|
from_object: Union[dict[str, Any], object],
|
|
670
839
|
parent_object: Optional[dict[str, Any]] = None,
|
|
840
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
671
841
|
) -> dict[str, Any]:
|
|
672
842
|
to_object: dict[str, Any] = {}
|
|
673
843
|
if getv(from_object, ['sdkHttpResponse']) is not None:
|
|
@@ -675,135 +845,185 @@ def _TuningOperation_from_mldev(
|
|
|
675
845
|
to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
|
|
676
846
|
)
|
|
677
847
|
|
|
678
|
-
if getv(from_object, ['
|
|
679
|
-
setv(to_object, ['
|
|
680
|
-
|
|
681
|
-
if getv(from_object, ['metadata']) is not None:
|
|
682
|
-
setv(to_object, ['metadata'], getv(from_object, ['metadata']))
|
|
683
|
-
|
|
684
|
-
if getv(from_object, ['done']) is not None:
|
|
685
|
-
setv(to_object, ['done'], getv(from_object, ['done']))
|
|
848
|
+
if getv(from_object, ['nextPageToken']) is not None:
|
|
849
|
+
setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
|
|
686
850
|
|
|
687
|
-
if getv(from_object, ['
|
|
688
|
-
setv(
|
|
851
|
+
if getv(from_object, ['tuningJobs']) is not None:
|
|
852
|
+
setv(
|
|
853
|
+
to_object,
|
|
854
|
+
['tuning_jobs'],
|
|
855
|
+
[
|
|
856
|
+
_TuningJob_from_vertex(item, to_object, root_object)
|
|
857
|
+
for item in getv(from_object, ['tuningJobs'])
|
|
858
|
+
],
|
|
859
|
+
)
|
|
689
860
|
|
|
690
861
|
return to_object
|
|
691
862
|
|
|
692
863
|
|
|
693
|
-
def
|
|
864
|
+
def _SpeechConfig_to_vertex(
|
|
694
865
|
from_object: Union[dict[str, Any], object],
|
|
695
866
|
parent_object: Optional[dict[str, Any]] = None,
|
|
867
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
696
868
|
) -> dict[str, Any]:
|
|
697
869
|
to_object: dict[str, Any] = {}
|
|
698
|
-
if getv(from_object, ['
|
|
699
|
-
setv(to_object, ['
|
|
700
|
-
|
|
701
|
-
if getv(from_object, ['epoch']) is not None:
|
|
702
|
-
setv(to_object, ['epoch'], getv(from_object, ['epoch']))
|
|
870
|
+
if getv(from_object, ['language_code']) is not None:
|
|
871
|
+
setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
|
|
703
872
|
|
|
704
|
-
if getv(from_object, ['
|
|
705
|
-
setv(to_object, ['
|
|
873
|
+
if getv(from_object, ['voice_config']) is not None:
|
|
874
|
+
setv(to_object, ['voiceConfig'], getv(from_object, ['voice_config']))
|
|
706
875
|
|
|
707
|
-
if getv(from_object, ['
|
|
708
|
-
|
|
876
|
+
if getv(from_object, ['multi_speaker_voice_config']) is not None:
|
|
877
|
+
raise ValueError(
|
|
878
|
+
'multi_speaker_voice_config parameter is not supported in Vertex AI.'
|
|
879
|
+
)
|
|
709
880
|
|
|
710
881
|
return to_object
|
|
711
882
|
|
|
712
883
|
|
|
713
|
-
def
|
|
884
|
+
def _TunedModel_from_mldev(
|
|
714
885
|
from_object: Union[dict[str, Any], object],
|
|
715
886
|
parent_object: Optional[dict[str, Any]] = None,
|
|
887
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
716
888
|
) -> dict[str, Any]:
|
|
717
889
|
to_object: dict[str, Any] = {}
|
|
718
|
-
if getv(from_object, ['
|
|
719
|
-
setv(to_object, ['model'], getv(from_object, ['
|
|
720
|
-
|
|
721
|
-
if getv(from_object, ['endpoint']) is not None:
|
|
722
|
-
setv(to_object, ['endpoint'], getv(from_object, ['endpoint']))
|
|
890
|
+
if getv(from_object, ['name']) is not None:
|
|
891
|
+
setv(to_object, ['model'], getv(from_object, ['name']))
|
|
723
892
|
|
|
724
|
-
if getv(from_object, ['
|
|
725
|
-
setv(
|
|
726
|
-
to_object,
|
|
727
|
-
['checkpoints'],
|
|
728
|
-
[
|
|
729
|
-
_TunedModelCheckpoint_from_vertex(item, to_object)
|
|
730
|
-
for item in getv(from_object, ['checkpoints'])
|
|
731
|
-
],
|
|
732
|
-
)
|
|
893
|
+
if getv(from_object, ['name']) is not None:
|
|
894
|
+
setv(to_object, ['endpoint'], getv(from_object, ['name']))
|
|
733
895
|
|
|
734
896
|
return to_object
|
|
735
897
|
|
|
736
898
|
|
|
737
|
-
def
|
|
899
|
+
def _TuningDataset_to_mldev(
|
|
738
900
|
from_object: Union[dict[str, Any], object],
|
|
739
901
|
parent_object: Optional[dict[str, Any]] = None,
|
|
902
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
740
903
|
) -> dict[str, Any]:
|
|
741
904
|
to_object: dict[str, Any] = {}
|
|
742
|
-
if getv(from_object, ['
|
|
743
|
-
|
|
744
|
-
to_object, ['output_uri_prefix'], getv(from_object, ['outputUriPrefix'])
|
|
745
|
-
)
|
|
746
|
-
|
|
747
|
-
return to_object
|
|
905
|
+
if getv(from_object, ['gcs_uri']) is not None:
|
|
906
|
+
raise ValueError('gcs_uri parameter is not supported in Gemini API.')
|
|
748
907
|
|
|
908
|
+
if getv(from_object, ['vertex_dataset_resource']) is not None:
|
|
909
|
+
raise ValueError(
|
|
910
|
+
'vertex_dataset_resource parameter is not supported in Gemini API.'
|
|
911
|
+
)
|
|
749
912
|
|
|
750
|
-
|
|
751
|
-
from_object: Union[dict[str, Any], object],
|
|
752
|
-
parent_object: Optional[dict[str, Any]] = None,
|
|
753
|
-
) -> dict[str, Any]:
|
|
754
|
-
to_object: dict[str, Any] = {}
|
|
755
|
-
if getv(from_object, ['gcsDestination']) is not None:
|
|
913
|
+
if getv(from_object, ['examples']) is not None:
|
|
756
914
|
setv(
|
|
757
915
|
to_object,
|
|
758
|
-
['
|
|
759
|
-
|
|
760
|
-
getv(from_object, ['gcsDestination']), to_object
|
|
761
|
-
),
|
|
916
|
+
['examples', 'examples'],
|
|
917
|
+
[item for item in getv(from_object, ['examples'])],
|
|
762
918
|
)
|
|
763
919
|
|
|
764
920
|
return to_object
|
|
765
921
|
|
|
766
922
|
|
|
767
|
-
def
|
|
923
|
+
def _TuningDataset_to_vertex(
|
|
768
924
|
from_object: Union[dict[str, Any], object],
|
|
769
925
|
parent_object: Optional[dict[str, Any]] = None,
|
|
926
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
770
927
|
) -> dict[str, Any]:
|
|
771
928
|
to_object: dict[str, Any] = {}
|
|
772
|
-
if getv(from_object, ['samplingCount']) is not None:
|
|
773
|
-
setv(to_object, ['sampling_count'], getv(from_object, ['samplingCount']))
|
|
774
929
|
|
|
775
|
-
|
|
776
|
-
|
|
930
|
+
discriminator = getv(root_object, ['config', 'method'])
|
|
931
|
+
if discriminator is None:
|
|
932
|
+
discriminator = 'SUPERVISED_FINE_TUNING'
|
|
933
|
+
if discriminator == 'SUPERVISED_FINE_TUNING':
|
|
934
|
+
if getv(from_object, ['gcs_uri']) is not None:
|
|
935
|
+
setv(
|
|
936
|
+
parent_object,
|
|
937
|
+
['supervisedTuningSpec', 'trainingDatasetUri'],
|
|
938
|
+
getv(from_object, ['gcs_uri']),
|
|
939
|
+
)
|
|
777
940
|
|
|
778
|
-
|
|
779
|
-
|
|
941
|
+
elif discriminator == 'PREFERENCE_TUNING':
|
|
942
|
+
if getv(from_object, ['gcs_uri']) is not None:
|
|
943
|
+
setv(
|
|
944
|
+
parent_object,
|
|
945
|
+
['preferenceOptimizationSpec', 'trainingDatasetUri'],
|
|
946
|
+
getv(from_object, ['gcs_uri']),
|
|
947
|
+
)
|
|
948
|
+
|
|
949
|
+
discriminator = getv(root_object, ['config', 'method'])
|
|
950
|
+
if discriminator is None:
|
|
951
|
+
discriminator = 'SUPERVISED_FINE_TUNING'
|
|
952
|
+
if discriminator == 'SUPERVISED_FINE_TUNING':
|
|
953
|
+
if getv(from_object, ['vertex_dataset_resource']) is not None:
|
|
954
|
+
setv(
|
|
955
|
+
parent_object,
|
|
956
|
+
['supervisedTuningSpec', 'trainingDatasetUri'],
|
|
957
|
+
getv(from_object, ['vertex_dataset_resource']),
|
|
958
|
+
)
|
|
959
|
+
|
|
960
|
+
elif discriminator == 'PREFERENCE_TUNING':
|
|
961
|
+
if getv(from_object, ['vertex_dataset_resource']) is not None:
|
|
962
|
+
setv(
|
|
963
|
+
parent_object,
|
|
964
|
+
['preferenceOptimizationSpec', 'trainingDatasetUri'],
|
|
965
|
+
getv(from_object, ['vertex_dataset_resource']),
|
|
966
|
+
)
|
|
967
|
+
|
|
968
|
+
if getv(from_object, ['examples']) is not None:
|
|
969
|
+
raise ValueError('examples parameter is not supported in Vertex AI.')
|
|
780
970
|
|
|
781
971
|
return to_object
|
|
782
972
|
|
|
783
973
|
|
|
784
|
-
def
|
|
974
|
+
def _TuningJob_from_mldev(
|
|
785
975
|
from_object: Union[dict[str, Any], object],
|
|
786
976
|
parent_object: Optional[dict[str, Any]] = None,
|
|
977
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
787
978
|
) -> dict[str, Any]:
|
|
788
979
|
to_object: dict[str, Any] = {}
|
|
789
|
-
if getv(from_object, ['
|
|
790
|
-
setv(
|
|
980
|
+
if getv(from_object, ['sdkHttpResponse']) is not None:
|
|
981
|
+
setv(
|
|
982
|
+
to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
|
|
983
|
+
)
|
|
791
984
|
|
|
792
|
-
if getv(from_object, ['
|
|
985
|
+
if getv(from_object, ['name']) is not None:
|
|
986
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
|
987
|
+
|
|
988
|
+
if getv(from_object, ['state']) is not None:
|
|
793
989
|
setv(
|
|
794
990
|
to_object,
|
|
795
|
-
['
|
|
796
|
-
|
|
797
|
-
getv(from_object, ['outputConfig']), to_object
|
|
798
|
-
),
|
|
991
|
+
['state'],
|
|
992
|
+
t.t_tuning_job_status(getv(from_object, ['state'])),
|
|
799
993
|
)
|
|
800
994
|
|
|
801
|
-
if getv(from_object, ['
|
|
995
|
+
if getv(from_object, ['createTime']) is not None:
|
|
996
|
+
setv(to_object, ['create_time'], getv(from_object, ['createTime']))
|
|
997
|
+
|
|
998
|
+
if getv(from_object, ['tuningTask', 'startTime']) is not None:
|
|
802
999
|
setv(
|
|
803
1000
|
to_object,
|
|
804
|
-
['
|
|
805
|
-
|
|
806
|
-
|
|
1001
|
+
['start_time'],
|
|
1002
|
+
getv(from_object, ['tuningTask', 'startTime']),
|
|
1003
|
+
)
|
|
1004
|
+
|
|
1005
|
+
if getv(from_object, ['tuningTask', 'completeTime']) is not None:
|
|
1006
|
+
setv(
|
|
1007
|
+
to_object,
|
|
1008
|
+
['end_time'],
|
|
1009
|
+
getv(from_object, ['tuningTask', 'completeTime']),
|
|
1010
|
+
)
|
|
1011
|
+
|
|
1012
|
+
if getv(from_object, ['updateTime']) is not None:
|
|
1013
|
+
setv(to_object, ['update_time'], getv(from_object, ['updateTime']))
|
|
1014
|
+
|
|
1015
|
+
if getv(from_object, ['description']) is not None:
|
|
1016
|
+
setv(to_object, ['description'], getv(from_object, ['description']))
|
|
1017
|
+
|
|
1018
|
+
if getv(from_object, ['baseModel']) is not None:
|
|
1019
|
+
setv(to_object, ['base_model'], getv(from_object, ['baseModel']))
|
|
1020
|
+
|
|
1021
|
+
if getv(from_object, ['_self']) is not None:
|
|
1022
|
+
setv(
|
|
1023
|
+
to_object,
|
|
1024
|
+
['tuned_model'],
|
|
1025
|
+
_TunedModel_from_mldev(
|
|
1026
|
+
getv(from_object, ['_self']), to_object, root_object
|
|
807
1027
|
),
|
|
808
1028
|
)
|
|
809
1029
|
|
|
@@ -813,6 +1033,7 @@ def _EvaluationConfig_from_vertex(
|
|
|
813
1033
|
def _TuningJob_from_vertex(
|
|
814
1034
|
from_object: Union[dict[str, Any], object],
|
|
815
1035
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1036
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
816
1037
|
) -> dict[str, Any]:
|
|
817
1038
|
to_object: dict[str, Any] = {}
|
|
818
1039
|
if getv(from_object, ['sdkHttpResponse']) is not None:
|
|
@@ -852,11 +1073,7 @@ def _TuningJob_from_vertex(
|
|
|
852
1073
|
setv(to_object, ['base_model'], getv(from_object, ['baseModel']))
|
|
853
1074
|
|
|
854
1075
|
if getv(from_object, ['tunedModel']) is not None:
|
|
855
|
-
setv(
|
|
856
|
-
to_object,
|
|
857
|
-
['tuned_model'],
|
|
858
|
-
_TunedModel_from_vertex(getv(from_object, ['tunedModel']), to_object),
|
|
859
|
-
)
|
|
1076
|
+
setv(to_object, ['tuned_model'], getv(from_object, ['tunedModel']))
|
|
860
1077
|
|
|
861
1078
|
if getv(from_object, ['preTunedModel']) is not None:
|
|
862
1079
|
setv(to_object, ['pre_tuned_model'], getv(from_object, ['preTunedModel']))
|
|
@@ -868,6 +1085,13 @@ def _TuningJob_from_vertex(
|
|
|
868
1085
|
getv(from_object, ['supervisedTuningSpec']),
|
|
869
1086
|
)
|
|
870
1087
|
|
|
1088
|
+
if getv(from_object, ['preferenceOptimizationSpec']) is not None:
|
|
1089
|
+
setv(
|
|
1090
|
+
to_object,
|
|
1091
|
+
['preference_optimization_spec'],
|
|
1092
|
+
getv(from_object, ['preferenceOptimizationSpec']),
|
|
1093
|
+
)
|
|
1094
|
+
|
|
871
1095
|
if getv(from_object, ['tuningDataStats']) is not None:
|
|
872
1096
|
setv(
|
|
873
1097
|
to_object, ['tuning_data_stats'], getv(from_object, ['tuningDataStats'])
|
|
@@ -888,7 +1112,7 @@ def _TuningJob_from_vertex(
|
|
|
888
1112
|
to_object,
|
|
889
1113
|
['evaluation_config'],
|
|
890
1114
|
_EvaluationConfig_from_vertex(
|
|
891
|
-
getv(from_object, ['evaluationConfig']), to_object
|
|
1115
|
+
getv(from_object, ['evaluationConfig']), to_object, root_object
|
|
892
1116
|
),
|
|
893
1117
|
)
|
|
894
1118
|
|
|
@@ -919,12 +1143,16 @@ def _TuningJob_from_vertex(
|
|
|
919
1143
|
getv(from_object, ['tunedModelDisplayName']),
|
|
920
1144
|
)
|
|
921
1145
|
|
|
1146
|
+
if getv(from_object, ['veoTuningSpec']) is not None:
|
|
1147
|
+
setv(to_object, ['veo_tuning_spec'], getv(from_object, ['veoTuningSpec']))
|
|
1148
|
+
|
|
922
1149
|
return to_object
|
|
923
1150
|
|
|
924
1151
|
|
|
925
|
-
def
|
|
1152
|
+
def _TuningOperation_from_mldev(
|
|
926
1153
|
from_object: Union[dict[str, Any], object],
|
|
927
1154
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1155
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
928
1156
|
) -> dict[str, Any]:
|
|
929
1157
|
to_object: dict[str, Any] = {}
|
|
930
1158
|
if getv(from_object, ['sdkHttpResponse']) is not None:
|
|
@@ -932,17 +1160,35 @@ def _ListTuningJobsResponse_from_vertex(
|
|
|
932
1160
|
to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
|
|
933
1161
|
)
|
|
934
1162
|
|
|
935
|
-
if getv(from_object, ['
|
|
936
|
-
setv(to_object, ['
|
|
1163
|
+
if getv(from_object, ['name']) is not None:
|
|
1164
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
|
937
1165
|
|
|
938
|
-
if getv(from_object, ['
|
|
1166
|
+
if getv(from_object, ['metadata']) is not None:
|
|
1167
|
+
setv(to_object, ['metadata'], getv(from_object, ['metadata']))
|
|
1168
|
+
|
|
1169
|
+
if getv(from_object, ['done']) is not None:
|
|
1170
|
+
setv(to_object, ['done'], getv(from_object, ['done']))
|
|
1171
|
+
|
|
1172
|
+
if getv(from_object, ['error']) is not None:
|
|
1173
|
+
setv(to_object, ['error'], getv(from_object, ['error']))
|
|
1174
|
+
|
|
1175
|
+
return to_object
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
def _TuningValidationDataset_to_vertex(
|
|
1179
|
+
from_object: Union[dict[str, Any], object],
|
|
1180
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1181
|
+
root_object: Optional[Union[dict[str, Any], object]] = None,
|
|
1182
|
+
) -> dict[str, Any]:
|
|
1183
|
+
to_object: dict[str, Any] = {}
|
|
1184
|
+
if getv(from_object, ['gcs_uri']) is not None:
|
|
1185
|
+
setv(to_object, ['validationDatasetUri'], getv(from_object, ['gcs_uri']))
|
|
1186
|
+
|
|
1187
|
+
if getv(from_object, ['vertex_dataset_resource']) is not None:
|
|
939
1188
|
setv(
|
|
940
1189
|
to_object,
|
|
941
|
-
['
|
|
942
|
-
[
|
|
943
|
-
_TuningJob_from_vertex(item, to_object)
|
|
944
|
-
for item in getv(from_object, ['tuningJobs'])
|
|
945
|
-
],
|
|
1190
|
+
['validationDatasetUri'],
|
|
1191
|
+
getv(from_object, ['vertex_dataset_resource']),
|
|
946
1192
|
)
|
|
947
1193
|
|
|
948
1194
|
return to_object
|
|
@@ -973,14 +1219,18 @@ class Tunings(_api_module.BaseModule):
|
|
|
973
1219
|
request_url_dict: Optional[dict[str, str]]
|
|
974
1220
|
|
|
975
1221
|
if self._api_client.vertexai:
|
|
976
|
-
request_dict = _GetTuningJobParameters_to_vertex(
|
|
1222
|
+
request_dict = _GetTuningJobParameters_to_vertex(
|
|
1223
|
+
parameter_model, None, parameter_model
|
|
1224
|
+
)
|
|
977
1225
|
request_url_dict = request_dict.get('_url')
|
|
978
1226
|
if request_url_dict:
|
|
979
1227
|
path = '{name}'.format_map(request_url_dict)
|
|
980
1228
|
else:
|
|
981
1229
|
path = '{name}'
|
|
982
1230
|
else:
|
|
983
|
-
request_dict = _GetTuningJobParameters_to_mldev(
|
|
1231
|
+
request_dict = _GetTuningJobParameters_to_mldev(
|
|
1232
|
+
parameter_model, None, parameter_model
|
|
1233
|
+
)
|
|
984
1234
|
request_url_dict = request_dict.get('_url')
|
|
985
1235
|
if request_url_dict:
|
|
986
1236
|
path = '{name}'.format_map(request_url_dict)
|
|
@@ -1004,12 +1254,12 @@ class Tunings(_api_module.BaseModule):
|
|
|
1004
1254
|
|
|
1005
1255
|
response = self._api_client.request('get', path, request_dict, http_options)
|
|
1006
1256
|
|
|
1007
|
-
response_dict =
|
|
1257
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1008
1258
|
|
|
1009
1259
|
if self._api_client.vertexai:
|
|
1010
1260
|
response_dict = _TuningJob_from_vertex(response_dict)
|
|
1011
1261
|
|
|
1012
|
-
|
|
1262
|
+
if not self._api_client.vertexai:
|
|
1013
1263
|
response_dict = _TuningJob_from_mldev(response_dict)
|
|
1014
1264
|
|
|
1015
1265
|
return_value = types.TuningJob._from_response(
|
|
@@ -1024,15 +1274,6 @@ class Tunings(_api_module.BaseModule):
|
|
|
1024
1274
|
def _list(
|
|
1025
1275
|
self, *, config: Optional[types.ListTuningJobsConfigOrDict] = None
|
|
1026
1276
|
) -> types.ListTuningJobsResponse:
|
|
1027
|
-
"""Lists `TuningJob` objects.
|
|
1028
|
-
|
|
1029
|
-
Args:
|
|
1030
|
-
config: The configuration for the list request.
|
|
1031
|
-
|
|
1032
|
-
Returns:
|
|
1033
|
-
A list of `TuningJob` objects.
|
|
1034
|
-
"""
|
|
1035
|
-
|
|
1036
1277
|
parameter_model = types._ListTuningJobsParameters(
|
|
1037
1278
|
config=config,
|
|
1038
1279
|
)
|
|
@@ -1040,14 +1281,18 @@ class Tunings(_api_module.BaseModule):
|
|
|
1040
1281
|
request_url_dict: Optional[dict[str, str]]
|
|
1041
1282
|
|
|
1042
1283
|
if self._api_client.vertexai:
|
|
1043
|
-
request_dict = _ListTuningJobsParameters_to_vertex(
|
|
1284
|
+
request_dict = _ListTuningJobsParameters_to_vertex(
|
|
1285
|
+
parameter_model, None, parameter_model
|
|
1286
|
+
)
|
|
1044
1287
|
request_url_dict = request_dict.get('_url')
|
|
1045
1288
|
if request_url_dict:
|
|
1046
1289
|
path = 'tuningJobs'.format_map(request_url_dict)
|
|
1047
1290
|
else:
|
|
1048
1291
|
path = 'tuningJobs'
|
|
1049
1292
|
else:
|
|
1050
|
-
request_dict = _ListTuningJobsParameters_to_mldev(
|
|
1293
|
+
request_dict = _ListTuningJobsParameters_to_mldev(
|
|
1294
|
+
parameter_model, None, parameter_model
|
|
1295
|
+
)
|
|
1051
1296
|
request_url_dict = request_dict.get('_url')
|
|
1052
1297
|
if request_url_dict:
|
|
1053
1298
|
path = 'tunedModels'.format_map(request_url_dict)
|
|
@@ -1071,12 +1316,12 @@ class Tunings(_api_module.BaseModule):
|
|
|
1071
1316
|
|
|
1072
1317
|
response = self._api_client.request('get', path, request_dict, http_options)
|
|
1073
1318
|
|
|
1074
|
-
response_dict =
|
|
1319
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1075
1320
|
|
|
1076
1321
|
if self._api_client.vertexai:
|
|
1077
1322
|
response_dict = _ListTuningJobsResponse_from_vertex(response_dict)
|
|
1078
1323
|
|
|
1079
|
-
|
|
1324
|
+
if not self._api_client.vertexai:
|
|
1080
1325
|
response_dict = _ListTuningJobsResponse_from_mldev(response_dict)
|
|
1081
1326
|
|
|
1082
1327
|
return_value = types.ListTuningJobsResponse._from_response(
|
|
@@ -1093,7 +1338,7 @@ class Tunings(_api_module.BaseModule):
|
|
|
1093
1338
|
*,
|
|
1094
1339
|
name: str,
|
|
1095
1340
|
config: Optional[types.CancelTuningJobConfigOrDict] = None,
|
|
1096
|
-
) ->
|
|
1341
|
+
) -> types.CancelTuningJobResponse:
|
|
1097
1342
|
"""Cancels a tuning job.
|
|
1098
1343
|
|
|
1099
1344
|
Args:
|
|
@@ -1108,14 +1353,18 @@ class Tunings(_api_module.BaseModule):
|
|
|
1108
1353
|
request_url_dict: Optional[dict[str, str]]
|
|
1109
1354
|
|
|
1110
1355
|
if self._api_client.vertexai:
|
|
1111
|
-
request_dict = _CancelTuningJobParameters_to_vertex(
|
|
1356
|
+
request_dict = _CancelTuningJobParameters_to_vertex(
|
|
1357
|
+
parameter_model, None, parameter_model
|
|
1358
|
+
)
|
|
1112
1359
|
request_url_dict = request_dict.get('_url')
|
|
1113
1360
|
if request_url_dict:
|
|
1114
1361
|
path = '{name}:cancel'.format_map(request_url_dict)
|
|
1115
1362
|
else:
|
|
1116
1363
|
path = '{name}:cancel'
|
|
1117
1364
|
else:
|
|
1118
|
-
request_dict = _CancelTuningJobParameters_to_mldev(
|
|
1365
|
+
request_dict = _CancelTuningJobParameters_to_mldev(
|
|
1366
|
+
parameter_model, None, parameter_model
|
|
1367
|
+
)
|
|
1119
1368
|
request_url_dict = request_dict.get('_url')
|
|
1120
1369
|
if request_url_dict:
|
|
1121
1370
|
path = '{name}:cancel'.format_map(request_url_dict)
|
|
@@ -1141,6 +1390,23 @@ class Tunings(_api_module.BaseModule):
|
|
|
1141
1390
|
'post', path, request_dict, http_options
|
|
1142
1391
|
)
|
|
1143
1392
|
|
|
1393
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1394
|
+
|
|
1395
|
+
if self._api_client.vertexai:
|
|
1396
|
+
response_dict = _CancelTuningJobResponse_from_vertex(response_dict)
|
|
1397
|
+
|
|
1398
|
+
if not self._api_client.vertexai:
|
|
1399
|
+
response_dict = _CancelTuningJobResponse_from_mldev(response_dict)
|
|
1400
|
+
|
|
1401
|
+
return_value = types.CancelTuningJobResponse._from_response(
|
|
1402
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
|
1403
|
+
)
|
|
1404
|
+
return_value.sdk_http_response = types.HttpResponse(
|
|
1405
|
+
headers=response.headers
|
|
1406
|
+
)
|
|
1407
|
+
self._api_client._verify_response(return_value)
|
|
1408
|
+
return return_value
|
|
1409
|
+
|
|
1144
1410
|
def _tune(
|
|
1145
1411
|
self,
|
|
1146
1412
|
*,
|
|
@@ -1149,7 +1415,7 @@ class Tunings(_api_module.BaseModule):
|
|
|
1149
1415
|
training_dataset: types.TuningDatasetOrDict,
|
|
1150
1416
|
config: Optional[types.CreateTuningJobConfigOrDict] = None,
|
|
1151
1417
|
) -> types.TuningJob:
|
|
1152
|
-
"""Creates a
|
|
1418
|
+
"""Creates a tuning job and returns the TuningJob object.
|
|
1153
1419
|
|
|
1154
1420
|
Args:
|
|
1155
1421
|
base_model: The name of the model to tune.
|
|
@@ -1172,7 +1438,7 @@ class Tunings(_api_module.BaseModule):
|
|
|
1172
1438
|
raise ValueError('This method is only supported in the Vertex AI client.')
|
|
1173
1439
|
else:
|
|
1174
1440
|
request_dict = _CreateTuningJobParametersPrivate_to_vertex(
|
|
1175
|
-
parameter_model
|
|
1441
|
+
parameter_model, None, parameter_model
|
|
1176
1442
|
)
|
|
1177
1443
|
request_url_dict = request_dict.get('_url')
|
|
1178
1444
|
if request_url_dict:
|
|
@@ -1200,7 +1466,7 @@ class Tunings(_api_module.BaseModule):
|
|
|
1200
1466
|
'post', path, request_dict, http_options
|
|
1201
1467
|
)
|
|
1202
1468
|
|
|
1203
|
-
response_dict =
|
|
1469
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1204
1470
|
|
|
1205
1471
|
if self._api_client.vertexai:
|
|
1206
1472
|
response_dict = _TuningJob_from_vertex(response_dict)
|
|
@@ -1222,7 +1488,7 @@ class Tunings(_api_module.BaseModule):
|
|
|
1222
1488
|
training_dataset: types.TuningDatasetOrDict,
|
|
1223
1489
|
config: Optional[types.CreateTuningJobConfigOrDict] = None,
|
|
1224
1490
|
) -> types.TuningOperation:
|
|
1225
|
-
"""Creates a
|
|
1491
|
+
"""Creates a tuning job and returns the TuningJob object.
|
|
1226
1492
|
|
|
1227
1493
|
Args:
|
|
1228
1494
|
base_model: The name of the model to tune.
|
|
@@ -1246,7 +1512,9 @@ class Tunings(_api_module.BaseModule):
|
|
|
1246
1512
|
'This method is only supported in the Gemini Developer client.'
|
|
1247
1513
|
)
|
|
1248
1514
|
else:
|
|
1249
|
-
request_dict = _CreateTuningJobParametersPrivate_to_mldev(
|
|
1515
|
+
request_dict = _CreateTuningJobParametersPrivate_to_mldev(
|
|
1516
|
+
parameter_model, None, parameter_model
|
|
1517
|
+
)
|
|
1250
1518
|
request_url_dict = request_dict.get('_url')
|
|
1251
1519
|
if request_url_dict:
|
|
1252
1520
|
path = 'tunedModels'.format_map(request_url_dict)
|
|
@@ -1273,7 +1541,7 @@ class Tunings(_api_module.BaseModule):
|
|
|
1273
1541
|
'post', path, request_dict, http_options
|
|
1274
1542
|
)
|
|
1275
1543
|
|
|
1276
|
-
response_dict =
|
|
1544
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1277
1545
|
|
|
1278
1546
|
if not self._api_client.vertexai:
|
|
1279
1547
|
response_dict = _TuningOperation_from_mldev(response_dict)
|
|
@@ -1290,9 +1558,26 @@ class Tunings(_api_module.BaseModule):
|
|
|
1290
1558
|
def list(
|
|
1291
1559
|
self, *, config: Optional[types.ListTuningJobsConfigOrDict] = None
|
|
1292
1560
|
) -> Pager[types.TuningJob]:
|
|
1561
|
+
"""Lists `TuningJob` objects.
|
|
1562
|
+
|
|
1563
|
+
Args:
|
|
1564
|
+
config: The configuration for the list request.
|
|
1565
|
+
|
|
1566
|
+
Returns:
|
|
1567
|
+
A Pager object that contains one page of tuning jobs. When iterating over
|
|
1568
|
+
the pager, it automatically fetches the next page if there are more.
|
|
1569
|
+
|
|
1570
|
+
Usage:
|
|
1571
|
+
|
|
1572
|
+
.. code-block:: python
|
|
1573
|
+
for tuning_job in client.tunings.list():
|
|
1574
|
+
print(tuning_job.name)
|
|
1575
|
+
"""
|
|
1576
|
+
|
|
1577
|
+
list_request = self._list
|
|
1293
1578
|
return Pager(
|
|
1294
1579
|
'tuning_jobs',
|
|
1295
|
-
|
|
1580
|
+
list_request,
|
|
1296
1581
|
self._list(config=config),
|
|
1297
1582
|
config,
|
|
1298
1583
|
)
|
|
@@ -1328,7 +1613,12 @@ class Tunings(_api_module.BaseModule):
|
|
|
1328
1613
|
) -> types.TuningJob:
|
|
1329
1614
|
if self._api_client.vertexai:
|
|
1330
1615
|
if base_model.startswith('projects/'): # Pre-tuned model
|
|
1331
|
-
|
|
1616
|
+
checkpoint_id = None
|
|
1617
|
+
if config:
|
|
1618
|
+
checkpoint_id = getattr(config, 'pre_tuned_model_checkpoint_id', None)
|
|
1619
|
+
pre_tuned_model = types.PreTunedModel(
|
|
1620
|
+
tuned_model_name=base_model, checkpoint_id=checkpoint_id
|
|
1621
|
+
)
|
|
1332
1622
|
tuning_job = self._tune(
|
|
1333
1623
|
pre_tuned_model=pre_tuned_model,
|
|
1334
1624
|
training_dataset=training_dataset,
|
|
@@ -1419,14 +1709,18 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1419
1709
|
request_url_dict: Optional[dict[str, str]]
|
|
1420
1710
|
|
|
1421
1711
|
if self._api_client.vertexai:
|
|
1422
|
-
request_dict = _GetTuningJobParameters_to_vertex(
|
|
1712
|
+
request_dict = _GetTuningJobParameters_to_vertex(
|
|
1713
|
+
parameter_model, None, parameter_model
|
|
1714
|
+
)
|
|
1423
1715
|
request_url_dict = request_dict.get('_url')
|
|
1424
1716
|
if request_url_dict:
|
|
1425
1717
|
path = '{name}'.format_map(request_url_dict)
|
|
1426
1718
|
else:
|
|
1427
1719
|
path = '{name}'
|
|
1428
1720
|
else:
|
|
1429
|
-
request_dict = _GetTuningJobParameters_to_mldev(
|
|
1721
|
+
request_dict = _GetTuningJobParameters_to_mldev(
|
|
1722
|
+
parameter_model, None, parameter_model
|
|
1723
|
+
)
|
|
1430
1724
|
request_url_dict = request_dict.get('_url')
|
|
1431
1725
|
if request_url_dict:
|
|
1432
1726
|
path = '{name}'.format_map(request_url_dict)
|
|
@@ -1452,12 +1746,12 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1452
1746
|
'get', path, request_dict, http_options
|
|
1453
1747
|
)
|
|
1454
1748
|
|
|
1455
|
-
response_dict =
|
|
1749
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1456
1750
|
|
|
1457
1751
|
if self._api_client.vertexai:
|
|
1458
1752
|
response_dict = _TuningJob_from_vertex(response_dict)
|
|
1459
1753
|
|
|
1460
|
-
|
|
1754
|
+
if not self._api_client.vertexai:
|
|
1461
1755
|
response_dict = _TuningJob_from_mldev(response_dict)
|
|
1462
1756
|
|
|
1463
1757
|
return_value = types.TuningJob._from_response(
|
|
@@ -1472,15 +1766,6 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1472
1766
|
async def _list(
|
|
1473
1767
|
self, *, config: Optional[types.ListTuningJobsConfigOrDict] = None
|
|
1474
1768
|
) -> types.ListTuningJobsResponse:
|
|
1475
|
-
"""Lists `TuningJob` objects.
|
|
1476
|
-
|
|
1477
|
-
Args:
|
|
1478
|
-
config: The configuration for the list request.
|
|
1479
|
-
|
|
1480
|
-
Returns:
|
|
1481
|
-
A list of `TuningJob` objects.
|
|
1482
|
-
"""
|
|
1483
|
-
|
|
1484
1769
|
parameter_model = types._ListTuningJobsParameters(
|
|
1485
1770
|
config=config,
|
|
1486
1771
|
)
|
|
@@ -1488,14 +1773,18 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1488
1773
|
request_url_dict: Optional[dict[str, str]]
|
|
1489
1774
|
|
|
1490
1775
|
if self._api_client.vertexai:
|
|
1491
|
-
request_dict = _ListTuningJobsParameters_to_vertex(
|
|
1776
|
+
request_dict = _ListTuningJobsParameters_to_vertex(
|
|
1777
|
+
parameter_model, None, parameter_model
|
|
1778
|
+
)
|
|
1492
1779
|
request_url_dict = request_dict.get('_url')
|
|
1493
1780
|
if request_url_dict:
|
|
1494
1781
|
path = 'tuningJobs'.format_map(request_url_dict)
|
|
1495
1782
|
else:
|
|
1496
1783
|
path = 'tuningJobs'
|
|
1497
1784
|
else:
|
|
1498
|
-
request_dict = _ListTuningJobsParameters_to_mldev(
|
|
1785
|
+
request_dict = _ListTuningJobsParameters_to_mldev(
|
|
1786
|
+
parameter_model, None, parameter_model
|
|
1787
|
+
)
|
|
1499
1788
|
request_url_dict = request_dict.get('_url')
|
|
1500
1789
|
if request_url_dict:
|
|
1501
1790
|
path = 'tunedModels'.format_map(request_url_dict)
|
|
@@ -1521,12 +1810,12 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1521
1810
|
'get', path, request_dict, http_options
|
|
1522
1811
|
)
|
|
1523
1812
|
|
|
1524
|
-
response_dict =
|
|
1813
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1525
1814
|
|
|
1526
1815
|
if self._api_client.vertexai:
|
|
1527
1816
|
response_dict = _ListTuningJobsResponse_from_vertex(response_dict)
|
|
1528
1817
|
|
|
1529
|
-
|
|
1818
|
+
if not self._api_client.vertexai:
|
|
1530
1819
|
response_dict = _ListTuningJobsResponse_from_mldev(response_dict)
|
|
1531
1820
|
|
|
1532
1821
|
return_value = types.ListTuningJobsResponse._from_response(
|
|
@@ -1543,7 +1832,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1543
1832
|
*,
|
|
1544
1833
|
name: str,
|
|
1545
1834
|
config: Optional[types.CancelTuningJobConfigOrDict] = None,
|
|
1546
|
-
) ->
|
|
1835
|
+
) -> types.CancelTuningJobResponse:
|
|
1547
1836
|
"""Cancels a tuning job asynchronously.
|
|
1548
1837
|
|
|
1549
1838
|
Args:
|
|
@@ -1558,14 +1847,18 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1558
1847
|
request_url_dict: Optional[dict[str, str]]
|
|
1559
1848
|
|
|
1560
1849
|
if self._api_client.vertexai:
|
|
1561
|
-
request_dict = _CancelTuningJobParameters_to_vertex(
|
|
1850
|
+
request_dict = _CancelTuningJobParameters_to_vertex(
|
|
1851
|
+
parameter_model, None, parameter_model
|
|
1852
|
+
)
|
|
1562
1853
|
request_url_dict = request_dict.get('_url')
|
|
1563
1854
|
if request_url_dict:
|
|
1564
1855
|
path = '{name}:cancel'.format_map(request_url_dict)
|
|
1565
1856
|
else:
|
|
1566
1857
|
path = '{name}:cancel'
|
|
1567
1858
|
else:
|
|
1568
|
-
request_dict = _CancelTuningJobParameters_to_mldev(
|
|
1859
|
+
request_dict = _CancelTuningJobParameters_to_mldev(
|
|
1860
|
+
parameter_model, None, parameter_model
|
|
1861
|
+
)
|
|
1569
1862
|
request_url_dict = request_dict.get('_url')
|
|
1570
1863
|
if request_url_dict:
|
|
1571
1864
|
path = '{name}:cancel'.format_map(request_url_dict)
|
|
@@ -1591,6 +1884,23 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1591
1884
|
'post', path, request_dict, http_options
|
|
1592
1885
|
)
|
|
1593
1886
|
|
|
1887
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1888
|
+
|
|
1889
|
+
if self._api_client.vertexai:
|
|
1890
|
+
response_dict = _CancelTuningJobResponse_from_vertex(response_dict)
|
|
1891
|
+
|
|
1892
|
+
if not self._api_client.vertexai:
|
|
1893
|
+
response_dict = _CancelTuningJobResponse_from_mldev(response_dict)
|
|
1894
|
+
|
|
1895
|
+
return_value = types.CancelTuningJobResponse._from_response(
|
|
1896
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
|
1897
|
+
)
|
|
1898
|
+
return_value.sdk_http_response = types.HttpResponse(
|
|
1899
|
+
headers=response.headers
|
|
1900
|
+
)
|
|
1901
|
+
self._api_client._verify_response(return_value)
|
|
1902
|
+
return return_value
|
|
1903
|
+
|
|
1594
1904
|
async def _tune(
|
|
1595
1905
|
self,
|
|
1596
1906
|
*,
|
|
@@ -1599,7 +1909,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1599
1909
|
training_dataset: types.TuningDatasetOrDict,
|
|
1600
1910
|
config: Optional[types.CreateTuningJobConfigOrDict] = None,
|
|
1601
1911
|
) -> types.TuningJob:
|
|
1602
|
-
"""Creates a
|
|
1912
|
+
"""Creates a tuning job and returns the TuningJob object.
|
|
1603
1913
|
|
|
1604
1914
|
Args:
|
|
1605
1915
|
base_model: The name of the model to tune.
|
|
@@ -1622,7 +1932,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1622
1932
|
raise ValueError('This method is only supported in the Vertex AI client.')
|
|
1623
1933
|
else:
|
|
1624
1934
|
request_dict = _CreateTuningJobParametersPrivate_to_vertex(
|
|
1625
|
-
parameter_model
|
|
1935
|
+
parameter_model, None, parameter_model
|
|
1626
1936
|
)
|
|
1627
1937
|
request_url_dict = request_dict.get('_url')
|
|
1628
1938
|
if request_url_dict:
|
|
@@ -1650,7 +1960,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1650
1960
|
'post', path, request_dict, http_options
|
|
1651
1961
|
)
|
|
1652
1962
|
|
|
1653
|
-
response_dict =
|
|
1963
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1654
1964
|
|
|
1655
1965
|
if self._api_client.vertexai:
|
|
1656
1966
|
response_dict = _TuningJob_from_vertex(response_dict)
|
|
@@ -1672,7 +1982,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1672
1982
|
training_dataset: types.TuningDatasetOrDict,
|
|
1673
1983
|
config: Optional[types.CreateTuningJobConfigOrDict] = None,
|
|
1674
1984
|
) -> types.TuningOperation:
|
|
1675
|
-
"""Creates a
|
|
1985
|
+
"""Creates a tuning job and returns the TuningJob object.
|
|
1676
1986
|
|
|
1677
1987
|
Args:
|
|
1678
1988
|
base_model: The name of the model to tune.
|
|
@@ -1696,7 +2006,9 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1696
2006
|
'This method is only supported in the Gemini Developer client.'
|
|
1697
2007
|
)
|
|
1698
2008
|
else:
|
|
1699
|
-
request_dict = _CreateTuningJobParametersPrivate_to_mldev(
|
|
2009
|
+
request_dict = _CreateTuningJobParametersPrivate_to_mldev(
|
|
2010
|
+
parameter_model, None, parameter_model
|
|
2011
|
+
)
|
|
1700
2012
|
request_url_dict = request_dict.get('_url')
|
|
1701
2013
|
if request_url_dict:
|
|
1702
2014
|
path = 'tunedModels'.format_map(request_url_dict)
|
|
@@ -1723,7 +2035,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1723
2035
|
'post', path, request_dict, http_options
|
|
1724
2036
|
)
|
|
1725
2037
|
|
|
1726
|
-
response_dict =
|
|
2038
|
+
response_dict = {} if not response.body else json.loads(response.body)
|
|
1727
2039
|
|
|
1728
2040
|
if not self._api_client.vertexai:
|
|
1729
2041
|
response_dict = _TuningOperation_from_mldev(response_dict)
|
|
@@ -1740,9 +2052,26 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1740
2052
|
async def list(
|
|
1741
2053
|
self, *, config: Optional[types.ListTuningJobsConfigOrDict] = None
|
|
1742
2054
|
) -> AsyncPager[types.TuningJob]:
|
|
2055
|
+
"""Lists `TuningJob` objects asynchronously.
|
|
2056
|
+
|
|
2057
|
+
Args:
|
|
2058
|
+
config: The configuration for the list request.
|
|
2059
|
+
|
|
2060
|
+
Returns:
|
|
2061
|
+
A Pager object that contains one page of tuning jobs. When iterating over
|
|
2062
|
+
the pager, it automatically fetches the next page if there are more.
|
|
2063
|
+
|
|
2064
|
+
Usage:
|
|
2065
|
+
|
|
2066
|
+
.. code-block:: python
|
|
2067
|
+
async for tuning_job in await client.aio.tunings.list():
|
|
2068
|
+
print(tuning_job.name)
|
|
2069
|
+
"""
|
|
2070
|
+
|
|
2071
|
+
list_request = self._list
|
|
1743
2072
|
return AsyncPager(
|
|
1744
2073
|
'tuning_jobs',
|
|
1745
|
-
|
|
2074
|
+
list_request,
|
|
1746
2075
|
await self._list(config=config),
|
|
1747
2076
|
config,
|
|
1748
2077
|
)
|
|
@@ -1778,7 +2107,12 @@ class AsyncTunings(_api_module.BaseModule):
|
|
|
1778
2107
|
) -> types.TuningJob:
|
|
1779
2108
|
if self._api_client.vertexai:
|
|
1780
2109
|
if base_model.startswith('projects/'): # Pre-tuned model
|
|
1781
|
-
|
|
2110
|
+
checkpoint_id = None
|
|
2111
|
+
if config:
|
|
2112
|
+
checkpoint_id = getattr(config, 'pre_tuned_model_checkpoint_id', None)
|
|
2113
|
+
pre_tuned_model = types.PreTunedModel(
|
|
2114
|
+
tuned_model_name=base_model, checkpoint_id=checkpoint_id
|
|
2115
|
+
)
|
|
1782
2116
|
|
|
1783
2117
|
tuning_job = await self._tune(
|
|
1784
2118
|
pre_tuned_model=pre_tuned_model,
|