google-genai 1.39.1__py3-none-any.whl → 1.40.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/_live_converters.py +38 -42
- google/genai/_tokens_converters.py +19 -21
- google/genai/batches.py +37 -21
- google/genai/caches.py +38 -42
- google/genai/live.py +33 -4
- google/genai/models.py +74 -42
- google/genai/types.py +44 -5
- google/genai/version.py +1 -1
- {google_genai-1.39.1.dist-info → google_genai-1.40.0.dist-info}/METADATA +1 -1
- {google_genai-1.39.1.dist-info → google_genai-1.40.0.dist-info}/RECORD +13 -13
- {google_genai-1.39.1.dist-info → google_genai-1.40.0.dist-info}/WHEEL +0 -0
- {google_genai-1.39.1.dist-info → google_genai-1.40.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.39.1.dist-info → google_genai-1.40.0.dist-info}/top_level.txt +0 -0
google/genai/_live_converters.py
CHANGED
@@ -291,6 +291,42 @@ def _Blob_to_vertex(
|
|
291
291
|
return to_object
|
292
292
|
|
293
293
|
|
294
|
+
def _ComputerUse_to_mldev(
|
295
|
+
from_object: Union[dict[str, Any], object],
|
296
|
+
parent_object: Optional[dict[str, Any]] = None,
|
297
|
+
) -> dict[str, Any]:
|
298
|
+
to_object: dict[str, Any] = {}
|
299
|
+
if getv(from_object, ['environment']) is not None:
|
300
|
+
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
301
|
+
|
302
|
+
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
303
|
+
setv(
|
304
|
+
to_object,
|
305
|
+
['excludedPredefinedFunctions'],
|
306
|
+
getv(from_object, ['excluded_predefined_functions']),
|
307
|
+
)
|
308
|
+
|
309
|
+
return to_object
|
310
|
+
|
311
|
+
|
312
|
+
def _ComputerUse_to_vertex(
|
313
|
+
from_object: Union[dict[str, Any], object],
|
314
|
+
parent_object: Optional[dict[str, Any]] = None,
|
315
|
+
) -> dict[str, Any]:
|
316
|
+
to_object: dict[str, Any] = {}
|
317
|
+
if getv(from_object, ['environment']) is not None:
|
318
|
+
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
319
|
+
|
320
|
+
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
321
|
+
setv(
|
322
|
+
to_object,
|
323
|
+
['excludedPredefinedFunctions'],
|
324
|
+
getv(from_object, ['excluded_predefined_functions']),
|
325
|
+
)
|
326
|
+
|
327
|
+
return to_object
|
328
|
+
|
329
|
+
|
294
330
|
def _Content_from_mldev(
|
295
331
|
from_object: Union[dict[str, Any], object],
|
296
332
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -3189,42 +3225,6 @@ def _SpeechConfig_to_vertex(
|
|
3189
3225
|
return to_object
|
3190
3226
|
|
3191
3227
|
|
3192
|
-
def _ToolComputerUse_to_mldev(
|
3193
|
-
from_object: Union[dict[str, Any], object],
|
3194
|
-
parent_object: Optional[dict[str, Any]] = None,
|
3195
|
-
) -> dict[str, Any]:
|
3196
|
-
to_object: dict[str, Any] = {}
|
3197
|
-
if getv(from_object, ['environment']) is not None:
|
3198
|
-
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
3199
|
-
|
3200
|
-
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
3201
|
-
setv(
|
3202
|
-
to_object,
|
3203
|
-
['excludedPredefinedFunctions'],
|
3204
|
-
getv(from_object, ['excluded_predefined_functions']),
|
3205
|
-
)
|
3206
|
-
|
3207
|
-
return to_object
|
3208
|
-
|
3209
|
-
|
3210
|
-
def _ToolComputerUse_to_vertex(
|
3211
|
-
from_object: Union[dict[str, Any], object],
|
3212
|
-
parent_object: Optional[dict[str, Any]] = None,
|
3213
|
-
) -> dict[str, Any]:
|
3214
|
-
to_object: dict[str, Any] = {}
|
3215
|
-
if getv(from_object, ['environment']) is not None:
|
3216
|
-
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
3217
|
-
|
3218
|
-
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
3219
|
-
setv(
|
3220
|
-
to_object,
|
3221
|
-
['excludedPredefinedFunctions'],
|
3222
|
-
getv(from_object, ['excluded_predefined_functions']),
|
3223
|
-
)
|
3224
|
-
|
3225
|
-
return to_object
|
3226
|
-
|
3227
|
-
|
3228
3228
|
def _Tool_to_mldev(
|
3229
3229
|
from_object: Union[dict[str, Any], object],
|
3230
3230
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -3278,9 +3278,7 @@ def _Tool_to_mldev(
|
|
3278
3278
|
setv(
|
3279
3279
|
to_object,
|
3280
3280
|
['computerUse'],
|
3281
|
-
|
3282
|
-
getv(from_object, ['computer_use']), to_object
|
3283
|
-
),
|
3281
|
+
_ComputerUse_to_mldev(getv(from_object, ['computer_use']), to_object),
|
3284
3282
|
)
|
3285
3283
|
|
3286
3284
|
if getv(from_object, ['code_execution']) is not None:
|
@@ -3352,9 +3350,7 @@ def _Tool_to_vertex(
|
|
3352
3350
|
setv(
|
3353
3351
|
to_object,
|
3354
3352
|
['computerUse'],
|
3355
|
-
|
3356
|
-
getv(from_object, ['computer_use']), to_object
|
3357
|
-
),
|
3353
|
+
_ComputerUse_to_vertex(getv(from_object, ['computer_use']), to_object),
|
3358
3354
|
)
|
3359
3355
|
|
3360
3356
|
if getv(from_object, ['code_execution']) is not None:
|
@@ -106,6 +106,24 @@ def _Blob_to_mldev(
|
|
106
106
|
return to_object
|
107
107
|
|
108
108
|
|
109
|
+
def _ComputerUse_to_mldev(
|
110
|
+
from_object: Union[dict[str, Any], object],
|
111
|
+
parent_object: Optional[dict[str, Any]] = None,
|
112
|
+
) -> dict[str, Any]:
|
113
|
+
to_object: dict[str, Any] = {}
|
114
|
+
if getv(from_object, ['environment']) is not None:
|
115
|
+
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
116
|
+
|
117
|
+
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
118
|
+
setv(
|
119
|
+
to_object,
|
120
|
+
['excludedPredefinedFunctions'],
|
121
|
+
getv(from_object, ['excluded_predefined_functions']),
|
122
|
+
)
|
123
|
+
|
124
|
+
return to_object
|
125
|
+
|
126
|
+
|
109
127
|
def _Content_to_mldev(
|
110
128
|
from_object: Union[dict[str, Any], object],
|
111
129
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -743,24 +761,6 @@ def _SpeechConfig_to_mldev(
|
|
743
761
|
return to_object
|
744
762
|
|
745
763
|
|
746
|
-
def _ToolComputerUse_to_mldev(
|
747
|
-
from_object: Union[dict[str, Any], object],
|
748
|
-
parent_object: Optional[dict[str, Any]] = None,
|
749
|
-
) -> dict[str, Any]:
|
750
|
-
to_object: dict[str, Any] = {}
|
751
|
-
if getv(from_object, ['environment']) is not None:
|
752
|
-
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
753
|
-
|
754
|
-
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
755
|
-
setv(
|
756
|
-
to_object,
|
757
|
-
['excludedPredefinedFunctions'],
|
758
|
-
getv(from_object, ['excluded_predefined_functions']),
|
759
|
-
)
|
760
|
-
|
761
|
-
return to_object
|
762
|
-
|
763
|
-
|
764
764
|
def _Tool_to_mldev(
|
765
765
|
from_object: Union[dict[str, Any], object],
|
766
766
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -814,9 +814,7 @@ def _Tool_to_mldev(
|
|
814
814
|
setv(
|
815
815
|
to_object,
|
816
816
|
['computerUse'],
|
817
|
-
|
818
|
-
getv(from_object, ['computer_use']), to_object
|
819
|
-
),
|
817
|
+
_ComputerUse_to_mldev(getv(from_object, ['computer_use']), to_object),
|
820
818
|
)
|
821
819
|
|
822
820
|
if getv(from_object, ['code_execution']) is not None:
|
google/genai/batches.py
CHANGED
@@ -467,6 +467,24 @@ def _CitationMetadata_from_mldev(
|
|
467
467
|
return to_object
|
468
468
|
|
469
469
|
|
470
|
+
def _ComputerUse_to_mldev(
|
471
|
+
from_object: Union[dict[str, Any], object],
|
472
|
+
parent_object: Optional[dict[str, Any]] = None,
|
473
|
+
) -> dict[str, Any]:
|
474
|
+
to_object: dict[str, Any] = {}
|
475
|
+
if getv(from_object, ['environment']) is not None:
|
476
|
+
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
477
|
+
|
478
|
+
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
479
|
+
setv(
|
480
|
+
to_object,
|
481
|
+
['excludedPredefinedFunctions'],
|
482
|
+
getv(from_object, ['excluded_predefined_functions']),
|
483
|
+
)
|
484
|
+
|
485
|
+
return to_object
|
486
|
+
|
487
|
+
|
470
488
|
def _ContentEmbedding_from_mldev(
|
471
489
|
from_object: Union[dict[str, Any], object],
|
472
490
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -1131,6 +1149,13 @@ def _GenerateContentConfig_to_mldev(
|
|
1131
1149
|
),
|
1132
1150
|
)
|
1133
1151
|
|
1152
|
+
if getv(from_object, ['image_config']) is not None:
|
1153
|
+
setv(
|
1154
|
+
to_object,
|
1155
|
+
['imageConfig'],
|
1156
|
+
_ImageConfig_to_mldev(getv(from_object, ['image_config']), to_object),
|
1157
|
+
)
|
1158
|
+
|
1134
1159
|
return to_object
|
1135
1160
|
|
1136
1161
|
|
@@ -1238,6 +1263,17 @@ def _GoogleSearch_to_mldev(
|
|
1238
1263
|
return to_object
|
1239
1264
|
|
1240
1265
|
|
1266
|
+
def _ImageConfig_to_mldev(
|
1267
|
+
from_object: Union[dict[str, Any], object],
|
1268
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1269
|
+
) -> dict[str, Any]:
|
1270
|
+
to_object: dict[str, Any] = {}
|
1271
|
+
if getv(from_object, ['aspect_ratio']) is not None:
|
1272
|
+
setv(to_object, ['aspectRatio'], getv(from_object, ['aspect_ratio']))
|
1273
|
+
|
1274
|
+
return to_object
|
1275
|
+
|
1276
|
+
|
1241
1277
|
def _InlinedEmbedContentResponse_from_mldev(
|
1242
1278
|
from_object: Union[dict[str, Any], object],
|
1243
1279
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -1877,24 +1913,6 @@ def _ThinkingConfig_to_mldev(
|
|
1877
1913
|
return to_object
|
1878
1914
|
|
1879
1915
|
|
1880
|
-
def _ToolComputerUse_to_mldev(
|
1881
|
-
from_object: Union[dict[str, Any], object],
|
1882
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1883
|
-
) -> dict[str, Any]:
|
1884
|
-
to_object: dict[str, Any] = {}
|
1885
|
-
if getv(from_object, ['environment']) is not None:
|
1886
|
-
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
1887
|
-
|
1888
|
-
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
1889
|
-
setv(
|
1890
|
-
to_object,
|
1891
|
-
['excludedPredefinedFunctions'],
|
1892
|
-
getv(from_object, ['excluded_predefined_functions']),
|
1893
|
-
)
|
1894
|
-
|
1895
|
-
return to_object
|
1896
|
-
|
1897
|
-
|
1898
1916
|
def _ToolConfig_to_mldev(
|
1899
1917
|
from_object: Union[dict[str, Any], object],
|
1900
1918
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -1974,9 +1992,7 @@ def _Tool_to_mldev(
|
|
1974
1992
|
setv(
|
1975
1993
|
to_object,
|
1976
1994
|
['computerUse'],
|
1977
|
-
|
1978
|
-
getv(from_object, ['computer_use']), to_object
|
1979
|
-
),
|
1995
|
+
_ComputerUse_to_mldev(getv(from_object, ['computer_use']), to_object),
|
1980
1996
|
)
|
1981
1997
|
|
1982
1998
|
if getv(from_object, ['code_execution']) is not None:
|
google/genai/caches.py
CHANGED
@@ -181,6 +181,42 @@ def _CachedContent_from_vertex(
|
|
181
181
|
return to_object
|
182
182
|
|
183
183
|
|
184
|
+
def _ComputerUse_to_mldev(
|
185
|
+
from_object: Union[dict[str, Any], object],
|
186
|
+
parent_object: Optional[dict[str, Any]] = None,
|
187
|
+
) -> dict[str, Any]:
|
188
|
+
to_object: dict[str, Any] = {}
|
189
|
+
if getv(from_object, ['environment']) is not None:
|
190
|
+
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
191
|
+
|
192
|
+
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
193
|
+
setv(
|
194
|
+
to_object,
|
195
|
+
['excludedPredefinedFunctions'],
|
196
|
+
getv(from_object, ['excluded_predefined_functions']),
|
197
|
+
)
|
198
|
+
|
199
|
+
return to_object
|
200
|
+
|
201
|
+
|
202
|
+
def _ComputerUse_to_vertex(
|
203
|
+
from_object: Union[dict[str, Any], object],
|
204
|
+
parent_object: Optional[dict[str, Any]] = None,
|
205
|
+
) -> dict[str, Any]:
|
206
|
+
to_object: dict[str, Any] = {}
|
207
|
+
if getv(from_object, ['environment']) is not None:
|
208
|
+
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
209
|
+
|
210
|
+
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
211
|
+
setv(
|
212
|
+
to_object,
|
213
|
+
['excludedPredefinedFunctions'],
|
214
|
+
getv(from_object, ['excluded_predefined_functions']),
|
215
|
+
)
|
216
|
+
|
217
|
+
return to_object
|
218
|
+
|
219
|
+
|
184
220
|
def _Content_to_mldev(
|
185
221
|
from_object: Union[dict[str, Any], object],
|
186
222
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -1135,42 +1171,6 @@ def _RetrievalConfig_to_vertex(
|
|
1135
1171
|
return to_object
|
1136
1172
|
|
1137
1173
|
|
1138
|
-
def _ToolComputerUse_to_mldev(
|
1139
|
-
from_object: Union[dict[str, Any], object],
|
1140
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1141
|
-
) -> dict[str, Any]:
|
1142
|
-
to_object: dict[str, Any] = {}
|
1143
|
-
if getv(from_object, ['environment']) is not None:
|
1144
|
-
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
1145
|
-
|
1146
|
-
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
1147
|
-
setv(
|
1148
|
-
to_object,
|
1149
|
-
['excludedPredefinedFunctions'],
|
1150
|
-
getv(from_object, ['excluded_predefined_functions']),
|
1151
|
-
)
|
1152
|
-
|
1153
|
-
return to_object
|
1154
|
-
|
1155
|
-
|
1156
|
-
def _ToolComputerUse_to_vertex(
|
1157
|
-
from_object: Union[dict[str, Any], object],
|
1158
|
-
parent_object: Optional[dict[str, Any]] = None,
|
1159
|
-
) -> dict[str, Any]:
|
1160
|
-
to_object: dict[str, Any] = {}
|
1161
|
-
if getv(from_object, ['environment']) is not None:
|
1162
|
-
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
1163
|
-
|
1164
|
-
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
1165
|
-
setv(
|
1166
|
-
to_object,
|
1167
|
-
['excludedPredefinedFunctions'],
|
1168
|
-
getv(from_object, ['excluded_predefined_functions']),
|
1169
|
-
)
|
1170
|
-
|
1171
|
-
return to_object
|
1172
|
-
|
1173
|
-
|
1174
1174
|
def _ToolConfig_to_mldev(
|
1175
1175
|
from_object: Union[dict[str, Any], object],
|
1176
1176
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -1276,9 +1276,7 @@ def _Tool_to_mldev(
|
|
1276
1276
|
setv(
|
1277
1277
|
to_object,
|
1278
1278
|
['computerUse'],
|
1279
|
-
|
1280
|
-
getv(from_object, ['computer_use']), to_object
|
1281
|
-
),
|
1279
|
+
_ComputerUse_to_mldev(getv(from_object, ['computer_use']), to_object),
|
1282
1280
|
)
|
1283
1281
|
|
1284
1282
|
if getv(from_object, ['code_execution']) is not None:
|
@@ -1350,9 +1348,7 @@ def _Tool_to_vertex(
|
|
1350
1348
|
setv(
|
1351
1349
|
to_object,
|
1352
1350
|
['computerUse'],
|
1353
|
-
|
1354
|
-
getv(from_object, ['computer_use']), to_object
|
1355
|
-
),
|
1351
|
+
_ComputerUse_to_vertex(getv(from_object, ['computer_use']), to_object),
|
1356
1352
|
)
|
1357
1353
|
|
1358
1354
|
if getv(from_object, ['code_execution']) is not None:
|
google/genai/live.py
CHANGED
@@ -82,9 +82,15 @@ _FUNCTION_RESPONSE_REQUIRES_ID = (
|
|
82
82
|
class AsyncSession:
|
83
83
|
"""[Preview] AsyncSession."""
|
84
84
|
|
85
|
-
def __init__(
|
85
|
+
def __init__(
|
86
|
+
self,
|
87
|
+
api_client: BaseApiClient,
|
88
|
+
websocket: ClientConnection,
|
89
|
+
session_id: Optional[str] = None,
|
90
|
+
):
|
86
91
|
self._api_client = api_client
|
87
92
|
self._ws = websocket
|
93
|
+
self.session_id = session_id
|
88
94
|
|
89
95
|
async def send(
|
90
96
|
self,
|
@@ -1054,11 +1060,34 @@ class AsyncLive(_api_module.BaseModule):
|
|
1054
1060
|
await ws.send(request)
|
1055
1061
|
try:
|
1056
1062
|
# websockets 14.0+
|
1057
|
-
|
1063
|
+
raw_response = await ws.recv(decode=False)
|
1058
1064
|
except TypeError:
|
1059
|
-
|
1065
|
+
raw_response = await ws.recv() # type: ignore[assignment]
|
1066
|
+
if raw_response:
|
1067
|
+
try:
|
1068
|
+
response = json.loads(raw_response)
|
1069
|
+
except json.decoder.JSONDecodeError:
|
1070
|
+
raise ValueError(f'Failed to parse response: {raw_response!r}')
|
1071
|
+
else:
|
1072
|
+
response = {}
|
1060
1073
|
|
1061
|
-
|
1074
|
+
if self._api_client.vertexai:
|
1075
|
+
response_dict = live_converters._LiveServerMessage_from_vertex(response)
|
1076
|
+
else:
|
1077
|
+
response_dict = live_converters._LiveServerMessage_from_mldev(response)
|
1078
|
+
|
1079
|
+
setup_response = types.LiveServerMessage._from_response(
|
1080
|
+
response=response_dict, kwargs=parameter_model.model_dump()
|
1081
|
+
)
|
1082
|
+
if setup_response.setup_complete:
|
1083
|
+
session_id = setup_response.setup_complete.session_id
|
1084
|
+
else:
|
1085
|
+
session_id = None
|
1086
|
+
yield AsyncSession(
|
1087
|
+
api_client=self._api_client,
|
1088
|
+
websocket=ws,
|
1089
|
+
session_id=session_id,
|
1090
|
+
)
|
1062
1091
|
|
1063
1092
|
|
1064
1093
|
async def _t_live_connect_config(
|
google/genai/models.py
CHANGED
@@ -366,6 +366,42 @@ def _ComputeTokensResponse_from_vertex(
|
|
366
366
|
return to_object
|
367
367
|
|
368
368
|
|
369
|
+
def _ComputerUse_to_mldev(
|
370
|
+
from_object: Union[dict[str, Any], object],
|
371
|
+
parent_object: Optional[dict[str, Any]] = None,
|
372
|
+
) -> dict[str, Any]:
|
373
|
+
to_object: dict[str, Any] = {}
|
374
|
+
if getv(from_object, ['environment']) is not None:
|
375
|
+
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
376
|
+
|
377
|
+
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
378
|
+
setv(
|
379
|
+
to_object,
|
380
|
+
['excludedPredefinedFunctions'],
|
381
|
+
getv(from_object, ['excluded_predefined_functions']),
|
382
|
+
)
|
383
|
+
|
384
|
+
return to_object
|
385
|
+
|
386
|
+
|
387
|
+
def _ComputerUse_to_vertex(
|
388
|
+
from_object: Union[dict[str, Any], object],
|
389
|
+
parent_object: Optional[dict[str, Any]] = None,
|
390
|
+
) -> dict[str, Any]:
|
391
|
+
to_object: dict[str, Any] = {}
|
392
|
+
if getv(from_object, ['environment']) is not None:
|
393
|
+
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
394
|
+
|
395
|
+
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
396
|
+
setv(
|
397
|
+
to_object,
|
398
|
+
['excludedPredefinedFunctions'],
|
399
|
+
getv(from_object, ['excluded_predefined_functions']),
|
400
|
+
)
|
401
|
+
|
402
|
+
return to_object
|
403
|
+
|
404
|
+
|
369
405
|
def _ContentEmbeddingStatistics_from_vertex(
|
370
406
|
from_object: Union[dict[str, Any], object],
|
371
407
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -1602,6 +1638,13 @@ def _GenerateContentConfig_to_mldev(
|
|
1602
1638
|
),
|
1603
1639
|
)
|
1604
1640
|
|
1641
|
+
if getv(from_object, ['image_config']) is not None:
|
1642
|
+
setv(
|
1643
|
+
to_object,
|
1644
|
+
['imageConfig'],
|
1645
|
+
_ImageConfig_to_mldev(getv(from_object, ['image_config']), to_object),
|
1646
|
+
)
|
1647
|
+
|
1605
1648
|
return to_object
|
1606
1649
|
|
1607
1650
|
|
@@ -1774,6 +1817,13 @@ def _GenerateContentConfig_to_vertex(
|
|
1774
1817
|
),
|
1775
1818
|
)
|
1776
1819
|
|
1820
|
+
if getv(from_object, ['image_config']) is not None:
|
1821
|
+
setv(
|
1822
|
+
to_object,
|
1823
|
+
['imageConfig'],
|
1824
|
+
_ImageConfig_to_vertex(getv(from_object, ['image_config']), to_object),
|
1825
|
+
)
|
1826
|
+
|
1777
1827
|
return to_object
|
1778
1828
|
|
1779
1829
|
|
@@ -2960,6 +3010,28 @@ def _GoogleSearch_to_vertex(
|
|
2960
3010
|
return to_object
|
2961
3011
|
|
2962
3012
|
|
3013
|
+
def _ImageConfig_to_mldev(
|
3014
|
+
from_object: Union[dict[str, Any], object],
|
3015
|
+
parent_object: Optional[dict[str, Any]] = None,
|
3016
|
+
) -> dict[str, Any]:
|
3017
|
+
to_object: dict[str, Any] = {}
|
3018
|
+
if getv(from_object, ['aspect_ratio']) is not None:
|
3019
|
+
setv(to_object, ['aspectRatio'], getv(from_object, ['aspect_ratio']))
|
3020
|
+
|
3021
|
+
return to_object
|
3022
|
+
|
3023
|
+
|
3024
|
+
def _ImageConfig_to_vertex(
|
3025
|
+
from_object: Union[dict[str, Any], object],
|
3026
|
+
parent_object: Optional[dict[str, Any]] = None,
|
3027
|
+
) -> dict[str, Any]:
|
3028
|
+
to_object: dict[str, Any] = {}
|
3029
|
+
if getv(from_object, ['aspect_ratio']) is not None:
|
3030
|
+
setv(to_object, ['aspectRatio'], getv(from_object, ['aspect_ratio']))
|
3031
|
+
|
3032
|
+
return to_object
|
3033
|
+
|
3034
|
+
|
2963
3035
|
def _Image_from_mldev(
|
2964
3036
|
from_object: Union[dict[str, Any], object],
|
2965
3037
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -4467,42 +4539,6 @@ def _ThinkingConfig_to_vertex(
|
|
4467
4539
|
return to_object
|
4468
4540
|
|
4469
4541
|
|
4470
|
-
def _ToolComputerUse_to_mldev(
|
4471
|
-
from_object: Union[dict[str, Any], object],
|
4472
|
-
parent_object: Optional[dict[str, Any]] = None,
|
4473
|
-
) -> dict[str, Any]:
|
4474
|
-
to_object: dict[str, Any] = {}
|
4475
|
-
if getv(from_object, ['environment']) is not None:
|
4476
|
-
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
4477
|
-
|
4478
|
-
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
4479
|
-
setv(
|
4480
|
-
to_object,
|
4481
|
-
['excludedPredefinedFunctions'],
|
4482
|
-
getv(from_object, ['excluded_predefined_functions']),
|
4483
|
-
)
|
4484
|
-
|
4485
|
-
return to_object
|
4486
|
-
|
4487
|
-
|
4488
|
-
def _ToolComputerUse_to_vertex(
|
4489
|
-
from_object: Union[dict[str, Any], object],
|
4490
|
-
parent_object: Optional[dict[str, Any]] = None,
|
4491
|
-
) -> dict[str, Any]:
|
4492
|
-
to_object: dict[str, Any] = {}
|
4493
|
-
if getv(from_object, ['environment']) is not None:
|
4494
|
-
setv(to_object, ['environment'], getv(from_object, ['environment']))
|
4495
|
-
|
4496
|
-
if getv(from_object, ['excluded_predefined_functions']) is not None:
|
4497
|
-
setv(
|
4498
|
-
to_object,
|
4499
|
-
['excludedPredefinedFunctions'],
|
4500
|
-
getv(from_object, ['excluded_predefined_functions']),
|
4501
|
-
)
|
4502
|
-
|
4503
|
-
return to_object
|
4504
|
-
|
4505
|
-
|
4506
4542
|
def _ToolConfig_to_mldev(
|
4507
4543
|
from_object: Union[dict[str, Any], object],
|
4508
4544
|
parent_object: Optional[dict[str, Any]] = None,
|
@@ -4608,9 +4644,7 @@ def _Tool_to_mldev(
|
|
4608
4644
|
setv(
|
4609
4645
|
to_object,
|
4610
4646
|
['computerUse'],
|
4611
|
-
|
4612
|
-
getv(from_object, ['computer_use']), to_object
|
4613
|
-
),
|
4647
|
+
_ComputerUse_to_mldev(getv(from_object, ['computer_use']), to_object),
|
4614
4648
|
)
|
4615
4649
|
|
4616
4650
|
if getv(from_object, ['code_execution']) is not None:
|
@@ -4682,9 +4716,7 @@ def _Tool_to_vertex(
|
|
4682
4716
|
setv(
|
4683
4717
|
to_object,
|
4684
4718
|
['computerUse'],
|
4685
|
-
|
4686
|
-
getv(from_object, ['computer_use']), to_object
|
4687
|
-
),
|
4719
|
+
_ComputerUse_to_vertex(getv(from_object, ['computer_use']), to_object),
|
4688
4720
|
)
|
4689
4721
|
|
4690
4722
|
if getv(from_object, ['code_execution']) is not None:
|
google/genai/types.py
CHANGED
@@ -285,6 +285,8 @@ class FinishReason(_common.CaseInSensitiveEnum):
|
|
285
285
|
"""Token generation stopped because generated images have safety violations."""
|
286
286
|
UNEXPECTED_TOOL_CALL = 'UNEXPECTED_TOOL_CALL'
|
287
287
|
"""The tool call generated by the model is invalid."""
|
288
|
+
IMAGE_PROHIBITED_CONTENT = 'IMAGE_PROHIBITED_CONTENT'
|
289
|
+
"""Image generation stopped because the generated images have prohibited content."""
|
288
290
|
|
289
291
|
|
290
292
|
class HarmProbability(_common.CaseInSensitiveEnum):
|
@@ -2795,7 +2797,7 @@ class UrlContextDict(TypedDict, total=False):
|
|
2795
2797
|
UrlContextOrDict = Union[UrlContext, UrlContextDict]
|
2796
2798
|
|
2797
2799
|
|
2798
|
-
class
|
2800
|
+
class ComputerUse(_common.BaseModel):
|
2799
2801
|
"""Tool to support computer use."""
|
2800
2802
|
|
2801
2803
|
environment: Optional[Environment] = Field(
|
@@ -2811,7 +2813,7 @@ class ToolComputerUse(_common.BaseModel):
|
|
2811
2813
|
)
|
2812
2814
|
|
2813
2815
|
|
2814
|
-
class
|
2816
|
+
class ComputerUseDict(TypedDict, total=False):
|
2815
2817
|
"""Tool to support computer use."""
|
2816
2818
|
|
2817
2819
|
environment: Optional[Environment]
|
@@ -2825,7 +2827,7 @@ class ToolComputerUseDict(TypedDict, total=False):
|
|
2825
2827
|
2. Improving the definitions / instructions of predefined functions."""
|
2826
2828
|
|
2827
2829
|
|
2828
|
-
|
2830
|
+
ComputerUseOrDict = Union[ComputerUse, ComputerUseDict]
|
2829
2831
|
|
2830
2832
|
|
2831
2833
|
class ApiAuthApiKeyConfig(_common.BaseModel):
|
@@ -3422,7 +3424,7 @@ class Tool(_common.BaseModel):
|
|
3422
3424
|
default=None,
|
3423
3425
|
description="""Optional. Tool to support URL context retrieval.""",
|
3424
3426
|
)
|
3425
|
-
computer_use: Optional[
|
3427
|
+
computer_use: Optional[ComputerUse] = Field(
|
3426
3428
|
default=None,
|
3427
3429
|
description="""Optional. Tool to support the model interacting directly with the
|
3428
3430
|
computer. If enabled, it automatically populates computer-use specific
|
@@ -3461,7 +3463,7 @@ class ToolDict(TypedDict, total=False):
|
|
3461
3463
|
url_context: Optional[UrlContextDict]
|
3462
3464
|
"""Optional. Tool to support URL context retrieval."""
|
3463
3465
|
|
3464
|
-
computer_use: Optional[
|
3466
|
+
computer_use: Optional[ComputerUseDict]
|
3465
3467
|
"""Optional. Tool to support the model interacting directly with the
|
3466
3468
|
computer. If enabled, it automatically populates computer-use specific
|
3467
3469
|
Function Declarations."""
|
@@ -3826,6 +3828,27 @@ class ThinkingConfigDict(TypedDict, total=False):
|
|
3826
3828
|
ThinkingConfigOrDict = Union[ThinkingConfig, ThinkingConfigDict]
|
3827
3829
|
|
3828
3830
|
|
3831
|
+
class ImageConfig(_common.BaseModel):
|
3832
|
+
"""The image generation configuration to be used in GenerateContentConfig."""
|
3833
|
+
|
3834
|
+
aspect_ratio: Optional[str] = Field(
|
3835
|
+
default=None,
|
3836
|
+
description="""Aspect ratio of the generated images. Supported values are
|
3837
|
+
"1:1", "2:3", "3:2", "3:4", "4:3", "9:16", "16:9", and "21:9".""",
|
3838
|
+
)
|
3839
|
+
|
3840
|
+
|
3841
|
+
class ImageConfigDict(TypedDict, total=False):
|
3842
|
+
"""The image generation configuration to be used in GenerateContentConfig."""
|
3843
|
+
|
3844
|
+
aspect_ratio: Optional[str]
|
3845
|
+
"""Aspect ratio of the generated images. Supported values are
|
3846
|
+
"1:1", "2:3", "3:2", "3:4", "4:3", "9:16", "16:9", and "21:9"."""
|
3847
|
+
|
3848
|
+
|
3849
|
+
ImageConfigOrDict = Union[ImageConfig, ImageConfigDict]
|
3850
|
+
|
3851
|
+
|
3829
3852
|
class FileStatus(_common.BaseModel):
|
3830
3853
|
"""Status of a File that uses a common error model."""
|
3831
3854
|
|
@@ -4263,6 +4286,11 @@ class GenerateContentConfig(_common.BaseModel):
|
|
4263
4286
|
description="""The thinking features configuration.
|
4264
4287
|
""",
|
4265
4288
|
)
|
4289
|
+
image_config: Optional[ImageConfig] = Field(
|
4290
|
+
default=None,
|
4291
|
+
description="""The image generation configuration.
|
4292
|
+
""",
|
4293
|
+
)
|
4266
4294
|
|
4267
4295
|
@pydantic.field_validator('response_schema', mode='before')
|
4268
4296
|
@classmethod
|
@@ -4278,6 +4306,13 @@ class GenerateContentConfig(_common.BaseModel):
|
|
4278
4306
|
return Enum('PlaceholderLiteralEnum', {s: s for s in enum_vals})
|
4279
4307
|
return value
|
4280
4308
|
|
4309
|
+
@pydantic.field_validator('image_config', mode='before')
|
4310
|
+
@classmethod
|
4311
|
+
def _check_image_config_type(cls, value: Any) -> Any:
|
4312
|
+
if not isinstance(value, ImageConfig):
|
4313
|
+
raise ValueError('image_config must be an instance of ImageConfig.')
|
4314
|
+
return value
|
4315
|
+
|
4281
4316
|
|
4282
4317
|
class GenerateContentConfigDict(TypedDict, total=False):
|
4283
4318
|
"""Optional model configuration parameters.
|
@@ -4452,6 +4487,10 @@ class GenerateContentConfigDict(TypedDict, total=False):
|
|
4452
4487
|
"""The thinking features configuration.
|
4453
4488
|
"""
|
4454
4489
|
|
4490
|
+
image_config: Optional[ImageConfigDict]
|
4491
|
+
"""The image generation configuration.
|
4492
|
+
"""
|
4493
|
+
|
4455
4494
|
|
4456
4495
|
GenerateContentConfigOrDict = Union[
|
4457
4496
|
GenerateContentConfig, GenerateContentConfigDict
|
google/genai/version.py
CHANGED
@@ -7,33 +7,33 @@ google/genai/_base_transformers.py,sha256=wljA6m4tLl4XLGlBC2DNOls5N9-X9tffBq0M7i
|
|
7
7
|
google/genai/_base_url.py,sha256=E5H4dew14Y16qfnB3XRnjSCi19cJVlkaMNoM_8ip-PM,1597
|
8
8
|
google/genai/_common.py,sha256=YU5842SoZOW0usJRnz58Wi8hqJ1f-Dd01flGTsqI8-U,20653
|
9
9
|
google/genai/_extra_utils.py,sha256=myEPyU_-RXExXtMGitJUKEMWUPiDudScgTN9LqFC8h4,20468
|
10
|
-
google/genai/_live_converters.py,sha256=
|
10
|
+
google/genai/_live_converters.py,sha256=6Ei_jePRUAxcRM53BbXeiB0eecRmFhEa9S8Sxea_MPg,107972
|
11
11
|
google/genai/_local_tokenizer_loader.py,sha256=cGN1F0f7hNjRIGCGTLeox7IGAZf_YcvZjSp2rCyhUak,7465
|
12
12
|
google/genai/_mcp_utils.py,sha256=HuWJ8FUjquv40Mf_QjcL5r5yXWrS-JjINsjlOSbbyAc,3870
|
13
13
|
google/genai/_operations_converters.py,sha256=hPmrlU_yJWT4di2arA0VKaoQIB1MbCPglmAZ4D8M-Ds,8744
|
14
14
|
google/genai/_replay_api_client.py,sha256=MmpzqE5AxVeyvCahEnmukYGIZqN8lxS-suSgUszvLSw,22555
|
15
15
|
google/genai/_test_api_client.py,sha256=4ruFIy5_1qcbKqqIBu3HSQbpSOBrxiecBtDZaTGFR1s,4797
|
16
|
-
google/genai/_tokens_converters.py,sha256=
|
16
|
+
google/genai/_tokens_converters.py,sha256=J8Ji9E7dvfxNExAG8QBjiY69nArqEPXrJh6zV3_FyZU,25143
|
17
17
|
google/genai/_transformers.py,sha256=-1GIrDNS4fH6Qx2jNm-VhcmlTSjWxanna7N7Tp_ctQ8,40861
|
18
|
-
google/genai/batches.py,sha256=
|
19
|
-
google/genai/caches.py,sha256
|
18
|
+
google/genai/batches.py,sha256=Xs4pZ6t8sjKGZ2N3ATOPFbobDgWxduSqc9-Zpo2Sdj8,102539
|
19
|
+
google/genai/caches.py,sha256=xq3kZBpUoc7Tv6In15gDOrKBnzfeIG3lCBY4zM8Y2sQ,67127
|
20
20
|
google/genai/chats.py,sha256=pIBw8d13llupLn4a7vP6vnpbzDcvCCrZZ-Q2r8Cvo7g,16652
|
21
21
|
google/genai/client.py,sha256=bwKV5gHKpxzmfFTtoudQ_hEz5QfUzKYMJHYT-AnQfNU,13066
|
22
22
|
google/genai/errors.py,sha256=zaPEs_GrtZuypvSPnOe32CTHO6nEVtshvc3Av2ug2Ac,5822
|
23
23
|
google/genai/files.py,sha256=wNM0k9Hab8I7STThiZtA8BdRDaj6fNIdN7DxMr8zzxc,40211
|
24
|
-
google/genai/live.py,sha256=
|
24
|
+
google/genai/live.py,sha256=PM5fXqhURdrdyM7AVCH_ogLe8_Zzhixzz2rXWm0FHxA,40590
|
25
25
|
google/genai/live_music.py,sha256=3GG9nsto8Vhkohcs-4CPMS4DFp1ZtMuLYzHfvEPYAeg,6971
|
26
26
|
google/genai/local_tokenizer.py,sha256=EKZ72cV2Zfutlo_efMOPnLRNZN4WQe57rD3G80cF340,14109
|
27
|
-
google/genai/models.py,sha256=
|
27
|
+
google/genai/models.py,sha256=2Rnjqhh2AsZZiqN6c8LK4Z_O0XhP7gpSb7MU9DypHqU,267634
|
28
28
|
google/genai/operations.py,sha256=mgRuVCoqUf7z0RfB84W9x7S839VCttmIQZkXovHAMrE,17061
|
29
29
|
google/genai/pagers.py,sha256=m0SfWWn1EJs2k1On3DZx371qb8g2BRm_188ExsicIRc,7098
|
30
30
|
google/genai/py.typed,sha256=RsMFoLwBkAvY05t6izop4UHZtqOPLiKp3GkIEizzmQY,40
|
31
31
|
google/genai/tokens.py,sha256=8RbZ0kgvyKT3SwbgIUOHr6TTZL24v4fqYarhlA8r1ac,12503
|
32
32
|
google/genai/tunings.py,sha256=_VzlKhlqFQHB7Lt4vU1HfGD11E5iolDfPdWrnigu5pw,62885
|
33
|
-
google/genai/types.py,sha256=
|
34
|
-
google/genai/version.py,sha256=
|
35
|
-
google_genai-1.
|
36
|
-
google_genai-1.
|
37
|
-
google_genai-1.
|
38
|
-
google_genai-1.
|
39
|
-
google_genai-1.
|
33
|
+
google/genai/types.py,sha256=Njz3WlXFGn8syv2ULSQe-TDuNXlDkjimeXeSIuEwsD0,552187
|
34
|
+
google/genai/version.py,sha256=YopdGBhZLesh97vOAU0CgtyVJve3kdnqv76cpaBukgg,627
|
35
|
+
google_genai-1.40.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
36
|
+
google_genai-1.40.0.dist-info/METADATA,sha256=j_xEOkXs3OwigTSP80GPgYULWKFtCq9vGpJ2Q9TdEuQ,45381
|
37
|
+
google_genai-1.40.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
38
|
+
google_genai-1.40.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
|
39
|
+
google_genai-1.40.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|