google-genai 1.11.0__py3-none-any.whl → 1.12.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- google/genai/_api_client.py +25 -24
- google/genai/_automatic_function_calling_util.py +4 -24
- google/genai/_common.py +40 -37
- google/genai/_extra_utils.py +7 -7
- google/genai/_live_converters.py +2487 -0
- google/genai/_replay_api_client.py +32 -26
- google/genai/_transformers.py +46 -81
- google/genai/batches.py +45 -45
- google/genai/caches.py +126 -126
- google/genai/chats.py +13 -9
- google/genai/client.py +3 -2
- google/genai/errors.py +6 -6
- google/genai/files.py +38 -38
- google/genai/live.py +69 -17
- google/genai/models.py +388 -388
- google/genai/operations.py +33 -33
- google/genai/pagers.py +2 -2
- google/genai/py.typed +1 -0
- google/genai/tunings.py +70 -70
- google/genai/types.py +455 -24
- google/genai/version.py +1 -1
- {google_genai-1.11.0.dist-info → google_genai-1.12.0.dist-info}/METADATA +1 -1
- google_genai-1.12.0.dist-info/RECORD +29 -0
- {google_genai-1.11.0.dist-info → google_genai-1.12.0.dist-info}/WHEEL +1 -1
- google/genai/live_converters.py +0 -1298
- google_genai-1.11.0.dist-info/RECORD +0 -28
- {google_genai-1.11.0.dist-info → google_genai-1.12.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.11.0.dist-info → google_genai-1.12.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,2487 @@
|
|
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
|
+
from . import _transformers as t
|
20
|
+
from ._api_client import BaseApiClient
|
21
|
+
from ._common import get_value_by_path as getv
|
22
|
+
from ._common import set_value_by_path as setv
|
23
|
+
|
24
|
+
|
25
|
+
def _Part_to_mldev(
|
26
|
+
api_client: BaseApiClient,
|
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, ['video_metadata']) is not None:
|
32
|
+
raise ValueError('video_metadata parameter is not supported in Gemini API.')
|
33
|
+
|
34
|
+
if getv(from_object, ['thought']) is not None:
|
35
|
+
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
36
|
+
|
37
|
+
if getv(from_object, ['code_execution_result']) is not None:
|
38
|
+
setv(
|
39
|
+
to_object,
|
40
|
+
['codeExecutionResult'],
|
41
|
+
getv(from_object, ['code_execution_result']),
|
42
|
+
)
|
43
|
+
|
44
|
+
if getv(from_object, ['executable_code']) is not None:
|
45
|
+
setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
|
46
|
+
|
47
|
+
if getv(from_object, ['file_data']) is not None:
|
48
|
+
setv(to_object, ['fileData'], getv(from_object, ['file_data']))
|
49
|
+
|
50
|
+
if getv(from_object, ['function_call']) is not None:
|
51
|
+
setv(to_object, ['functionCall'], getv(from_object, ['function_call']))
|
52
|
+
|
53
|
+
if getv(from_object, ['function_response']) is not None:
|
54
|
+
setv(
|
55
|
+
to_object,
|
56
|
+
['functionResponse'],
|
57
|
+
getv(from_object, ['function_response']),
|
58
|
+
)
|
59
|
+
|
60
|
+
if getv(from_object, ['inline_data']) is not None:
|
61
|
+
setv(to_object, ['inlineData'], getv(from_object, ['inline_data']))
|
62
|
+
|
63
|
+
if getv(from_object, ['text']) is not None:
|
64
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
65
|
+
|
66
|
+
return to_object
|
67
|
+
|
68
|
+
|
69
|
+
def _Part_to_vertex(
|
70
|
+
api_client: BaseApiClient,
|
71
|
+
from_object: Union[dict[str, Any], object],
|
72
|
+
parent_object: Optional[dict[str, Any]] = None,
|
73
|
+
) -> dict[str, Any]:
|
74
|
+
to_object: dict[str, Any] = {}
|
75
|
+
if getv(from_object, ['video_metadata']) is not None:
|
76
|
+
setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
|
77
|
+
|
78
|
+
if getv(from_object, ['thought']) is not None:
|
79
|
+
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
80
|
+
|
81
|
+
if getv(from_object, ['code_execution_result']) is not None:
|
82
|
+
setv(
|
83
|
+
to_object,
|
84
|
+
['codeExecutionResult'],
|
85
|
+
getv(from_object, ['code_execution_result']),
|
86
|
+
)
|
87
|
+
|
88
|
+
if getv(from_object, ['executable_code']) is not None:
|
89
|
+
setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
|
90
|
+
|
91
|
+
if getv(from_object, ['file_data']) is not None:
|
92
|
+
setv(to_object, ['fileData'], getv(from_object, ['file_data']))
|
93
|
+
|
94
|
+
if getv(from_object, ['function_call']) is not None:
|
95
|
+
setv(to_object, ['functionCall'], getv(from_object, ['function_call']))
|
96
|
+
|
97
|
+
if getv(from_object, ['function_response']) is not None:
|
98
|
+
setv(
|
99
|
+
to_object,
|
100
|
+
['functionResponse'],
|
101
|
+
getv(from_object, ['function_response']),
|
102
|
+
)
|
103
|
+
|
104
|
+
if getv(from_object, ['inline_data']) is not None:
|
105
|
+
setv(to_object, ['inlineData'], getv(from_object, ['inline_data']))
|
106
|
+
|
107
|
+
if getv(from_object, ['text']) is not None:
|
108
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
109
|
+
|
110
|
+
return to_object
|
111
|
+
|
112
|
+
|
113
|
+
def _Content_to_mldev(
|
114
|
+
api_client: BaseApiClient,
|
115
|
+
from_object: Union[dict[str, Any], object],
|
116
|
+
parent_object: Optional[dict[str, Any]] = None,
|
117
|
+
) -> dict[str, Any]:
|
118
|
+
to_object: dict[str, Any] = {}
|
119
|
+
if getv(from_object, ['parts']) is not None:
|
120
|
+
setv(
|
121
|
+
to_object,
|
122
|
+
['parts'],
|
123
|
+
[
|
124
|
+
_Part_to_mldev(api_client, item, to_object)
|
125
|
+
for item in getv(from_object, ['parts'])
|
126
|
+
],
|
127
|
+
)
|
128
|
+
|
129
|
+
if getv(from_object, ['role']) is not None:
|
130
|
+
setv(to_object, ['role'], getv(from_object, ['role']))
|
131
|
+
|
132
|
+
return to_object
|
133
|
+
|
134
|
+
|
135
|
+
def _Content_to_vertex(
|
136
|
+
api_client: BaseApiClient,
|
137
|
+
from_object: Union[dict[str, Any], object],
|
138
|
+
parent_object: Optional[dict[str, Any]] = None,
|
139
|
+
) -> dict[str, Any]:
|
140
|
+
to_object: dict[str, Any] = {}
|
141
|
+
if getv(from_object, ['parts']) is not None:
|
142
|
+
setv(
|
143
|
+
to_object,
|
144
|
+
['parts'],
|
145
|
+
[
|
146
|
+
_Part_to_vertex(api_client, item, to_object)
|
147
|
+
for item in getv(from_object, ['parts'])
|
148
|
+
],
|
149
|
+
)
|
150
|
+
|
151
|
+
if getv(from_object, ['role']) is not None:
|
152
|
+
setv(to_object, ['role'], getv(from_object, ['role']))
|
153
|
+
|
154
|
+
return to_object
|
155
|
+
|
156
|
+
|
157
|
+
def _Schema_to_mldev(
|
158
|
+
api_client: BaseApiClient,
|
159
|
+
from_object: Union[dict[str, Any], object],
|
160
|
+
parent_object: Optional[dict[str, Any]] = None,
|
161
|
+
) -> dict[str, Any]:
|
162
|
+
to_object: dict[str, Any] = {}
|
163
|
+
if getv(from_object, ['example']) is not None:
|
164
|
+
raise ValueError('example parameter is not supported in Gemini API.')
|
165
|
+
|
166
|
+
if getv(from_object, ['pattern']) is not None:
|
167
|
+
raise ValueError('pattern parameter is not supported in Gemini API.')
|
168
|
+
|
169
|
+
if getv(from_object, ['default']) is not None:
|
170
|
+
raise ValueError('default parameter is not supported in Gemini API.')
|
171
|
+
|
172
|
+
if getv(from_object, ['max_length']) is not None:
|
173
|
+
raise ValueError('max_length parameter is not supported in Gemini API.')
|
174
|
+
|
175
|
+
if getv(from_object, ['min_length']) is not None:
|
176
|
+
raise ValueError('min_length parameter is not supported in Gemini API.')
|
177
|
+
|
178
|
+
if getv(from_object, ['min_properties']) is not None:
|
179
|
+
raise ValueError('min_properties parameter is not supported in Gemini API.')
|
180
|
+
|
181
|
+
if getv(from_object, ['max_properties']) is not None:
|
182
|
+
raise ValueError('max_properties parameter is not supported in Gemini API.')
|
183
|
+
|
184
|
+
if getv(from_object, ['any_of']) is not None:
|
185
|
+
setv(to_object, ['anyOf'], getv(from_object, ['any_of']))
|
186
|
+
|
187
|
+
if getv(from_object, ['description']) is not None:
|
188
|
+
setv(to_object, ['description'], getv(from_object, ['description']))
|
189
|
+
|
190
|
+
if getv(from_object, ['enum']) is not None:
|
191
|
+
setv(to_object, ['enum'], getv(from_object, ['enum']))
|
192
|
+
|
193
|
+
if getv(from_object, ['format']) is not None:
|
194
|
+
setv(to_object, ['format'], getv(from_object, ['format']))
|
195
|
+
|
196
|
+
if getv(from_object, ['items']) is not None:
|
197
|
+
setv(to_object, ['items'], getv(from_object, ['items']))
|
198
|
+
|
199
|
+
if getv(from_object, ['max_items']) is not None:
|
200
|
+
setv(to_object, ['maxItems'], getv(from_object, ['max_items']))
|
201
|
+
|
202
|
+
if getv(from_object, ['maximum']) is not None:
|
203
|
+
setv(to_object, ['maximum'], getv(from_object, ['maximum']))
|
204
|
+
|
205
|
+
if getv(from_object, ['min_items']) is not None:
|
206
|
+
setv(to_object, ['minItems'], getv(from_object, ['min_items']))
|
207
|
+
|
208
|
+
if getv(from_object, ['minimum']) is not None:
|
209
|
+
setv(to_object, ['minimum'], getv(from_object, ['minimum']))
|
210
|
+
|
211
|
+
if getv(from_object, ['nullable']) is not None:
|
212
|
+
setv(to_object, ['nullable'], getv(from_object, ['nullable']))
|
213
|
+
|
214
|
+
if getv(from_object, ['properties']) is not None:
|
215
|
+
setv(to_object, ['properties'], getv(from_object, ['properties']))
|
216
|
+
|
217
|
+
if getv(from_object, ['property_ordering']) is not None:
|
218
|
+
setv(
|
219
|
+
to_object,
|
220
|
+
['propertyOrdering'],
|
221
|
+
getv(from_object, ['property_ordering']),
|
222
|
+
)
|
223
|
+
|
224
|
+
if getv(from_object, ['required']) is not None:
|
225
|
+
setv(to_object, ['required'], getv(from_object, ['required']))
|
226
|
+
|
227
|
+
if getv(from_object, ['title']) is not None:
|
228
|
+
setv(to_object, ['title'], getv(from_object, ['title']))
|
229
|
+
|
230
|
+
if getv(from_object, ['type']) is not None:
|
231
|
+
setv(to_object, ['type'], getv(from_object, ['type']))
|
232
|
+
|
233
|
+
return to_object
|
234
|
+
|
235
|
+
|
236
|
+
def _Schema_to_vertex(
|
237
|
+
api_client: BaseApiClient,
|
238
|
+
from_object: Union[dict[str, Any], object],
|
239
|
+
parent_object: Optional[dict[str, Any]] = None,
|
240
|
+
) -> dict[str, Any]:
|
241
|
+
to_object: dict[str, Any] = {}
|
242
|
+
if getv(from_object, ['example']) is not None:
|
243
|
+
setv(to_object, ['example'], getv(from_object, ['example']))
|
244
|
+
|
245
|
+
if getv(from_object, ['pattern']) is not None:
|
246
|
+
setv(to_object, ['pattern'], getv(from_object, ['pattern']))
|
247
|
+
|
248
|
+
if getv(from_object, ['default']) is not None:
|
249
|
+
setv(to_object, ['default'], getv(from_object, ['default']))
|
250
|
+
|
251
|
+
if getv(from_object, ['max_length']) is not None:
|
252
|
+
setv(to_object, ['maxLength'], getv(from_object, ['max_length']))
|
253
|
+
|
254
|
+
if getv(from_object, ['min_length']) is not None:
|
255
|
+
setv(to_object, ['minLength'], getv(from_object, ['min_length']))
|
256
|
+
|
257
|
+
if getv(from_object, ['min_properties']) is not None:
|
258
|
+
setv(to_object, ['minProperties'], getv(from_object, ['min_properties']))
|
259
|
+
|
260
|
+
if getv(from_object, ['max_properties']) is not None:
|
261
|
+
setv(to_object, ['maxProperties'], getv(from_object, ['max_properties']))
|
262
|
+
|
263
|
+
if getv(from_object, ['any_of']) is not None:
|
264
|
+
setv(to_object, ['anyOf'], getv(from_object, ['any_of']))
|
265
|
+
|
266
|
+
if getv(from_object, ['description']) is not None:
|
267
|
+
setv(to_object, ['description'], getv(from_object, ['description']))
|
268
|
+
|
269
|
+
if getv(from_object, ['enum']) is not None:
|
270
|
+
setv(to_object, ['enum'], getv(from_object, ['enum']))
|
271
|
+
|
272
|
+
if getv(from_object, ['format']) is not None:
|
273
|
+
setv(to_object, ['format'], getv(from_object, ['format']))
|
274
|
+
|
275
|
+
if getv(from_object, ['items']) is not None:
|
276
|
+
setv(to_object, ['items'], getv(from_object, ['items']))
|
277
|
+
|
278
|
+
if getv(from_object, ['max_items']) is not None:
|
279
|
+
setv(to_object, ['maxItems'], getv(from_object, ['max_items']))
|
280
|
+
|
281
|
+
if getv(from_object, ['maximum']) is not None:
|
282
|
+
setv(to_object, ['maximum'], getv(from_object, ['maximum']))
|
283
|
+
|
284
|
+
if getv(from_object, ['min_items']) is not None:
|
285
|
+
setv(to_object, ['minItems'], getv(from_object, ['min_items']))
|
286
|
+
|
287
|
+
if getv(from_object, ['minimum']) is not None:
|
288
|
+
setv(to_object, ['minimum'], getv(from_object, ['minimum']))
|
289
|
+
|
290
|
+
if getv(from_object, ['nullable']) is not None:
|
291
|
+
setv(to_object, ['nullable'], getv(from_object, ['nullable']))
|
292
|
+
|
293
|
+
if getv(from_object, ['properties']) is not None:
|
294
|
+
setv(to_object, ['properties'], getv(from_object, ['properties']))
|
295
|
+
|
296
|
+
if getv(from_object, ['property_ordering']) is not None:
|
297
|
+
setv(
|
298
|
+
to_object,
|
299
|
+
['propertyOrdering'],
|
300
|
+
getv(from_object, ['property_ordering']),
|
301
|
+
)
|
302
|
+
|
303
|
+
if getv(from_object, ['required']) is not None:
|
304
|
+
setv(to_object, ['required'], getv(from_object, ['required']))
|
305
|
+
|
306
|
+
if getv(from_object, ['title']) is not None:
|
307
|
+
setv(to_object, ['title'], getv(from_object, ['title']))
|
308
|
+
|
309
|
+
if getv(from_object, ['type']) is not None:
|
310
|
+
setv(to_object, ['type'], getv(from_object, ['type']))
|
311
|
+
|
312
|
+
return to_object
|
313
|
+
|
314
|
+
|
315
|
+
def _FunctionDeclaration_to_mldev(
|
316
|
+
api_client: BaseApiClient,
|
317
|
+
from_object: Union[dict[str, Any], object],
|
318
|
+
parent_object: Optional[dict[str, Any]] = None,
|
319
|
+
) -> dict[str, Any]:
|
320
|
+
to_object: dict[str, Any] = {}
|
321
|
+
if getv(from_object, ['response']) is not None:
|
322
|
+
raise ValueError('response parameter is not supported in Gemini API.')
|
323
|
+
|
324
|
+
if getv(from_object, ['description']) is not None:
|
325
|
+
setv(to_object, ['description'], getv(from_object, ['description']))
|
326
|
+
|
327
|
+
if getv(from_object, ['name']) is not None:
|
328
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
329
|
+
|
330
|
+
if getv(from_object, ['parameters']) is not None:
|
331
|
+
setv(to_object, ['parameters'], getv(from_object, ['parameters']))
|
332
|
+
|
333
|
+
return to_object
|
334
|
+
|
335
|
+
|
336
|
+
def _FunctionDeclaration_to_vertex(
|
337
|
+
api_client: BaseApiClient,
|
338
|
+
from_object: Union[dict[str, Any], object],
|
339
|
+
parent_object: Optional[dict[str, Any]] = None,
|
340
|
+
) -> dict[str, Any]:
|
341
|
+
to_object: dict[str, Any] = {}
|
342
|
+
if getv(from_object, ['response']) is not None:
|
343
|
+
setv(
|
344
|
+
to_object,
|
345
|
+
['response'],
|
346
|
+
_Schema_to_vertex(
|
347
|
+
api_client, getv(from_object, ['response']), to_object
|
348
|
+
),
|
349
|
+
)
|
350
|
+
|
351
|
+
if getv(from_object, ['description']) is not None:
|
352
|
+
setv(to_object, ['description'], getv(from_object, ['description']))
|
353
|
+
|
354
|
+
if getv(from_object, ['name']) is not None:
|
355
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
356
|
+
|
357
|
+
if getv(from_object, ['parameters']) is not None:
|
358
|
+
setv(to_object, ['parameters'], getv(from_object, ['parameters']))
|
359
|
+
|
360
|
+
return to_object
|
361
|
+
|
362
|
+
|
363
|
+
def _GoogleSearch_to_mldev(
|
364
|
+
api_client: BaseApiClient,
|
365
|
+
from_object: Union[dict[str, Any], object],
|
366
|
+
parent_object: Optional[dict[str, Any]] = None,
|
367
|
+
) -> dict[str, Any]:
|
368
|
+
to_object: dict[str, Any] = {}
|
369
|
+
|
370
|
+
return to_object
|
371
|
+
|
372
|
+
|
373
|
+
def _GoogleSearch_to_vertex(
|
374
|
+
api_client: BaseApiClient,
|
375
|
+
from_object: Union[dict[str, Any], object],
|
376
|
+
parent_object: Optional[dict[str, Any]] = None,
|
377
|
+
) -> dict[str, Any]:
|
378
|
+
to_object: dict[str, Any] = {}
|
379
|
+
|
380
|
+
return to_object
|
381
|
+
|
382
|
+
|
383
|
+
def _DynamicRetrievalConfig_to_mldev(
|
384
|
+
api_client: BaseApiClient,
|
385
|
+
from_object: Union[dict[str, Any], object],
|
386
|
+
parent_object: Optional[dict[str, Any]] = None,
|
387
|
+
) -> dict[str, Any]:
|
388
|
+
to_object: dict[str, Any] = {}
|
389
|
+
if getv(from_object, ['mode']) is not None:
|
390
|
+
setv(to_object, ['mode'], getv(from_object, ['mode']))
|
391
|
+
|
392
|
+
if getv(from_object, ['dynamic_threshold']) is not None:
|
393
|
+
setv(
|
394
|
+
to_object,
|
395
|
+
['dynamicThreshold'],
|
396
|
+
getv(from_object, ['dynamic_threshold']),
|
397
|
+
)
|
398
|
+
|
399
|
+
return to_object
|
400
|
+
|
401
|
+
|
402
|
+
def _DynamicRetrievalConfig_to_vertex(
|
403
|
+
api_client: BaseApiClient,
|
404
|
+
from_object: Union[dict[str, Any], object],
|
405
|
+
parent_object: Optional[dict[str, Any]] = None,
|
406
|
+
) -> dict[str, Any]:
|
407
|
+
to_object: dict[str, Any] = {}
|
408
|
+
if getv(from_object, ['mode']) is not None:
|
409
|
+
setv(to_object, ['mode'], getv(from_object, ['mode']))
|
410
|
+
|
411
|
+
if getv(from_object, ['dynamic_threshold']) is not None:
|
412
|
+
setv(
|
413
|
+
to_object,
|
414
|
+
['dynamicThreshold'],
|
415
|
+
getv(from_object, ['dynamic_threshold']),
|
416
|
+
)
|
417
|
+
|
418
|
+
return to_object
|
419
|
+
|
420
|
+
|
421
|
+
def _GoogleSearchRetrieval_to_mldev(
|
422
|
+
api_client: BaseApiClient,
|
423
|
+
from_object: Union[dict[str, Any], object],
|
424
|
+
parent_object: Optional[dict[str, Any]] = None,
|
425
|
+
) -> dict[str, Any]:
|
426
|
+
to_object: dict[str, Any] = {}
|
427
|
+
if getv(from_object, ['dynamic_retrieval_config']) is not None:
|
428
|
+
setv(
|
429
|
+
to_object,
|
430
|
+
['dynamicRetrievalConfig'],
|
431
|
+
_DynamicRetrievalConfig_to_mldev(
|
432
|
+
api_client,
|
433
|
+
getv(from_object, ['dynamic_retrieval_config']),
|
434
|
+
to_object,
|
435
|
+
),
|
436
|
+
)
|
437
|
+
|
438
|
+
return to_object
|
439
|
+
|
440
|
+
|
441
|
+
def _GoogleSearchRetrieval_to_vertex(
|
442
|
+
api_client: BaseApiClient,
|
443
|
+
from_object: Union[dict[str, Any], object],
|
444
|
+
parent_object: Optional[dict[str, Any]] = None,
|
445
|
+
) -> dict[str, Any]:
|
446
|
+
to_object: dict[str, Any] = {}
|
447
|
+
if getv(from_object, ['dynamic_retrieval_config']) is not None:
|
448
|
+
setv(
|
449
|
+
to_object,
|
450
|
+
['dynamicRetrievalConfig'],
|
451
|
+
_DynamicRetrievalConfig_to_vertex(
|
452
|
+
api_client,
|
453
|
+
getv(from_object, ['dynamic_retrieval_config']),
|
454
|
+
to_object,
|
455
|
+
),
|
456
|
+
)
|
457
|
+
|
458
|
+
return to_object
|
459
|
+
|
460
|
+
|
461
|
+
def _Tool_to_mldev(
|
462
|
+
api_client: BaseApiClient,
|
463
|
+
from_object: Union[dict[str, Any], object],
|
464
|
+
parent_object: Optional[dict[str, Any]] = None,
|
465
|
+
) -> dict[str, Any]:
|
466
|
+
to_object: dict[str, Any] = {}
|
467
|
+
if getv(from_object, ['function_declarations']) is not None:
|
468
|
+
setv(
|
469
|
+
to_object,
|
470
|
+
['functionDeclarations'],
|
471
|
+
[
|
472
|
+
_FunctionDeclaration_to_mldev(api_client, item, to_object)
|
473
|
+
for item in getv(from_object, ['function_declarations'])
|
474
|
+
],
|
475
|
+
)
|
476
|
+
|
477
|
+
if getv(from_object, ['retrieval']) is not None:
|
478
|
+
raise ValueError('retrieval parameter is not supported in Gemini API.')
|
479
|
+
|
480
|
+
if getv(from_object, ['google_search']) is not None:
|
481
|
+
setv(
|
482
|
+
to_object,
|
483
|
+
['googleSearch'],
|
484
|
+
_GoogleSearch_to_mldev(
|
485
|
+
api_client, getv(from_object, ['google_search']), to_object
|
486
|
+
),
|
487
|
+
)
|
488
|
+
|
489
|
+
if getv(from_object, ['google_search_retrieval']) is not None:
|
490
|
+
setv(
|
491
|
+
to_object,
|
492
|
+
['googleSearchRetrieval'],
|
493
|
+
_GoogleSearchRetrieval_to_mldev(
|
494
|
+
api_client,
|
495
|
+
getv(from_object, ['google_search_retrieval']),
|
496
|
+
to_object,
|
497
|
+
),
|
498
|
+
)
|
499
|
+
|
500
|
+
if getv(from_object, ['code_execution']) is not None:
|
501
|
+
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
502
|
+
|
503
|
+
return to_object
|
504
|
+
|
505
|
+
|
506
|
+
def _Tool_to_vertex(
|
507
|
+
api_client: BaseApiClient,
|
508
|
+
from_object: Union[dict[str, Any], object],
|
509
|
+
parent_object: Optional[dict[str, Any]] = None,
|
510
|
+
) -> dict[str, Any]:
|
511
|
+
to_object: dict[str, Any] = {}
|
512
|
+
if getv(from_object, ['function_declarations']) is not None:
|
513
|
+
setv(
|
514
|
+
to_object,
|
515
|
+
['functionDeclarations'],
|
516
|
+
[
|
517
|
+
_FunctionDeclaration_to_vertex(api_client, item, to_object)
|
518
|
+
for item in getv(from_object, ['function_declarations'])
|
519
|
+
],
|
520
|
+
)
|
521
|
+
|
522
|
+
if getv(from_object, ['retrieval']) is not None:
|
523
|
+
setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
|
524
|
+
|
525
|
+
if getv(from_object, ['google_search']) is not None:
|
526
|
+
setv(
|
527
|
+
to_object,
|
528
|
+
['googleSearch'],
|
529
|
+
_GoogleSearch_to_vertex(
|
530
|
+
api_client, getv(from_object, ['google_search']), to_object
|
531
|
+
),
|
532
|
+
)
|
533
|
+
|
534
|
+
if getv(from_object, ['google_search_retrieval']) is not None:
|
535
|
+
setv(
|
536
|
+
to_object,
|
537
|
+
['googleSearchRetrieval'],
|
538
|
+
_GoogleSearchRetrieval_to_vertex(
|
539
|
+
api_client,
|
540
|
+
getv(from_object, ['google_search_retrieval']),
|
541
|
+
to_object,
|
542
|
+
),
|
543
|
+
)
|
544
|
+
|
545
|
+
if getv(from_object, ['code_execution']) is not None:
|
546
|
+
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
|
547
|
+
|
548
|
+
return to_object
|
549
|
+
|
550
|
+
|
551
|
+
def _SessionResumptionConfig_to_mldev(
|
552
|
+
api_client: BaseApiClient,
|
553
|
+
from_object: Union[dict[str, Any], object],
|
554
|
+
parent_object: Optional[dict[str, Any]] = None,
|
555
|
+
) -> dict[str, Any]:
|
556
|
+
to_object: dict[str, Any] = {}
|
557
|
+
if getv(from_object, ['handle']) is not None:
|
558
|
+
setv(to_object, ['handle'], getv(from_object, ['handle']))
|
559
|
+
|
560
|
+
if getv(from_object, ['transparent']) is not None:
|
561
|
+
raise ValueError('transparent parameter is not supported in Gemini API.')
|
562
|
+
|
563
|
+
return to_object
|
564
|
+
|
565
|
+
|
566
|
+
def _SessionResumptionConfig_to_vertex(
|
567
|
+
api_client: BaseApiClient,
|
568
|
+
from_object: Union[dict[str, Any], object],
|
569
|
+
parent_object: Optional[dict[str, Any]] = None,
|
570
|
+
) -> dict[str, Any]:
|
571
|
+
to_object: dict[str, Any] = {}
|
572
|
+
if getv(from_object, ['handle']) is not None:
|
573
|
+
setv(to_object, ['handle'], getv(from_object, ['handle']))
|
574
|
+
|
575
|
+
if getv(from_object, ['transparent']) is not None:
|
576
|
+
setv(to_object, ['transparent'], getv(from_object, ['transparent']))
|
577
|
+
|
578
|
+
return to_object
|
579
|
+
|
580
|
+
|
581
|
+
def _AudioTranscriptionConfig_to_mldev(
|
582
|
+
api_client: BaseApiClient,
|
583
|
+
from_object: Union[dict[str, Any], object],
|
584
|
+
parent_object: Optional[dict[str, Any]] = None,
|
585
|
+
) -> dict[str, Any]:
|
586
|
+
to_object: dict[str, Any] = {}
|
587
|
+
|
588
|
+
return to_object
|
589
|
+
|
590
|
+
|
591
|
+
def _AudioTranscriptionConfig_to_vertex(
|
592
|
+
api_client: BaseApiClient,
|
593
|
+
from_object: Union[dict[str, Any], object],
|
594
|
+
parent_object: Optional[dict[str, Any]] = None,
|
595
|
+
) -> dict[str, Any]:
|
596
|
+
to_object: dict[str, Any] = {}
|
597
|
+
|
598
|
+
return to_object
|
599
|
+
|
600
|
+
|
601
|
+
def _AutomaticActivityDetection_to_mldev(
|
602
|
+
api_client: BaseApiClient,
|
603
|
+
from_object: Union[dict[str, Any], object],
|
604
|
+
parent_object: Optional[dict[str, Any]] = None,
|
605
|
+
) -> dict[str, Any]:
|
606
|
+
to_object: dict[str, Any] = {}
|
607
|
+
if getv(from_object, ['disabled']) is not None:
|
608
|
+
setv(to_object, ['disabled'], getv(from_object, ['disabled']))
|
609
|
+
|
610
|
+
if getv(from_object, ['start_of_speech_sensitivity']) is not None:
|
611
|
+
setv(
|
612
|
+
to_object,
|
613
|
+
['startOfSpeechSensitivity'],
|
614
|
+
getv(from_object, ['start_of_speech_sensitivity']),
|
615
|
+
)
|
616
|
+
|
617
|
+
if getv(from_object, ['end_of_speech_sensitivity']) is not None:
|
618
|
+
setv(
|
619
|
+
to_object,
|
620
|
+
['endOfSpeechSensitivity'],
|
621
|
+
getv(from_object, ['end_of_speech_sensitivity']),
|
622
|
+
)
|
623
|
+
|
624
|
+
if getv(from_object, ['prefix_padding_ms']) is not None:
|
625
|
+
setv(
|
626
|
+
to_object, ['prefixPaddingMs'], getv(from_object, ['prefix_padding_ms'])
|
627
|
+
)
|
628
|
+
|
629
|
+
if getv(from_object, ['silence_duration_ms']) is not None:
|
630
|
+
setv(
|
631
|
+
to_object,
|
632
|
+
['silenceDurationMs'],
|
633
|
+
getv(from_object, ['silence_duration_ms']),
|
634
|
+
)
|
635
|
+
|
636
|
+
return to_object
|
637
|
+
|
638
|
+
|
639
|
+
def _AutomaticActivityDetection_to_vertex(
|
640
|
+
api_client: BaseApiClient,
|
641
|
+
from_object: Union[dict[str, Any], object],
|
642
|
+
parent_object: Optional[dict[str, Any]] = None,
|
643
|
+
) -> dict[str, Any]:
|
644
|
+
to_object: dict[str, Any] = {}
|
645
|
+
if getv(from_object, ['disabled']) is not None:
|
646
|
+
setv(to_object, ['disabled'], getv(from_object, ['disabled']))
|
647
|
+
|
648
|
+
if getv(from_object, ['start_of_speech_sensitivity']) is not None:
|
649
|
+
setv(
|
650
|
+
to_object,
|
651
|
+
['startOfSpeechSensitivity'],
|
652
|
+
getv(from_object, ['start_of_speech_sensitivity']),
|
653
|
+
)
|
654
|
+
|
655
|
+
if getv(from_object, ['end_of_speech_sensitivity']) is not None:
|
656
|
+
setv(
|
657
|
+
to_object,
|
658
|
+
['endOfSpeechSensitivity'],
|
659
|
+
getv(from_object, ['end_of_speech_sensitivity']),
|
660
|
+
)
|
661
|
+
|
662
|
+
if getv(from_object, ['prefix_padding_ms']) is not None:
|
663
|
+
setv(
|
664
|
+
to_object, ['prefixPaddingMs'], getv(from_object, ['prefix_padding_ms'])
|
665
|
+
)
|
666
|
+
|
667
|
+
if getv(from_object, ['silence_duration_ms']) is not None:
|
668
|
+
setv(
|
669
|
+
to_object,
|
670
|
+
['silenceDurationMs'],
|
671
|
+
getv(from_object, ['silence_duration_ms']),
|
672
|
+
)
|
673
|
+
|
674
|
+
return to_object
|
675
|
+
|
676
|
+
|
677
|
+
def _RealtimeInputConfig_to_mldev(
|
678
|
+
api_client: BaseApiClient,
|
679
|
+
from_object: Union[dict[str, Any], object],
|
680
|
+
parent_object: Optional[dict[str, Any]] = None,
|
681
|
+
) -> dict[str, Any]:
|
682
|
+
to_object: dict[str, Any] = {}
|
683
|
+
if getv(from_object, ['automatic_activity_detection']) is not None:
|
684
|
+
setv(
|
685
|
+
to_object,
|
686
|
+
['automaticActivityDetection'],
|
687
|
+
_AutomaticActivityDetection_to_mldev(
|
688
|
+
api_client,
|
689
|
+
getv(from_object, ['automatic_activity_detection']),
|
690
|
+
to_object,
|
691
|
+
),
|
692
|
+
)
|
693
|
+
|
694
|
+
if getv(from_object, ['activity_handling']) is not None:
|
695
|
+
setv(
|
696
|
+
to_object,
|
697
|
+
['activityHandling'],
|
698
|
+
getv(from_object, ['activity_handling']),
|
699
|
+
)
|
700
|
+
|
701
|
+
if getv(from_object, ['turn_coverage']) is not None:
|
702
|
+
setv(to_object, ['turnCoverage'], getv(from_object, ['turn_coverage']))
|
703
|
+
|
704
|
+
return to_object
|
705
|
+
|
706
|
+
|
707
|
+
def _RealtimeInputConfig_to_vertex(
|
708
|
+
api_client: BaseApiClient,
|
709
|
+
from_object: Union[dict[str, Any], object],
|
710
|
+
parent_object: Optional[dict[str, Any]] = None,
|
711
|
+
) -> dict[str, Any]:
|
712
|
+
to_object: dict[str, Any] = {}
|
713
|
+
if getv(from_object, ['automatic_activity_detection']) is not None:
|
714
|
+
setv(
|
715
|
+
to_object,
|
716
|
+
['automaticActivityDetection'],
|
717
|
+
_AutomaticActivityDetection_to_vertex(
|
718
|
+
api_client,
|
719
|
+
getv(from_object, ['automatic_activity_detection']),
|
720
|
+
to_object,
|
721
|
+
),
|
722
|
+
)
|
723
|
+
|
724
|
+
if getv(from_object, ['activity_handling']) is not None:
|
725
|
+
setv(
|
726
|
+
to_object,
|
727
|
+
['activityHandling'],
|
728
|
+
getv(from_object, ['activity_handling']),
|
729
|
+
)
|
730
|
+
|
731
|
+
if getv(from_object, ['turn_coverage']) is not None:
|
732
|
+
setv(to_object, ['turnCoverage'], getv(from_object, ['turn_coverage']))
|
733
|
+
|
734
|
+
return to_object
|
735
|
+
|
736
|
+
|
737
|
+
def _SlidingWindow_to_mldev(
|
738
|
+
api_client: BaseApiClient,
|
739
|
+
from_object: Union[dict[str, Any], object],
|
740
|
+
parent_object: Optional[dict[str, Any]] = None,
|
741
|
+
) -> dict[str, Any]:
|
742
|
+
to_object: dict[str, Any] = {}
|
743
|
+
if getv(from_object, ['target_tokens']) is not None:
|
744
|
+
setv(to_object, ['targetTokens'], getv(from_object, ['target_tokens']))
|
745
|
+
|
746
|
+
return to_object
|
747
|
+
|
748
|
+
|
749
|
+
def _SlidingWindow_to_vertex(
|
750
|
+
api_client: BaseApiClient,
|
751
|
+
from_object: Union[dict[str, Any], object],
|
752
|
+
parent_object: Optional[dict[str, Any]] = None,
|
753
|
+
) -> dict[str, Any]:
|
754
|
+
to_object: dict[str, Any] = {}
|
755
|
+
if getv(from_object, ['target_tokens']) is not None:
|
756
|
+
setv(to_object, ['targetTokens'], getv(from_object, ['target_tokens']))
|
757
|
+
|
758
|
+
return to_object
|
759
|
+
|
760
|
+
|
761
|
+
def _ContextWindowCompressionConfig_to_mldev(
|
762
|
+
api_client: BaseApiClient,
|
763
|
+
from_object: Union[dict[str, Any], object],
|
764
|
+
parent_object: Optional[dict[str, Any]] = None,
|
765
|
+
) -> dict[str, Any]:
|
766
|
+
to_object: dict[str, Any] = {}
|
767
|
+
if getv(from_object, ['trigger_tokens']) is not None:
|
768
|
+
setv(to_object, ['triggerTokens'], getv(from_object, ['trigger_tokens']))
|
769
|
+
|
770
|
+
if getv(from_object, ['sliding_window']) is not None:
|
771
|
+
setv(
|
772
|
+
to_object,
|
773
|
+
['slidingWindow'],
|
774
|
+
_SlidingWindow_to_mldev(
|
775
|
+
api_client, getv(from_object, ['sliding_window']), to_object
|
776
|
+
),
|
777
|
+
)
|
778
|
+
|
779
|
+
return to_object
|
780
|
+
|
781
|
+
|
782
|
+
def _ContextWindowCompressionConfig_to_vertex(
|
783
|
+
api_client: BaseApiClient,
|
784
|
+
from_object: Union[dict[str, Any], object],
|
785
|
+
parent_object: Optional[dict[str, Any]] = None,
|
786
|
+
) -> dict[str, Any]:
|
787
|
+
to_object: dict[str, Any] = {}
|
788
|
+
if getv(from_object, ['trigger_tokens']) is not None:
|
789
|
+
setv(to_object, ['triggerTokens'], getv(from_object, ['trigger_tokens']))
|
790
|
+
|
791
|
+
if getv(from_object, ['sliding_window']) is not None:
|
792
|
+
setv(
|
793
|
+
to_object,
|
794
|
+
['slidingWindow'],
|
795
|
+
_SlidingWindow_to_vertex(
|
796
|
+
api_client, getv(from_object, ['sliding_window']), to_object
|
797
|
+
),
|
798
|
+
)
|
799
|
+
|
800
|
+
return to_object
|
801
|
+
|
802
|
+
|
803
|
+
def _LiveConnectConfig_to_mldev(
|
804
|
+
api_client: BaseApiClient,
|
805
|
+
from_object: Union[dict[str, Any], object],
|
806
|
+
parent_object: Optional[dict[str, Any]] = None,
|
807
|
+
) -> dict[str, Any]:
|
808
|
+
to_object: dict[str, Any] = {}
|
809
|
+
if getv(from_object, ['generation_config']) is not None:
|
810
|
+
setv(
|
811
|
+
parent_object,
|
812
|
+
['setup', 'generationConfig'],
|
813
|
+
getv(from_object, ['generation_config']),
|
814
|
+
)
|
815
|
+
|
816
|
+
if getv(from_object, ['response_modalities']) is not None:
|
817
|
+
setv(
|
818
|
+
parent_object,
|
819
|
+
['setup', 'generationConfig', 'responseModalities'],
|
820
|
+
getv(from_object, ['response_modalities']),
|
821
|
+
)
|
822
|
+
|
823
|
+
if getv(from_object, ['temperature']) is not None:
|
824
|
+
setv(
|
825
|
+
parent_object,
|
826
|
+
['setup', 'generationConfig', 'temperature'],
|
827
|
+
getv(from_object, ['temperature']),
|
828
|
+
)
|
829
|
+
|
830
|
+
if getv(from_object, ['top_p']) is not None:
|
831
|
+
setv(
|
832
|
+
parent_object,
|
833
|
+
['setup', 'generationConfig', 'topP'],
|
834
|
+
getv(from_object, ['top_p']),
|
835
|
+
)
|
836
|
+
|
837
|
+
if getv(from_object, ['top_k']) is not None:
|
838
|
+
setv(
|
839
|
+
parent_object,
|
840
|
+
['setup', 'generationConfig', 'topK'],
|
841
|
+
getv(from_object, ['top_k']),
|
842
|
+
)
|
843
|
+
|
844
|
+
if getv(from_object, ['max_output_tokens']) is not None:
|
845
|
+
setv(
|
846
|
+
parent_object,
|
847
|
+
['setup', 'generationConfig', 'maxOutputTokens'],
|
848
|
+
getv(from_object, ['max_output_tokens']),
|
849
|
+
)
|
850
|
+
|
851
|
+
if getv(from_object, ['media_resolution']) is not None:
|
852
|
+
setv(
|
853
|
+
parent_object,
|
854
|
+
['setup', 'generationConfig', 'mediaResolution'],
|
855
|
+
getv(from_object, ['media_resolution']),
|
856
|
+
)
|
857
|
+
|
858
|
+
if getv(from_object, ['seed']) is not None:
|
859
|
+
setv(
|
860
|
+
parent_object,
|
861
|
+
['setup', 'generationConfig', 'seed'],
|
862
|
+
getv(from_object, ['seed']),
|
863
|
+
)
|
864
|
+
|
865
|
+
if getv(from_object, ['speech_config']) is not None:
|
866
|
+
setv(
|
867
|
+
parent_object,
|
868
|
+
['setup', 'generationConfig', 'speechConfig'],
|
869
|
+
getv(from_object, ['speech_config']),
|
870
|
+
)
|
871
|
+
|
872
|
+
if getv(from_object, ['system_instruction']) is not None:
|
873
|
+
setv(
|
874
|
+
parent_object,
|
875
|
+
['setup', 'systemInstruction'],
|
876
|
+
_Content_to_mldev(
|
877
|
+
api_client,
|
878
|
+
t.t_content(api_client, getv(from_object, ['system_instruction'])),
|
879
|
+
to_object,
|
880
|
+
),
|
881
|
+
)
|
882
|
+
|
883
|
+
if getv(from_object, ['tools']) is not None:
|
884
|
+
setv(
|
885
|
+
parent_object,
|
886
|
+
['setup', 'tools'],
|
887
|
+
[
|
888
|
+
_Tool_to_mldev(api_client, t.t_tool(api_client, item), to_object)
|
889
|
+
for item in t.t_tools(api_client, getv(from_object, ['tools']))
|
890
|
+
],
|
891
|
+
)
|
892
|
+
|
893
|
+
if getv(from_object, ['session_resumption']) is not None:
|
894
|
+
setv(
|
895
|
+
parent_object,
|
896
|
+
['setup', 'sessionResumption'],
|
897
|
+
_SessionResumptionConfig_to_mldev(
|
898
|
+
api_client, getv(from_object, ['session_resumption']), to_object
|
899
|
+
),
|
900
|
+
)
|
901
|
+
|
902
|
+
if getv(from_object, ['input_audio_transcription']) is not None:
|
903
|
+
raise ValueError(
|
904
|
+
'input_audio_transcription parameter is not supported in Gemini API.'
|
905
|
+
)
|
906
|
+
|
907
|
+
if getv(from_object, ['output_audio_transcription']) is not None:
|
908
|
+
setv(
|
909
|
+
parent_object,
|
910
|
+
['setup', 'outputAudioTranscription'],
|
911
|
+
_AudioTranscriptionConfig_to_mldev(
|
912
|
+
api_client,
|
913
|
+
getv(from_object, ['output_audio_transcription']),
|
914
|
+
to_object,
|
915
|
+
),
|
916
|
+
)
|
917
|
+
|
918
|
+
if getv(from_object, ['realtime_input_config']) is not None:
|
919
|
+
setv(
|
920
|
+
parent_object,
|
921
|
+
['setup', 'realtimeInputConfig'],
|
922
|
+
_RealtimeInputConfig_to_mldev(
|
923
|
+
api_client, getv(from_object, ['realtime_input_config']), to_object
|
924
|
+
),
|
925
|
+
)
|
926
|
+
|
927
|
+
if getv(from_object, ['context_window_compression']) is not None:
|
928
|
+
setv(
|
929
|
+
parent_object,
|
930
|
+
['setup', 'contextWindowCompression'],
|
931
|
+
_ContextWindowCompressionConfig_to_mldev(
|
932
|
+
api_client,
|
933
|
+
getv(from_object, ['context_window_compression']),
|
934
|
+
to_object,
|
935
|
+
),
|
936
|
+
)
|
937
|
+
|
938
|
+
return to_object
|
939
|
+
|
940
|
+
|
941
|
+
def _LiveConnectConfig_to_vertex(
|
942
|
+
api_client: BaseApiClient,
|
943
|
+
from_object: Union[dict[str, Any], object],
|
944
|
+
parent_object: Optional[dict[str, Any]] = None,
|
945
|
+
) -> dict[str, Any]:
|
946
|
+
to_object: dict[str, Any] = {}
|
947
|
+
if getv(from_object, ['generation_config']) is not None:
|
948
|
+
setv(
|
949
|
+
parent_object,
|
950
|
+
['setup', 'generationConfig'],
|
951
|
+
getv(from_object, ['generation_config']),
|
952
|
+
)
|
953
|
+
|
954
|
+
if getv(from_object, ['response_modalities']) is not None:
|
955
|
+
setv(
|
956
|
+
parent_object,
|
957
|
+
['setup', 'generationConfig', 'responseModalities'],
|
958
|
+
getv(from_object, ['response_modalities']),
|
959
|
+
)
|
960
|
+
|
961
|
+
if getv(from_object, ['temperature']) is not None:
|
962
|
+
setv(
|
963
|
+
parent_object,
|
964
|
+
['setup', 'generationConfig', 'temperature'],
|
965
|
+
getv(from_object, ['temperature']),
|
966
|
+
)
|
967
|
+
|
968
|
+
if getv(from_object, ['top_p']) is not None:
|
969
|
+
setv(
|
970
|
+
parent_object,
|
971
|
+
['setup', 'generationConfig', 'topP'],
|
972
|
+
getv(from_object, ['top_p']),
|
973
|
+
)
|
974
|
+
|
975
|
+
if getv(from_object, ['top_k']) is not None:
|
976
|
+
setv(
|
977
|
+
parent_object,
|
978
|
+
['setup', 'generationConfig', 'topK'],
|
979
|
+
getv(from_object, ['top_k']),
|
980
|
+
)
|
981
|
+
|
982
|
+
if getv(from_object, ['max_output_tokens']) is not None:
|
983
|
+
setv(
|
984
|
+
parent_object,
|
985
|
+
['setup', 'generationConfig', 'maxOutputTokens'],
|
986
|
+
getv(from_object, ['max_output_tokens']),
|
987
|
+
)
|
988
|
+
|
989
|
+
if getv(from_object, ['media_resolution']) is not None:
|
990
|
+
setv(
|
991
|
+
parent_object,
|
992
|
+
['setup', 'generationConfig', 'mediaResolution'],
|
993
|
+
getv(from_object, ['media_resolution']),
|
994
|
+
)
|
995
|
+
|
996
|
+
if getv(from_object, ['seed']) is not None:
|
997
|
+
setv(
|
998
|
+
parent_object,
|
999
|
+
['setup', 'generationConfig', 'seed'],
|
1000
|
+
getv(from_object, ['seed']),
|
1001
|
+
)
|
1002
|
+
|
1003
|
+
if getv(from_object, ['speech_config']) is not None:
|
1004
|
+
setv(
|
1005
|
+
parent_object,
|
1006
|
+
['setup', 'generationConfig', 'speechConfig'],
|
1007
|
+
getv(from_object, ['speech_config']),
|
1008
|
+
)
|
1009
|
+
|
1010
|
+
if getv(from_object, ['system_instruction']) is not None:
|
1011
|
+
setv(
|
1012
|
+
parent_object,
|
1013
|
+
['setup', 'systemInstruction'],
|
1014
|
+
_Content_to_vertex(
|
1015
|
+
api_client,
|
1016
|
+
t.t_content(api_client, getv(from_object, ['system_instruction'])),
|
1017
|
+
to_object,
|
1018
|
+
),
|
1019
|
+
)
|
1020
|
+
|
1021
|
+
if getv(from_object, ['tools']) is not None:
|
1022
|
+
setv(
|
1023
|
+
parent_object,
|
1024
|
+
['setup', 'tools'],
|
1025
|
+
[
|
1026
|
+
_Tool_to_vertex(api_client, t.t_tool(api_client, item), to_object)
|
1027
|
+
for item in t.t_tools(api_client, getv(from_object, ['tools']))
|
1028
|
+
],
|
1029
|
+
)
|
1030
|
+
|
1031
|
+
if getv(from_object, ['session_resumption']) is not None:
|
1032
|
+
setv(
|
1033
|
+
parent_object,
|
1034
|
+
['setup', 'sessionResumption'],
|
1035
|
+
_SessionResumptionConfig_to_vertex(
|
1036
|
+
api_client, getv(from_object, ['session_resumption']), to_object
|
1037
|
+
),
|
1038
|
+
)
|
1039
|
+
|
1040
|
+
if getv(from_object, ['input_audio_transcription']) is not None:
|
1041
|
+
setv(
|
1042
|
+
parent_object,
|
1043
|
+
['setup', 'inputAudioTranscription'],
|
1044
|
+
_AudioTranscriptionConfig_to_vertex(
|
1045
|
+
api_client,
|
1046
|
+
getv(from_object, ['input_audio_transcription']),
|
1047
|
+
to_object,
|
1048
|
+
),
|
1049
|
+
)
|
1050
|
+
|
1051
|
+
if getv(from_object, ['output_audio_transcription']) is not None:
|
1052
|
+
setv(
|
1053
|
+
parent_object,
|
1054
|
+
['setup', 'outputAudioTranscription'],
|
1055
|
+
_AudioTranscriptionConfig_to_vertex(
|
1056
|
+
api_client,
|
1057
|
+
getv(from_object, ['output_audio_transcription']),
|
1058
|
+
to_object,
|
1059
|
+
),
|
1060
|
+
)
|
1061
|
+
|
1062
|
+
if getv(from_object, ['realtime_input_config']) is not None:
|
1063
|
+
setv(
|
1064
|
+
parent_object,
|
1065
|
+
['setup', 'realtimeInputConfig'],
|
1066
|
+
_RealtimeInputConfig_to_vertex(
|
1067
|
+
api_client, getv(from_object, ['realtime_input_config']), to_object
|
1068
|
+
),
|
1069
|
+
)
|
1070
|
+
|
1071
|
+
if getv(from_object, ['context_window_compression']) is not None:
|
1072
|
+
setv(
|
1073
|
+
parent_object,
|
1074
|
+
['setup', 'contextWindowCompression'],
|
1075
|
+
_ContextWindowCompressionConfig_to_vertex(
|
1076
|
+
api_client,
|
1077
|
+
getv(from_object, ['context_window_compression']),
|
1078
|
+
to_object,
|
1079
|
+
),
|
1080
|
+
)
|
1081
|
+
|
1082
|
+
return to_object
|
1083
|
+
|
1084
|
+
|
1085
|
+
def _LiveConnectParameters_to_mldev(
|
1086
|
+
api_client: BaseApiClient,
|
1087
|
+
from_object: Union[dict[str, Any], object],
|
1088
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1089
|
+
) -> dict[str, Any]:
|
1090
|
+
to_object: dict[str, Any] = {}
|
1091
|
+
if getv(from_object, ['model']) is not None:
|
1092
|
+
setv(
|
1093
|
+
to_object,
|
1094
|
+
['setup', 'model'],
|
1095
|
+
t.t_model(api_client, getv(from_object, ['model'])),
|
1096
|
+
)
|
1097
|
+
|
1098
|
+
if getv(from_object, ['config']) is not None:
|
1099
|
+
setv(
|
1100
|
+
to_object,
|
1101
|
+
['config'],
|
1102
|
+
_LiveConnectConfig_to_mldev(
|
1103
|
+
api_client, getv(from_object, ['config']), to_object
|
1104
|
+
),
|
1105
|
+
)
|
1106
|
+
|
1107
|
+
return to_object
|
1108
|
+
|
1109
|
+
|
1110
|
+
def _LiveConnectParameters_to_vertex(
|
1111
|
+
api_client: BaseApiClient,
|
1112
|
+
from_object: Union[dict[str, Any], object],
|
1113
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1114
|
+
) -> dict[str, Any]:
|
1115
|
+
to_object: dict[str, Any] = {}
|
1116
|
+
if getv(from_object, ['model']) is not None:
|
1117
|
+
setv(
|
1118
|
+
to_object,
|
1119
|
+
['setup', 'model'],
|
1120
|
+
t.t_model(api_client, getv(from_object, ['model'])),
|
1121
|
+
)
|
1122
|
+
|
1123
|
+
if getv(from_object, ['config']) is not None:
|
1124
|
+
setv(
|
1125
|
+
to_object,
|
1126
|
+
['config'],
|
1127
|
+
_LiveConnectConfig_to_vertex(
|
1128
|
+
api_client, getv(from_object, ['config']), to_object
|
1129
|
+
),
|
1130
|
+
)
|
1131
|
+
|
1132
|
+
return to_object
|
1133
|
+
|
1134
|
+
|
1135
|
+
def _ActivityStart_to_mldev(
|
1136
|
+
api_client: BaseApiClient,
|
1137
|
+
from_object: Union[dict[str, Any], object],
|
1138
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1139
|
+
) -> dict[str, Any]:
|
1140
|
+
to_object: dict[str, Any] = {}
|
1141
|
+
|
1142
|
+
return to_object
|
1143
|
+
|
1144
|
+
|
1145
|
+
def _ActivityStart_to_vertex(
|
1146
|
+
api_client: BaseApiClient,
|
1147
|
+
from_object: Union[dict[str, Any], object],
|
1148
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1149
|
+
) -> dict[str, Any]:
|
1150
|
+
to_object: dict[str, Any] = {}
|
1151
|
+
|
1152
|
+
return to_object
|
1153
|
+
|
1154
|
+
|
1155
|
+
def _ActivityEnd_to_mldev(
|
1156
|
+
api_client: BaseApiClient,
|
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
|
+
|
1162
|
+
return to_object
|
1163
|
+
|
1164
|
+
|
1165
|
+
def _ActivityEnd_to_vertex(
|
1166
|
+
api_client: BaseApiClient,
|
1167
|
+
from_object: Union[dict[str, Any], object],
|
1168
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1169
|
+
) -> dict[str, Any]:
|
1170
|
+
to_object: dict[str, Any] = {}
|
1171
|
+
|
1172
|
+
return to_object
|
1173
|
+
|
1174
|
+
|
1175
|
+
def _LiveSendRealtimeInputParameters_to_mldev(
|
1176
|
+
api_client: BaseApiClient,
|
1177
|
+
from_object: Union[dict[str, Any], object],
|
1178
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1179
|
+
) -> dict[str, Any]:
|
1180
|
+
to_object: dict[str, Any] = {}
|
1181
|
+
if getv(from_object, ['media']) is not None:
|
1182
|
+
setv(
|
1183
|
+
to_object,
|
1184
|
+
['mediaChunks'],
|
1185
|
+
t.t_blobs(api_client, getv(from_object, ['media'])),
|
1186
|
+
)
|
1187
|
+
|
1188
|
+
if getv(from_object, ['audio']) is not None:
|
1189
|
+
setv(
|
1190
|
+
to_object,
|
1191
|
+
['audio'],
|
1192
|
+
t.t_audio_blob(api_client, getv(from_object, ['audio'])),
|
1193
|
+
)
|
1194
|
+
|
1195
|
+
if getv(from_object, ['audio_stream_end']) is not None:
|
1196
|
+
setv(to_object, ['audioStreamEnd'], getv(from_object, ['audio_stream_end']))
|
1197
|
+
|
1198
|
+
if getv(from_object, ['video']) is not None:
|
1199
|
+
setv(
|
1200
|
+
to_object,
|
1201
|
+
['video'],
|
1202
|
+
t.t_image_blob(api_client, getv(from_object, ['video'])),
|
1203
|
+
)
|
1204
|
+
|
1205
|
+
if getv(from_object, ['text']) is not None:
|
1206
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
1207
|
+
|
1208
|
+
if getv(from_object, ['activity_start']) is not None:
|
1209
|
+
setv(
|
1210
|
+
to_object,
|
1211
|
+
['activityStart'],
|
1212
|
+
_ActivityStart_to_mldev(
|
1213
|
+
api_client, getv(from_object, ['activity_start']), to_object
|
1214
|
+
),
|
1215
|
+
)
|
1216
|
+
|
1217
|
+
if getv(from_object, ['activity_end']) is not None:
|
1218
|
+
setv(
|
1219
|
+
to_object,
|
1220
|
+
['activityEnd'],
|
1221
|
+
_ActivityEnd_to_mldev(
|
1222
|
+
api_client, getv(from_object, ['activity_end']), to_object
|
1223
|
+
),
|
1224
|
+
)
|
1225
|
+
|
1226
|
+
return to_object
|
1227
|
+
|
1228
|
+
|
1229
|
+
def _LiveSendRealtimeInputParameters_to_vertex(
|
1230
|
+
api_client: BaseApiClient,
|
1231
|
+
from_object: Union[dict[str, Any], object],
|
1232
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1233
|
+
) -> dict[str, Any]:
|
1234
|
+
to_object: dict[str, Any] = {}
|
1235
|
+
if getv(from_object, ['media']) is not None:
|
1236
|
+
setv(
|
1237
|
+
to_object,
|
1238
|
+
['mediaChunks'],
|
1239
|
+
t.t_blobs(api_client, getv(from_object, ['media'])),
|
1240
|
+
)
|
1241
|
+
|
1242
|
+
if getv(from_object, ['audio']) is not None:
|
1243
|
+
raise ValueError('audio parameter is not supported in Vertex AI.')
|
1244
|
+
|
1245
|
+
if getv(from_object, ['audio_stream_end']) is not None:
|
1246
|
+
setv(to_object, ['audioStreamEnd'], getv(from_object, ['audio_stream_end']))
|
1247
|
+
|
1248
|
+
if getv(from_object, ['video']) is not None:
|
1249
|
+
raise ValueError('video parameter is not supported in Vertex AI.')
|
1250
|
+
|
1251
|
+
if getv(from_object, ['text']) is not None:
|
1252
|
+
raise ValueError('text parameter is not supported in Vertex AI.')
|
1253
|
+
|
1254
|
+
if getv(from_object, ['activity_start']) is not None:
|
1255
|
+
setv(
|
1256
|
+
to_object,
|
1257
|
+
['activityStart'],
|
1258
|
+
_ActivityStart_to_vertex(
|
1259
|
+
api_client, getv(from_object, ['activity_start']), to_object
|
1260
|
+
),
|
1261
|
+
)
|
1262
|
+
|
1263
|
+
if getv(from_object, ['activity_end']) is not None:
|
1264
|
+
setv(
|
1265
|
+
to_object,
|
1266
|
+
['activityEnd'],
|
1267
|
+
_ActivityEnd_to_vertex(
|
1268
|
+
api_client, getv(from_object, ['activity_end']), to_object
|
1269
|
+
),
|
1270
|
+
)
|
1271
|
+
|
1272
|
+
return to_object
|
1273
|
+
|
1274
|
+
|
1275
|
+
def _LiveClientSetup_to_mldev(
|
1276
|
+
api_client: BaseApiClient,
|
1277
|
+
from_object: Union[dict[str, Any], object],
|
1278
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1279
|
+
) -> dict[str, Any]:
|
1280
|
+
to_object: dict[str, Any] = {}
|
1281
|
+
if getv(from_object, ['model']) is not None:
|
1282
|
+
setv(to_object, ['model'], getv(from_object, ['model']))
|
1283
|
+
|
1284
|
+
if getv(from_object, ['generation_config']) is not None:
|
1285
|
+
setv(
|
1286
|
+
to_object,
|
1287
|
+
['generationConfig'],
|
1288
|
+
getv(from_object, ['generation_config']),
|
1289
|
+
)
|
1290
|
+
|
1291
|
+
if getv(from_object, ['system_instruction']) is not None:
|
1292
|
+
setv(
|
1293
|
+
to_object,
|
1294
|
+
['systemInstruction'],
|
1295
|
+
_Content_to_mldev(
|
1296
|
+
api_client,
|
1297
|
+
t.t_content(api_client, getv(from_object, ['system_instruction'])),
|
1298
|
+
to_object,
|
1299
|
+
),
|
1300
|
+
)
|
1301
|
+
|
1302
|
+
if getv(from_object, ['tools']) is not None:
|
1303
|
+
setv(
|
1304
|
+
to_object,
|
1305
|
+
['tools'],
|
1306
|
+
[
|
1307
|
+
_Tool_to_mldev(api_client, t.t_tool(api_client, item), to_object)
|
1308
|
+
for item in t.t_tools(api_client, getv(from_object, ['tools']))
|
1309
|
+
],
|
1310
|
+
)
|
1311
|
+
|
1312
|
+
if getv(from_object, ['session_resumption']) is not None:
|
1313
|
+
setv(
|
1314
|
+
to_object,
|
1315
|
+
['sessionResumption'],
|
1316
|
+
_SessionResumptionConfig_to_mldev(
|
1317
|
+
api_client, getv(from_object, ['session_resumption']), to_object
|
1318
|
+
),
|
1319
|
+
)
|
1320
|
+
|
1321
|
+
if getv(from_object, ['context_window_compression']) is not None:
|
1322
|
+
setv(
|
1323
|
+
to_object,
|
1324
|
+
['contextWindowCompression'],
|
1325
|
+
_ContextWindowCompressionConfig_to_mldev(
|
1326
|
+
api_client,
|
1327
|
+
getv(from_object, ['context_window_compression']),
|
1328
|
+
to_object,
|
1329
|
+
),
|
1330
|
+
)
|
1331
|
+
|
1332
|
+
return to_object
|
1333
|
+
|
1334
|
+
|
1335
|
+
def _LiveClientSetup_to_vertex(
|
1336
|
+
api_client: BaseApiClient,
|
1337
|
+
from_object: Union[dict[str, Any], object],
|
1338
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1339
|
+
) -> dict[str, Any]:
|
1340
|
+
to_object: dict[str, Any] = {}
|
1341
|
+
if getv(from_object, ['model']) is not None:
|
1342
|
+
setv(to_object, ['model'], getv(from_object, ['model']))
|
1343
|
+
|
1344
|
+
if getv(from_object, ['generation_config']) is not None:
|
1345
|
+
setv(
|
1346
|
+
to_object,
|
1347
|
+
['generationConfig'],
|
1348
|
+
getv(from_object, ['generation_config']),
|
1349
|
+
)
|
1350
|
+
|
1351
|
+
if getv(from_object, ['system_instruction']) is not None:
|
1352
|
+
setv(
|
1353
|
+
to_object,
|
1354
|
+
['systemInstruction'],
|
1355
|
+
_Content_to_vertex(
|
1356
|
+
api_client,
|
1357
|
+
t.t_content(api_client, getv(from_object, ['system_instruction'])),
|
1358
|
+
to_object,
|
1359
|
+
),
|
1360
|
+
)
|
1361
|
+
|
1362
|
+
if getv(from_object, ['tools']) is not None:
|
1363
|
+
setv(
|
1364
|
+
to_object,
|
1365
|
+
['tools'],
|
1366
|
+
[
|
1367
|
+
_Tool_to_vertex(api_client, t.t_tool(api_client, item), to_object)
|
1368
|
+
for item in t.t_tools(api_client, getv(from_object, ['tools']))
|
1369
|
+
],
|
1370
|
+
)
|
1371
|
+
|
1372
|
+
if getv(from_object, ['session_resumption']) is not None:
|
1373
|
+
setv(
|
1374
|
+
to_object,
|
1375
|
+
['sessionResumption'],
|
1376
|
+
_SessionResumptionConfig_to_vertex(
|
1377
|
+
api_client, getv(from_object, ['session_resumption']), to_object
|
1378
|
+
),
|
1379
|
+
)
|
1380
|
+
|
1381
|
+
if getv(from_object, ['context_window_compression']) is not None:
|
1382
|
+
setv(
|
1383
|
+
to_object,
|
1384
|
+
['contextWindowCompression'],
|
1385
|
+
_ContextWindowCompressionConfig_to_vertex(
|
1386
|
+
api_client,
|
1387
|
+
getv(from_object, ['context_window_compression']),
|
1388
|
+
to_object,
|
1389
|
+
),
|
1390
|
+
)
|
1391
|
+
|
1392
|
+
return to_object
|
1393
|
+
|
1394
|
+
|
1395
|
+
def _LiveClientContent_to_mldev(
|
1396
|
+
api_client: BaseApiClient,
|
1397
|
+
from_object: Union[dict[str, Any], object],
|
1398
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1399
|
+
) -> dict[str, Any]:
|
1400
|
+
to_object: dict[str, Any] = {}
|
1401
|
+
if getv(from_object, ['turns']) is not None:
|
1402
|
+
setv(
|
1403
|
+
to_object,
|
1404
|
+
['turns'],
|
1405
|
+
[
|
1406
|
+
_Content_to_mldev(api_client, item, to_object)
|
1407
|
+
for item in getv(from_object, ['turns'])
|
1408
|
+
],
|
1409
|
+
)
|
1410
|
+
|
1411
|
+
if getv(from_object, ['turn_complete']) is not None:
|
1412
|
+
setv(to_object, ['turnComplete'], getv(from_object, ['turn_complete']))
|
1413
|
+
|
1414
|
+
return to_object
|
1415
|
+
|
1416
|
+
|
1417
|
+
def _LiveClientContent_to_vertex(
|
1418
|
+
api_client: BaseApiClient,
|
1419
|
+
from_object: Union[dict[str, Any], object],
|
1420
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1421
|
+
) -> dict[str, Any]:
|
1422
|
+
to_object: dict[str, Any] = {}
|
1423
|
+
if getv(from_object, ['turns']) is not None:
|
1424
|
+
setv(
|
1425
|
+
to_object,
|
1426
|
+
['turns'],
|
1427
|
+
[
|
1428
|
+
_Content_to_vertex(api_client, item, to_object)
|
1429
|
+
for item in getv(from_object, ['turns'])
|
1430
|
+
],
|
1431
|
+
)
|
1432
|
+
|
1433
|
+
if getv(from_object, ['turn_complete']) is not None:
|
1434
|
+
setv(to_object, ['turnComplete'], getv(from_object, ['turn_complete']))
|
1435
|
+
|
1436
|
+
return to_object
|
1437
|
+
|
1438
|
+
|
1439
|
+
def _LiveClientRealtimeInput_to_mldev(
|
1440
|
+
api_client: BaseApiClient,
|
1441
|
+
from_object: Union[dict[str, Any], object],
|
1442
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1443
|
+
) -> dict[str, Any]:
|
1444
|
+
to_object: dict[str, Any] = {}
|
1445
|
+
if getv(from_object, ['media_chunks']) is not None:
|
1446
|
+
setv(to_object, ['mediaChunks'], getv(from_object, ['media_chunks']))
|
1447
|
+
|
1448
|
+
if getv(from_object, ['audio']) is not None:
|
1449
|
+
setv(to_object, ['audio'], getv(from_object, ['audio']))
|
1450
|
+
|
1451
|
+
if getv(from_object, ['audio_stream_end']) is not None:
|
1452
|
+
setv(to_object, ['audioStreamEnd'], getv(from_object, ['audio_stream_end']))
|
1453
|
+
|
1454
|
+
if getv(from_object, ['video']) is not None:
|
1455
|
+
setv(to_object, ['video'], getv(from_object, ['video']))
|
1456
|
+
|
1457
|
+
if getv(from_object, ['text']) is not None:
|
1458
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
1459
|
+
|
1460
|
+
if getv(from_object, ['activity_start']) is not None:
|
1461
|
+
setv(
|
1462
|
+
to_object,
|
1463
|
+
['activityStart'],
|
1464
|
+
_ActivityStart_to_mldev(
|
1465
|
+
api_client, getv(from_object, ['activity_start']), to_object
|
1466
|
+
),
|
1467
|
+
)
|
1468
|
+
|
1469
|
+
if getv(from_object, ['activity_end']) is not None:
|
1470
|
+
setv(
|
1471
|
+
to_object,
|
1472
|
+
['activityEnd'],
|
1473
|
+
_ActivityEnd_to_mldev(
|
1474
|
+
api_client, getv(from_object, ['activity_end']), to_object
|
1475
|
+
),
|
1476
|
+
)
|
1477
|
+
|
1478
|
+
return to_object
|
1479
|
+
|
1480
|
+
|
1481
|
+
def _LiveClientRealtimeInput_to_vertex(
|
1482
|
+
api_client: BaseApiClient,
|
1483
|
+
from_object: Union[dict[str, Any], object],
|
1484
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1485
|
+
) -> dict[str, Any]:
|
1486
|
+
to_object: dict[str, Any] = {}
|
1487
|
+
if getv(from_object, ['media_chunks']) is not None:
|
1488
|
+
setv(to_object, ['mediaChunks'], getv(from_object, ['media_chunks']))
|
1489
|
+
|
1490
|
+
if getv(from_object, ['audio']) is not None:
|
1491
|
+
raise ValueError('audio parameter is not supported in Vertex AI.')
|
1492
|
+
|
1493
|
+
if getv(from_object, ['audio_stream_end']) is not None:
|
1494
|
+
raise ValueError(
|
1495
|
+
'audio_stream_end parameter is not supported in Vertex AI.'
|
1496
|
+
)
|
1497
|
+
|
1498
|
+
if getv(from_object, ['video']) is not None:
|
1499
|
+
raise ValueError('video parameter is not supported in Vertex AI.')
|
1500
|
+
|
1501
|
+
if getv(from_object, ['text']) is not None:
|
1502
|
+
raise ValueError('text parameter is not supported in Vertex AI.')
|
1503
|
+
|
1504
|
+
if getv(from_object, ['activity_start']) is not None:
|
1505
|
+
setv(
|
1506
|
+
to_object,
|
1507
|
+
['activityStart'],
|
1508
|
+
_ActivityStart_to_vertex(
|
1509
|
+
api_client, getv(from_object, ['activity_start']), to_object
|
1510
|
+
),
|
1511
|
+
)
|
1512
|
+
|
1513
|
+
if getv(from_object, ['activity_end']) is not None:
|
1514
|
+
setv(
|
1515
|
+
to_object,
|
1516
|
+
['activityEnd'],
|
1517
|
+
_ActivityEnd_to_vertex(
|
1518
|
+
api_client, getv(from_object, ['activity_end']), to_object
|
1519
|
+
),
|
1520
|
+
)
|
1521
|
+
|
1522
|
+
return to_object
|
1523
|
+
|
1524
|
+
|
1525
|
+
def _FunctionResponse_to_mldev(
|
1526
|
+
api_client: BaseApiClient,
|
1527
|
+
from_object: Union[dict[str, Any], object],
|
1528
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1529
|
+
) -> dict[str, Any]:
|
1530
|
+
to_object: dict[str, Any] = {}
|
1531
|
+
if getv(from_object, ['id']) is not None:
|
1532
|
+
setv(to_object, ['id'], getv(from_object, ['id']))
|
1533
|
+
|
1534
|
+
if getv(from_object, ['name']) is not None:
|
1535
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
1536
|
+
|
1537
|
+
if getv(from_object, ['response']) is not None:
|
1538
|
+
setv(to_object, ['response'], getv(from_object, ['response']))
|
1539
|
+
|
1540
|
+
return to_object
|
1541
|
+
|
1542
|
+
|
1543
|
+
def _FunctionResponse_to_vertex(
|
1544
|
+
api_client: BaseApiClient,
|
1545
|
+
from_object: Union[dict[str, Any], object],
|
1546
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1547
|
+
) -> dict[str, Any]:
|
1548
|
+
to_object: dict[str, Any] = {}
|
1549
|
+
if getv(from_object, ['id']) is not None:
|
1550
|
+
raise ValueError('id parameter is not supported in Vertex AI.')
|
1551
|
+
|
1552
|
+
if getv(from_object, ['name']) is not None:
|
1553
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
1554
|
+
|
1555
|
+
if getv(from_object, ['response']) is not None:
|
1556
|
+
setv(to_object, ['response'], getv(from_object, ['response']))
|
1557
|
+
|
1558
|
+
return to_object
|
1559
|
+
|
1560
|
+
|
1561
|
+
def _LiveClientToolResponse_to_mldev(
|
1562
|
+
api_client: BaseApiClient,
|
1563
|
+
from_object: Union[dict[str, Any], object],
|
1564
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1565
|
+
) -> dict[str, Any]:
|
1566
|
+
to_object: dict[str, Any] = {}
|
1567
|
+
if getv(from_object, ['function_responses']) is not None:
|
1568
|
+
setv(
|
1569
|
+
to_object,
|
1570
|
+
['functionResponses'],
|
1571
|
+
[
|
1572
|
+
_FunctionResponse_to_mldev(api_client, item, to_object)
|
1573
|
+
for item in getv(from_object, ['function_responses'])
|
1574
|
+
],
|
1575
|
+
)
|
1576
|
+
|
1577
|
+
return to_object
|
1578
|
+
|
1579
|
+
|
1580
|
+
def _LiveClientToolResponse_to_vertex(
|
1581
|
+
api_client: BaseApiClient,
|
1582
|
+
from_object: Union[dict[str, Any], object],
|
1583
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1584
|
+
) -> dict[str, Any]:
|
1585
|
+
to_object: dict[str, Any] = {}
|
1586
|
+
if getv(from_object, ['function_responses']) is not None:
|
1587
|
+
setv(
|
1588
|
+
to_object,
|
1589
|
+
['functionResponses'],
|
1590
|
+
[
|
1591
|
+
_FunctionResponse_to_vertex(api_client, item, to_object)
|
1592
|
+
for item in getv(from_object, ['function_responses'])
|
1593
|
+
],
|
1594
|
+
)
|
1595
|
+
|
1596
|
+
return to_object
|
1597
|
+
|
1598
|
+
|
1599
|
+
def _LiveClientMessage_to_mldev(
|
1600
|
+
api_client: BaseApiClient,
|
1601
|
+
from_object: Union[dict[str, Any], object],
|
1602
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1603
|
+
) -> dict[str, Any]:
|
1604
|
+
to_object: dict[str, Any] = {}
|
1605
|
+
if getv(from_object, ['setup']) is not None:
|
1606
|
+
setv(
|
1607
|
+
to_object,
|
1608
|
+
['setup'],
|
1609
|
+
_LiveClientSetup_to_mldev(
|
1610
|
+
api_client, getv(from_object, ['setup']), to_object
|
1611
|
+
),
|
1612
|
+
)
|
1613
|
+
|
1614
|
+
if getv(from_object, ['client_content']) is not None:
|
1615
|
+
setv(
|
1616
|
+
to_object,
|
1617
|
+
['clientContent'],
|
1618
|
+
_LiveClientContent_to_mldev(
|
1619
|
+
api_client, getv(from_object, ['client_content']), to_object
|
1620
|
+
),
|
1621
|
+
)
|
1622
|
+
|
1623
|
+
if getv(from_object, ['realtime_input']) is not None:
|
1624
|
+
setv(
|
1625
|
+
to_object,
|
1626
|
+
['realtimeInput'],
|
1627
|
+
_LiveClientRealtimeInput_to_mldev(
|
1628
|
+
api_client, getv(from_object, ['realtime_input']), to_object
|
1629
|
+
),
|
1630
|
+
)
|
1631
|
+
|
1632
|
+
if getv(from_object, ['tool_response']) is not None:
|
1633
|
+
setv(
|
1634
|
+
to_object,
|
1635
|
+
['toolResponse'],
|
1636
|
+
_LiveClientToolResponse_to_mldev(
|
1637
|
+
api_client, getv(from_object, ['tool_response']), to_object
|
1638
|
+
),
|
1639
|
+
)
|
1640
|
+
|
1641
|
+
return to_object
|
1642
|
+
|
1643
|
+
|
1644
|
+
def _LiveClientMessage_to_vertex(
|
1645
|
+
api_client: BaseApiClient,
|
1646
|
+
from_object: Union[dict[str, Any], object],
|
1647
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1648
|
+
) -> dict[str, Any]:
|
1649
|
+
to_object: dict[str, Any] = {}
|
1650
|
+
if getv(from_object, ['setup']) is not None:
|
1651
|
+
setv(
|
1652
|
+
to_object,
|
1653
|
+
['setup'],
|
1654
|
+
_LiveClientSetup_to_vertex(
|
1655
|
+
api_client, getv(from_object, ['setup']), to_object
|
1656
|
+
),
|
1657
|
+
)
|
1658
|
+
|
1659
|
+
if getv(from_object, ['client_content']) is not None:
|
1660
|
+
setv(
|
1661
|
+
to_object,
|
1662
|
+
['clientContent'],
|
1663
|
+
_LiveClientContent_to_vertex(
|
1664
|
+
api_client, getv(from_object, ['client_content']), to_object
|
1665
|
+
),
|
1666
|
+
)
|
1667
|
+
|
1668
|
+
if getv(from_object, ['realtime_input']) is not None:
|
1669
|
+
setv(
|
1670
|
+
to_object,
|
1671
|
+
['realtimeInput'],
|
1672
|
+
_LiveClientRealtimeInput_to_vertex(
|
1673
|
+
api_client, getv(from_object, ['realtime_input']), to_object
|
1674
|
+
),
|
1675
|
+
)
|
1676
|
+
|
1677
|
+
if getv(from_object, ['tool_response']) is not None:
|
1678
|
+
setv(
|
1679
|
+
to_object,
|
1680
|
+
['toolResponse'],
|
1681
|
+
_LiveClientToolResponse_to_vertex(
|
1682
|
+
api_client, getv(from_object, ['tool_response']), to_object
|
1683
|
+
),
|
1684
|
+
)
|
1685
|
+
|
1686
|
+
return to_object
|
1687
|
+
|
1688
|
+
|
1689
|
+
def _LiveServerSetupComplete_from_mldev(
|
1690
|
+
api_client: BaseApiClient,
|
1691
|
+
from_object: Union[dict[str, Any], object],
|
1692
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1693
|
+
) -> dict[str, Any]:
|
1694
|
+
to_object: dict[str, Any] = {}
|
1695
|
+
|
1696
|
+
return to_object
|
1697
|
+
|
1698
|
+
|
1699
|
+
def _LiveServerSetupComplete_from_vertex(
|
1700
|
+
api_client: BaseApiClient,
|
1701
|
+
from_object: Union[dict[str, Any], object],
|
1702
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1703
|
+
) -> dict[str, Any]:
|
1704
|
+
to_object: dict[str, Any] = {}
|
1705
|
+
|
1706
|
+
return to_object
|
1707
|
+
|
1708
|
+
|
1709
|
+
def _Part_from_mldev(
|
1710
|
+
api_client: BaseApiClient,
|
1711
|
+
from_object: Union[dict[str, Any], object],
|
1712
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1713
|
+
) -> dict[str, Any]:
|
1714
|
+
to_object: dict[str, Any] = {}
|
1715
|
+
|
1716
|
+
if getv(from_object, ['thought']) is not None:
|
1717
|
+
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
1718
|
+
|
1719
|
+
if getv(from_object, ['codeExecutionResult']) is not None:
|
1720
|
+
setv(
|
1721
|
+
to_object,
|
1722
|
+
['code_execution_result'],
|
1723
|
+
getv(from_object, ['codeExecutionResult']),
|
1724
|
+
)
|
1725
|
+
|
1726
|
+
if getv(from_object, ['executableCode']) is not None:
|
1727
|
+
setv(to_object, ['executable_code'], getv(from_object, ['executableCode']))
|
1728
|
+
|
1729
|
+
if getv(from_object, ['fileData']) is not None:
|
1730
|
+
setv(to_object, ['file_data'], getv(from_object, ['fileData']))
|
1731
|
+
|
1732
|
+
if getv(from_object, ['functionCall']) is not None:
|
1733
|
+
setv(to_object, ['function_call'], getv(from_object, ['functionCall']))
|
1734
|
+
|
1735
|
+
if getv(from_object, ['functionResponse']) is not None:
|
1736
|
+
setv(
|
1737
|
+
to_object,
|
1738
|
+
['function_response'],
|
1739
|
+
getv(from_object, ['functionResponse']),
|
1740
|
+
)
|
1741
|
+
|
1742
|
+
if getv(from_object, ['inlineData']) is not None:
|
1743
|
+
setv(to_object, ['inline_data'], getv(from_object, ['inlineData']))
|
1744
|
+
|
1745
|
+
if getv(from_object, ['text']) is not None:
|
1746
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
1747
|
+
|
1748
|
+
return to_object
|
1749
|
+
|
1750
|
+
|
1751
|
+
def _Part_from_vertex(
|
1752
|
+
api_client: BaseApiClient,
|
1753
|
+
from_object: Union[dict[str, Any], object],
|
1754
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1755
|
+
) -> dict[str, Any]:
|
1756
|
+
to_object: dict[str, Any] = {}
|
1757
|
+
if getv(from_object, ['videoMetadata']) is not None:
|
1758
|
+
setv(to_object, ['video_metadata'], getv(from_object, ['videoMetadata']))
|
1759
|
+
|
1760
|
+
if getv(from_object, ['thought']) is not None:
|
1761
|
+
setv(to_object, ['thought'], getv(from_object, ['thought']))
|
1762
|
+
|
1763
|
+
if getv(from_object, ['codeExecutionResult']) is not None:
|
1764
|
+
setv(
|
1765
|
+
to_object,
|
1766
|
+
['code_execution_result'],
|
1767
|
+
getv(from_object, ['codeExecutionResult']),
|
1768
|
+
)
|
1769
|
+
|
1770
|
+
if getv(from_object, ['executableCode']) is not None:
|
1771
|
+
setv(to_object, ['executable_code'], getv(from_object, ['executableCode']))
|
1772
|
+
|
1773
|
+
if getv(from_object, ['fileData']) is not None:
|
1774
|
+
setv(to_object, ['file_data'], getv(from_object, ['fileData']))
|
1775
|
+
|
1776
|
+
if getv(from_object, ['functionCall']) is not None:
|
1777
|
+
setv(to_object, ['function_call'], getv(from_object, ['functionCall']))
|
1778
|
+
|
1779
|
+
if getv(from_object, ['functionResponse']) is not None:
|
1780
|
+
setv(
|
1781
|
+
to_object,
|
1782
|
+
['function_response'],
|
1783
|
+
getv(from_object, ['functionResponse']),
|
1784
|
+
)
|
1785
|
+
|
1786
|
+
if getv(from_object, ['inlineData']) is not None:
|
1787
|
+
setv(to_object, ['inline_data'], getv(from_object, ['inlineData']))
|
1788
|
+
|
1789
|
+
if getv(from_object, ['text']) is not None:
|
1790
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
1791
|
+
|
1792
|
+
return to_object
|
1793
|
+
|
1794
|
+
|
1795
|
+
def _Content_from_mldev(
|
1796
|
+
api_client: BaseApiClient,
|
1797
|
+
from_object: Union[dict[str, Any], object],
|
1798
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1799
|
+
) -> dict[str, Any]:
|
1800
|
+
to_object: dict[str, Any] = {}
|
1801
|
+
if getv(from_object, ['parts']) is not None:
|
1802
|
+
setv(
|
1803
|
+
to_object,
|
1804
|
+
['parts'],
|
1805
|
+
[
|
1806
|
+
_Part_from_mldev(api_client, item, to_object)
|
1807
|
+
for item in getv(from_object, ['parts'])
|
1808
|
+
],
|
1809
|
+
)
|
1810
|
+
|
1811
|
+
if getv(from_object, ['role']) is not None:
|
1812
|
+
setv(to_object, ['role'], getv(from_object, ['role']))
|
1813
|
+
|
1814
|
+
return to_object
|
1815
|
+
|
1816
|
+
|
1817
|
+
def _Content_from_vertex(
|
1818
|
+
api_client: BaseApiClient,
|
1819
|
+
from_object: Union[dict[str, Any], object],
|
1820
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1821
|
+
) -> dict[str, Any]:
|
1822
|
+
to_object: dict[str, Any] = {}
|
1823
|
+
if getv(from_object, ['parts']) is not None:
|
1824
|
+
setv(
|
1825
|
+
to_object,
|
1826
|
+
['parts'],
|
1827
|
+
[
|
1828
|
+
_Part_from_vertex(api_client, item, to_object)
|
1829
|
+
for item in getv(from_object, ['parts'])
|
1830
|
+
],
|
1831
|
+
)
|
1832
|
+
|
1833
|
+
if getv(from_object, ['role']) is not None:
|
1834
|
+
setv(to_object, ['role'], getv(from_object, ['role']))
|
1835
|
+
|
1836
|
+
return to_object
|
1837
|
+
|
1838
|
+
|
1839
|
+
def _Transcription_from_mldev(
|
1840
|
+
api_client: BaseApiClient,
|
1841
|
+
from_object: Union[dict[str, Any], object],
|
1842
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1843
|
+
) -> dict[str, Any]:
|
1844
|
+
to_object: dict[str, Any] = {}
|
1845
|
+
if getv(from_object, ['text']) is not None:
|
1846
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
1847
|
+
|
1848
|
+
if getv(from_object, ['finished']) is not None:
|
1849
|
+
setv(to_object, ['finished'], getv(from_object, ['finished']))
|
1850
|
+
|
1851
|
+
return to_object
|
1852
|
+
|
1853
|
+
|
1854
|
+
def _Transcription_from_vertex(
|
1855
|
+
api_client: BaseApiClient,
|
1856
|
+
from_object: Union[dict[str, Any], object],
|
1857
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1858
|
+
) -> dict[str, Any]:
|
1859
|
+
to_object: dict[str, Any] = {}
|
1860
|
+
if getv(from_object, ['text']) is not None:
|
1861
|
+
setv(to_object, ['text'], getv(from_object, ['text']))
|
1862
|
+
|
1863
|
+
if getv(from_object, ['finished']) is not None:
|
1864
|
+
setv(to_object, ['finished'], getv(from_object, ['finished']))
|
1865
|
+
|
1866
|
+
return to_object
|
1867
|
+
|
1868
|
+
|
1869
|
+
def _LiveServerContent_from_mldev(
|
1870
|
+
api_client: BaseApiClient,
|
1871
|
+
from_object: Union[dict[str, Any], object],
|
1872
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1873
|
+
) -> dict[str, Any]:
|
1874
|
+
to_object: dict[str, Any] = {}
|
1875
|
+
if getv(from_object, ['modelTurn']) is not None:
|
1876
|
+
setv(
|
1877
|
+
to_object,
|
1878
|
+
['model_turn'],
|
1879
|
+
_Content_from_mldev(
|
1880
|
+
api_client, getv(from_object, ['modelTurn']), to_object
|
1881
|
+
),
|
1882
|
+
)
|
1883
|
+
|
1884
|
+
if getv(from_object, ['turnComplete']) is not None:
|
1885
|
+
setv(to_object, ['turn_complete'], getv(from_object, ['turnComplete']))
|
1886
|
+
|
1887
|
+
if getv(from_object, ['interrupted']) is not None:
|
1888
|
+
setv(to_object, ['interrupted'], getv(from_object, ['interrupted']))
|
1889
|
+
|
1890
|
+
if getv(from_object, ['generationComplete']) is not None:
|
1891
|
+
setv(
|
1892
|
+
to_object,
|
1893
|
+
['generation_complete'],
|
1894
|
+
getv(from_object, ['generationComplete']),
|
1895
|
+
)
|
1896
|
+
|
1897
|
+
if getv(from_object, ['inputTranscription']) is not None:
|
1898
|
+
setv(
|
1899
|
+
to_object,
|
1900
|
+
['input_transcription'],
|
1901
|
+
_Transcription_from_mldev(
|
1902
|
+
api_client, getv(from_object, ['inputTranscription']), to_object
|
1903
|
+
),
|
1904
|
+
)
|
1905
|
+
|
1906
|
+
if getv(from_object, ['outputTranscription']) is not None:
|
1907
|
+
setv(
|
1908
|
+
to_object,
|
1909
|
+
['output_transcription'],
|
1910
|
+
_Transcription_from_mldev(
|
1911
|
+
api_client, getv(from_object, ['outputTranscription']), to_object
|
1912
|
+
),
|
1913
|
+
)
|
1914
|
+
|
1915
|
+
return to_object
|
1916
|
+
|
1917
|
+
|
1918
|
+
def _LiveServerContent_from_vertex(
|
1919
|
+
api_client: BaseApiClient,
|
1920
|
+
from_object: Union[dict[str, Any], object],
|
1921
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1922
|
+
) -> dict[str, Any]:
|
1923
|
+
to_object: dict[str, Any] = {}
|
1924
|
+
if getv(from_object, ['modelTurn']) is not None:
|
1925
|
+
setv(
|
1926
|
+
to_object,
|
1927
|
+
['model_turn'],
|
1928
|
+
_Content_from_vertex(
|
1929
|
+
api_client, getv(from_object, ['modelTurn']), to_object
|
1930
|
+
),
|
1931
|
+
)
|
1932
|
+
|
1933
|
+
if getv(from_object, ['turnComplete']) is not None:
|
1934
|
+
setv(to_object, ['turn_complete'], getv(from_object, ['turnComplete']))
|
1935
|
+
|
1936
|
+
if getv(from_object, ['interrupted']) is not None:
|
1937
|
+
setv(to_object, ['interrupted'], getv(from_object, ['interrupted']))
|
1938
|
+
|
1939
|
+
if getv(from_object, ['generationComplete']) is not None:
|
1940
|
+
setv(
|
1941
|
+
to_object,
|
1942
|
+
['generation_complete'],
|
1943
|
+
getv(from_object, ['generationComplete']),
|
1944
|
+
)
|
1945
|
+
|
1946
|
+
if getv(from_object, ['inputTranscription']) is not None:
|
1947
|
+
setv(
|
1948
|
+
to_object,
|
1949
|
+
['input_transcription'],
|
1950
|
+
_Transcription_from_vertex(
|
1951
|
+
api_client, getv(from_object, ['inputTranscription']), to_object
|
1952
|
+
),
|
1953
|
+
)
|
1954
|
+
|
1955
|
+
if getv(from_object, ['outputTranscription']) is not None:
|
1956
|
+
setv(
|
1957
|
+
to_object,
|
1958
|
+
['output_transcription'],
|
1959
|
+
_Transcription_from_vertex(
|
1960
|
+
api_client, getv(from_object, ['outputTranscription']), to_object
|
1961
|
+
),
|
1962
|
+
)
|
1963
|
+
|
1964
|
+
return to_object
|
1965
|
+
|
1966
|
+
|
1967
|
+
def _FunctionCall_from_mldev(
|
1968
|
+
api_client: BaseApiClient,
|
1969
|
+
from_object: Union[dict[str, Any], object],
|
1970
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1971
|
+
) -> dict[str, Any]:
|
1972
|
+
to_object: dict[str, Any] = {}
|
1973
|
+
if getv(from_object, ['id']) is not None:
|
1974
|
+
setv(to_object, ['id'], getv(from_object, ['id']))
|
1975
|
+
|
1976
|
+
if getv(from_object, ['args']) is not None:
|
1977
|
+
setv(to_object, ['args'], getv(from_object, ['args']))
|
1978
|
+
|
1979
|
+
if getv(from_object, ['name']) is not None:
|
1980
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
1981
|
+
|
1982
|
+
return to_object
|
1983
|
+
|
1984
|
+
|
1985
|
+
def _FunctionCall_from_vertex(
|
1986
|
+
api_client: BaseApiClient,
|
1987
|
+
from_object: Union[dict[str, Any], object],
|
1988
|
+
parent_object: Optional[dict[str, Any]] = None,
|
1989
|
+
) -> dict[str, Any]:
|
1990
|
+
to_object: dict[str, Any] = {}
|
1991
|
+
|
1992
|
+
if getv(from_object, ['args']) is not None:
|
1993
|
+
setv(to_object, ['args'], getv(from_object, ['args']))
|
1994
|
+
|
1995
|
+
if getv(from_object, ['name']) is not None:
|
1996
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
1997
|
+
|
1998
|
+
return to_object
|
1999
|
+
|
2000
|
+
|
2001
|
+
def _LiveServerToolCall_from_mldev(
|
2002
|
+
api_client: BaseApiClient,
|
2003
|
+
from_object: Union[dict[str, Any], object],
|
2004
|
+
parent_object: Optional[dict[str, Any]] = None,
|
2005
|
+
) -> dict[str, Any]:
|
2006
|
+
to_object: dict[str, Any] = {}
|
2007
|
+
if getv(from_object, ['functionCalls']) is not None:
|
2008
|
+
setv(
|
2009
|
+
to_object,
|
2010
|
+
['function_calls'],
|
2011
|
+
[
|
2012
|
+
_FunctionCall_from_mldev(api_client, item, to_object)
|
2013
|
+
for item in getv(from_object, ['functionCalls'])
|
2014
|
+
],
|
2015
|
+
)
|
2016
|
+
|
2017
|
+
return to_object
|
2018
|
+
|
2019
|
+
|
2020
|
+
def _LiveServerToolCall_from_vertex(
|
2021
|
+
api_client: BaseApiClient,
|
2022
|
+
from_object: Union[dict[str, Any], object],
|
2023
|
+
parent_object: Optional[dict[str, Any]] = None,
|
2024
|
+
) -> dict[str, Any]:
|
2025
|
+
to_object: dict[str, Any] = {}
|
2026
|
+
if getv(from_object, ['functionCalls']) is not None:
|
2027
|
+
setv(
|
2028
|
+
to_object,
|
2029
|
+
['function_calls'],
|
2030
|
+
[
|
2031
|
+
_FunctionCall_from_vertex(api_client, item, to_object)
|
2032
|
+
for item in getv(from_object, ['functionCalls'])
|
2033
|
+
],
|
2034
|
+
)
|
2035
|
+
|
2036
|
+
return to_object
|
2037
|
+
|
2038
|
+
|
2039
|
+
def _LiveServerToolCallCancellation_from_mldev(
|
2040
|
+
api_client: BaseApiClient,
|
2041
|
+
from_object: Union[dict[str, Any], object],
|
2042
|
+
parent_object: Optional[dict[str, Any]] = None,
|
2043
|
+
) -> dict[str, Any]:
|
2044
|
+
to_object: dict[str, Any] = {}
|
2045
|
+
if getv(from_object, ['ids']) is not None:
|
2046
|
+
setv(to_object, ['ids'], getv(from_object, ['ids']))
|
2047
|
+
|
2048
|
+
return to_object
|
2049
|
+
|
2050
|
+
|
2051
|
+
def _LiveServerToolCallCancellation_from_vertex(
|
2052
|
+
api_client: BaseApiClient,
|
2053
|
+
from_object: Union[dict[str, Any], object],
|
2054
|
+
parent_object: Optional[dict[str, Any]] = None,
|
2055
|
+
) -> dict[str, Any]:
|
2056
|
+
to_object: dict[str, Any] = {}
|
2057
|
+
if getv(from_object, ['ids']) is not None:
|
2058
|
+
setv(to_object, ['ids'], getv(from_object, ['ids']))
|
2059
|
+
|
2060
|
+
return to_object
|
2061
|
+
|
2062
|
+
|
2063
|
+
def _ModalityTokenCount_from_mldev(
|
2064
|
+
api_client: BaseApiClient,
|
2065
|
+
from_object: Union[dict[str, Any], object],
|
2066
|
+
parent_object: Optional[dict[str, Any]] = None,
|
2067
|
+
) -> dict[str, Any]:
|
2068
|
+
to_object: dict[str, Any] = {}
|
2069
|
+
if getv(from_object, ['modality']) is not None:
|
2070
|
+
setv(to_object, ['modality'], getv(from_object, ['modality']))
|
2071
|
+
|
2072
|
+
if getv(from_object, ['tokenCount']) is not None:
|
2073
|
+
setv(to_object, ['token_count'], getv(from_object, ['tokenCount']))
|
2074
|
+
|
2075
|
+
return to_object
|
2076
|
+
|
2077
|
+
|
2078
|
+
def _ModalityTokenCount_from_vertex(
|
2079
|
+
api_client: BaseApiClient,
|
2080
|
+
from_object: Union[dict[str, Any], object],
|
2081
|
+
parent_object: Optional[dict[str, Any]] = None,
|
2082
|
+
) -> dict[str, Any]:
|
2083
|
+
to_object: dict[str, Any] = {}
|
2084
|
+
if getv(from_object, ['modality']) is not None:
|
2085
|
+
setv(to_object, ['modality'], getv(from_object, ['modality']))
|
2086
|
+
|
2087
|
+
if getv(from_object, ['tokenCount']) is not None:
|
2088
|
+
setv(to_object, ['token_count'], getv(from_object, ['tokenCount']))
|
2089
|
+
|
2090
|
+
return to_object
|
2091
|
+
|
2092
|
+
|
2093
|
+
def _UsageMetadata_from_mldev(
|
2094
|
+
api_client: BaseApiClient,
|
2095
|
+
from_object: Union[dict[str, Any], object],
|
2096
|
+
parent_object: Optional[dict[str, Any]] = None,
|
2097
|
+
) -> dict[str, Any]:
|
2098
|
+
to_object: dict[str, Any] = {}
|
2099
|
+
if getv(from_object, ['promptTokenCount']) is not None:
|
2100
|
+
setv(
|
2101
|
+
to_object,
|
2102
|
+
['prompt_token_count'],
|
2103
|
+
getv(from_object, ['promptTokenCount']),
|
2104
|
+
)
|
2105
|
+
|
2106
|
+
if getv(from_object, ['cachedContentTokenCount']) is not None:
|
2107
|
+
setv(
|
2108
|
+
to_object,
|
2109
|
+
['cached_content_token_count'],
|
2110
|
+
getv(from_object, ['cachedContentTokenCount']),
|
2111
|
+
)
|
2112
|
+
|
2113
|
+
if getv(from_object, ['responseTokenCount']) is not None:
|
2114
|
+
setv(
|
2115
|
+
to_object,
|
2116
|
+
['response_token_count'],
|
2117
|
+
getv(from_object, ['responseTokenCount']),
|
2118
|
+
)
|
2119
|
+
|
2120
|
+
if getv(from_object, ['toolUsePromptTokenCount']) is not None:
|
2121
|
+
setv(
|
2122
|
+
to_object,
|
2123
|
+
['tool_use_prompt_token_count'],
|
2124
|
+
getv(from_object, ['toolUsePromptTokenCount']),
|
2125
|
+
)
|
2126
|
+
|
2127
|
+
if getv(from_object, ['thoughtsTokenCount']) is not None:
|
2128
|
+
setv(
|
2129
|
+
to_object,
|
2130
|
+
['thoughts_token_count'],
|
2131
|
+
getv(from_object, ['thoughtsTokenCount']),
|
2132
|
+
)
|
2133
|
+
|
2134
|
+
if getv(from_object, ['totalTokenCount']) is not None:
|
2135
|
+
setv(
|
2136
|
+
to_object, ['total_token_count'], getv(from_object, ['totalTokenCount'])
|
2137
|
+
)
|
2138
|
+
|
2139
|
+
if getv(from_object, ['promptTokensDetails']) is not None:
|
2140
|
+
setv(
|
2141
|
+
to_object,
|
2142
|
+
['prompt_tokens_details'],
|
2143
|
+
[
|
2144
|
+
_ModalityTokenCount_from_mldev(api_client, item, to_object)
|
2145
|
+
for item in getv(from_object, ['promptTokensDetails'])
|
2146
|
+
],
|
2147
|
+
)
|
2148
|
+
|
2149
|
+
if getv(from_object, ['cacheTokensDetails']) is not None:
|
2150
|
+
setv(
|
2151
|
+
to_object,
|
2152
|
+
['cache_tokens_details'],
|
2153
|
+
[
|
2154
|
+
_ModalityTokenCount_from_mldev(api_client, item, to_object)
|
2155
|
+
for item in getv(from_object, ['cacheTokensDetails'])
|
2156
|
+
],
|
2157
|
+
)
|
2158
|
+
|
2159
|
+
if getv(from_object, ['responseTokensDetails']) is not None:
|
2160
|
+
setv(
|
2161
|
+
to_object,
|
2162
|
+
['response_tokens_details'],
|
2163
|
+
[
|
2164
|
+
_ModalityTokenCount_from_mldev(api_client, item, to_object)
|
2165
|
+
for item in getv(from_object, ['responseTokensDetails'])
|
2166
|
+
],
|
2167
|
+
)
|
2168
|
+
|
2169
|
+
if getv(from_object, ['toolUsePromptTokensDetails']) is not None:
|
2170
|
+
setv(
|
2171
|
+
to_object,
|
2172
|
+
['tool_use_prompt_tokens_details'],
|
2173
|
+
[
|
2174
|
+
_ModalityTokenCount_from_mldev(api_client, item, to_object)
|
2175
|
+
for item in getv(from_object, ['toolUsePromptTokensDetails'])
|
2176
|
+
],
|
2177
|
+
)
|
2178
|
+
|
2179
|
+
return to_object
|
2180
|
+
|
2181
|
+
|
2182
|
+
def _UsageMetadata_from_vertex(
|
2183
|
+
api_client: BaseApiClient,
|
2184
|
+
from_object: Union[dict[str, Any], object],
|
2185
|
+
parent_object: Optional[dict[str, Any]] = None,
|
2186
|
+
) -> dict[str, Any]:
|
2187
|
+
to_object: dict[str, Any] = {}
|
2188
|
+
if getv(from_object, ['promptTokenCount']) is not None:
|
2189
|
+
setv(
|
2190
|
+
to_object,
|
2191
|
+
['prompt_token_count'],
|
2192
|
+
getv(from_object, ['promptTokenCount']),
|
2193
|
+
)
|
2194
|
+
|
2195
|
+
if getv(from_object, ['cachedContentTokenCount']) is not None:
|
2196
|
+
setv(
|
2197
|
+
to_object,
|
2198
|
+
['cached_content_token_count'],
|
2199
|
+
getv(from_object, ['cachedContentTokenCount']),
|
2200
|
+
)
|
2201
|
+
|
2202
|
+
if getv(from_object, ['candidatesTokenCount']) is not None:
|
2203
|
+
setv(
|
2204
|
+
to_object,
|
2205
|
+
['response_token_count'],
|
2206
|
+
getv(from_object, ['candidatesTokenCount']),
|
2207
|
+
)
|
2208
|
+
|
2209
|
+
if getv(from_object, ['toolUsePromptTokenCount']) is not None:
|
2210
|
+
setv(
|
2211
|
+
to_object,
|
2212
|
+
['tool_use_prompt_token_count'],
|
2213
|
+
getv(from_object, ['toolUsePromptTokenCount']),
|
2214
|
+
)
|
2215
|
+
|
2216
|
+
if getv(from_object, ['thoughtsTokenCount']) is not None:
|
2217
|
+
setv(
|
2218
|
+
to_object,
|
2219
|
+
['thoughts_token_count'],
|
2220
|
+
getv(from_object, ['thoughtsTokenCount']),
|
2221
|
+
)
|
2222
|
+
|
2223
|
+
if getv(from_object, ['totalTokenCount']) is not None:
|
2224
|
+
setv(
|
2225
|
+
to_object, ['total_token_count'], getv(from_object, ['totalTokenCount'])
|
2226
|
+
)
|
2227
|
+
|
2228
|
+
if getv(from_object, ['promptTokensDetails']) is not None:
|
2229
|
+
setv(
|
2230
|
+
to_object,
|
2231
|
+
['prompt_tokens_details'],
|
2232
|
+
[
|
2233
|
+
_ModalityTokenCount_from_vertex(api_client, item, to_object)
|
2234
|
+
for item in getv(from_object, ['promptTokensDetails'])
|
2235
|
+
],
|
2236
|
+
)
|
2237
|
+
|
2238
|
+
if getv(from_object, ['cacheTokensDetails']) is not None:
|
2239
|
+
setv(
|
2240
|
+
to_object,
|
2241
|
+
['cache_tokens_details'],
|
2242
|
+
[
|
2243
|
+
_ModalityTokenCount_from_vertex(api_client, item, to_object)
|
2244
|
+
for item in getv(from_object, ['cacheTokensDetails'])
|
2245
|
+
],
|
2246
|
+
)
|
2247
|
+
|
2248
|
+
if getv(from_object, ['candidatesTokensDetails']) is not None:
|
2249
|
+
setv(
|
2250
|
+
to_object,
|
2251
|
+
['response_tokens_details'],
|
2252
|
+
[
|
2253
|
+
_ModalityTokenCount_from_vertex(api_client, item, to_object)
|
2254
|
+
for item in getv(from_object, ['candidatesTokensDetails'])
|
2255
|
+
],
|
2256
|
+
)
|
2257
|
+
|
2258
|
+
if getv(from_object, ['toolUsePromptTokensDetails']) is not None:
|
2259
|
+
setv(
|
2260
|
+
to_object,
|
2261
|
+
['tool_use_prompt_tokens_details'],
|
2262
|
+
[
|
2263
|
+
_ModalityTokenCount_from_vertex(api_client, item, to_object)
|
2264
|
+
for item in getv(from_object, ['toolUsePromptTokensDetails'])
|
2265
|
+
],
|
2266
|
+
)
|
2267
|
+
|
2268
|
+
if getv(from_object, ['trafficType']) is not None:
|
2269
|
+
setv(to_object, ['traffic_type'], getv(from_object, ['trafficType']))
|
2270
|
+
|
2271
|
+
return to_object
|
2272
|
+
|
2273
|
+
|
2274
|
+
def _LiveServerGoAway_from_mldev(
|
2275
|
+
api_client: BaseApiClient,
|
2276
|
+
from_object: Union[dict[str, Any], object],
|
2277
|
+
parent_object: Optional[dict[str, Any]] = None,
|
2278
|
+
) -> dict[str, Any]:
|
2279
|
+
to_object: dict[str, Any] = {}
|
2280
|
+
if getv(from_object, ['timeLeft']) is not None:
|
2281
|
+
setv(to_object, ['time_left'], getv(from_object, ['timeLeft']))
|
2282
|
+
|
2283
|
+
return to_object
|
2284
|
+
|
2285
|
+
|
2286
|
+
def _LiveServerGoAway_from_vertex(
|
2287
|
+
api_client: BaseApiClient,
|
2288
|
+
from_object: Union[dict[str, Any], object],
|
2289
|
+
parent_object: Optional[dict[str, Any]] = None,
|
2290
|
+
) -> dict[str, Any]:
|
2291
|
+
to_object: dict[str, Any] = {}
|
2292
|
+
if getv(from_object, ['timeLeft']) is not None:
|
2293
|
+
setv(to_object, ['time_left'], getv(from_object, ['timeLeft']))
|
2294
|
+
|
2295
|
+
return to_object
|
2296
|
+
|
2297
|
+
|
2298
|
+
def _LiveServerSessionResumptionUpdate_from_mldev(
|
2299
|
+
api_client: BaseApiClient,
|
2300
|
+
from_object: Union[dict[str, Any], object],
|
2301
|
+
parent_object: Optional[dict[str, Any]] = None,
|
2302
|
+
) -> dict[str, Any]:
|
2303
|
+
to_object: dict[str, Any] = {}
|
2304
|
+
if getv(from_object, ['newHandle']) is not None:
|
2305
|
+
setv(to_object, ['new_handle'], getv(from_object, ['newHandle']))
|
2306
|
+
|
2307
|
+
if getv(from_object, ['resumable']) is not None:
|
2308
|
+
setv(to_object, ['resumable'], getv(from_object, ['resumable']))
|
2309
|
+
|
2310
|
+
if getv(from_object, ['lastConsumedClientMessageIndex']) is not None:
|
2311
|
+
setv(
|
2312
|
+
to_object,
|
2313
|
+
['last_consumed_client_message_index'],
|
2314
|
+
getv(from_object, ['lastConsumedClientMessageIndex']),
|
2315
|
+
)
|
2316
|
+
|
2317
|
+
return to_object
|
2318
|
+
|
2319
|
+
|
2320
|
+
def _LiveServerSessionResumptionUpdate_from_vertex(
|
2321
|
+
api_client: BaseApiClient,
|
2322
|
+
from_object: Union[dict[str, Any], object],
|
2323
|
+
parent_object: Optional[dict[str, Any]] = None,
|
2324
|
+
) -> dict[str, Any]:
|
2325
|
+
to_object: dict[str, Any] = {}
|
2326
|
+
if getv(from_object, ['newHandle']) is not None:
|
2327
|
+
setv(to_object, ['new_handle'], getv(from_object, ['newHandle']))
|
2328
|
+
|
2329
|
+
if getv(from_object, ['resumable']) is not None:
|
2330
|
+
setv(to_object, ['resumable'], getv(from_object, ['resumable']))
|
2331
|
+
|
2332
|
+
if getv(from_object, ['lastConsumedClientMessageIndex']) is not None:
|
2333
|
+
setv(
|
2334
|
+
to_object,
|
2335
|
+
['last_consumed_client_message_index'],
|
2336
|
+
getv(from_object, ['lastConsumedClientMessageIndex']),
|
2337
|
+
)
|
2338
|
+
|
2339
|
+
return to_object
|
2340
|
+
|
2341
|
+
|
2342
|
+
def _LiveServerMessage_from_mldev(
|
2343
|
+
api_client: BaseApiClient,
|
2344
|
+
from_object: Union[dict[str, Any], object],
|
2345
|
+
parent_object: Optional[dict[str, Any]] = None,
|
2346
|
+
) -> dict[str, Any]:
|
2347
|
+
to_object: dict[str, Any] = {}
|
2348
|
+
if getv(from_object, ['setupComplete']) is not None:
|
2349
|
+
setv(
|
2350
|
+
to_object,
|
2351
|
+
['setup_complete'],
|
2352
|
+
_LiveServerSetupComplete_from_mldev(
|
2353
|
+
api_client, getv(from_object, ['setupComplete']), to_object
|
2354
|
+
),
|
2355
|
+
)
|
2356
|
+
|
2357
|
+
if getv(from_object, ['serverContent']) is not None:
|
2358
|
+
setv(
|
2359
|
+
to_object,
|
2360
|
+
['server_content'],
|
2361
|
+
_LiveServerContent_from_mldev(
|
2362
|
+
api_client, getv(from_object, ['serverContent']), to_object
|
2363
|
+
),
|
2364
|
+
)
|
2365
|
+
|
2366
|
+
if getv(from_object, ['toolCall']) is not None:
|
2367
|
+
setv(
|
2368
|
+
to_object,
|
2369
|
+
['tool_call'],
|
2370
|
+
_LiveServerToolCall_from_mldev(
|
2371
|
+
api_client, getv(from_object, ['toolCall']), to_object
|
2372
|
+
),
|
2373
|
+
)
|
2374
|
+
|
2375
|
+
if getv(from_object, ['toolCallCancellation']) is not None:
|
2376
|
+
setv(
|
2377
|
+
to_object,
|
2378
|
+
['tool_call_cancellation'],
|
2379
|
+
_LiveServerToolCallCancellation_from_mldev(
|
2380
|
+
api_client, getv(from_object, ['toolCallCancellation']), to_object
|
2381
|
+
),
|
2382
|
+
)
|
2383
|
+
|
2384
|
+
if getv(from_object, ['usageMetadata']) is not None:
|
2385
|
+
setv(
|
2386
|
+
to_object,
|
2387
|
+
['usage_metadata'],
|
2388
|
+
_UsageMetadata_from_mldev(
|
2389
|
+
api_client, getv(from_object, ['usageMetadata']), to_object
|
2390
|
+
),
|
2391
|
+
)
|
2392
|
+
|
2393
|
+
if getv(from_object, ['goAway']) is not None:
|
2394
|
+
setv(
|
2395
|
+
to_object,
|
2396
|
+
['go_away'],
|
2397
|
+
_LiveServerGoAway_from_mldev(
|
2398
|
+
api_client, getv(from_object, ['goAway']), to_object
|
2399
|
+
),
|
2400
|
+
)
|
2401
|
+
|
2402
|
+
if getv(from_object, ['sessionResumptionUpdate']) is not None:
|
2403
|
+
setv(
|
2404
|
+
to_object,
|
2405
|
+
['session_resumption_update'],
|
2406
|
+
_LiveServerSessionResumptionUpdate_from_mldev(
|
2407
|
+
api_client,
|
2408
|
+
getv(from_object, ['sessionResumptionUpdate']),
|
2409
|
+
to_object,
|
2410
|
+
),
|
2411
|
+
)
|
2412
|
+
|
2413
|
+
return to_object
|
2414
|
+
|
2415
|
+
|
2416
|
+
def _LiveServerMessage_from_vertex(
|
2417
|
+
api_client: BaseApiClient,
|
2418
|
+
from_object: Union[dict[str, Any], object],
|
2419
|
+
parent_object: Optional[dict[str, Any]] = None,
|
2420
|
+
) -> dict[str, Any]:
|
2421
|
+
to_object: dict[str, Any] = {}
|
2422
|
+
if getv(from_object, ['setupComplete']) is not None:
|
2423
|
+
setv(
|
2424
|
+
to_object,
|
2425
|
+
['setup_complete'],
|
2426
|
+
_LiveServerSetupComplete_from_vertex(
|
2427
|
+
api_client, getv(from_object, ['setupComplete']), to_object
|
2428
|
+
),
|
2429
|
+
)
|
2430
|
+
|
2431
|
+
if getv(from_object, ['serverContent']) is not None:
|
2432
|
+
setv(
|
2433
|
+
to_object,
|
2434
|
+
['server_content'],
|
2435
|
+
_LiveServerContent_from_vertex(
|
2436
|
+
api_client, getv(from_object, ['serverContent']), to_object
|
2437
|
+
),
|
2438
|
+
)
|
2439
|
+
|
2440
|
+
if getv(from_object, ['toolCall']) is not None:
|
2441
|
+
setv(
|
2442
|
+
to_object,
|
2443
|
+
['tool_call'],
|
2444
|
+
_LiveServerToolCall_from_vertex(
|
2445
|
+
api_client, getv(from_object, ['toolCall']), to_object
|
2446
|
+
),
|
2447
|
+
)
|
2448
|
+
|
2449
|
+
if getv(from_object, ['toolCallCancellation']) is not None:
|
2450
|
+
setv(
|
2451
|
+
to_object,
|
2452
|
+
['tool_call_cancellation'],
|
2453
|
+
_LiveServerToolCallCancellation_from_vertex(
|
2454
|
+
api_client, getv(from_object, ['toolCallCancellation']), to_object
|
2455
|
+
),
|
2456
|
+
)
|
2457
|
+
|
2458
|
+
if getv(from_object, ['usageMetadata']) is not None:
|
2459
|
+
setv(
|
2460
|
+
to_object,
|
2461
|
+
['usage_metadata'],
|
2462
|
+
_UsageMetadata_from_vertex(
|
2463
|
+
api_client, getv(from_object, ['usageMetadata']), to_object
|
2464
|
+
),
|
2465
|
+
)
|
2466
|
+
|
2467
|
+
if getv(from_object, ['goAway']) is not None:
|
2468
|
+
setv(
|
2469
|
+
to_object,
|
2470
|
+
['go_away'],
|
2471
|
+
_LiveServerGoAway_from_vertex(
|
2472
|
+
api_client, getv(from_object, ['goAway']), to_object
|
2473
|
+
),
|
2474
|
+
)
|
2475
|
+
|
2476
|
+
if getv(from_object, ['sessionResumptionUpdate']) is not None:
|
2477
|
+
setv(
|
2478
|
+
to_object,
|
2479
|
+
['session_resumption_update'],
|
2480
|
+
_LiveServerSessionResumptionUpdate_from_vertex(
|
2481
|
+
api_client,
|
2482
|
+
getv(from_object, ['sessionResumptionUpdate']),
|
2483
|
+
to_object,
|
2484
|
+
),
|
2485
|
+
)
|
2486
|
+
|
2487
|
+
return to_object
|