google-genai 1.7.0__py3-none-any.whl → 1.53.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 +4 -2
- google/genai/_adapters.py +55 -0
- google/genai/_api_client.py +1301 -299
- google/genai/_api_module.py +1 -1
- google/genai/_automatic_function_calling_util.py +54 -33
- google/genai/_base_transformers.py +26 -0
- google/genai/_base_url.py +50 -0
- google/genai/_common.py +560 -59
- google/genai/_extra_utils.py +371 -38
- google/genai/_live_converters.py +1467 -0
- google/genai/_local_tokenizer_loader.py +214 -0
- google/genai/_mcp_utils.py +117 -0
- google/genai/_operations_converters.py +394 -0
- google/genai/_replay_api_client.py +204 -92
- google/genai/_test_api_client.py +1 -1
- google/genai/_tokens_converters.py +520 -0
- google/genai/_transformers.py +633 -233
- google/genai/batches.py +1733 -538
- google/genai/caches.py +678 -1012
- google/genai/chats.py +48 -38
- google/genai/client.py +142 -15
- google/genai/documents.py +532 -0
- google/genai/errors.py +141 -35
- google/genai/file_search_stores.py +1296 -0
- google/genai/files.py +312 -744
- google/genai/live.py +617 -367
- google/genai/live_music.py +197 -0
- google/genai/local_tokenizer.py +395 -0
- google/genai/models.py +3598 -3116
- google/genai/operations.py +201 -362
- google/genai/pagers.py +23 -7
- google/genai/py.typed +1 -0
- google/genai/tokens.py +362 -0
- google/genai/tunings.py +1274 -496
- google/genai/types.py +14535 -5454
- google/genai/version.py +2 -2
- {google_genai-1.7.0.dist-info → google_genai-1.53.0.dist-info}/METADATA +736 -234
- google_genai-1.53.0.dist-info/RECORD +41 -0
- {google_genai-1.7.0.dist-info → google_genai-1.53.0.dist-info}/WHEEL +1 -1
- google_genai-1.7.0.dist-info/RECORD +0 -27
- {google_genai-1.7.0.dist-info → google_genai-1.53.0.dist-info/licenses}/LICENSE +0 -0
- {google_genai-1.7.0.dist-info → google_genai-1.53.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,1467 @@
|
|
|
1
|
+
# Copyright 2025 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
# Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
|
17
|
+
|
|
18
|
+
from typing import Any, Optional, Union
|
|
19
|
+
|
|
20
|
+
from . import _transformers as t
|
|
21
|
+
from ._api_client import BaseApiClient
|
|
22
|
+
from ._common import get_value_by_path as getv
|
|
23
|
+
from ._common import set_value_by_path as setv
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _Blob_to_mldev(
|
|
27
|
+
from_object: Union[dict[str, Any], object],
|
|
28
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
29
|
+
) -> dict[str, Any]:
|
|
30
|
+
to_object: dict[str, Any] = {}
|
|
31
|
+
if getv(from_object, ['data']) is not None:
|
|
32
|
+
setv(to_object, ['data'], getv(from_object, ['data']))
|
|
33
|
+
|
|
34
|
+
if getv(from_object, ['display_name']) is not None:
|
|
35
|
+
raise ValueError('display_name parameter is not supported in Gemini API.')
|
|
36
|
+
|
|
37
|
+
if getv(from_object, ['mime_type']) is not None:
|
|
38
|
+
setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
|
|
39
|
+
|
|
40
|
+
return to_object
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _Content_to_mldev(
|
|
44
|
+
from_object: Union[dict[str, Any], object],
|
|
45
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
46
|
+
) -> dict[str, Any]:
|
|
47
|
+
to_object: dict[str, Any] = {}
|
|
48
|
+
if getv(from_object, ['parts']) is not None:
|
|
49
|
+
setv(
|
|
50
|
+
to_object,
|
|
51
|
+
['parts'],
|
|
52
|
+
[
|
|
53
|
+
_Part_to_mldev(item, to_object)
|
|
54
|
+
for item in getv(from_object, ['parts'])
|
|
55
|
+
],
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
if getv(from_object, ['role']) is not None:
|
|
59
|
+
setv(to_object, ['role'], getv(from_object, ['role']))
|
|
60
|
+
|
|
61
|
+
return to_object
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _FileData_to_mldev(
|
|
65
|
+
from_object: Union[dict[str, Any], object],
|
|
66
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
67
|
+
) -> dict[str, Any]:
|
|
68
|
+
to_object: dict[str, Any] = {}
|
|
69
|
+
if getv(from_object, ['display_name']) is not None:
|
|
70
|
+
raise ValueError('display_name parameter is not supported in Gemini API.')
|
|
71
|
+
|
|
72
|
+
if getv(from_object, ['file_uri']) is not None:
|
|
73
|
+
setv(to_object, ['fileUri'], getv(from_object, ['file_uri']))
|
|
74
|
+
|
|
75
|
+
if getv(from_object, ['mime_type']) is not None:
|
|
76
|
+
setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
|
|
77
|
+
|
|
78
|
+
return to_object
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _FunctionCall_to_mldev(
|
|
82
|
+
from_object: Union[dict[str, Any], object],
|
|
83
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
84
|
+
) -> dict[str, Any]:
|
|
85
|
+
to_object: dict[str, Any] = {}
|
|
86
|
+
if getv(from_object, ['id']) is not None:
|
|
87
|
+
setv(to_object, ['id'], getv(from_object, ['id']))
|
|
88
|
+
|
|
89
|
+
if getv(from_object, ['args']) is not None:
|
|
90
|
+
setv(to_object, ['args'], getv(from_object, ['args']))
|
|
91
|
+
|
|
92
|
+
if getv(from_object, ['name']) is not None:
|
|
93
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
|
94
|
+
|
|
95
|
+
if getv(from_object, ['partial_args']) is not None:
|
|
96
|
+
raise ValueError('partial_args parameter is not supported in Gemini API.')
|
|
97
|
+
|
|
98
|
+
if getv(from_object, ['will_continue']) is not None:
|
|
99
|
+
raise ValueError('will_continue parameter is not supported in Gemini API.')
|
|
100
|
+
|
|
101
|
+
return to_object
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def _FunctionDeclaration_to_vertex(
|
|
105
|
+
from_object: Union[dict[str, Any], object],
|
|
106
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
107
|
+
) -> dict[str, Any]:
|
|
108
|
+
to_object: dict[str, Any] = {}
|
|
109
|
+
if getv(from_object, ['behavior']) is not None:
|
|
110
|
+
raise ValueError('behavior parameter is not supported in Vertex AI.')
|
|
111
|
+
|
|
112
|
+
if getv(from_object, ['description']) is not None:
|
|
113
|
+
setv(to_object, ['description'], getv(from_object, ['description']))
|
|
114
|
+
|
|
115
|
+
if getv(from_object, ['name']) is not None:
|
|
116
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
|
117
|
+
|
|
118
|
+
if getv(from_object, ['parameters']) is not None:
|
|
119
|
+
setv(to_object, ['parameters'], getv(from_object, ['parameters']))
|
|
120
|
+
|
|
121
|
+
if getv(from_object, ['parameters_json_schema']) is not None:
|
|
122
|
+
setv(
|
|
123
|
+
to_object,
|
|
124
|
+
['parametersJsonSchema'],
|
|
125
|
+
getv(from_object, ['parameters_json_schema']),
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
if getv(from_object, ['response']) is not None:
|
|
129
|
+
setv(to_object, ['response'], getv(from_object, ['response']))
|
|
130
|
+
|
|
131
|
+
if getv(from_object, ['response_json_schema']) is not None:
|
|
132
|
+
setv(
|
|
133
|
+
to_object,
|
|
134
|
+
['responseJsonSchema'],
|
|
135
|
+
getv(from_object, ['response_json_schema']),
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
return to_object
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _GenerationConfig_to_vertex(
|
|
142
|
+
from_object: Union[dict[str, Any], object],
|
|
143
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
144
|
+
) -> dict[str, Any]:
|
|
145
|
+
to_object: dict[str, Any] = {}
|
|
146
|
+
if getv(from_object, ['model_selection_config']) is not None:
|
|
147
|
+
setv(
|
|
148
|
+
to_object,
|
|
149
|
+
['modelConfig'],
|
|
150
|
+
getv(from_object, ['model_selection_config']),
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
if getv(from_object, ['response_json_schema']) is not None:
|
|
154
|
+
setv(
|
|
155
|
+
to_object,
|
|
156
|
+
['responseJsonSchema'],
|
|
157
|
+
getv(from_object, ['response_json_schema']),
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
if getv(from_object, ['audio_timestamp']) is not None:
|
|
161
|
+
setv(to_object, ['audioTimestamp'], getv(from_object, ['audio_timestamp']))
|
|
162
|
+
|
|
163
|
+
if getv(from_object, ['candidate_count']) is not None:
|
|
164
|
+
setv(to_object, ['candidateCount'], getv(from_object, ['candidate_count']))
|
|
165
|
+
|
|
166
|
+
if getv(from_object, ['enable_affective_dialog']) is not None:
|
|
167
|
+
setv(
|
|
168
|
+
to_object,
|
|
169
|
+
['enableAffectiveDialog'],
|
|
170
|
+
getv(from_object, ['enable_affective_dialog']),
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
if getv(from_object, ['frequency_penalty']) is not None:
|
|
174
|
+
setv(
|
|
175
|
+
to_object,
|
|
176
|
+
['frequencyPenalty'],
|
|
177
|
+
getv(from_object, ['frequency_penalty']),
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
if getv(from_object, ['logprobs']) is not None:
|
|
181
|
+
setv(to_object, ['logprobs'], getv(from_object, ['logprobs']))
|
|
182
|
+
|
|
183
|
+
if getv(from_object, ['max_output_tokens']) is not None:
|
|
184
|
+
setv(
|
|
185
|
+
to_object, ['maxOutputTokens'], getv(from_object, ['max_output_tokens'])
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
if getv(from_object, ['media_resolution']) is not None:
|
|
189
|
+
setv(
|
|
190
|
+
to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
if getv(from_object, ['presence_penalty']) is not None:
|
|
194
|
+
setv(
|
|
195
|
+
to_object, ['presencePenalty'], getv(from_object, ['presence_penalty'])
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
if getv(from_object, ['response_logprobs']) is not None:
|
|
199
|
+
setv(
|
|
200
|
+
to_object,
|
|
201
|
+
['responseLogprobs'],
|
|
202
|
+
getv(from_object, ['response_logprobs']),
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
if getv(from_object, ['response_mime_type']) is not None:
|
|
206
|
+
setv(
|
|
207
|
+
to_object,
|
|
208
|
+
['responseMimeType'],
|
|
209
|
+
getv(from_object, ['response_mime_type']),
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
if getv(from_object, ['response_modalities']) is not None:
|
|
213
|
+
setv(
|
|
214
|
+
to_object,
|
|
215
|
+
['responseModalities'],
|
|
216
|
+
getv(from_object, ['response_modalities']),
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
if getv(from_object, ['response_schema']) is not None:
|
|
220
|
+
setv(to_object, ['responseSchema'], getv(from_object, ['response_schema']))
|
|
221
|
+
|
|
222
|
+
if getv(from_object, ['routing_config']) is not None:
|
|
223
|
+
setv(to_object, ['routingConfig'], getv(from_object, ['routing_config']))
|
|
224
|
+
|
|
225
|
+
if getv(from_object, ['seed']) is not None:
|
|
226
|
+
setv(to_object, ['seed'], getv(from_object, ['seed']))
|
|
227
|
+
|
|
228
|
+
if getv(from_object, ['speech_config']) is not None:
|
|
229
|
+
setv(
|
|
230
|
+
to_object,
|
|
231
|
+
['speechConfig'],
|
|
232
|
+
_SpeechConfig_to_vertex(
|
|
233
|
+
getv(from_object, ['speech_config']), to_object
|
|
234
|
+
),
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
if getv(from_object, ['stop_sequences']) is not None:
|
|
238
|
+
setv(to_object, ['stopSequences'], getv(from_object, ['stop_sequences']))
|
|
239
|
+
|
|
240
|
+
if getv(from_object, ['temperature']) is not None:
|
|
241
|
+
setv(to_object, ['temperature'], getv(from_object, ['temperature']))
|
|
242
|
+
|
|
243
|
+
if getv(from_object, ['thinking_config']) is not None:
|
|
244
|
+
setv(to_object, ['thinkingConfig'], getv(from_object, ['thinking_config']))
|
|
245
|
+
|
|
246
|
+
if getv(from_object, ['top_k']) is not None:
|
|
247
|
+
setv(to_object, ['topK'], getv(from_object, ['top_k']))
|
|
248
|
+
|
|
249
|
+
if getv(from_object, ['top_p']) is not None:
|
|
250
|
+
setv(to_object, ['topP'], getv(from_object, ['top_p']))
|
|
251
|
+
|
|
252
|
+
if getv(from_object, ['enable_enhanced_civic_answers']) is not None:
|
|
253
|
+
raise ValueError(
|
|
254
|
+
'enable_enhanced_civic_answers parameter is not supported in Vertex AI.'
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
return to_object
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def _GoogleMaps_to_mldev(
|
|
261
|
+
from_object: Union[dict[str, Any], object],
|
|
262
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
263
|
+
) -> dict[str, Any]:
|
|
264
|
+
to_object: dict[str, Any] = {}
|
|
265
|
+
if getv(from_object, ['auth_config']) is not None:
|
|
266
|
+
raise ValueError('auth_config parameter is not supported in Gemini API.')
|
|
267
|
+
|
|
268
|
+
if getv(from_object, ['enable_widget']) is not None:
|
|
269
|
+
setv(to_object, ['enableWidget'], getv(from_object, ['enable_widget']))
|
|
270
|
+
|
|
271
|
+
return to_object
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def _GoogleSearch_to_mldev(
|
|
275
|
+
from_object: Union[dict[str, Any], object],
|
|
276
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
277
|
+
) -> dict[str, Any]:
|
|
278
|
+
to_object: dict[str, Any] = {}
|
|
279
|
+
if getv(from_object, ['exclude_domains']) is not None:
|
|
280
|
+
raise ValueError(
|
|
281
|
+
'exclude_domains parameter is not supported in Gemini API.'
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
if getv(from_object, ['blocking_confidence']) is not None:
|
|
285
|
+
raise ValueError(
|
|
286
|
+
'blocking_confidence parameter is not supported in Gemini API.'
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
if getv(from_object, ['time_range_filter']) is not None:
|
|
290
|
+
setv(
|
|
291
|
+
to_object, ['timeRangeFilter'], getv(from_object, ['time_range_filter'])
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
return to_object
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def _LiveClientContent_to_mldev(
|
|
298
|
+
from_object: Union[dict[str, Any], object],
|
|
299
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
300
|
+
) -> dict[str, Any]:
|
|
301
|
+
to_object: dict[str, Any] = {}
|
|
302
|
+
if getv(from_object, ['turns']) is not None:
|
|
303
|
+
setv(
|
|
304
|
+
to_object,
|
|
305
|
+
['turns'],
|
|
306
|
+
[
|
|
307
|
+
_Content_to_mldev(item, to_object)
|
|
308
|
+
for item in getv(from_object, ['turns'])
|
|
309
|
+
],
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
if getv(from_object, ['turn_complete']) is not None:
|
|
313
|
+
setv(to_object, ['turnComplete'], getv(from_object, ['turn_complete']))
|
|
314
|
+
|
|
315
|
+
return to_object
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def _LiveClientMessage_to_mldev(
|
|
319
|
+
api_client: BaseApiClient,
|
|
320
|
+
from_object: Union[dict[str, Any], object],
|
|
321
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
322
|
+
) -> dict[str, Any]:
|
|
323
|
+
to_object: dict[str, Any] = {}
|
|
324
|
+
if getv(from_object, ['setup']) is not None:
|
|
325
|
+
setv(
|
|
326
|
+
to_object,
|
|
327
|
+
['setup'],
|
|
328
|
+
_LiveClientSetup_to_mldev(
|
|
329
|
+
api_client, getv(from_object, ['setup']), to_object
|
|
330
|
+
),
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
if getv(from_object, ['client_content']) is not None:
|
|
334
|
+
setv(
|
|
335
|
+
to_object,
|
|
336
|
+
['clientContent'],
|
|
337
|
+
_LiveClientContent_to_mldev(
|
|
338
|
+
getv(from_object, ['client_content']), to_object
|
|
339
|
+
),
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
if getv(from_object, ['realtime_input']) is not None:
|
|
343
|
+
setv(
|
|
344
|
+
to_object,
|
|
345
|
+
['realtimeInput'],
|
|
346
|
+
_LiveClientRealtimeInput_to_mldev(
|
|
347
|
+
getv(from_object, ['realtime_input']), to_object
|
|
348
|
+
),
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
if getv(from_object, ['tool_response']) is not None:
|
|
352
|
+
setv(to_object, ['toolResponse'], getv(from_object, ['tool_response']))
|
|
353
|
+
|
|
354
|
+
return to_object
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
def _LiveClientMessage_to_vertex(
|
|
358
|
+
api_client: BaseApiClient,
|
|
359
|
+
from_object: Union[dict[str, Any], object],
|
|
360
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
361
|
+
) -> dict[str, Any]:
|
|
362
|
+
to_object: dict[str, Any] = {}
|
|
363
|
+
if getv(from_object, ['setup']) is not None:
|
|
364
|
+
setv(
|
|
365
|
+
to_object,
|
|
366
|
+
['setup'],
|
|
367
|
+
_LiveClientSetup_to_vertex(
|
|
368
|
+
api_client, getv(from_object, ['setup']), to_object
|
|
369
|
+
),
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
if getv(from_object, ['client_content']) is not None:
|
|
373
|
+
setv(to_object, ['clientContent'], getv(from_object, ['client_content']))
|
|
374
|
+
|
|
375
|
+
if getv(from_object, ['realtime_input']) is not None:
|
|
376
|
+
setv(
|
|
377
|
+
to_object,
|
|
378
|
+
['realtimeInput'],
|
|
379
|
+
_LiveClientRealtimeInput_to_vertex(
|
|
380
|
+
getv(from_object, ['realtime_input']), to_object
|
|
381
|
+
),
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
if getv(from_object, ['tool_response']) is not None:
|
|
385
|
+
setv(to_object, ['toolResponse'], getv(from_object, ['tool_response']))
|
|
386
|
+
|
|
387
|
+
return to_object
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
def _LiveClientRealtimeInput_to_mldev(
|
|
391
|
+
from_object: Union[dict[str, Any], object],
|
|
392
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
393
|
+
) -> dict[str, Any]:
|
|
394
|
+
to_object: dict[str, Any] = {}
|
|
395
|
+
if getv(from_object, ['media_chunks']) is not None:
|
|
396
|
+
setv(
|
|
397
|
+
to_object,
|
|
398
|
+
['mediaChunks'],
|
|
399
|
+
[
|
|
400
|
+
_Blob_to_mldev(item, to_object)
|
|
401
|
+
for item in getv(from_object, ['media_chunks'])
|
|
402
|
+
],
|
|
403
|
+
)
|
|
404
|
+
|
|
405
|
+
if getv(from_object, ['audio']) is not None:
|
|
406
|
+
setv(
|
|
407
|
+
to_object,
|
|
408
|
+
['audio'],
|
|
409
|
+
_Blob_to_mldev(getv(from_object, ['audio']), to_object),
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
if getv(from_object, ['audio_stream_end']) is not None:
|
|
413
|
+
setv(to_object, ['audioStreamEnd'], getv(from_object, ['audio_stream_end']))
|
|
414
|
+
|
|
415
|
+
if getv(from_object, ['video']) is not None:
|
|
416
|
+
setv(
|
|
417
|
+
to_object,
|
|
418
|
+
['video'],
|
|
419
|
+
_Blob_to_mldev(getv(from_object, ['video']), to_object),
|
|
420
|
+
)
|
|
421
|
+
|
|
422
|
+
if getv(from_object, ['text']) is not None:
|
|
423
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
|
424
|
+
|
|
425
|
+
if getv(from_object, ['activity_start']) is not None:
|
|
426
|
+
setv(to_object, ['activityStart'], getv(from_object, ['activity_start']))
|
|
427
|
+
|
|
428
|
+
if getv(from_object, ['activity_end']) is not None:
|
|
429
|
+
setv(to_object, ['activityEnd'], getv(from_object, ['activity_end']))
|
|
430
|
+
|
|
431
|
+
return to_object
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
def _LiveClientRealtimeInput_to_vertex(
|
|
435
|
+
from_object: Union[dict[str, Any], object],
|
|
436
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
437
|
+
) -> dict[str, Any]:
|
|
438
|
+
to_object: dict[str, Any] = {}
|
|
439
|
+
if getv(from_object, ['media_chunks']) is not None:
|
|
440
|
+
setv(
|
|
441
|
+
to_object,
|
|
442
|
+
['mediaChunks'],
|
|
443
|
+
[item for item in getv(from_object, ['media_chunks'])],
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
if getv(from_object, ['audio']) is not None:
|
|
447
|
+
setv(to_object, ['audio'], getv(from_object, ['audio']))
|
|
448
|
+
|
|
449
|
+
if getv(from_object, ['audio_stream_end']) is not None:
|
|
450
|
+
raise ValueError(
|
|
451
|
+
'audio_stream_end parameter is not supported in Vertex AI.'
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
if getv(from_object, ['video']) is not None:
|
|
455
|
+
setv(to_object, ['video'], getv(from_object, ['video']))
|
|
456
|
+
|
|
457
|
+
if getv(from_object, ['text']) is not None:
|
|
458
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
|
459
|
+
|
|
460
|
+
if getv(from_object, ['activity_start']) is not None:
|
|
461
|
+
setv(to_object, ['activityStart'], getv(from_object, ['activity_start']))
|
|
462
|
+
|
|
463
|
+
if getv(from_object, ['activity_end']) is not None:
|
|
464
|
+
setv(to_object, ['activityEnd'], getv(from_object, ['activity_end']))
|
|
465
|
+
|
|
466
|
+
return to_object
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
def _LiveClientSetup_to_mldev(
|
|
470
|
+
api_client: BaseApiClient,
|
|
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, ['model']) is not None:
|
|
476
|
+
setv(to_object, ['model'], getv(from_object, ['model']))
|
|
477
|
+
|
|
478
|
+
if getv(from_object, ['generation_config']) is not None:
|
|
479
|
+
setv(
|
|
480
|
+
to_object,
|
|
481
|
+
['generationConfig'],
|
|
482
|
+
getv(from_object, ['generation_config']),
|
|
483
|
+
)
|
|
484
|
+
|
|
485
|
+
if getv(from_object, ['system_instruction']) is not None:
|
|
486
|
+
setv(
|
|
487
|
+
to_object,
|
|
488
|
+
['systemInstruction'],
|
|
489
|
+
_Content_to_mldev(
|
|
490
|
+
t.t_content(getv(from_object, ['system_instruction'])), to_object
|
|
491
|
+
),
|
|
492
|
+
)
|
|
493
|
+
|
|
494
|
+
if getv(from_object, ['tools']) is not None:
|
|
495
|
+
setv(
|
|
496
|
+
to_object,
|
|
497
|
+
['tools'],
|
|
498
|
+
[
|
|
499
|
+
_Tool_to_mldev(t.t_tool(api_client, item), to_object)
|
|
500
|
+
for item in t.t_tools(api_client, getv(from_object, ['tools']))
|
|
501
|
+
],
|
|
502
|
+
)
|
|
503
|
+
|
|
504
|
+
if getv(from_object, ['session_resumption']) is not None:
|
|
505
|
+
setv(
|
|
506
|
+
to_object,
|
|
507
|
+
['sessionResumption'],
|
|
508
|
+
_SessionResumptionConfig_to_mldev(
|
|
509
|
+
getv(from_object, ['session_resumption']), to_object
|
|
510
|
+
),
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
if getv(from_object, ['context_window_compression']) is not None:
|
|
514
|
+
setv(
|
|
515
|
+
to_object,
|
|
516
|
+
['contextWindowCompression'],
|
|
517
|
+
getv(from_object, ['context_window_compression']),
|
|
518
|
+
)
|
|
519
|
+
|
|
520
|
+
if getv(from_object, ['input_audio_transcription']) is not None:
|
|
521
|
+
setv(
|
|
522
|
+
to_object,
|
|
523
|
+
['inputAudioTranscription'],
|
|
524
|
+
getv(from_object, ['input_audio_transcription']),
|
|
525
|
+
)
|
|
526
|
+
|
|
527
|
+
if getv(from_object, ['output_audio_transcription']) is not None:
|
|
528
|
+
setv(
|
|
529
|
+
to_object,
|
|
530
|
+
['outputAudioTranscription'],
|
|
531
|
+
getv(from_object, ['output_audio_transcription']),
|
|
532
|
+
)
|
|
533
|
+
|
|
534
|
+
if getv(from_object, ['proactivity']) is not None:
|
|
535
|
+
setv(to_object, ['proactivity'], getv(from_object, ['proactivity']))
|
|
536
|
+
|
|
537
|
+
return to_object
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
def _LiveClientSetup_to_vertex(
|
|
541
|
+
api_client: BaseApiClient,
|
|
542
|
+
from_object: Union[dict[str, Any], object],
|
|
543
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
544
|
+
) -> dict[str, Any]:
|
|
545
|
+
to_object: dict[str, Any] = {}
|
|
546
|
+
if getv(from_object, ['model']) is not None:
|
|
547
|
+
setv(to_object, ['model'], getv(from_object, ['model']))
|
|
548
|
+
|
|
549
|
+
if getv(from_object, ['generation_config']) is not None:
|
|
550
|
+
setv(
|
|
551
|
+
to_object,
|
|
552
|
+
['generationConfig'],
|
|
553
|
+
_GenerationConfig_to_vertex(
|
|
554
|
+
getv(from_object, ['generation_config']), to_object
|
|
555
|
+
),
|
|
556
|
+
)
|
|
557
|
+
|
|
558
|
+
if getv(from_object, ['system_instruction']) is not None:
|
|
559
|
+
setv(
|
|
560
|
+
to_object,
|
|
561
|
+
['systemInstruction'],
|
|
562
|
+
t.t_content(getv(from_object, ['system_instruction'])),
|
|
563
|
+
)
|
|
564
|
+
|
|
565
|
+
if getv(from_object, ['tools']) is not None:
|
|
566
|
+
setv(
|
|
567
|
+
to_object,
|
|
568
|
+
['tools'],
|
|
569
|
+
[
|
|
570
|
+
_Tool_to_vertex(t.t_tool(api_client, item), to_object)
|
|
571
|
+
for item in t.t_tools(api_client, getv(from_object, ['tools']))
|
|
572
|
+
],
|
|
573
|
+
)
|
|
574
|
+
|
|
575
|
+
if getv(from_object, ['session_resumption']) is not None:
|
|
576
|
+
setv(
|
|
577
|
+
to_object,
|
|
578
|
+
['sessionResumption'],
|
|
579
|
+
getv(from_object, ['session_resumption']),
|
|
580
|
+
)
|
|
581
|
+
|
|
582
|
+
if getv(from_object, ['context_window_compression']) is not None:
|
|
583
|
+
setv(
|
|
584
|
+
to_object,
|
|
585
|
+
['contextWindowCompression'],
|
|
586
|
+
getv(from_object, ['context_window_compression']),
|
|
587
|
+
)
|
|
588
|
+
|
|
589
|
+
if getv(from_object, ['input_audio_transcription']) is not None:
|
|
590
|
+
setv(
|
|
591
|
+
to_object,
|
|
592
|
+
['inputAudioTranscription'],
|
|
593
|
+
getv(from_object, ['input_audio_transcription']),
|
|
594
|
+
)
|
|
595
|
+
|
|
596
|
+
if getv(from_object, ['output_audio_transcription']) is not None:
|
|
597
|
+
setv(
|
|
598
|
+
to_object,
|
|
599
|
+
['outputAudioTranscription'],
|
|
600
|
+
getv(from_object, ['output_audio_transcription']),
|
|
601
|
+
)
|
|
602
|
+
|
|
603
|
+
if getv(from_object, ['proactivity']) is not None:
|
|
604
|
+
setv(to_object, ['proactivity'], getv(from_object, ['proactivity']))
|
|
605
|
+
|
|
606
|
+
return to_object
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
def _LiveConnectConfig_to_mldev(
|
|
610
|
+
api_client: BaseApiClient,
|
|
611
|
+
from_object: Union[dict[str, Any], object],
|
|
612
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
613
|
+
) -> dict[str, Any]:
|
|
614
|
+
to_object: dict[str, Any] = {}
|
|
615
|
+
|
|
616
|
+
if getv(from_object, ['generation_config']) is not None:
|
|
617
|
+
setv(
|
|
618
|
+
parent_object,
|
|
619
|
+
['setup', 'generationConfig'],
|
|
620
|
+
getv(from_object, ['generation_config']),
|
|
621
|
+
)
|
|
622
|
+
|
|
623
|
+
if getv(from_object, ['response_modalities']) is not None:
|
|
624
|
+
setv(
|
|
625
|
+
parent_object,
|
|
626
|
+
['setup', 'generationConfig', 'responseModalities'],
|
|
627
|
+
getv(from_object, ['response_modalities']),
|
|
628
|
+
)
|
|
629
|
+
|
|
630
|
+
if getv(from_object, ['temperature']) is not None:
|
|
631
|
+
setv(
|
|
632
|
+
parent_object,
|
|
633
|
+
['setup', 'generationConfig', 'temperature'],
|
|
634
|
+
getv(from_object, ['temperature']),
|
|
635
|
+
)
|
|
636
|
+
|
|
637
|
+
if getv(from_object, ['top_p']) is not None:
|
|
638
|
+
setv(
|
|
639
|
+
parent_object,
|
|
640
|
+
['setup', 'generationConfig', 'topP'],
|
|
641
|
+
getv(from_object, ['top_p']),
|
|
642
|
+
)
|
|
643
|
+
|
|
644
|
+
if getv(from_object, ['top_k']) is not None:
|
|
645
|
+
setv(
|
|
646
|
+
parent_object,
|
|
647
|
+
['setup', 'generationConfig', 'topK'],
|
|
648
|
+
getv(from_object, ['top_k']),
|
|
649
|
+
)
|
|
650
|
+
|
|
651
|
+
if getv(from_object, ['max_output_tokens']) is not None:
|
|
652
|
+
setv(
|
|
653
|
+
parent_object,
|
|
654
|
+
['setup', 'generationConfig', 'maxOutputTokens'],
|
|
655
|
+
getv(from_object, ['max_output_tokens']),
|
|
656
|
+
)
|
|
657
|
+
|
|
658
|
+
if getv(from_object, ['media_resolution']) is not None:
|
|
659
|
+
setv(
|
|
660
|
+
parent_object,
|
|
661
|
+
['setup', 'generationConfig', 'mediaResolution'],
|
|
662
|
+
getv(from_object, ['media_resolution']),
|
|
663
|
+
)
|
|
664
|
+
|
|
665
|
+
if getv(from_object, ['seed']) is not None:
|
|
666
|
+
setv(
|
|
667
|
+
parent_object,
|
|
668
|
+
['setup', 'generationConfig', 'seed'],
|
|
669
|
+
getv(from_object, ['seed']),
|
|
670
|
+
)
|
|
671
|
+
|
|
672
|
+
if getv(from_object, ['speech_config']) is not None:
|
|
673
|
+
setv(
|
|
674
|
+
parent_object,
|
|
675
|
+
['setup', 'generationConfig', 'speechConfig'],
|
|
676
|
+
t.t_live_speech_config(getv(from_object, ['speech_config'])),
|
|
677
|
+
)
|
|
678
|
+
|
|
679
|
+
if getv(from_object, ['thinking_config']) is not None:
|
|
680
|
+
setv(
|
|
681
|
+
parent_object,
|
|
682
|
+
['setup', 'generationConfig', 'thinkingConfig'],
|
|
683
|
+
getv(from_object, ['thinking_config']),
|
|
684
|
+
)
|
|
685
|
+
|
|
686
|
+
if getv(from_object, ['enable_affective_dialog']) is not None:
|
|
687
|
+
setv(
|
|
688
|
+
parent_object,
|
|
689
|
+
['setup', 'generationConfig', 'enableAffectiveDialog'],
|
|
690
|
+
getv(from_object, ['enable_affective_dialog']),
|
|
691
|
+
)
|
|
692
|
+
|
|
693
|
+
if getv(from_object, ['system_instruction']) is not None:
|
|
694
|
+
setv(
|
|
695
|
+
parent_object,
|
|
696
|
+
['setup', 'systemInstruction'],
|
|
697
|
+
_Content_to_mldev(
|
|
698
|
+
t.t_content(getv(from_object, ['system_instruction'])), to_object
|
|
699
|
+
),
|
|
700
|
+
)
|
|
701
|
+
|
|
702
|
+
if getv(from_object, ['tools']) is not None:
|
|
703
|
+
setv(
|
|
704
|
+
parent_object,
|
|
705
|
+
['setup', 'tools'],
|
|
706
|
+
[
|
|
707
|
+
_Tool_to_mldev(t.t_tool(api_client, item), to_object)
|
|
708
|
+
for item in t.t_tools(api_client, getv(from_object, ['tools']))
|
|
709
|
+
],
|
|
710
|
+
)
|
|
711
|
+
|
|
712
|
+
if getv(from_object, ['session_resumption']) is not None:
|
|
713
|
+
setv(
|
|
714
|
+
parent_object,
|
|
715
|
+
['setup', 'sessionResumption'],
|
|
716
|
+
_SessionResumptionConfig_to_mldev(
|
|
717
|
+
getv(from_object, ['session_resumption']), to_object
|
|
718
|
+
),
|
|
719
|
+
)
|
|
720
|
+
|
|
721
|
+
if getv(from_object, ['input_audio_transcription']) is not None:
|
|
722
|
+
setv(
|
|
723
|
+
parent_object,
|
|
724
|
+
['setup', 'inputAudioTranscription'],
|
|
725
|
+
getv(from_object, ['input_audio_transcription']),
|
|
726
|
+
)
|
|
727
|
+
|
|
728
|
+
if getv(from_object, ['output_audio_transcription']) is not None:
|
|
729
|
+
setv(
|
|
730
|
+
parent_object,
|
|
731
|
+
['setup', 'outputAudioTranscription'],
|
|
732
|
+
getv(from_object, ['output_audio_transcription']),
|
|
733
|
+
)
|
|
734
|
+
|
|
735
|
+
if getv(from_object, ['realtime_input_config']) is not None:
|
|
736
|
+
setv(
|
|
737
|
+
parent_object,
|
|
738
|
+
['setup', 'realtimeInputConfig'],
|
|
739
|
+
getv(from_object, ['realtime_input_config']),
|
|
740
|
+
)
|
|
741
|
+
|
|
742
|
+
if getv(from_object, ['context_window_compression']) is not None:
|
|
743
|
+
setv(
|
|
744
|
+
parent_object,
|
|
745
|
+
['setup', 'contextWindowCompression'],
|
|
746
|
+
getv(from_object, ['context_window_compression']),
|
|
747
|
+
)
|
|
748
|
+
|
|
749
|
+
if getv(from_object, ['proactivity']) is not None:
|
|
750
|
+
setv(
|
|
751
|
+
parent_object,
|
|
752
|
+
['setup', 'proactivity'],
|
|
753
|
+
getv(from_object, ['proactivity']),
|
|
754
|
+
)
|
|
755
|
+
|
|
756
|
+
return to_object
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
def _LiveConnectConfig_to_vertex(
|
|
760
|
+
api_client: BaseApiClient,
|
|
761
|
+
from_object: Union[dict[str, Any], object],
|
|
762
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
763
|
+
) -> dict[str, Any]:
|
|
764
|
+
to_object: dict[str, Any] = {}
|
|
765
|
+
|
|
766
|
+
if getv(from_object, ['generation_config']) is not None:
|
|
767
|
+
setv(
|
|
768
|
+
parent_object,
|
|
769
|
+
['setup', 'generationConfig'],
|
|
770
|
+
_GenerationConfig_to_vertex(
|
|
771
|
+
getv(from_object, ['generation_config']), to_object
|
|
772
|
+
),
|
|
773
|
+
)
|
|
774
|
+
|
|
775
|
+
if getv(from_object, ['response_modalities']) is not None:
|
|
776
|
+
setv(
|
|
777
|
+
parent_object,
|
|
778
|
+
['setup', 'generationConfig', 'responseModalities'],
|
|
779
|
+
getv(from_object, ['response_modalities']),
|
|
780
|
+
)
|
|
781
|
+
|
|
782
|
+
if getv(from_object, ['temperature']) is not None:
|
|
783
|
+
setv(
|
|
784
|
+
parent_object,
|
|
785
|
+
['setup', 'generationConfig', 'temperature'],
|
|
786
|
+
getv(from_object, ['temperature']),
|
|
787
|
+
)
|
|
788
|
+
|
|
789
|
+
if getv(from_object, ['top_p']) is not None:
|
|
790
|
+
setv(
|
|
791
|
+
parent_object,
|
|
792
|
+
['setup', 'generationConfig', 'topP'],
|
|
793
|
+
getv(from_object, ['top_p']),
|
|
794
|
+
)
|
|
795
|
+
|
|
796
|
+
if getv(from_object, ['top_k']) is not None:
|
|
797
|
+
setv(
|
|
798
|
+
parent_object,
|
|
799
|
+
['setup', 'generationConfig', 'topK'],
|
|
800
|
+
getv(from_object, ['top_k']),
|
|
801
|
+
)
|
|
802
|
+
|
|
803
|
+
if getv(from_object, ['max_output_tokens']) is not None:
|
|
804
|
+
setv(
|
|
805
|
+
parent_object,
|
|
806
|
+
['setup', 'generationConfig', 'maxOutputTokens'],
|
|
807
|
+
getv(from_object, ['max_output_tokens']),
|
|
808
|
+
)
|
|
809
|
+
|
|
810
|
+
if getv(from_object, ['media_resolution']) is not None:
|
|
811
|
+
setv(
|
|
812
|
+
parent_object,
|
|
813
|
+
['setup', 'generationConfig', 'mediaResolution'],
|
|
814
|
+
getv(from_object, ['media_resolution']),
|
|
815
|
+
)
|
|
816
|
+
|
|
817
|
+
if getv(from_object, ['seed']) is not None:
|
|
818
|
+
setv(
|
|
819
|
+
parent_object,
|
|
820
|
+
['setup', 'generationConfig', 'seed'],
|
|
821
|
+
getv(from_object, ['seed']),
|
|
822
|
+
)
|
|
823
|
+
|
|
824
|
+
if getv(from_object, ['speech_config']) is not None:
|
|
825
|
+
setv(
|
|
826
|
+
parent_object,
|
|
827
|
+
['setup', 'generationConfig', 'speechConfig'],
|
|
828
|
+
_SpeechConfig_to_vertex(
|
|
829
|
+
t.t_live_speech_config(getv(from_object, ['speech_config'])),
|
|
830
|
+
to_object,
|
|
831
|
+
),
|
|
832
|
+
)
|
|
833
|
+
|
|
834
|
+
if getv(from_object, ['thinking_config']) is not None:
|
|
835
|
+
setv(
|
|
836
|
+
parent_object,
|
|
837
|
+
['setup', 'generationConfig', 'thinkingConfig'],
|
|
838
|
+
getv(from_object, ['thinking_config']),
|
|
839
|
+
)
|
|
840
|
+
|
|
841
|
+
if getv(from_object, ['enable_affective_dialog']) is not None:
|
|
842
|
+
setv(
|
|
843
|
+
parent_object,
|
|
844
|
+
['setup', 'generationConfig', 'enableAffectiveDialog'],
|
|
845
|
+
getv(from_object, ['enable_affective_dialog']),
|
|
846
|
+
)
|
|
847
|
+
|
|
848
|
+
if getv(from_object, ['system_instruction']) is not None:
|
|
849
|
+
setv(
|
|
850
|
+
parent_object,
|
|
851
|
+
['setup', 'systemInstruction'],
|
|
852
|
+
t.t_content(getv(from_object, ['system_instruction'])),
|
|
853
|
+
)
|
|
854
|
+
|
|
855
|
+
if getv(from_object, ['tools']) is not None:
|
|
856
|
+
setv(
|
|
857
|
+
parent_object,
|
|
858
|
+
['setup', 'tools'],
|
|
859
|
+
[
|
|
860
|
+
_Tool_to_vertex(t.t_tool(api_client, item), to_object)
|
|
861
|
+
for item in t.t_tools(api_client, getv(from_object, ['tools']))
|
|
862
|
+
],
|
|
863
|
+
)
|
|
864
|
+
|
|
865
|
+
if getv(from_object, ['session_resumption']) is not None:
|
|
866
|
+
setv(
|
|
867
|
+
parent_object,
|
|
868
|
+
['setup', 'sessionResumption'],
|
|
869
|
+
getv(from_object, ['session_resumption']),
|
|
870
|
+
)
|
|
871
|
+
|
|
872
|
+
if getv(from_object, ['input_audio_transcription']) is not None:
|
|
873
|
+
setv(
|
|
874
|
+
parent_object,
|
|
875
|
+
['setup', 'inputAudioTranscription'],
|
|
876
|
+
getv(from_object, ['input_audio_transcription']),
|
|
877
|
+
)
|
|
878
|
+
|
|
879
|
+
if getv(from_object, ['output_audio_transcription']) is not None:
|
|
880
|
+
setv(
|
|
881
|
+
parent_object,
|
|
882
|
+
['setup', 'outputAudioTranscription'],
|
|
883
|
+
getv(from_object, ['output_audio_transcription']),
|
|
884
|
+
)
|
|
885
|
+
|
|
886
|
+
if getv(from_object, ['realtime_input_config']) is not None:
|
|
887
|
+
setv(
|
|
888
|
+
parent_object,
|
|
889
|
+
['setup', 'realtimeInputConfig'],
|
|
890
|
+
getv(from_object, ['realtime_input_config']),
|
|
891
|
+
)
|
|
892
|
+
|
|
893
|
+
if getv(from_object, ['context_window_compression']) is not None:
|
|
894
|
+
setv(
|
|
895
|
+
parent_object,
|
|
896
|
+
['setup', 'contextWindowCompression'],
|
|
897
|
+
getv(from_object, ['context_window_compression']),
|
|
898
|
+
)
|
|
899
|
+
|
|
900
|
+
if getv(from_object, ['proactivity']) is not None:
|
|
901
|
+
setv(
|
|
902
|
+
parent_object,
|
|
903
|
+
['setup', 'proactivity'],
|
|
904
|
+
getv(from_object, ['proactivity']),
|
|
905
|
+
)
|
|
906
|
+
|
|
907
|
+
return to_object
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
def _LiveConnectParameters_to_mldev(
|
|
911
|
+
api_client: BaseApiClient,
|
|
912
|
+
from_object: Union[dict[str, Any], object],
|
|
913
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
914
|
+
) -> dict[str, Any]:
|
|
915
|
+
to_object: dict[str, Any] = {}
|
|
916
|
+
if getv(from_object, ['model']) is not None:
|
|
917
|
+
setv(
|
|
918
|
+
to_object,
|
|
919
|
+
['setup', 'model'],
|
|
920
|
+
t.t_model(api_client, getv(from_object, ['model'])),
|
|
921
|
+
)
|
|
922
|
+
|
|
923
|
+
if getv(from_object, ['config']) is not None:
|
|
924
|
+
setv(
|
|
925
|
+
to_object,
|
|
926
|
+
['config'],
|
|
927
|
+
_LiveConnectConfig_to_mldev(
|
|
928
|
+
api_client, getv(from_object, ['config']), to_object
|
|
929
|
+
),
|
|
930
|
+
)
|
|
931
|
+
|
|
932
|
+
return to_object
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
def _LiveConnectParameters_to_vertex(
|
|
936
|
+
api_client: BaseApiClient,
|
|
937
|
+
from_object: Union[dict[str, Any], object],
|
|
938
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
939
|
+
) -> dict[str, Any]:
|
|
940
|
+
to_object: dict[str, Any] = {}
|
|
941
|
+
if getv(from_object, ['model']) is not None:
|
|
942
|
+
setv(
|
|
943
|
+
to_object,
|
|
944
|
+
['setup', 'model'],
|
|
945
|
+
t.t_model(api_client, getv(from_object, ['model'])),
|
|
946
|
+
)
|
|
947
|
+
|
|
948
|
+
if getv(from_object, ['config']) is not None:
|
|
949
|
+
setv(
|
|
950
|
+
to_object,
|
|
951
|
+
['config'],
|
|
952
|
+
_LiveConnectConfig_to_vertex(
|
|
953
|
+
api_client, getv(from_object, ['config']), to_object
|
|
954
|
+
),
|
|
955
|
+
)
|
|
956
|
+
|
|
957
|
+
return to_object
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
def _LiveMusicClientMessage_to_vertex(
|
|
961
|
+
from_object: Union[dict[str, Any], object],
|
|
962
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
963
|
+
) -> dict[str, Any]:
|
|
964
|
+
to_object: dict[str, Any] = {}
|
|
965
|
+
if getv(from_object, ['setup']) is not None:
|
|
966
|
+
raise ValueError('setup parameter is not supported in Vertex AI.')
|
|
967
|
+
|
|
968
|
+
if getv(from_object, ['client_content']) is not None:
|
|
969
|
+
raise ValueError('client_content parameter is not supported in Vertex AI.')
|
|
970
|
+
|
|
971
|
+
if getv(from_object, ['music_generation_config']) is not None:
|
|
972
|
+
raise ValueError(
|
|
973
|
+
'music_generation_config parameter is not supported in Vertex AI.'
|
|
974
|
+
)
|
|
975
|
+
|
|
976
|
+
if getv(from_object, ['playback_control']) is not None:
|
|
977
|
+
raise ValueError(
|
|
978
|
+
'playback_control parameter is not supported in Vertex AI.'
|
|
979
|
+
)
|
|
980
|
+
|
|
981
|
+
return to_object
|
|
982
|
+
|
|
983
|
+
|
|
984
|
+
def _LiveMusicConnectParameters_to_mldev(
|
|
985
|
+
from_object: Union[dict[str, Any], object],
|
|
986
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
987
|
+
) -> dict[str, Any]:
|
|
988
|
+
to_object: dict[str, Any] = {}
|
|
989
|
+
if getv(from_object, ['model']) is not None:
|
|
990
|
+
setv(to_object, ['setup', 'model'], getv(from_object, ['model']))
|
|
991
|
+
|
|
992
|
+
return to_object
|
|
993
|
+
|
|
994
|
+
|
|
995
|
+
def _LiveMusicConnectParameters_to_vertex(
|
|
996
|
+
from_object: Union[dict[str, Any], object],
|
|
997
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
998
|
+
) -> dict[str, Any]:
|
|
999
|
+
to_object: dict[str, Any] = {}
|
|
1000
|
+
if getv(from_object, ['model']) is not None:
|
|
1001
|
+
raise ValueError('model parameter is not supported in Vertex AI.')
|
|
1002
|
+
|
|
1003
|
+
return to_object
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
def _LiveMusicSetConfigParameters_to_mldev(
|
|
1007
|
+
from_object: Union[dict[str, Any], object],
|
|
1008
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1009
|
+
) -> dict[str, Any]:
|
|
1010
|
+
to_object: dict[str, Any] = {}
|
|
1011
|
+
if getv(from_object, ['music_generation_config']) is not None:
|
|
1012
|
+
setv(
|
|
1013
|
+
to_object,
|
|
1014
|
+
['musicGenerationConfig'],
|
|
1015
|
+
getv(from_object, ['music_generation_config']),
|
|
1016
|
+
)
|
|
1017
|
+
|
|
1018
|
+
return to_object
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
def _LiveMusicSetConfigParameters_to_vertex(
|
|
1022
|
+
from_object: Union[dict[str, Any], object],
|
|
1023
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1024
|
+
) -> dict[str, Any]:
|
|
1025
|
+
to_object: dict[str, Any] = {}
|
|
1026
|
+
if getv(from_object, ['music_generation_config']) is not None:
|
|
1027
|
+
raise ValueError(
|
|
1028
|
+
'music_generation_config parameter is not supported in Vertex AI.'
|
|
1029
|
+
)
|
|
1030
|
+
|
|
1031
|
+
return to_object
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
def _LiveMusicSetWeightedPromptsParameters_to_mldev(
|
|
1035
|
+
from_object: Union[dict[str, Any], object],
|
|
1036
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1037
|
+
) -> dict[str, Any]:
|
|
1038
|
+
to_object: dict[str, Any] = {}
|
|
1039
|
+
if getv(from_object, ['weighted_prompts']) is not None:
|
|
1040
|
+
setv(
|
|
1041
|
+
to_object,
|
|
1042
|
+
['weightedPrompts'],
|
|
1043
|
+
[item for item in getv(from_object, ['weighted_prompts'])],
|
|
1044
|
+
)
|
|
1045
|
+
|
|
1046
|
+
return to_object
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
def _LiveMusicSetWeightedPromptsParameters_to_vertex(
|
|
1050
|
+
from_object: Union[dict[str, Any], object],
|
|
1051
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1052
|
+
) -> dict[str, Any]:
|
|
1053
|
+
to_object: dict[str, Any] = {}
|
|
1054
|
+
if getv(from_object, ['weighted_prompts']) is not None:
|
|
1055
|
+
raise ValueError(
|
|
1056
|
+
'weighted_prompts parameter is not supported in Vertex AI.'
|
|
1057
|
+
)
|
|
1058
|
+
|
|
1059
|
+
return to_object
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
def _LiveSendRealtimeInputParameters_to_mldev(
|
|
1063
|
+
from_object: Union[dict[str, Any], object],
|
|
1064
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1065
|
+
) -> dict[str, Any]:
|
|
1066
|
+
to_object: dict[str, Any] = {}
|
|
1067
|
+
if getv(from_object, ['media']) is not None:
|
|
1068
|
+
setv(
|
|
1069
|
+
to_object,
|
|
1070
|
+
['mediaChunks'],
|
|
1071
|
+
[
|
|
1072
|
+
_Blob_to_mldev(item, to_object)
|
|
1073
|
+
for item in t.t_blobs(getv(from_object, ['media']))
|
|
1074
|
+
],
|
|
1075
|
+
)
|
|
1076
|
+
|
|
1077
|
+
if getv(from_object, ['audio']) is not None:
|
|
1078
|
+
setv(
|
|
1079
|
+
to_object,
|
|
1080
|
+
['audio'],
|
|
1081
|
+
_Blob_to_mldev(t.t_audio_blob(getv(from_object, ['audio'])), to_object),
|
|
1082
|
+
)
|
|
1083
|
+
|
|
1084
|
+
if getv(from_object, ['audio_stream_end']) is not None:
|
|
1085
|
+
setv(to_object, ['audioStreamEnd'], getv(from_object, ['audio_stream_end']))
|
|
1086
|
+
|
|
1087
|
+
if getv(from_object, ['video']) is not None:
|
|
1088
|
+
setv(
|
|
1089
|
+
to_object,
|
|
1090
|
+
['video'],
|
|
1091
|
+
_Blob_to_mldev(t.t_image_blob(getv(from_object, ['video'])), to_object),
|
|
1092
|
+
)
|
|
1093
|
+
|
|
1094
|
+
if getv(from_object, ['text']) is not None:
|
|
1095
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
|
1096
|
+
|
|
1097
|
+
if getv(from_object, ['activity_start']) is not None:
|
|
1098
|
+
setv(to_object, ['activityStart'], getv(from_object, ['activity_start']))
|
|
1099
|
+
|
|
1100
|
+
if getv(from_object, ['activity_end']) is not None:
|
|
1101
|
+
setv(to_object, ['activityEnd'], getv(from_object, ['activity_end']))
|
|
1102
|
+
|
|
1103
|
+
return to_object
|
|
1104
|
+
|
|
1105
|
+
|
|
1106
|
+
def _LiveSendRealtimeInputParameters_to_vertex(
|
|
1107
|
+
from_object: Union[dict[str, Any], object],
|
|
1108
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1109
|
+
) -> dict[str, Any]:
|
|
1110
|
+
to_object: dict[str, Any] = {}
|
|
1111
|
+
if getv(from_object, ['media']) is not None:
|
|
1112
|
+
setv(
|
|
1113
|
+
to_object,
|
|
1114
|
+
['mediaChunks'],
|
|
1115
|
+
[item for item in t.t_blobs(getv(from_object, ['media']))],
|
|
1116
|
+
)
|
|
1117
|
+
|
|
1118
|
+
if getv(from_object, ['audio']) is not None:
|
|
1119
|
+
setv(to_object, ['audio'], t.t_audio_blob(getv(from_object, ['audio'])))
|
|
1120
|
+
|
|
1121
|
+
if getv(from_object, ['audio_stream_end']) is not None:
|
|
1122
|
+
setv(to_object, ['audioStreamEnd'], getv(from_object, ['audio_stream_end']))
|
|
1123
|
+
|
|
1124
|
+
if getv(from_object, ['video']) is not None:
|
|
1125
|
+
setv(to_object, ['video'], t.t_image_blob(getv(from_object, ['video'])))
|
|
1126
|
+
|
|
1127
|
+
if getv(from_object, ['text']) is not None:
|
|
1128
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
|
1129
|
+
|
|
1130
|
+
if getv(from_object, ['activity_start']) is not None:
|
|
1131
|
+
setv(to_object, ['activityStart'], getv(from_object, ['activity_start']))
|
|
1132
|
+
|
|
1133
|
+
if getv(from_object, ['activity_end']) is not None:
|
|
1134
|
+
setv(to_object, ['activityEnd'], getv(from_object, ['activity_end']))
|
|
1135
|
+
|
|
1136
|
+
return to_object
|
|
1137
|
+
|
|
1138
|
+
|
|
1139
|
+
def _LiveServerMessage_from_vertex(
|
|
1140
|
+
from_object: Union[dict[str, Any], object],
|
|
1141
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1142
|
+
) -> dict[str, Any]:
|
|
1143
|
+
to_object: dict[str, Any] = {}
|
|
1144
|
+
if getv(from_object, ['setupComplete']) is not None:
|
|
1145
|
+
setv(to_object, ['setup_complete'], getv(from_object, ['setupComplete']))
|
|
1146
|
+
|
|
1147
|
+
if getv(from_object, ['serverContent']) is not None:
|
|
1148
|
+
setv(to_object, ['server_content'], getv(from_object, ['serverContent']))
|
|
1149
|
+
|
|
1150
|
+
if getv(from_object, ['toolCall']) is not None:
|
|
1151
|
+
setv(to_object, ['tool_call'], getv(from_object, ['toolCall']))
|
|
1152
|
+
|
|
1153
|
+
if getv(from_object, ['toolCallCancellation']) is not None:
|
|
1154
|
+
setv(
|
|
1155
|
+
to_object,
|
|
1156
|
+
['tool_call_cancellation'],
|
|
1157
|
+
getv(from_object, ['toolCallCancellation']),
|
|
1158
|
+
)
|
|
1159
|
+
|
|
1160
|
+
if getv(from_object, ['usageMetadata']) is not None:
|
|
1161
|
+
setv(
|
|
1162
|
+
to_object,
|
|
1163
|
+
['usage_metadata'],
|
|
1164
|
+
_UsageMetadata_from_vertex(
|
|
1165
|
+
getv(from_object, ['usageMetadata']), to_object
|
|
1166
|
+
),
|
|
1167
|
+
)
|
|
1168
|
+
|
|
1169
|
+
if getv(from_object, ['goAway']) is not None:
|
|
1170
|
+
setv(to_object, ['go_away'], getv(from_object, ['goAway']))
|
|
1171
|
+
|
|
1172
|
+
if getv(from_object, ['sessionResumptionUpdate']) is not None:
|
|
1173
|
+
setv(
|
|
1174
|
+
to_object,
|
|
1175
|
+
['session_resumption_update'],
|
|
1176
|
+
getv(from_object, ['sessionResumptionUpdate']),
|
|
1177
|
+
)
|
|
1178
|
+
|
|
1179
|
+
return to_object
|
|
1180
|
+
|
|
1181
|
+
|
|
1182
|
+
def _Part_to_mldev(
|
|
1183
|
+
from_object: Union[dict[str, Any], object],
|
|
1184
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1185
|
+
) -> dict[str, Any]:
|
|
1186
|
+
to_object: dict[str, Any] = {}
|
|
1187
|
+
if getv(from_object, ['media_resolution']) is not None:
|
|
1188
|
+
setv(
|
|
1189
|
+
to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
|
|
1190
|
+
)
|
|
1191
|
+
|
|
1192
|
+
if getv(from_object, ['code_execution_result']) is not None:
|
|
1193
|
+
setv(
|
|
1194
|
+
to_object,
|
|
1195
|
+
['codeExecutionResult'],
|
|
1196
|
+
getv(from_object, ['code_execution_result']),
|
|
1197
|
+
)
|
|
1198
|
+
|
|
1199
|
+
if getv(from_object, ['executable_code']) is not None:
|
|
1200
|
+
setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
|
|
1201
|
+
|
|
1202
|
+
if getv(from_object, ['file_data']) is not None:
|
|
1203
|
+
setv(
|
|
1204
|
+
to_object,
|
|
1205
|
+
['fileData'],
|
|
1206
|
+
_FileData_to_mldev(getv(from_object, ['file_data']), to_object),
|
|
1207
|
+
)
|
|
1208
|
+
|
|
1209
|
+
if getv(from_object, ['function_call']) is not None:
|
|
1210
|
+
setv(
|
|
1211
|
+
to_object,
|
|
1212
|
+
['functionCall'],
|
|
1213
|
+
_FunctionCall_to_mldev(getv(from_object, ['function_call']), to_object),
|
|
1214
|
+
)
|
|
1215
|
+
|
|
1216
|
+
if getv(from_object, ['function_response']) is not None:
|
|
1217
|
+
setv(
|
|
1218
|
+
to_object,
|
|
1219
|
+
['functionResponse'],
|
|
1220
|
+
getv(from_object, ['function_response']),
|
|
1221
|
+
)
|
|
1222
|
+
|
|
1223
|
+
if getv(from_object, ['inline_data']) is not None:
|
|
1224
|
+
setv(
|
|
1225
|
+
to_object,
|
|
1226
|
+
['inlineData'],
|
|
1227
|
+
_Blob_to_mldev(getv(from_object, ['inline_data']), to_object),
|
|
1228
|
+
)
|
|
1229
|
+
|
|
1230
|
+
if getv(from_object, ['text']) is not None:
|
|
1231
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
|
1232
|
+
|
|
1233
|
+
if getv(from_object, ['thought']) is not None:
|
|
1234
|
+
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
|
1235
|
+
|
|
1236
|
+
if getv(from_object, ['thought_signature']) is not None:
|
|
1237
|
+
setv(
|
|
1238
|
+
to_object,
|
|
1239
|
+
['thoughtSignature'],
|
|
1240
|
+
getv(from_object, ['thought_signature']),
|
|
1241
|
+
)
|
|
1242
|
+
|
|
1243
|
+
if getv(from_object, ['video_metadata']) is not None:
|
|
1244
|
+
setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
|
|
1245
|
+
|
|
1246
|
+
return to_object
|
|
1247
|
+
|
|
1248
|
+
|
|
1249
|
+
def _SessionResumptionConfig_to_mldev(
|
|
1250
|
+
from_object: Union[dict[str, Any], object],
|
|
1251
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1252
|
+
) -> dict[str, Any]:
|
|
1253
|
+
to_object: dict[str, Any] = {}
|
|
1254
|
+
if getv(from_object, ['handle']) is not None:
|
|
1255
|
+
setv(to_object, ['handle'], getv(from_object, ['handle']))
|
|
1256
|
+
|
|
1257
|
+
if getv(from_object, ['transparent']) is not None:
|
|
1258
|
+
raise ValueError('transparent parameter is not supported in Gemini API.')
|
|
1259
|
+
|
|
1260
|
+
return to_object
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
def _SpeechConfig_to_vertex(
|
|
1264
|
+
from_object: Union[dict[str, Any], object],
|
|
1265
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1266
|
+
) -> dict[str, Any]:
|
|
1267
|
+
to_object: dict[str, Any] = {}
|
|
1268
|
+
if getv(from_object, ['language_code']) is not None:
|
|
1269
|
+
setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
|
|
1270
|
+
|
|
1271
|
+
if getv(from_object, ['voice_config']) is not None:
|
|
1272
|
+
setv(to_object, ['voiceConfig'], getv(from_object, ['voice_config']))
|
|
1273
|
+
|
|
1274
|
+
if getv(from_object, ['multi_speaker_voice_config']) is not None:
|
|
1275
|
+
raise ValueError(
|
|
1276
|
+
'multi_speaker_voice_config parameter is not supported in Vertex AI.'
|
|
1277
|
+
)
|
|
1278
|
+
|
|
1279
|
+
return to_object
|
|
1280
|
+
|
|
1281
|
+
|
|
1282
|
+
def _Tool_to_mldev(
|
|
1283
|
+
from_object: Union[dict[str, Any], object],
|
|
1284
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1285
|
+
) -> dict[str, Any]:
|
|
1286
|
+
to_object: dict[str, Any] = {}
|
|
1287
|
+
if getv(from_object, ['function_declarations']) is not None:
|
|
1288
|
+
setv(
|
|
1289
|
+
to_object,
|
|
1290
|
+
['functionDeclarations'],
|
|
1291
|
+
[item for item in getv(from_object, ['function_declarations'])],
|
|
1292
|
+
)
|
|
1293
|
+
|
|
1294
|
+
if getv(from_object, ['retrieval']) is not None:
|
|
1295
|
+
raise ValueError('retrieval parameter is not supported in Gemini API.')
|
|
1296
|
+
|
|
1297
|
+
if getv(from_object, ['google_search_retrieval']) is not None:
|
|
1298
|
+
setv(
|
|
1299
|
+
to_object,
|
|
1300
|
+
['googleSearchRetrieval'],
|
|
1301
|
+
getv(from_object, ['google_search_retrieval']),
|
|
1302
|
+
)
|
|
1303
|
+
|
|
1304
|
+
if getv(from_object, ['computer_use']) is not None:
|
|
1305
|
+
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
|
|
1306
|
+
|
|
1307
|
+
if getv(from_object, ['file_search']) is not None:
|
|
1308
|
+
setv(to_object, ['fileSearch'], getv(from_object, ['file_search']))
|
|
1309
|
+
|
|
1310
|
+
if getv(from_object, ['code_execution']) is not None:
|
|
1311
|
+
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
|
1312
|
+
|
|
1313
|
+
if getv(from_object, ['enterprise_web_search']) is not None:
|
|
1314
|
+
raise ValueError(
|
|
1315
|
+
'enterprise_web_search parameter is not supported in Gemini API.'
|
|
1316
|
+
)
|
|
1317
|
+
|
|
1318
|
+
if getv(from_object, ['google_maps']) is not None:
|
|
1319
|
+
setv(
|
|
1320
|
+
to_object,
|
|
1321
|
+
['googleMaps'],
|
|
1322
|
+
_GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
|
|
1323
|
+
)
|
|
1324
|
+
|
|
1325
|
+
if getv(from_object, ['google_search']) is not None:
|
|
1326
|
+
setv(
|
|
1327
|
+
to_object,
|
|
1328
|
+
['googleSearch'],
|
|
1329
|
+
_GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
|
|
1330
|
+
)
|
|
1331
|
+
|
|
1332
|
+
if getv(from_object, ['url_context']) is not None:
|
|
1333
|
+
setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
|
|
1334
|
+
|
|
1335
|
+
return to_object
|
|
1336
|
+
|
|
1337
|
+
|
|
1338
|
+
def _Tool_to_vertex(
|
|
1339
|
+
from_object: Union[dict[str, Any], object],
|
|
1340
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1341
|
+
) -> dict[str, Any]:
|
|
1342
|
+
to_object: dict[str, Any] = {}
|
|
1343
|
+
if getv(from_object, ['function_declarations']) is not None:
|
|
1344
|
+
setv(
|
|
1345
|
+
to_object,
|
|
1346
|
+
['functionDeclarations'],
|
|
1347
|
+
[
|
|
1348
|
+
_FunctionDeclaration_to_vertex(item, to_object)
|
|
1349
|
+
for item in getv(from_object, ['function_declarations'])
|
|
1350
|
+
],
|
|
1351
|
+
)
|
|
1352
|
+
|
|
1353
|
+
if getv(from_object, ['retrieval']) is not None:
|
|
1354
|
+
setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
|
|
1355
|
+
|
|
1356
|
+
if getv(from_object, ['google_search_retrieval']) is not None:
|
|
1357
|
+
setv(
|
|
1358
|
+
to_object,
|
|
1359
|
+
['googleSearchRetrieval'],
|
|
1360
|
+
getv(from_object, ['google_search_retrieval']),
|
|
1361
|
+
)
|
|
1362
|
+
|
|
1363
|
+
if getv(from_object, ['computer_use']) is not None:
|
|
1364
|
+
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
|
|
1365
|
+
|
|
1366
|
+
if getv(from_object, ['file_search']) is not None:
|
|
1367
|
+
raise ValueError('file_search parameter is not supported in Vertex AI.')
|
|
1368
|
+
|
|
1369
|
+
if getv(from_object, ['code_execution']) is not None:
|
|
1370
|
+
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
|
1371
|
+
|
|
1372
|
+
if getv(from_object, ['enterprise_web_search']) is not None:
|
|
1373
|
+
setv(
|
|
1374
|
+
to_object,
|
|
1375
|
+
['enterpriseWebSearch'],
|
|
1376
|
+
getv(from_object, ['enterprise_web_search']),
|
|
1377
|
+
)
|
|
1378
|
+
|
|
1379
|
+
if getv(from_object, ['google_maps']) is not None:
|
|
1380
|
+
setv(to_object, ['googleMaps'], getv(from_object, ['google_maps']))
|
|
1381
|
+
|
|
1382
|
+
if getv(from_object, ['google_search']) is not None:
|
|
1383
|
+
setv(to_object, ['googleSearch'], getv(from_object, ['google_search']))
|
|
1384
|
+
|
|
1385
|
+
if getv(from_object, ['url_context']) is not None:
|
|
1386
|
+
setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
|
|
1387
|
+
|
|
1388
|
+
return to_object
|
|
1389
|
+
|
|
1390
|
+
|
|
1391
|
+
def _UsageMetadata_from_vertex(
|
|
1392
|
+
from_object: Union[dict[str, Any], object],
|
|
1393
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1394
|
+
) -> dict[str, Any]:
|
|
1395
|
+
to_object: dict[str, Any] = {}
|
|
1396
|
+
if getv(from_object, ['promptTokenCount']) is not None:
|
|
1397
|
+
setv(
|
|
1398
|
+
to_object,
|
|
1399
|
+
['prompt_token_count'],
|
|
1400
|
+
getv(from_object, ['promptTokenCount']),
|
|
1401
|
+
)
|
|
1402
|
+
|
|
1403
|
+
if getv(from_object, ['cachedContentTokenCount']) is not None:
|
|
1404
|
+
setv(
|
|
1405
|
+
to_object,
|
|
1406
|
+
['cached_content_token_count'],
|
|
1407
|
+
getv(from_object, ['cachedContentTokenCount']),
|
|
1408
|
+
)
|
|
1409
|
+
|
|
1410
|
+
if getv(from_object, ['candidatesTokenCount']) is not None:
|
|
1411
|
+
setv(
|
|
1412
|
+
to_object,
|
|
1413
|
+
['response_token_count'],
|
|
1414
|
+
getv(from_object, ['candidatesTokenCount']),
|
|
1415
|
+
)
|
|
1416
|
+
|
|
1417
|
+
if getv(from_object, ['toolUsePromptTokenCount']) is not None:
|
|
1418
|
+
setv(
|
|
1419
|
+
to_object,
|
|
1420
|
+
['tool_use_prompt_token_count'],
|
|
1421
|
+
getv(from_object, ['toolUsePromptTokenCount']),
|
|
1422
|
+
)
|
|
1423
|
+
|
|
1424
|
+
if getv(from_object, ['thoughtsTokenCount']) is not None:
|
|
1425
|
+
setv(
|
|
1426
|
+
to_object,
|
|
1427
|
+
['thoughts_token_count'],
|
|
1428
|
+
getv(from_object, ['thoughtsTokenCount']),
|
|
1429
|
+
)
|
|
1430
|
+
|
|
1431
|
+
if getv(from_object, ['totalTokenCount']) is not None:
|
|
1432
|
+
setv(
|
|
1433
|
+
to_object, ['total_token_count'], getv(from_object, ['totalTokenCount'])
|
|
1434
|
+
)
|
|
1435
|
+
|
|
1436
|
+
if getv(from_object, ['promptTokensDetails']) is not None:
|
|
1437
|
+
setv(
|
|
1438
|
+
to_object,
|
|
1439
|
+
['prompt_tokens_details'],
|
|
1440
|
+
[item for item in getv(from_object, ['promptTokensDetails'])],
|
|
1441
|
+
)
|
|
1442
|
+
|
|
1443
|
+
if getv(from_object, ['cacheTokensDetails']) is not None:
|
|
1444
|
+
setv(
|
|
1445
|
+
to_object,
|
|
1446
|
+
['cache_tokens_details'],
|
|
1447
|
+
[item for item in getv(from_object, ['cacheTokensDetails'])],
|
|
1448
|
+
)
|
|
1449
|
+
|
|
1450
|
+
if getv(from_object, ['candidatesTokensDetails']) is not None:
|
|
1451
|
+
setv(
|
|
1452
|
+
to_object,
|
|
1453
|
+
['response_tokens_details'],
|
|
1454
|
+
[item for item in getv(from_object, ['candidatesTokensDetails'])],
|
|
1455
|
+
)
|
|
1456
|
+
|
|
1457
|
+
if getv(from_object, ['toolUsePromptTokensDetails']) is not None:
|
|
1458
|
+
setv(
|
|
1459
|
+
to_object,
|
|
1460
|
+
['tool_use_prompt_tokens_details'],
|
|
1461
|
+
[item for item in getv(from_object, ['toolUsePromptTokensDetails'])],
|
|
1462
|
+
)
|
|
1463
|
+
|
|
1464
|
+
if getv(from_object, ['trafficType']) is not None:
|
|
1465
|
+
setv(to_object, ['traffic_type'], getv(from_object, ['trafficType']))
|
|
1466
|
+
|
|
1467
|
+
return to_object
|