google-genai 0.4.0__py3-none-any.whl → 0.6.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 +240 -71
- google/genai/_common.py +47 -31
- google/genai/_extra_utils.py +3 -3
- google/genai/_replay_api_client.py +51 -74
- google/genai/_transformers.py +197 -30
- google/genai/batches.py +74 -72
- google/genai/caches.py +104 -90
- google/genai/chats.py +5 -8
- google/genai/client.py +2 -1
- google/genai/errors.py +1 -1
- google/genai/files.py +302 -102
- google/genai/live.py +42 -30
- google/genai/models.py +379 -250
- google/genai/tunings.py +78 -76
- google/genai/types.py +563 -350
- google/genai/version.py +1 -1
- google_genai-0.6.0.dist-info/METADATA +973 -0
- google_genai-0.6.0.dist-info/RECORD +25 -0
- google_genai-0.4.0.dist-info/METADATA +0 -888
- google_genai-0.4.0.dist-info/RECORD +0 -25
- {google_genai-0.4.0.dist-info → google_genai-0.6.0.dist-info}/LICENSE +0 -0
- {google_genai-0.4.0.dist-info → google_genai-0.6.0.dist-info}/WHEEL +0 -0
- {google_genai-0.4.0.dist-info → google_genai-0.6.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
|
@@ -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')
|
@@ -987,21 +989,21 @@ class Tunings(_common.BaseModule):
|
|
987
989
|
config = request_dict.pop('config', None)
|
988
990
|
http_options = config.pop('httpOptions', None) if config else None
|
989
991
|
request_dict = _common.convert_to_dict(request_dict)
|
990
|
-
request_dict = _common.
|
992
|
+
request_dict = _common.encode_unserializable_types(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')
|
@@ -1037,25 +1039,25 @@ class Tunings(_common.BaseModule):
|
|
1037
1039
|
config = request_dict.pop('config', None)
|
1038
1040
|
http_options = config.pop('httpOptions', None) if config else None
|
1039
1041
|
request_dict = _common.convert_to_dict(request_dict)
|
1040
|
-
request_dict = _common.
|
1042
|
+
request_dict = _common.encode_unserializable_types(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')
|
@@ -1099,25 +1101,25 @@ class Tunings(_common.BaseModule):
|
|
1099
1101
|
config = request_dict.pop('config', None)
|
1100
1102
|
http_options = config.pop('httpOptions', None) if config else None
|
1101
1103
|
request_dict = _common.convert_to_dict(request_dict)
|
1102
|
-
request_dict = _common.
|
1104
|
+
request_dict = _common.encode_unserializable_types(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
|
|
@@ -1162,21 +1164,21 @@ class Tunings(_common.BaseModule):
|
|
1162
1164
|
config = request_dict.pop('config', None)
|
1163
1165
|
http_options = config.pop('httpOptions', None) if config else None
|
1164
1166
|
request_dict = _common.convert_to_dict(request_dict)
|
1165
|
-
request_dict = _common.
|
1167
|
+
request_dict = _common.encode_unserializable_types(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')
|
@@ -1259,21 +1261,21 @@ class AsyncTunings(_common.BaseModule):
|
|
1259
1261
|
config = request_dict.pop('config', None)
|
1260
1262
|
http_options = config.pop('httpOptions', None) if config else None
|
1261
1263
|
request_dict = _common.convert_to_dict(request_dict)
|
1262
|
-
request_dict = _common.
|
1264
|
+
request_dict = _common.encode_unserializable_types(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')
|
@@ -1309,25 +1311,25 @@ class AsyncTunings(_common.BaseModule):
|
|
1309
1311
|
config = request_dict.pop('config', None)
|
1310
1312
|
http_options = config.pop('httpOptions', None) if config else None
|
1311
1313
|
request_dict = _common.convert_to_dict(request_dict)
|
1312
|
-
request_dict = _common.
|
1314
|
+
request_dict = _common.encode_unserializable_types(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')
|
@@ -1371,25 +1373,25 @@ class AsyncTunings(_common.BaseModule):
|
|
1371
1373
|
config = request_dict.pop('config', None)
|
1372
1374
|
http_options = config.pop('httpOptions', None) if config else None
|
1373
1375
|
request_dict = _common.convert_to_dict(request_dict)
|
1374
|
-
request_dict = _common.
|
1376
|
+
request_dict = _common.encode_unserializable_types(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
|
|
@@ -1434,21 +1436,21 @@ class AsyncTunings(_common.BaseModule):
|
|
1434
1436
|
config = request_dict.pop('config', None)
|
1435
1437
|
http_options = config.pop('httpOptions', None) if config else None
|
1436
1438
|
request_dict = _common.convert_to_dict(request_dict)
|
1437
|
-
request_dict = _common.
|
1439
|
+
request_dict = _common.encode_unserializable_types(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
|
|