google-genai 1.14.0__py3-none-any.whl → 1.16.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/__init__.py +5 -3
- google/genai/_adapters.py +55 -0
- google/genai/_api_client.py +24 -20
- google/genai/_api_module.py +1 -1
- google/genai/_automatic_function_calling_util.py +2 -2
- google/genai/_common.py +1 -1
- google/genai/_extra_utils.py +117 -9
- google/genai/_live_converters.py +2127 -758
- google/genai/_mcp_utils.py +117 -0
- google/genai/_replay_api_client.py +1 -1
- google/genai/_test_api_client.py +1 -1
- google/genai/_tokens_converters.py +1701 -0
- google/genai/_transformers.py +66 -33
- google/genai/caches.py +277 -26
- google/genai/chats.py +1 -1
- google/genai/client.py +12 -1
- google/genai/errors.py +1 -1
- google/genai/live.py +218 -35
- google/genai/live_music.py +201 -0
- google/genai/models.py +670 -56
- google/genai/pagers.py +1 -1
- google/genai/tokens.py +357 -0
- google/genai/tunings.py +53 -0
- google/genai/types.py +4892 -3606
- google/genai/version.py +2 -2
- {google_genai-1.14.0.dist-info → google_genai-1.16.0.dist-info}/METADATA +111 -22
- google_genai-1.16.0.dist-info/RECORD +35 -0
- {google_genai-1.14.0.dist-info → google_genai-1.16.0.dist-info}/WHEEL +1 -1
- google_genai-1.14.0.dist-info/RECORD +0 -30
- {google_genai-1.14.0.dist-info → google_genai-1.16.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.14.0.dist-info → google_genai-1.16.0.dist-info}/top_level.txt +0 -0
google/genai/_transformers.py
CHANGED
@@ -27,6 +27,7 @@ import time
|
|
27
27
|
import types as builtin_types
|
28
28
|
import typing
|
29
29
|
from typing import Any, GenericAlias, Optional, Sequence, Union # type: ignore[attr-defined]
|
30
|
+
from ._mcp_utils import mcp_to_gemini_tool
|
30
31
|
|
31
32
|
if typing.TYPE_CHECKING:
|
32
33
|
import PIL.Image
|
@@ -47,6 +48,20 @@ else:
|
|
47
48
|
_UNION_TYPES = (typing.Union,)
|
48
49
|
from typing_extensions import TypeGuard
|
49
50
|
|
51
|
+
if typing.TYPE_CHECKING:
|
52
|
+
from mcp import ClientSession as McpClientSession
|
53
|
+
from mcp.types import Tool as McpTool
|
54
|
+
else:
|
55
|
+
McpClientSession: typing.Type = Any
|
56
|
+
McpTool: typing.Type = Any
|
57
|
+
try:
|
58
|
+
from mcp import ClientSession as McpClientSession
|
59
|
+
from mcp.types import Tool as McpTool
|
60
|
+
except ImportError:
|
61
|
+
McpClientSession = None
|
62
|
+
McpTool = None
|
63
|
+
|
64
|
+
|
50
65
|
def _resource_name(
|
51
66
|
client: _api_client.BaseApiClient,
|
52
67
|
resource_name: str,
|
@@ -211,7 +226,9 @@ def t_extract_models(
|
|
211
226
|
return []
|
212
227
|
|
213
228
|
|
214
|
-
def t_caches_model(
|
229
|
+
def t_caches_model(
|
230
|
+
api_client: _api_client.BaseApiClient, model: str
|
231
|
+
) -> Optional[str]:
|
215
232
|
model = t_model(api_client, model)
|
216
233
|
if not model:
|
217
234
|
return None
|
@@ -262,10 +279,11 @@ def t_function_response(
|
|
262
279
|
return function_response
|
263
280
|
else:
|
264
281
|
raise TypeError(
|
265
|
-
|
282
|
+
'Could not parse input as FunctionResponse. Unsupported'
|
266
283
|
f' function_response type: {type(function_response)}'
|
267
284
|
)
|
268
285
|
|
286
|
+
|
269
287
|
def t_function_responses(
|
270
288
|
function_responses: Union[
|
271
289
|
types.FunctionResponseOrDict,
|
@@ -361,7 +379,9 @@ def t_part(part: Optional[types.PartUnionDict]) -> types.Part:
|
|
361
379
|
|
362
380
|
|
363
381
|
def t_parts(
|
364
|
-
parts: Optional[
|
382
|
+
parts: Optional[
|
383
|
+
Union[list[types.PartUnionDict], types.PartUnionDict, list[types.Part]]
|
384
|
+
],
|
365
385
|
) -> list[types.Part]:
|
366
386
|
#
|
367
387
|
if parts is None or (isinstance(parts, list) and not parts):
|
@@ -442,9 +462,7 @@ def t_contents_for_embed(
|
|
442
462
|
if part.text:
|
443
463
|
text_parts.append(part.text)
|
444
464
|
else:
|
445
|
-
logger.warning(
|
446
|
-
f'Non-text part found, only returning text parts.'
|
447
|
-
)
|
465
|
+
logger.warning(f'Non-text part found, only returning text parts.')
|
448
466
|
return text_parts
|
449
467
|
else:
|
450
468
|
return transformed_contents
|
@@ -471,7 +489,9 @@ def t_contents(
|
|
471
489
|
result: list[types.Content] = []
|
472
490
|
accumulated_parts: list[types.Part] = []
|
473
491
|
|
474
|
-
def _is_part(
|
492
|
+
def _is_part(
|
493
|
+
part: Union[types.PartUnionDict, Any],
|
494
|
+
) -> TypeGuard[types.PartUnionDict]:
|
475
495
|
if (
|
476
496
|
isinstance(part, str)
|
477
497
|
or isinstance(part, types.File)
|
@@ -538,7 +558,7 @@ def t_contents(
|
|
538
558
|
result.append(types.UserContent(parts=content)) # type: ignore[arg-type]
|
539
559
|
else:
|
540
560
|
result.append(content)
|
541
|
-
elif
|
561
|
+
elif _is_part(content):
|
542
562
|
_handle_current_part(result, accumulated_parts, content)
|
543
563
|
elif isinstance(content, dict):
|
544
564
|
# PactDict is already handled in _is_part
|
@@ -777,7 +797,9 @@ def _process_enum(
|
|
777
797
|
return types.Schema.model_validate(enum_schema)
|
778
798
|
|
779
799
|
|
780
|
-
def _is_type_dict_str_any(
|
800
|
+
def _is_type_dict_str_any(
|
801
|
+
origin: Union[types.SchemaUnionDict, Any],
|
802
|
+
) -> TypeGuard[dict[str, Any]]:
|
781
803
|
"""Verifies the schema is of type dict[str, Any] for mypy type checking."""
|
782
804
|
return isinstance(origin, dict) and all(
|
783
805
|
isinstance(key, str) for key in origin
|
@@ -844,27 +866,32 @@ def t_speech_config(
|
|
844
866
|
prebuilt_voice_config=types.PrebuiltVoiceConfig(voice_name=origin)
|
845
867
|
)
|
846
868
|
)
|
847
|
-
if (
|
848
|
-
|
849
|
-
|
850
|
-
and origin['voice_config'] is not None
|
851
|
-
and 'prebuilt_voice_config' in origin['voice_config']
|
852
|
-
and origin['voice_config']['prebuilt_voice_config'] is not None
|
853
|
-
and 'voice_name' in origin['voice_config']['prebuilt_voice_config']
|
854
|
-
):
|
855
|
-
return types.SpeechConfig(
|
856
|
-
voice_config=types.VoiceConfig(
|
857
|
-
prebuilt_voice_config=types.PrebuiltVoiceConfig(
|
858
|
-
voice_name=origin['voice_config']['prebuilt_voice_config'].get(
|
859
|
-
'voice_name'
|
860
|
-
)
|
861
|
-
)
|
862
|
-
)
|
863
|
-
)
|
869
|
+
if isinstance(origin, dict):
|
870
|
+
return types.SpeechConfig.model_validate(origin)
|
871
|
+
|
864
872
|
raise ValueError(f'Unsupported speechConfig type: {type(origin)}')
|
865
873
|
|
866
874
|
|
867
|
-
def
|
875
|
+
def t_live_speech_config(
|
876
|
+
client: _api_client.BaseApiClient,
|
877
|
+
origin: types.SpeechConfigOrDict,
|
878
|
+
) -> Optional[types.SpeechConfig]:
|
879
|
+
if isinstance(origin, types.SpeechConfig):
|
880
|
+
speech_config = origin
|
881
|
+
if isinstance(origin, dict):
|
882
|
+
speech_config = types.SpeechConfig.model_validate(origin)
|
883
|
+
|
884
|
+
if speech_config.multi_speaker_voice_config is not None:
|
885
|
+
raise ValueError(
|
886
|
+
'multi_speaker_voice_config is not supported in the live API.'
|
887
|
+
)
|
888
|
+
|
889
|
+
return speech_config
|
890
|
+
|
891
|
+
|
892
|
+
def t_tool(
|
893
|
+
client: _api_client.BaseApiClient, origin: Any
|
894
|
+
) -> Optional[Union[types.Tool, Any]]:
|
868
895
|
if not origin:
|
869
896
|
return None
|
870
897
|
if inspect.isfunction(origin) or inspect.ismethod(origin):
|
@@ -875,13 +902,14 @@ def t_tool(client: _api_client.BaseApiClient, origin: Any) -> Optional[Union[typ
|
|
875
902
|
)
|
876
903
|
]
|
877
904
|
)
|
905
|
+
elif McpTool is not None and isinstance(origin, McpTool):
|
906
|
+
return mcp_to_gemini_tool(origin)
|
878
907
|
elif isinstance(origin, dict):
|
879
908
|
return types.Tool.model_validate(origin)
|
880
909
|
else:
|
881
910
|
return origin
|
882
911
|
|
883
912
|
|
884
|
-
# Only support functions now.
|
885
913
|
def t_tools(
|
886
914
|
client: _api_client.BaseApiClient, origin: list[Any]
|
887
915
|
) -> list[types.Tool]:
|
@@ -911,7 +939,9 @@ def t_cached_content_name(client: _api_client.BaseApiClient, name: str) -> str:
|
|
911
939
|
return _resource_name(client, name, collection_identifier='cachedContents')
|
912
940
|
|
913
941
|
|
914
|
-
def t_batch_job_source(
|
942
|
+
def t_batch_job_source(
|
943
|
+
client: _api_client.BaseApiClient, src: str
|
944
|
+
) -> types.BatchJobSource:
|
915
945
|
if src.startswith('gs://'):
|
916
946
|
return types.BatchJobSource(
|
917
947
|
format='jsonl',
|
@@ -926,7 +956,9 @@ def t_batch_job_source(client: _api_client.BaseApiClient, src: str) -> types.Bat
|
|
926
956
|
raise ValueError(f'Unsupported source: {src}')
|
927
957
|
|
928
958
|
|
929
|
-
def t_batch_job_destination(
|
959
|
+
def t_batch_job_destination(
|
960
|
+
client: _api_client.BaseApiClient, dest: str
|
961
|
+
) -> types.BatchJobDestination:
|
930
962
|
if dest.startswith('gs://'):
|
931
963
|
return types.BatchJobDestination(
|
932
964
|
format='jsonl',
|
@@ -960,7 +992,9 @@ LRO_POLLING_TIMEOUT_SECONDS = 900.0
|
|
960
992
|
LRO_POLLING_MULTIPLIER = 1.5
|
961
993
|
|
962
994
|
|
963
|
-
def t_resolve_operation(
|
995
|
+
def t_resolve_operation(
|
996
|
+
api_client: _api_client.BaseApiClient, struct: dict[str, Any]
|
997
|
+
) -> Any:
|
964
998
|
if (name := struct.get('name')) and '/operations/' in name:
|
965
999
|
operation: dict[str, Any] = struct
|
966
1000
|
total_seconds = 0.0
|
@@ -1058,8 +1092,7 @@ def t_content_strict(content: types.ContentOrDict) -> types.Content:
|
|
1058
1092
|
return content
|
1059
1093
|
else:
|
1060
1094
|
raise ValueError(
|
1061
|
-
f'Could not convert input (type "{type(content)}") to '
|
1062
|
-
'`types.Content`'
|
1095
|
+
f'Could not convert input (type "{type(content)}") to `types.Content`'
|
1063
1096
|
)
|
1064
1097
|
|
1065
1098
|
|
google/genai/caches.py
CHANGED
@@ -30,6 +30,42 @@ from .pagers import AsyncPager, Pager
|
|
30
30
|
logger = logging.getLogger('google_genai.caches')
|
31
31
|
|
32
32
|
|
33
|
+
def _VideoMetadata_to_mldev(
|
34
|
+
api_client: BaseApiClient,
|
35
|
+
from_object: Union[dict[str, Any], object],
|
36
|
+
parent_object: Optional[dict[str, Any]] = None,
|
37
|
+
) -> dict[str, Any]:
|
38
|
+
to_object: dict[str, Any] = {}
|
39
|
+
if getv(from_object, ['fps']) is not None:
|
40
|
+
setv(to_object, ['fps'], getv(from_object, ['fps']))
|
41
|
+
|
42
|
+
if getv(from_object, ['end_offset']) is not None:
|
43
|
+
setv(to_object, ['endOffset'], getv(from_object, ['end_offset']))
|
44
|
+
|
45
|
+
if getv(from_object, ['start_offset']) is not None:
|
46
|
+
setv(to_object, ['startOffset'], getv(from_object, ['start_offset']))
|
47
|
+
|
48
|
+
return to_object
|
49
|
+
|
50
|
+
|
51
|
+
def _Blob_to_mldev(
|
52
|
+
api_client: BaseApiClient,
|
53
|
+
from_object: Union[dict[str, Any], object],
|
54
|
+
parent_object: Optional[dict[str, Any]] = None,
|
55
|
+
) -> dict[str, Any]:
|
56
|
+
to_object: dict[str, Any] = {}
|
57
|
+
if getv(from_object, ['display_name']) is not None:
|
58
|
+
raise ValueError('display_name parameter is not supported in Gemini API.')
|
59
|
+
|
60
|
+
if getv(from_object, ['data']) is not None:
|
61
|
+
setv(to_object, ['data'], getv(from_object, ['data']))
|
62
|
+
|
63
|
+
if getv(from_object, ['mime_type']) is not None:
|
64
|
+
setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
|
65
|
+
|
66
|
+
return to_object
|
67
|
+
|
68
|
+
|
33
69
|
def _Part_to_mldev(
|
34
70
|
api_client: BaseApiClient,
|
35
71
|
from_object: Union[dict[str, Any], object],
|
@@ -37,11 +73,26 @@ def _Part_to_mldev(
|
|
37
73
|
) -> dict[str, Any]:
|
38
74
|
to_object: dict[str, Any] = {}
|
39
75
|
if getv(from_object, ['video_metadata']) is not None:
|
40
|
-
|
76
|
+
setv(
|
77
|
+
to_object,
|
78
|
+
['videoMetadata'],
|
79
|
+
_VideoMetadata_to_mldev(
|
80
|
+
api_client, getv(from_object, ['video_metadata']), to_object
|
81
|
+
),
|
82
|
+
)
|
41
83
|
|
42
84
|
if getv(from_object, ['thought']) is not None:
|
43
85
|
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
44
86
|
|
87
|
+
if getv(from_object, ['inline_data']) is not None:
|
88
|
+
setv(
|
89
|
+
to_object,
|
90
|
+
['inlineData'],
|
91
|
+
_Blob_to_mldev(
|
92
|
+
api_client, getv(from_object, ['inline_data']), to_object
|
93
|
+
),
|
94
|
+
)
|
95
|
+
|
45
96
|
if getv(from_object, ['code_execution_result']) is not None:
|
46
97
|
setv(
|
47
98
|
to_object,
|
@@ -65,9 +116,6 @@ def _Part_to_mldev(
|
|
65
116
|
getv(from_object, ['function_response']),
|
66
117
|
)
|
67
118
|
|
68
|
-
if getv(from_object, ['inline_data']) is not None:
|
69
|
-
setv(to_object, ['inlineData'], getv(from_object, ['inline_data']))
|
70
|
-
|
71
119
|
if getv(from_object, ['text']) is not None:
|
72
120
|
setv(to_object, ['text'], getv(from_object, ['text']))
|
73
121
|
|
@@ -96,12 +144,59 @@ def _Content_to_mldev(
|
|
96
144
|
return to_object
|
97
145
|
|
98
146
|
|
147
|
+
def _FunctionDeclaration_to_mldev(
|
148
|
+
api_client: BaseApiClient,
|
149
|
+
from_object: Union[dict[str, Any], object],
|
150
|
+
parent_object: Optional[dict[str, Any]] = None,
|
151
|
+
) -> dict[str, Any]:
|
152
|
+
to_object: dict[str, Any] = {}
|
153
|
+
if getv(from_object, ['behavior']) is not None:
|
154
|
+
setv(to_object, ['behavior'], getv(from_object, ['behavior']))
|
155
|
+
|
156
|
+
if getv(from_object, ['description']) is not None:
|
157
|
+
setv(to_object, ['description'], getv(from_object, ['description']))
|
158
|
+
|
159
|
+
if getv(from_object, ['name']) is not None:
|
160
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
161
|
+
|
162
|
+
if getv(from_object, ['parameters']) is not None:
|
163
|
+
setv(to_object, ['parameters'], getv(from_object, ['parameters']))
|
164
|
+
|
165
|
+
if getv(from_object, ['response']) is not None:
|
166
|
+
setv(to_object, ['response'], getv(from_object, ['response']))
|
167
|
+
|
168
|
+
return to_object
|
169
|
+
|
170
|
+
|
171
|
+
def _Interval_to_mldev(
|
172
|
+
api_client: BaseApiClient,
|
173
|
+
from_object: Union[dict[str, Any], object],
|
174
|
+
parent_object: Optional[dict[str, Any]] = None,
|
175
|
+
) -> dict[str, Any]:
|
176
|
+
to_object: dict[str, Any] = {}
|
177
|
+
if getv(from_object, ['start_time']) is not None:
|
178
|
+
setv(to_object, ['startTime'], getv(from_object, ['start_time']))
|
179
|
+
|
180
|
+
if getv(from_object, ['end_time']) is not None:
|
181
|
+
setv(to_object, ['endTime'], getv(from_object, ['end_time']))
|
182
|
+
|
183
|
+
return to_object
|
184
|
+
|
185
|
+
|
99
186
|
def _GoogleSearch_to_mldev(
|
100
187
|
api_client: BaseApiClient,
|
101
188
|
from_object: Union[dict[str, Any], object],
|
102
189
|
parent_object: Optional[dict[str, Any]] = None,
|
103
190
|
) -> dict[str, Any]:
|
104
191
|
to_object: dict[str, Any] = {}
|
192
|
+
if getv(from_object, ['time_range_filter']) is not None:
|
193
|
+
setv(
|
194
|
+
to_object,
|
195
|
+
['timeRangeFilter'],
|
196
|
+
_Interval_to_mldev(
|
197
|
+
api_client, getv(from_object, ['time_range_filter']), to_object
|
198
|
+
),
|
199
|
+
)
|
105
200
|
|
106
201
|
return to_object
|
107
202
|
|
@@ -214,12 +309,32 @@ def _GoogleMaps_to_mldev(
|
|
214
309
|
return to_object
|
215
310
|
|
216
311
|
|
312
|
+
def _UrlContext_to_mldev(
|
313
|
+
api_client: BaseApiClient,
|
314
|
+
from_object: Union[dict[str, Any], object],
|
315
|
+
parent_object: Optional[dict[str, Any]] = None,
|
316
|
+
) -> dict[str, Any]:
|
317
|
+
to_object: dict[str, Any] = {}
|
318
|
+
|
319
|
+
return to_object
|
320
|
+
|
321
|
+
|
217
322
|
def _Tool_to_mldev(
|
218
323
|
api_client: BaseApiClient,
|
219
324
|
from_object: Union[dict[str, Any], object],
|
220
325
|
parent_object: Optional[dict[str, Any]] = None,
|
221
326
|
) -> dict[str, Any]:
|
222
327
|
to_object: dict[str, Any] = {}
|
328
|
+
if getv(from_object, ['function_declarations']) is not None:
|
329
|
+
setv(
|
330
|
+
to_object,
|
331
|
+
['functionDeclarations'],
|
332
|
+
[
|
333
|
+
_FunctionDeclaration_to_mldev(api_client, item, to_object)
|
334
|
+
for item in getv(from_object, ['function_declarations'])
|
335
|
+
],
|
336
|
+
)
|
337
|
+
|
223
338
|
if getv(from_object, ['retrieval']) is not None:
|
224
339
|
raise ValueError('retrieval parameter is not supported in Gemini API.')
|
225
340
|
|
@@ -251,16 +366,18 @@ def _Tool_to_mldev(
|
|
251
366
|
if getv(from_object, ['google_maps']) is not None:
|
252
367
|
raise ValueError('google_maps parameter is not supported in Gemini API.')
|
253
368
|
|
254
|
-
if getv(from_object, ['
|
255
|
-
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
256
|
-
|
257
|
-
if getv(from_object, ['function_declarations']) is not None:
|
369
|
+
if getv(from_object, ['url_context']) is not None:
|
258
370
|
setv(
|
259
371
|
to_object,
|
260
|
-
['
|
261
|
-
|
372
|
+
['urlContext'],
|
373
|
+
_UrlContext_to_mldev(
|
374
|
+
api_client, getv(from_object, ['url_context']), to_object
|
375
|
+
),
|
262
376
|
)
|
263
377
|
|
378
|
+
if getv(from_object, ['code_execution']) is not None:
|
379
|
+
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
380
|
+
|
264
381
|
return to_object
|
265
382
|
|
266
383
|
|
@@ -290,10 +407,10 @@ def _LatLng_to_mldev(
|
|
290
407
|
) -> dict[str, Any]:
|
291
408
|
to_object: dict[str, Any] = {}
|
292
409
|
if getv(from_object, ['latitude']) is not None:
|
293
|
-
|
410
|
+
setv(to_object, ['latitude'], getv(from_object, ['latitude']))
|
294
411
|
|
295
412
|
if getv(from_object, ['longitude']) is not None:
|
296
|
-
|
413
|
+
setv(to_object, ['longitude'], getv(from_object, ['longitude']))
|
297
414
|
|
298
415
|
return to_object
|
299
416
|
|
@@ -305,7 +422,11 @@ def _RetrievalConfig_to_mldev(
|
|
305
422
|
) -> dict[str, Any]:
|
306
423
|
to_object: dict[str, Any] = {}
|
307
424
|
if getv(from_object, ['lat_lng']) is not None:
|
308
|
-
|
425
|
+
setv(
|
426
|
+
to_object,
|
427
|
+
['latLng'],
|
428
|
+
_LatLng_to_mldev(api_client, getv(from_object, ['lat_lng']), to_object),
|
429
|
+
)
|
309
430
|
|
310
431
|
return to_object
|
311
432
|
|
@@ -328,8 +449,12 @@ def _ToolConfig_to_mldev(
|
|
328
449
|
)
|
329
450
|
|
330
451
|
if getv(from_object, ['retrieval_config']) is not None:
|
331
|
-
|
332
|
-
|
452
|
+
setv(
|
453
|
+
to_object,
|
454
|
+
['retrievalConfig'],
|
455
|
+
_RetrievalConfig_to_mldev(
|
456
|
+
api_client, getv(from_object, ['retrieval_config']), to_object
|
457
|
+
),
|
333
458
|
)
|
334
459
|
|
335
460
|
return to_object
|
@@ -393,6 +518,9 @@ def _CreateCachedContentConfig_to_mldev(
|
|
393
518
|
),
|
394
519
|
)
|
395
520
|
|
521
|
+
if getv(from_object, ['kms_key_name']) is not None:
|
522
|
+
raise ValueError('kms_key_name parameter is not supported in Gemini API.')
|
523
|
+
|
396
524
|
return to_object
|
397
525
|
|
398
526
|
|
@@ -540,6 +668,42 @@ def _ListCachedContentsParameters_to_mldev(
|
|
540
668
|
return to_object
|
541
669
|
|
542
670
|
|
671
|
+
def _VideoMetadata_to_vertex(
|
672
|
+
api_client: BaseApiClient,
|
673
|
+
from_object: Union[dict[str, Any], object],
|
674
|
+
parent_object: Optional[dict[str, Any]] = None,
|
675
|
+
) -> dict[str, Any]:
|
676
|
+
to_object: dict[str, Any] = {}
|
677
|
+
if getv(from_object, ['fps']) is not None:
|
678
|
+
setv(to_object, ['fps'], getv(from_object, ['fps']))
|
679
|
+
|
680
|
+
if getv(from_object, ['end_offset']) is not None:
|
681
|
+
setv(to_object, ['endOffset'], getv(from_object, ['end_offset']))
|
682
|
+
|
683
|
+
if getv(from_object, ['start_offset']) is not None:
|
684
|
+
setv(to_object, ['startOffset'], getv(from_object, ['start_offset']))
|
685
|
+
|
686
|
+
return to_object
|
687
|
+
|
688
|
+
|
689
|
+
def _Blob_to_vertex(
|
690
|
+
api_client: BaseApiClient,
|
691
|
+
from_object: Union[dict[str, Any], object],
|
692
|
+
parent_object: Optional[dict[str, Any]] = None,
|
693
|
+
) -> dict[str, Any]:
|
694
|
+
to_object: dict[str, Any] = {}
|
695
|
+
if getv(from_object, ['display_name']) is not None:
|
696
|
+
setv(to_object, ['displayName'], getv(from_object, ['display_name']))
|
697
|
+
|
698
|
+
if getv(from_object, ['data']) is not None:
|
699
|
+
setv(to_object, ['data'], getv(from_object, ['data']))
|
700
|
+
|
701
|
+
if getv(from_object, ['mime_type']) is not None:
|
702
|
+
setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
|
703
|
+
|
704
|
+
return to_object
|
705
|
+
|
706
|
+
|
543
707
|
def _Part_to_vertex(
|
544
708
|
api_client: BaseApiClient,
|
545
709
|
from_object: Union[dict[str, Any], object],
|
@@ -547,11 +711,26 @@ def _Part_to_vertex(
|
|
547
711
|
) -> dict[str, Any]:
|
548
712
|
to_object: dict[str, Any] = {}
|
549
713
|
if getv(from_object, ['video_metadata']) is not None:
|
550
|
-
setv(
|
714
|
+
setv(
|
715
|
+
to_object,
|
716
|
+
['videoMetadata'],
|
717
|
+
_VideoMetadata_to_vertex(
|
718
|
+
api_client, getv(from_object, ['video_metadata']), to_object
|
719
|
+
),
|
720
|
+
)
|
551
721
|
|
552
722
|
if getv(from_object, ['thought']) is not None:
|
553
723
|
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
554
724
|
|
725
|
+
if getv(from_object, ['inline_data']) is not None:
|
726
|
+
setv(
|
727
|
+
to_object,
|
728
|
+
['inlineData'],
|
729
|
+
_Blob_to_vertex(
|
730
|
+
api_client, getv(from_object, ['inline_data']), to_object
|
731
|
+
),
|
732
|
+
)
|
733
|
+
|
555
734
|
if getv(from_object, ['code_execution_result']) is not None:
|
556
735
|
setv(
|
557
736
|
to_object,
|
@@ -575,9 +754,6 @@ def _Part_to_vertex(
|
|
575
754
|
getv(from_object, ['function_response']),
|
576
755
|
)
|
577
756
|
|
578
|
-
if getv(from_object, ['inline_data']) is not None:
|
579
|
-
setv(to_object, ['inlineData'], getv(from_object, ['inline_data']))
|
580
|
-
|
581
757
|
if getv(from_object, ['text']) is not None:
|
582
758
|
setv(to_object, ['text'], getv(from_object, ['text']))
|
583
759
|
|
@@ -606,12 +782,59 @@ def _Content_to_vertex(
|
|
606
782
|
return to_object
|
607
783
|
|
608
784
|
|
785
|
+
def _FunctionDeclaration_to_vertex(
|
786
|
+
api_client: BaseApiClient,
|
787
|
+
from_object: Union[dict[str, Any], object],
|
788
|
+
parent_object: Optional[dict[str, Any]] = None,
|
789
|
+
) -> dict[str, Any]:
|
790
|
+
to_object: dict[str, Any] = {}
|
791
|
+
if getv(from_object, ['behavior']) is not None:
|
792
|
+
raise ValueError('behavior parameter is not supported in Vertex AI.')
|
793
|
+
|
794
|
+
if getv(from_object, ['description']) is not None:
|
795
|
+
setv(to_object, ['description'], getv(from_object, ['description']))
|
796
|
+
|
797
|
+
if getv(from_object, ['name']) is not None:
|
798
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
799
|
+
|
800
|
+
if getv(from_object, ['parameters']) is not None:
|
801
|
+
setv(to_object, ['parameters'], getv(from_object, ['parameters']))
|
802
|
+
|
803
|
+
if getv(from_object, ['response']) is not None:
|
804
|
+
setv(to_object, ['response'], getv(from_object, ['response']))
|
805
|
+
|
806
|
+
return to_object
|
807
|
+
|
808
|
+
|
809
|
+
def _Interval_to_vertex(
|
810
|
+
api_client: BaseApiClient,
|
811
|
+
from_object: Union[dict[str, Any], object],
|
812
|
+
parent_object: Optional[dict[str, Any]] = None,
|
813
|
+
) -> dict[str, Any]:
|
814
|
+
to_object: dict[str, Any] = {}
|
815
|
+
if getv(from_object, ['start_time']) is not None:
|
816
|
+
setv(to_object, ['startTime'], getv(from_object, ['start_time']))
|
817
|
+
|
818
|
+
if getv(from_object, ['end_time']) is not None:
|
819
|
+
setv(to_object, ['endTime'], getv(from_object, ['end_time']))
|
820
|
+
|
821
|
+
return to_object
|
822
|
+
|
823
|
+
|
609
824
|
def _GoogleSearch_to_vertex(
|
610
825
|
api_client: BaseApiClient,
|
611
826
|
from_object: Union[dict[str, Any], object],
|
612
827
|
parent_object: Optional[dict[str, Any]] = None,
|
613
828
|
) -> dict[str, Any]:
|
614
829
|
to_object: dict[str, Any] = {}
|
830
|
+
if getv(from_object, ['time_range_filter']) is not None:
|
831
|
+
setv(
|
832
|
+
to_object,
|
833
|
+
['timeRangeFilter'],
|
834
|
+
_Interval_to_vertex(
|
835
|
+
api_client, getv(from_object, ['time_range_filter']), to_object
|
836
|
+
),
|
837
|
+
)
|
615
838
|
|
616
839
|
return to_object
|
617
840
|
|
@@ -736,12 +959,32 @@ def _GoogleMaps_to_vertex(
|
|
736
959
|
return to_object
|
737
960
|
|
738
961
|
|
962
|
+
def _UrlContext_to_vertex(
|
963
|
+
api_client: BaseApiClient,
|
964
|
+
from_object: Union[dict[str, Any], object],
|
965
|
+
parent_object: Optional[dict[str, Any]] = None,
|
966
|
+
) -> dict[str, Any]:
|
967
|
+
to_object: dict[str, Any] = {}
|
968
|
+
|
969
|
+
return to_object
|
970
|
+
|
971
|
+
|
739
972
|
def _Tool_to_vertex(
|
740
973
|
api_client: BaseApiClient,
|
741
974
|
from_object: Union[dict[str, Any], object],
|
742
975
|
parent_object: Optional[dict[str, Any]] = None,
|
743
976
|
) -> dict[str, Any]:
|
744
977
|
to_object: dict[str, Any] = {}
|
978
|
+
if getv(from_object, ['function_declarations']) is not None:
|
979
|
+
setv(
|
980
|
+
to_object,
|
981
|
+
['functionDeclarations'],
|
982
|
+
[
|
983
|
+
_FunctionDeclaration_to_vertex(api_client, item, to_object)
|
984
|
+
for item in getv(from_object, ['function_declarations'])
|
985
|
+
],
|
986
|
+
)
|
987
|
+
|
745
988
|
if getv(from_object, ['retrieval']) is not None:
|
746
989
|
setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
|
747
990
|
|
@@ -783,16 +1026,12 @@ def _Tool_to_vertex(
|
|
783
1026
|
),
|
784
1027
|
)
|
785
1028
|
|
1029
|
+
if getv(from_object, ['url_context']) is not None:
|
1030
|
+
raise ValueError('url_context parameter is not supported in Vertex AI.')
|
1031
|
+
|
786
1032
|
if getv(from_object, ['code_execution']) is not None:
|
787
1033
|
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
788
1034
|
|
789
|
-
if getv(from_object, ['function_declarations']) is not None:
|
790
|
-
setv(
|
791
|
-
to_object,
|
792
|
-
['functionDeclarations'],
|
793
|
-
getv(from_object, ['function_declarations']),
|
794
|
-
)
|
795
|
-
|
796
1035
|
return to_object
|
797
1036
|
|
798
1037
|
|
@@ -935,6 +1174,13 @@ def _CreateCachedContentConfig_to_vertex(
|
|
935
1174
|
),
|
936
1175
|
)
|
937
1176
|
|
1177
|
+
if getv(from_object, ['kms_key_name']) is not None:
|
1178
|
+
setv(
|
1179
|
+
parent_object,
|
1180
|
+
['encryption_spec', 'kmsKeyName'],
|
1181
|
+
getv(from_object, ['kms_key_name']),
|
1182
|
+
)
|
1183
|
+
|
938
1184
|
return to_object
|
939
1185
|
|
940
1186
|
|
@@ -1082,6 +1328,11 @@ def _ListCachedContentsParameters_to_vertex(
|
|
1082
1328
|
return to_object
|
1083
1329
|
|
1084
1330
|
|
1331
|
+
def _Behavior_to_vertex_enum_validate(enum_value: Any) -> None:
|
1332
|
+
if enum_value in set(['UNSPECIFIED', 'BLOCKING', 'NON_BLOCKING']):
|
1333
|
+
raise ValueError(f'{enum_value} enum value is not supported in Vertex AI.')
|
1334
|
+
|
1335
|
+
|
1085
1336
|
def _CachedContent_from_mldev(
|
1086
1337
|
api_client: BaseApiClient,
|
1087
1338
|
from_object: Union[dict[str, Any], object],
|
google/genai/chats.py
CHANGED