google-genai 1.30.0__py3-none-any.whl → 1.32.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 -32
- google/genai/_automatic_function_calling_util.py +12 -0
- google/genai/_base_transformers.py +26 -0
- google/genai/_live_converters.py +1 -0
- google/genai/_local_tokenizer_loader.py +223 -0
- google/genai/_operations_converters.py +307 -0
- google/genai/_tokens_converters.py +1 -0
- google/genai/_transformers.py +0 -10
- google/genai/batches.py +141 -0
- google/genai/caches.py +15 -2
- google/genai/files.py +11 -2
- google/genai/local_tokenizer.py +362 -0
- google/genai/models.py +518 -17
- google/genai/operations.py +1 -0
- google/genai/tunings.py +135 -0
- google/genai/types.py +781 -323
- google/genai/version.py +1 -1
- {google_genai-1.30.0.dist-info → google_genai-1.32.0.dist-info}/METADATA +6 -6
- google_genai-1.32.0.dist-info/RECORD +39 -0
- google_genai-1.30.0.dist-info/RECORD +0 -35
- {google_genai-1.30.0.dist-info → google_genai-1.32.0.dist-info}/WHEEL +0 -0
- {google_genai-1.30.0.dist-info → google_genai-1.32.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.30.0.dist-info → google_genai-1.32.0.dist-info}/top_level.txt +0 -0
google/genai/operations.py
CHANGED
google/genai/tunings.py
CHANGED
@@ -28,6 +28,7 @@ from ._common import get_value_by_path as getv
|
|
28
28
|
from ._common import set_value_by_path as setv
|
29
29
|
from .pagers import AsyncPager, Pager
|
30
30
|
|
31
|
+
|
31
32
|
logger = logging.getLogger('google_genai.tunings')
|
32
33
|
|
33
34
|
|
@@ -86,6 +87,20 @@ def _ListTuningJobsParameters_to_mldev(
|
|
86
87
|
return to_object
|
87
88
|
|
88
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
|
+
|
89
104
|
def _TuningExample_to_mldev(
|
90
105
|
from_object: Union[dict[str, Any], object],
|
91
106
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -284,6 +299,20 @@ def _ListTuningJobsParameters_to_vertex(
|
|
284
299
|
return to_object
|
285
300
|
|
286
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
|
+
|
287
316
|
def _TuningDataset_to_vertex(
|
288
317
|
from_object: Union[dict[str, Any], object],
|
289
318
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -1059,6 +1088,59 @@ class Tunings(_api_module.BaseModule):
|
|
1059
1088
|
self._api_client._verify_response(return_value)
|
1060
1089
|
return return_value
|
1061
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
|
+
|
1062
1144
|
def _tune(
|
1063
1145
|
self,
|
1064
1146
|
*,
|
@@ -1456,6 +1538,59 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1456
1538
|
self._api_client._verify_response(return_value)
|
1457
1539
|
return return_value
|
1458
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
|
+
|
1459
1594
|
async def _tune(
|
1460
1595
|
self,
|
1461
1596
|
*,
|