google-genai 1.31.0__py3-none-any.whl → 1.33.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 +32 -9
- google/genai/_base_transformers.py +26 -0
- google/genai/_local_tokenizer_loader.py +223 -0
- google/genai/_operations_converters.py +307 -0
- google/genai/_replay_api_client.py +15 -0
- google/genai/_transformers.py +0 -10
- google/genai/caches.py +14 -2
- google/genai/files.py +12 -2
- google/genai/local_tokenizer.py +362 -0
- google/genai/models.py +171 -196
- google/genai/tunings.py +134 -0
- google/genai/types.py +402 -304
- google/genai/version.py +1 -1
- {google_genai-1.31.0.dist-info → google_genai-1.33.0.dist-info}/METADATA +6 -6
- {google_genai-1.31.0.dist-info → google_genai-1.33.0.dist-info}/RECORD +18 -14
- {google_genai-1.31.0.dist-info → google_genai-1.33.0.dist-info}/WHEEL +0 -0
- {google_genai-1.31.0.dist-info → google_genai-1.33.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.31.0.dist-info → google_genai-1.33.0.dist-info}/top_level.txt +0 -0
google/genai/tunings.py
CHANGED
@@ -87,6 +87,20 @@ def _ListTuningJobsParameters_to_mldev(
|
|
87
87
|
return to_object
|
88
88
|
|
89
89
|
|
90
|
+
def _CancelTuningJobParameters_to_mldev(
|
91
|
+
from_object: Union[dict[str, Any], object],
|
92
|
+
parent_object: Optional[dict[str, Any]] = None,
|
93
|
+
) -> dict[str, Any]:
|
94
|
+
to_object: dict[str, Any] = {}
|
95
|
+
if getv(from_object, ['name']) is not None:
|
96
|
+
setv(to_object, ['_url', 'name'], getv(from_object, ['name']))
|
97
|
+
|
98
|
+
if getv(from_object, ['config']) is not None:
|
99
|
+
setv(to_object, ['config'], getv(from_object, ['config']))
|
100
|
+
|
101
|
+
return to_object
|
102
|
+
|
103
|
+
|
90
104
|
def _TuningExample_to_mldev(
|
91
105
|
from_object: Union[dict[str, Any], object],
|
92
106
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -285,6 +299,20 @@ def _ListTuningJobsParameters_to_vertex(
|
|
285
299
|
return to_object
|
286
300
|
|
287
301
|
|
302
|
+
def _CancelTuningJobParameters_to_vertex(
|
303
|
+
from_object: Union[dict[str, Any], object],
|
304
|
+
parent_object: Optional[dict[str, Any]] = None,
|
305
|
+
) -> dict[str, Any]:
|
306
|
+
to_object: dict[str, Any] = {}
|
307
|
+
if getv(from_object, ['name']) is not None:
|
308
|
+
setv(to_object, ['_url', 'name'], getv(from_object, ['name']))
|
309
|
+
|
310
|
+
if getv(from_object, ['config']) is not None:
|
311
|
+
setv(to_object, ['config'], getv(from_object, ['config']))
|
312
|
+
|
313
|
+
return to_object
|
314
|
+
|
315
|
+
|
288
316
|
def _TuningDataset_to_vertex(
|
289
317
|
from_object: Union[dict[str, Any], object],
|
290
318
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -1060,6 +1088,59 @@ class Tunings(_api_module.BaseModule):
|
|
1060
1088
|
self._api_client._verify_response(return_value)
|
1061
1089
|
return return_value
|
1062
1090
|
|
1091
|
+
def cancel(
|
1092
|
+
self,
|
1093
|
+
*,
|
1094
|
+
name: str,
|
1095
|
+
config: Optional[types.CancelTuningJobConfigOrDict] = None,
|
1096
|
+
) -> None:
|
1097
|
+
"""Cancels a tuning job.
|
1098
|
+
|
1099
|
+
Args:
|
1100
|
+
name (str): TuningJob resource name.
|
1101
|
+
"""
|
1102
|
+
|
1103
|
+
parameter_model = types._CancelTuningJobParameters(
|
1104
|
+
name=name,
|
1105
|
+
config=config,
|
1106
|
+
)
|
1107
|
+
|
1108
|
+
request_url_dict: Optional[dict[str, str]]
|
1109
|
+
|
1110
|
+
if self._api_client.vertexai:
|
1111
|
+
request_dict = _CancelTuningJobParameters_to_vertex(parameter_model)
|
1112
|
+
request_url_dict = request_dict.get('_url')
|
1113
|
+
if request_url_dict:
|
1114
|
+
path = '{name}:cancel'.format_map(request_url_dict)
|
1115
|
+
else:
|
1116
|
+
path = '{name}:cancel'
|
1117
|
+
else:
|
1118
|
+
request_dict = _CancelTuningJobParameters_to_mldev(parameter_model)
|
1119
|
+
request_url_dict = request_dict.get('_url')
|
1120
|
+
if request_url_dict:
|
1121
|
+
path = '{name}:cancel'.format_map(request_url_dict)
|
1122
|
+
else:
|
1123
|
+
path = '{name}:cancel'
|
1124
|
+
query_params = request_dict.get('_query')
|
1125
|
+
if query_params:
|
1126
|
+
path = f'{path}?{urlencode(query_params)}'
|
1127
|
+
# TODO: remove the hack that pops config.
|
1128
|
+
request_dict.pop('config', None)
|
1129
|
+
|
1130
|
+
http_options: Optional[types.HttpOptions] = None
|
1131
|
+
if (
|
1132
|
+
parameter_model.config is not None
|
1133
|
+
and parameter_model.config.http_options is not None
|
1134
|
+
):
|
1135
|
+
http_options = parameter_model.config.http_options
|
1136
|
+
|
1137
|
+
request_dict = _common.convert_to_dict(request_dict)
|
1138
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1139
|
+
|
1140
|
+
response = self._api_client.request(
|
1141
|
+
'post', path, request_dict, http_options
|
1142
|
+
)
|
1143
|
+
|
1063
1144
|
def _tune(
|
1064
1145
|
self,
|
1065
1146
|
*,
|
@@ -1457,6 +1538,59 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1457
1538
|
self._api_client._verify_response(return_value)
|
1458
1539
|
return return_value
|
1459
1540
|
|
1541
|
+
async def cancel(
|
1542
|
+
self,
|
1543
|
+
*,
|
1544
|
+
name: str,
|
1545
|
+
config: Optional[types.CancelTuningJobConfigOrDict] = None,
|
1546
|
+
) -> None:
|
1547
|
+
"""Cancels a tuning job asynchronously.
|
1548
|
+
|
1549
|
+
Args:
|
1550
|
+
name (str): A TuningJob resource name.
|
1551
|
+
"""
|
1552
|
+
|
1553
|
+
parameter_model = types._CancelTuningJobParameters(
|
1554
|
+
name=name,
|
1555
|
+
config=config,
|
1556
|
+
)
|
1557
|
+
|
1558
|
+
request_url_dict: Optional[dict[str, str]]
|
1559
|
+
|
1560
|
+
if self._api_client.vertexai:
|
1561
|
+
request_dict = _CancelTuningJobParameters_to_vertex(parameter_model)
|
1562
|
+
request_url_dict = request_dict.get('_url')
|
1563
|
+
if request_url_dict:
|
1564
|
+
path = '{name}:cancel'.format_map(request_url_dict)
|
1565
|
+
else:
|
1566
|
+
path = '{name}:cancel'
|
1567
|
+
else:
|
1568
|
+
request_dict = _CancelTuningJobParameters_to_mldev(parameter_model)
|
1569
|
+
request_url_dict = request_dict.get('_url')
|
1570
|
+
if request_url_dict:
|
1571
|
+
path = '{name}:cancel'.format_map(request_url_dict)
|
1572
|
+
else:
|
1573
|
+
path = '{name}:cancel'
|
1574
|
+
query_params = request_dict.get('_query')
|
1575
|
+
if query_params:
|
1576
|
+
path = f'{path}?{urlencode(query_params)}'
|
1577
|
+
# TODO: remove the hack that pops config.
|
1578
|
+
request_dict.pop('config', None)
|
1579
|
+
|
1580
|
+
http_options: Optional[types.HttpOptions] = None
|
1581
|
+
if (
|
1582
|
+
parameter_model.config is not None
|
1583
|
+
and parameter_model.config.http_options is not None
|
1584
|
+
):
|
1585
|
+
http_options = parameter_model.config.http_options
|
1586
|
+
|
1587
|
+
request_dict = _common.convert_to_dict(request_dict)
|
1588
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1589
|
+
|
1590
|
+
response = await self._api_client.async_request(
|
1591
|
+
'post', path, request_dict, http_options
|
1592
|
+
)
|
1593
|
+
|
1460
1594
|
async def _tune(
|
1461
1595
|
self,
|
1462
1596
|
*,
|