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
google/genai/live_converters.py
DELETED
@@ -1,1298 +0,0 @@
|
|
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
|
-
"""[Preview] Live API client."""
|
17
|
-
|
18
|
-
|
19
|
-
import logging
|
20
|
-
from typing import Any, Dict, Optional, Union
|
21
|
-
|
22
|
-
from . import _api_module
|
23
|
-
from . import _common
|
24
|
-
from . import _transformers as t
|
25
|
-
from . import types
|
26
|
-
from ._api_client import BaseApiClient
|
27
|
-
from ._common import get_value_by_path as getv
|
28
|
-
from ._common import set_value_by_path as setv
|
29
|
-
from .models import _Content_from_mldev
|
30
|
-
from .models import _Content_from_vertex
|
31
|
-
from .models import _Content_to_mldev
|
32
|
-
from .models import _Content_to_vertex
|
33
|
-
from .models import _GenerateContentConfig_to_mldev
|
34
|
-
from .models import _GenerateContentConfig_to_vertex
|
35
|
-
from .models import _SafetySetting_to_mldev
|
36
|
-
from .models import _SafetySetting_to_vertex
|
37
|
-
from .models import _SpeechConfig_to_mldev
|
38
|
-
from .models import _SpeechConfig_to_vertex
|
39
|
-
from .models import _Tool_to_mldev
|
40
|
-
from .models import _Tool_to_vertex
|
41
|
-
|
42
|
-
logger = logging.getLogger('google_genai._live_converters')
|
43
|
-
|
44
|
-
_FUNCTION_RESPONSE_REQUIRES_ID = (
|
45
|
-
'FunctionResponse request must have an `id` field from the'
|
46
|
-
' response of a ToolCall.FunctionalCalls in Google AI.'
|
47
|
-
)
|
48
|
-
|
49
|
-
def _SessionResumptionConfig_to_mldev(
|
50
|
-
api_client: BaseApiClient,
|
51
|
-
from_object: Union[dict, object],
|
52
|
-
parent_object: Optional[dict] = None,
|
53
|
-
) -> dict:
|
54
|
-
to_object: dict[str, Any] = {}
|
55
|
-
if getv(from_object, ['handle']) is not None:
|
56
|
-
setv(to_object, ['handle'], getv(from_object, ['handle']))
|
57
|
-
|
58
|
-
if getv(from_object, ['transparent']) is not None:
|
59
|
-
raise ValueError('transparent parameter is not supported in Gemini API.')
|
60
|
-
|
61
|
-
return to_object
|
62
|
-
|
63
|
-
|
64
|
-
def _SessionResumptionConfig_to_vertex(
|
65
|
-
api_client: BaseApiClient,
|
66
|
-
from_object: Union[dict, object],
|
67
|
-
parent_object: Optional[dict] = None,
|
68
|
-
) -> dict:
|
69
|
-
to_object: dict[str, Any] = {}
|
70
|
-
if getv(from_object, ['handle']) is not None:
|
71
|
-
setv(to_object, ['handle'], getv(from_object, ['handle']))
|
72
|
-
|
73
|
-
if getv(from_object, ['transparent']) is not None:
|
74
|
-
setv(to_object, ['transparent'], getv(from_object, ['transparent']))
|
75
|
-
|
76
|
-
return to_object
|
77
|
-
|
78
|
-
|
79
|
-
def _AudioTranscriptionConfig_to_mldev(
|
80
|
-
api_client: BaseApiClient,
|
81
|
-
from_object: Union[dict, object],
|
82
|
-
parent_object: Optional[dict] = None,
|
83
|
-
) -> dict:
|
84
|
-
to_object: dict[str, Any] = {}
|
85
|
-
|
86
|
-
return to_object
|
87
|
-
|
88
|
-
|
89
|
-
def _AudioTranscriptionConfig_to_vertex(
|
90
|
-
api_client: BaseApiClient,
|
91
|
-
from_object: Union[dict, object],
|
92
|
-
parent_object: Optional[dict] = None,
|
93
|
-
) -> dict:
|
94
|
-
to_object: dict[str, Any] = {}
|
95
|
-
|
96
|
-
return to_object
|
97
|
-
|
98
|
-
|
99
|
-
def _AutomaticActivityDetection_to_mldev(
|
100
|
-
api_client: BaseApiClient,
|
101
|
-
from_object: Union[dict, object],
|
102
|
-
parent_object: Optional[dict] = None,
|
103
|
-
) -> dict:
|
104
|
-
to_object: dict[str, Any] = {}
|
105
|
-
if getv(from_object, ['disabled']) is not None:
|
106
|
-
setv(to_object, ['disabled'], getv(from_object, ['disabled']))
|
107
|
-
|
108
|
-
if getv(from_object, ['start_of_speech_sensitivity']) is not None:
|
109
|
-
setv(
|
110
|
-
to_object,
|
111
|
-
['startOfSpeechSensitivity'],
|
112
|
-
getv(from_object, ['start_of_speech_sensitivity']),
|
113
|
-
)
|
114
|
-
|
115
|
-
if getv(from_object, ['end_of_speech_sensitivity']) is not None:
|
116
|
-
setv(
|
117
|
-
to_object,
|
118
|
-
['endOfSpeechSensitivity'],
|
119
|
-
getv(from_object, ['end_of_speech_sensitivity']),
|
120
|
-
)
|
121
|
-
|
122
|
-
if getv(from_object, ['prefix_padding_ms']) is not None:
|
123
|
-
setv(
|
124
|
-
to_object, ['prefixPaddingMs'], getv(from_object, ['prefix_padding_ms'])
|
125
|
-
)
|
126
|
-
|
127
|
-
if getv(from_object, ['silence_duration_ms']) is not None:
|
128
|
-
setv(
|
129
|
-
to_object,
|
130
|
-
['silenceDurationMs'],
|
131
|
-
getv(from_object, ['silence_duration_ms']),
|
132
|
-
)
|
133
|
-
|
134
|
-
return to_object
|
135
|
-
|
136
|
-
|
137
|
-
def _AutomaticActivityDetection_to_vertex(
|
138
|
-
api_client: BaseApiClient,
|
139
|
-
from_object: Union[dict, object],
|
140
|
-
parent_object: Optional[dict] = None,
|
141
|
-
) -> dict:
|
142
|
-
to_object: dict[str, Any] = {}
|
143
|
-
if getv(from_object, ['disabled']) is not None:
|
144
|
-
setv(to_object, ['disabled'], getv(from_object, ['disabled']))
|
145
|
-
|
146
|
-
if getv(from_object, ['start_of_speech_sensitivity']) is not None:
|
147
|
-
setv(
|
148
|
-
to_object,
|
149
|
-
['startOfSpeechSensitivity'],
|
150
|
-
getv(from_object, ['start_of_speech_sensitivity']),
|
151
|
-
)
|
152
|
-
|
153
|
-
if getv(from_object, ['end_of_speech_sensitivity']) is not None:
|
154
|
-
setv(
|
155
|
-
to_object,
|
156
|
-
['endOfSpeechSensitivity'],
|
157
|
-
getv(from_object, ['end_of_speech_sensitivity']),
|
158
|
-
)
|
159
|
-
|
160
|
-
if getv(from_object, ['prefix_padding_ms']) is not None:
|
161
|
-
setv(
|
162
|
-
to_object, ['prefixPaddingMs'], getv(from_object, ['prefix_padding_ms'])
|
163
|
-
)
|
164
|
-
|
165
|
-
if getv(from_object, ['silence_duration_ms']) is not None:
|
166
|
-
setv(
|
167
|
-
to_object,
|
168
|
-
['silenceDurationMs'],
|
169
|
-
getv(from_object, ['silence_duration_ms']),
|
170
|
-
)
|
171
|
-
|
172
|
-
return to_object
|
173
|
-
|
174
|
-
|
175
|
-
def _RealtimeInputConfig_to_mldev(
|
176
|
-
api_client: BaseApiClient,
|
177
|
-
from_object: Union[dict, object],
|
178
|
-
parent_object: Optional[dict] = None,
|
179
|
-
) -> dict:
|
180
|
-
to_object: dict[str, Any] = {}
|
181
|
-
if getv(from_object, ['automatic_activity_detection']) is not None:
|
182
|
-
setv(
|
183
|
-
to_object,
|
184
|
-
['automaticActivityDetection'],
|
185
|
-
_AutomaticActivityDetection_to_mldev(
|
186
|
-
api_client,
|
187
|
-
getv(from_object, ['automatic_activity_detection']),
|
188
|
-
to_object,
|
189
|
-
),
|
190
|
-
)
|
191
|
-
|
192
|
-
if getv(from_object, ['activity_handling']) is not None:
|
193
|
-
setv(
|
194
|
-
to_object,
|
195
|
-
['activityHandling'],
|
196
|
-
getv(from_object, ['activity_handling']),
|
197
|
-
)
|
198
|
-
|
199
|
-
if getv(from_object, ['turn_coverage']) is not None:
|
200
|
-
setv(to_object, ['turnCoverage'], getv(from_object, ['turn_coverage']))
|
201
|
-
|
202
|
-
return to_object
|
203
|
-
|
204
|
-
|
205
|
-
def _RealtimeInputConfig_to_vertex(
|
206
|
-
api_client: BaseApiClient,
|
207
|
-
from_object: Union[dict, object],
|
208
|
-
parent_object: Optional[dict] = None,
|
209
|
-
) -> dict:
|
210
|
-
to_object: dict[str, Any] = {}
|
211
|
-
if getv(from_object, ['automatic_activity_detection']) is not None:
|
212
|
-
setv(
|
213
|
-
to_object,
|
214
|
-
['automaticActivityDetection'],
|
215
|
-
_AutomaticActivityDetection_to_vertex(
|
216
|
-
api_client,
|
217
|
-
getv(from_object, ['automatic_activity_detection']),
|
218
|
-
to_object,
|
219
|
-
),
|
220
|
-
)
|
221
|
-
|
222
|
-
if getv(from_object, ['activity_handling']) is not None:
|
223
|
-
setv(
|
224
|
-
to_object,
|
225
|
-
['activityHandling'],
|
226
|
-
getv(from_object, ['activity_handling']),
|
227
|
-
)
|
228
|
-
|
229
|
-
if getv(from_object, ['turn_coverage']) is not None:
|
230
|
-
setv(to_object, ['turnCoverage'], getv(from_object, ['turn_coverage']))
|
231
|
-
|
232
|
-
return to_object
|
233
|
-
|
234
|
-
|
235
|
-
def _SlidingWindow_to_mldev(
|
236
|
-
api_client: BaseApiClient,
|
237
|
-
from_object: Union[dict, object],
|
238
|
-
parent_object: Optional[dict] = None,
|
239
|
-
) -> dict:
|
240
|
-
to_object: dict[str, Any] = {}
|
241
|
-
if getv(from_object, ['target_tokens']) is not None:
|
242
|
-
setv(to_object, ['targetTokens'], getv(from_object, ['target_tokens']))
|
243
|
-
|
244
|
-
return to_object
|
245
|
-
|
246
|
-
|
247
|
-
def _SlidingWindow_to_vertex(
|
248
|
-
api_client: BaseApiClient,
|
249
|
-
from_object: Union[dict, object],
|
250
|
-
parent_object: Optional[dict] = None,
|
251
|
-
) -> dict:
|
252
|
-
to_object: dict[str, Any] = {}
|
253
|
-
if getv(from_object, ['target_tokens']) is not None:
|
254
|
-
setv(to_object, ['targetTokens'], getv(from_object, ['target_tokens']))
|
255
|
-
|
256
|
-
return to_object
|
257
|
-
|
258
|
-
|
259
|
-
def _ContextWindowCompressionConfig_to_mldev(
|
260
|
-
api_client: BaseApiClient,
|
261
|
-
from_object: Union[dict, object],
|
262
|
-
parent_object: Optional[dict] = None,
|
263
|
-
) -> dict:
|
264
|
-
to_object: dict[str, Any] = {}
|
265
|
-
if getv(from_object, ['trigger_tokens']) is not None:
|
266
|
-
setv(to_object, ['triggerTokens'], getv(from_object, ['trigger_tokens']))
|
267
|
-
|
268
|
-
if getv(from_object, ['sliding_window']) is not None:
|
269
|
-
setv(
|
270
|
-
to_object,
|
271
|
-
['slidingWindow'],
|
272
|
-
_SlidingWindow_to_mldev(
|
273
|
-
api_client, getv(from_object, ['sliding_window']), to_object
|
274
|
-
),
|
275
|
-
)
|
276
|
-
|
277
|
-
return to_object
|
278
|
-
|
279
|
-
|
280
|
-
def _ContextWindowCompressionConfig_to_vertex(
|
281
|
-
api_client: BaseApiClient,
|
282
|
-
from_object: Union[dict, object],
|
283
|
-
parent_object: Optional[dict] = None,
|
284
|
-
) -> dict:
|
285
|
-
to_object: dict[str, Any] = {}
|
286
|
-
if getv(from_object, ['trigger_tokens']) is not None:
|
287
|
-
setv(to_object, ['triggerTokens'], getv(from_object, ['trigger_tokens']))
|
288
|
-
|
289
|
-
if getv(from_object, ['sliding_window']) is not None:
|
290
|
-
setv(
|
291
|
-
to_object,
|
292
|
-
['slidingWindow'],
|
293
|
-
_SlidingWindow_to_vertex(
|
294
|
-
api_client, getv(from_object, ['sliding_window']), to_object
|
295
|
-
),
|
296
|
-
)
|
297
|
-
|
298
|
-
return to_object
|
299
|
-
|
300
|
-
|
301
|
-
def _LiveConnectConfig_to_mldev(
|
302
|
-
api_client: BaseApiClient,
|
303
|
-
from_object: Union[dict, object],
|
304
|
-
parent_object: Optional[dict] = None,
|
305
|
-
) -> dict:
|
306
|
-
to_object: dict[str, Any] = {}
|
307
|
-
if getv(from_object, ['generation_config']) is not None:
|
308
|
-
setv(
|
309
|
-
parent_object,
|
310
|
-
['setup', 'generationConfig'],
|
311
|
-
getv(from_object, ['generation_config']),
|
312
|
-
)
|
313
|
-
|
314
|
-
if getv(from_object, ['response_modalities']) is not None:
|
315
|
-
setv(
|
316
|
-
parent_object,
|
317
|
-
['setup', 'generationConfig', 'responseModalities'],
|
318
|
-
getv(from_object, ['response_modalities']),
|
319
|
-
)
|
320
|
-
|
321
|
-
if getv(from_object, ['temperature']) is not None:
|
322
|
-
setv(
|
323
|
-
parent_object,
|
324
|
-
['setup', 'generationConfig', 'temperature'],
|
325
|
-
getv(from_object, ['temperature']),
|
326
|
-
)
|
327
|
-
|
328
|
-
if getv(from_object, ['top_p']) is not None:
|
329
|
-
setv(
|
330
|
-
parent_object,
|
331
|
-
['setup', 'generationConfig', 'topP'],
|
332
|
-
getv(from_object, ['top_p']),
|
333
|
-
)
|
334
|
-
|
335
|
-
if getv(from_object, ['top_k']) is not None:
|
336
|
-
setv(
|
337
|
-
parent_object,
|
338
|
-
['setup', 'generationConfig', 'topK'],
|
339
|
-
getv(from_object, ['top_k']),
|
340
|
-
)
|
341
|
-
|
342
|
-
if getv(from_object, ['max_output_tokens']) is not None:
|
343
|
-
setv(
|
344
|
-
parent_object,
|
345
|
-
['setup', 'generationConfig', 'maxOutputTokens'],
|
346
|
-
getv(from_object, ['max_output_tokens']),
|
347
|
-
)
|
348
|
-
|
349
|
-
if getv(from_object, ['media_resolution']) is not None:
|
350
|
-
setv(
|
351
|
-
parent_object,
|
352
|
-
['setup', 'generationConfig', 'mediaResolution'],
|
353
|
-
getv(from_object, ['media_resolution']),
|
354
|
-
)
|
355
|
-
|
356
|
-
if getv(from_object, ['seed']) is not None:
|
357
|
-
setv(
|
358
|
-
parent_object,
|
359
|
-
['setup', 'generationConfig', 'seed'],
|
360
|
-
getv(from_object, ['seed']),
|
361
|
-
)
|
362
|
-
|
363
|
-
if getv(from_object, ['speech_config']) is not None:
|
364
|
-
setv(
|
365
|
-
parent_object,
|
366
|
-
['setup', 'generationConfig', 'speechConfig'],
|
367
|
-
getv(from_object, ['speech_config']),
|
368
|
-
)
|
369
|
-
|
370
|
-
if getv(from_object, ['system_instruction']) is not None:
|
371
|
-
setv(
|
372
|
-
parent_object,
|
373
|
-
['setup', 'systemInstruction'],
|
374
|
-
_Content_to_mldev(
|
375
|
-
api_client,
|
376
|
-
t.t_content(api_client, getv(from_object, ['system_instruction'])),
|
377
|
-
to_object,
|
378
|
-
),
|
379
|
-
)
|
380
|
-
|
381
|
-
if getv(from_object, ['tools']) is not None:
|
382
|
-
setv(
|
383
|
-
parent_object,
|
384
|
-
['setup', 'tools'],
|
385
|
-
[
|
386
|
-
_Tool_to_mldev(api_client, t.t_tool(api_client, item), to_object)
|
387
|
-
for item in t.t_tools(api_client, getv(from_object, ['tools']))
|
388
|
-
],
|
389
|
-
)
|
390
|
-
|
391
|
-
if getv(from_object, ['session_resumption']) is not None:
|
392
|
-
setv(
|
393
|
-
parent_object,
|
394
|
-
['setup', 'sessionResumption'],
|
395
|
-
_SessionResumptionConfig_to_mldev(
|
396
|
-
api_client, getv(from_object, ['session_resumption']), to_object
|
397
|
-
),
|
398
|
-
)
|
399
|
-
|
400
|
-
if getv(from_object, ['input_audio_transcription']) is not None:
|
401
|
-
raise ValueError(
|
402
|
-
'input_audio_transcription parameter is not supported in Gemini API.'
|
403
|
-
)
|
404
|
-
|
405
|
-
if getv(from_object, ['output_audio_transcription']) is not None:
|
406
|
-
setv(
|
407
|
-
parent_object,
|
408
|
-
['setup', 'outputAudioTranscription'],
|
409
|
-
_AudioTranscriptionConfig_to_mldev(
|
410
|
-
api_client,
|
411
|
-
getv(from_object, ['output_audio_transcription']),
|
412
|
-
to_object,
|
413
|
-
),
|
414
|
-
)
|
415
|
-
|
416
|
-
if getv(from_object, ['realtime_input_config']) is not None:
|
417
|
-
setv(
|
418
|
-
parent_object,
|
419
|
-
['setup', 'realtimeInputConfig'],
|
420
|
-
_RealtimeInputConfig_to_mldev(
|
421
|
-
api_client, getv(from_object, ['realtime_input_config']), to_object
|
422
|
-
),
|
423
|
-
)
|
424
|
-
|
425
|
-
if getv(from_object, ['context_window_compression']) is not None:
|
426
|
-
setv(
|
427
|
-
parent_object,
|
428
|
-
['setup', 'contextWindowCompression'],
|
429
|
-
_ContextWindowCompressionConfig_to_mldev(
|
430
|
-
api_client,
|
431
|
-
getv(from_object, ['context_window_compression']),
|
432
|
-
to_object,
|
433
|
-
),
|
434
|
-
)
|
435
|
-
|
436
|
-
return to_object
|
437
|
-
|
438
|
-
|
439
|
-
def _LiveConnectConfig_to_vertex(
|
440
|
-
api_client: BaseApiClient,
|
441
|
-
from_object: Union[dict, object],
|
442
|
-
parent_object: Optional[dict] = None,
|
443
|
-
) -> dict:
|
444
|
-
to_object: dict[str, Any] = {}
|
445
|
-
if getv(from_object, ['generation_config']) is not None:
|
446
|
-
setv(
|
447
|
-
parent_object,
|
448
|
-
['setup', 'generationConfig'],
|
449
|
-
getv(from_object, ['generation_config']),
|
450
|
-
)
|
451
|
-
|
452
|
-
if getv(from_object, ['response_modalities']) is not None:
|
453
|
-
setv(
|
454
|
-
parent_object,
|
455
|
-
['setup', 'generationConfig', 'responseModalities'],
|
456
|
-
getv(from_object, ['response_modalities']),
|
457
|
-
)
|
458
|
-
|
459
|
-
if getv(from_object, ['temperature']) is not None:
|
460
|
-
setv(
|
461
|
-
parent_object,
|
462
|
-
['setup', 'generationConfig', 'temperature'],
|
463
|
-
getv(from_object, ['temperature']),
|
464
|
-
)
|
465
|
-
|
466
|
-
if getv(from_object, ['top_p']) is not None:
|
467
|
-
setv(
|
468
|
-
parent_object,
|
469
|
-
['setup', 'generationConfig', 'topP'],
|
470
|
-
getv(from_object, ['top_p']),
|
471
|
-
)
|
472
|
-
|
473
|
-
if getv(from_object, ['top_k']) is not None:
|
474
|
-
setv(
|
475
|
-
parent_object,
|
476
|
-
['setup', 'generationConfig', 'topK'],
|
477
|
-
getv(from_object, ['top_k']),
|
478
|
-
)
|
479
|
-
|
480
|
-
if getv(from_object, ['max_output_tokens']) is not None:
|
481
|
-
setv(
|
482
|
-
parent_object,
|
483
|
-
['setup', 'generationConfig', 'maxOutputTokens'],
|
484
|
-
getv(from_object, ['max_output_tokens']),
|
485
|
-
)
|
486
|
-
|
487
|
-
if getv(from_object, ['media_resolution']) is not None:
|
488
|
-
setv(
|
489
|
-
parent_object,
|
490
|
-
['setup', 'generationConfig', 'mediaResolution'],
|
491
|
-
getv(from_object, ['media_resolution']),
|
492
|
-
)
|
493
|
-
|
494
|
-
if getv(from_object, ['seed']) is not None:
|
495
|
-
setv(
|
496
|
-
parent_object,
|
497
|
-
['setup', 'generationConfig', 'seed'],
|
498
|
-
getv(from_object, ['seed']),
|
499
|
-
)
|
500
|
-
|
501
|
-
if getv(from_object, ['speech_config']) is not None:
|
502
|
-
setv(
|
503
|
-
parent_object,
|
504
|
-
['setup', 'generationConfig', 'speechConfig'],
|
505
|
-
getv(from_object, ['speech_config']),
|
506
|
-
)
|
507
|
-
|
508
|
-
if getv(from_object, ['system_instruction']) is not None:
|
509
|
-
setv(
|
510
|
-
parent_object,
|
511
|
-
['setup', 'systemInstruction'],
|
512
|
-
_Content_to_vertex(
|
513
|
-
api_client,
|
514
|
-
t.t_content(api_client, getv(from_object, ['system_instruction'])),
|
515
|
-
to_object,
|
516
|
-
),
|
517
|
-
)
|
518
|
-
|
519
|
-
if getv(from_object, ['tools']) is not None:
|
520
|
-
setv(
|
521
|
-
parent_object,
|
522
|
-
['setup', 'tools'],
|
523
|
-
[
|
524
|
-
_Tool_to_vertex(api_client, t.t_tool(api_client, item), to_object)
|
525
|
-
for item in t.t_tools(api_client, getv(from_object, ['tools']))
|
526
|
-
],
|
527
|
-
)
|
528
|
-
|
529
|
-
if getv(from_object, ['session_resumption']) is not None:
|
530
|
-
setv(
|
531
|
-
parent_object,
|
532
|
-
['setup', 'sessionResumption'],
|
533
|
-
_SessionResumptionConfig_to_vertex(
|
534
|
-
api_client, getv(from_object, ['session_resumption']), to_object
|
535
|
-
),
|
536
|
-
)
|
537
|
-
|
538
|
-
if getv(from_object, ['input_audio_transcription']) is not None:
|
539
|
-
setv(
|
540
|
-
parent_object,
|
541
|
-
['setup', 'inputAudioTranscription'],
|
542
|
-
_AudioTranscriptionConfig_to_vertex(
|
543
|
-
api_client,
|
544
|
-
getv(from_object, ['input_audio_transcription']),
|
545
|
-
to_object,
|
546
|
-
),
|
547
|
-
)
|
548
|
-
|
549
|
-
if getv(from_object, ['output_audio_transcription']) is not None:
|
550
|
-
setv(
|
551
|
-
parent_object,
|
552
|
-
['setup', 'outputAudioTranscription'],
|
553
|
-
_AudioTranscriptionConfig_to_vertex(
|
554
|
-
api_client,
|
555
|
-
getv(from_object, ['output_audio_transcription']),
|
556
|
-
to_object,
|
557
|
-
),
|
558
|
-
)
|
559
|
-
|
560
|
-
if getv(from_object, ['realtime_input_config']) is not None:
|
561
|
-
setv(
|
562
|
-
parent_object,
|
563
|
-
['setup', 'realtimeInputConfig'],
|
564
|
-
_RealtimeInputConfig_to_vertex(
|
565
|
-
api_client, getv(from_object, ['realtime_input_config']), to_object
|
566
|
-
),
|
567
|
-
)
|
568
|
-
|
569
|
-
if getv(from_object, ['context_window_compression']) is not None:
|
570
|
-
setv(
|
571
|
-
parent_object,
|
572
|
-
['setup', 'contextWindowCompression'],
|
573
|
-
_ContextWindowCompressionConfig_to_vertex(
|
574
|
-
api_client,
|
575
|
-
getv(from_object, ['context_window_compression']),
|
576
|
-
to_object,
|
577
|
-
),
|
578
|
-
)
|
579
|
-
|
580
|
-
return to_object
|
581
|
-
|
582
|
-
|
583
|
-
def _LiveConnectParameters_to_mldev(
|
584
|
-
api_client: BaseApiClient,
|
585
|
-
from_object: Union[dict, object],
|
586
|
-
parent_object: Optional[dict] = None,
|
587
|
-
) -> dict:
|
588
|
-
to_object: dict[str, Any] = {}
|
589
|
-
if getv(from_object, ['model']) is not None:
|
590
|
-
setv(
|
591
|
-
to_object,
|
592
|
-
['setup', 'model'],
|
593
|
-
t.t_model(api_client, getv(from_object, ['model'])),
|
594
|
-
)
|
595
|
-
|
596
|
-
if getv(from_object, ['config']) is not None:
|
597
|
-
setv(
|
598
|
-
to_object,
|
599
|
-
['config'],
|
600
|
-
_LiveConnectConfig_to_mldev(
|
601
|
-
api_client, getv(from_object, ['config']), to_object
|
602
|
-
),
|
603
|
-
)
|
604
|
-
|
605
|
-
return to_object
|
606
|
-
|
607
|
-
|
608
|
-
def _LiveConnectParameters_to_vertex(
|
609
|
-
api_client: BaseApiClient,
|
610
|
-
from_object: Union[dict, object],
|
611
|
-
parent_object: Optional[dict] = None,
|
612
|
-
) -> dict:
|
613
|
-
to_object: dict[str, Any] = {}
|
614
|
-
if getv(from_object, ['model']) is not None:
|
615
|
-
setv(
|
616
|
-
to_object,
|
617
|
-
['setup', 'model'],
|
618
|
-
t.t_model(api_client, getv(from_object, ['model'])),
|
619
|
-
)
|
620
|
-
|
621
|
-
if getv(from_object, ['config']) is not None:
|
622
|
-
setv(
|
623
|
-
to_object,
|
624
|
-
['config'],
|
625
|
-
_LiveConnectConfig_to_vertex(
|
626
|
-
api_client, getv(from_object, ['config']), to_object
|
627
|
-
),
|
628
|
-
)
|
629
|
-
|
630
|
-
return to_object
|
631
|
-
|
632
|
-
|
633
|
-
def _LiveClientSetup_to_mldev(
|
634
|
-
api_client: BaseApiClient,
|
635
|
-
from_object: Union[dict, object],
|
636
|
-
parent_object: Optional[dict] = None,
|
637
|
-
) -> dict:
|
638
|
-
to_object: dict[str, Any] = {}
|
639
|
-
if getv(from_object, ['model']) is not None:
|
640
|
-
setv(to_object, ['model'], getv(from_object, ['model']))
|
641
|
-
|
642
|
-
if getv(from_object, ['generation_config']) is not None:
|
643
|
-
setv(
|
644
|
-
to_object,
|
645
|
-
['generationConfig'],
|
646
|
-
getv(from_object, ['generation_config']),
|
647
|
-
)
|
648
|
-
|
649
|
-
if getv(from_object, ['system_instruction']) is not None:
|
650
|
-
setv(
|
651
|
-
to_object,
|
652
|
-
['systemInstruction'],
|
653
|
-
_Content_to_mldev(
|
654
|
-
api_client,
|
655
|
-
t.t_content(api_client, getv(from_object, ['system_instruction'])),
|
656
|
-
to_object,
|
657
|
-
),
|
658
|
-
)
|
659
|
-
|
660
|
-
if getv(from_object, ['tools']) is not None:
|
661
|
-
setv(
|
662
|
-
to_object,
|
663
|
-
['tools'],
|
664
|
-
[
|
665
|
-
_Tool_to_mldev(api_client, t.t_tool(api_client, item), to_object)
|
666
|
-
for item in t.t_tools(api_client, getv(from_object, ['tools']))
|
667
|
-
],
|
668
|
-
)
|
669
|
-
|
670
|
-
if getv(from_object, ['session_resumption']) is not None:
|
671
|
-
setv(
|
672
|
-
to_object,
|
673
|
-
['sessionResumption'],
|
674
|
-
_SessionResumptionConfig_to_mldev(
|
675
|
-
api_client, getv(from_object, ['session_resumption']), to_object
|
676
|
-
),
|
677
|
-
)
|
678
|
-
|
679
|
-
if getv(from_object, ['context_window_compression']) is not None:
|
680
|
-
setv(
|
681
|
-
to_object,
|
682
|
-
['contextWindowCompression'],
|
683
|
-
_ContextWindowCompressionConfig_to_mldev(
|
684
|
-
api_client,
|
685
|
-
getv(from_object, ['context_window_compression']),
|
686
|
-
to_object,
|
687
|
-
),
|
688
|
-
)
|
689
|
-
|
690
|
-
return to_object
|
691
|
-
|
692
|
-
|
693
|
-
def _LiveClientSetup_to_vertex(
|
694
|
-
api_client: BaseApiClient,
|
695
|
-
from_object: Union[dict, object],
|
696
|
-
parent_object: Optional[dict] = None,
|
697
|
-
) -> dict:
|
698
|
-
to_object: dict[str, Any] = {}
|
699
|
-
if getv(from_object, ['model']) is not None:
|
700
|
-
setv(to_object, ['model'], getv(from_object, ['model']))
|
701
|
-
|
702
|
-
if getv(from_object, ['generation_config']) is not None:
|
703
|
-
setv(
|
704
|
-
to_object,
|
705
|
-
['generationConfig'],
|
706
|
-
getv(from_object, ['generation_config']),
|
707
|
-
)
|
708
|
-
|
709
|
-
if getv(from_object, ['system_instruction']) is not None:
|
710
|
-
setv(
|
711
|
-
to_object,
|
712
|
-
['systemInstruction'],
|
713
|
-
_Content_to_vertex(
|
714
|
-
api_client,
|
715
|
-
t.t_content(api_client, getv(from_object, ['system_instruction'])),
|
716
|
-
to_object,
|
717
|
-
),
|
718
|
-
)
|
719
|
-
|
720
|
-
if getv(from_object, ['tools']) is not None:
|
721
|
-
setv(
|
722
|
-
to_object,
|
723
|
-
['tools'],
|
724
|
-
[
|
725
|
-
_Tool_to_vertex(api_client, t.t_tool(api_client, item), to_object)
|
726
|
-
for item in t.t_tools(api_client, getv(from_object, ['tools']))
|
727
|
-
],
|
728
|
-
)
|
729
|
-
|
730
|
-
if getv(from_object, ['session_resumption']) is not None:
|
731
|
-
setv(
|
732
|
-
to_object,
|
733
|
-
['sessionResumption'],
|
734
|
-
_SessionResumptionConfig_to_vertex(
|
735
|
-
api_client, getv(from_object, ['session_resumption']), to_object
|
736
|
-
),
|
737
|
-
)
|
738
|
-
|
739
|
-
if getv(from_object, ['context_window_compression']) is not None:
|
740
|
-
setv(
|
741
|
-
to_object,
|
742
|
-
['contextWindowCompression'],
|
743
|
-
_ContextWindowCompressionConfig_to_vertex(
|
744
|
-
api_client,
|
745
|
-
getv(from_object, ['context_window_compression']),
|
746
|
-
to_object,
|
747
|
-
),
|
748
|
-
)
|
749
|
-
|
750
|
-
return to_object
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
def _LiveClientContent_to_mldev(
|
755
|
-
api_client: BaseApiClient,
|
756
|
-
from_object: Union[dict, object],
|
757
|
-
parent_object: Optional[dict] = None,
|
758
|
-
) -> dict:
|
759
|
-
to_object: dict[str, Any] = {}
|
760
|
-
if getv(from_object, ['turns']) is not None:
|
761
|
-
setv(
|
762
|
-
to_object,
|
763
|
-
['turns'],
|
764
|
-
[
|
765
|
-
_Content_to_mldev(api_client, item, to_object)
|
766
|
-
for item in getv(from_object, ['turns'])
|
767
|
-
],
|
768
|
-
)
|
769
|
-
|
770
|
-
if getv(from_object, ['turn_complete']) is not None:
|
771
|
-
setv(to_object, ['turnComplete'], getv(from_object, ['turn_complete']))
|
772
|
-
|
773
|
-
return to_object
|
774
|
-
|
775
|
-
|
776
|
-
def _LiveClientContent_to_vertex(
|
777
|
-
api_client: BaseApiClient,
|
778
|
-
from_object: Union[dict, object],
|
779
|
-
parent_object: Optional[dict] = None,
|
780
|
-
) -> dict:
|
781
|
-
to_object: dict[str, Any] = {}
|
782
|
-
if getv(from_object, ['turns']) is not None:
|
783
|
-
setv(
|
784
|
-
to_object,
|
785
|
-
['turns'],
|
786
|
-
[
|
787
|
-
_Content_to_vertex(api_client, item, to_object)
|
788
|
-
for item in getv(from_object, ['turns'])
|
789
|
-
],
|
790
|
-
)
|
791
|
-
|
792
|
-
if getv(from_object, ['turn_complete']) is not None:
|
793
|
-
setv(to_object, ['turnComplete'], getv(from_object, ['turn_complete']))
|
794
|
-
|
795
|
-
return to_object
|
796
|
-
|
797
|
-
|
798
|
-
def _LiveClientToolResponse_to_mldev(
|
799
|
-
api_client: BaseApiClient,
|
800
|
-
from_object: types.LiveClientToolResponse,
|
801
|
-
) -> dict:
|
802
|
-
tool_response = from_object.model_dump(exclude_none=True, mode='json')
|
803
|
-
for response in tool_response.get('function_responses', []):
|
804
|
-
if response.get('id') is None:
|
805
|
-
raise ValueError(_FUNCTION_RESPONSE_REQUIRES_ID)
|
806
|
-
return tool_response
|
807
|
-
|
808
|
-
|
809
|
-
def _LiveClientToolResponse_to_vertex(
|
810
|
-
api_client: BaseApiClient,
|
811
|
-
from_object: types.LiveClientToolResponse,
|
812
|
-
) -> dict:
|
813
|
-
tool_response = from_object.model_dump(exclude_none=True, mode='json')
|
814
|
-
return tool_response
|
815
|
-
|
816
|
-
|
817
|
-
def _LiveServerContent_from_mldev(
|
818
|
-
api_client: BaseApiClient,
|
819
|
-
from_object: Union[dict, object],
|
820
|
-
) -> Dict[str, Any]:
|
821
|
-
to_object: dict[str, Any] = {}
|
822
|
-
if getv(from_object, ['modelTurn']) is not None:
|
823
|
-
setv(
|
824
|
-
to_object,
|
825
|
-
['model_turn'],
|
826
|
-
_Content_from_mldev(
|
827
|
-
api_client,
|
828
|
-
getv(from_object, ['modelTurn']),
|
829
|
-
),
|
830
|
-
)
|
831
|
-
if getv(from_object, ['turnComplete']) is not None:
|
832
|
-
setv(to_object, ['turn_complete'], getv(from_object, ['turnComplete']))
|
833
|
-
if getv(from_object, ['generationComplete']) is not None:
|
834
|
-
setv(
|
835
|
-
to_object,
|
836
|
-
['generation_complete'],
|
837
|
-
getv(from_object, ['generationComplete']),
|
838
|
-
)
|
839
|
-
if getv(from_object, ['inputTranscription']) is not None:
|
840
|
-
setv(
|
841
|
-
to_object,
|
842
|
-
['input_transcription'],
|
843
|
-
getv(from_object, ['inputTranscription']),
|
844
|
-
)
|
845
|
-
if getv(from_object, ['outputTranscription']) is not None:
|
846
|
-
setv(
|
847
|
-
to_object,
|
848
|
-
['output_transcription'],
|
849
|
-
getv(from_object, ['outputTranscription']),
|
850
|
-
)
|
851
|
-
if getv(from_object, ['interrupted']) is not None:
|
852
|
-
setv(to_object, ['interrupted'], getv(from_object, ['interrupted']))
|
853
|
-
return to_object
|
854
|
-
|
855
|
-
|
856
|
-
def _LiveServerContent_from_vertex(
|
857
|
-
api_client: BaseApiClient,
|
858
|
-
from_object: Union[dict, object],
|
859
|
-
) -> Dict[str, Any]:
|
860
|
-
to_object: dict[str, Any] = {}
|
861
|
-
if getv(from_object, ['modelTurn']) is not None:
|
862
|
-
setv(
|
863
|
-
to_object,
|
864
|
-
['model_turn'],
|
865
|
-
_Content_from_vertex(
|
866
|
-
api_client,
|
867
|
-
getv(from_object, ['modelTurn']),
|
868
|
-
),
|
869
|
-
)
|
870
|
-
if getv(from_object, ['turnComplete']) is not None:
|
871
|
-
setv(to_object, ['turn_complete'], getv(from_object, ['turnComplete']))
|
872
|
-
if getv(from_object, ['generationComplete']) is not None:
|
873
|
-
setv(
|
874
|
-
to_object,
|
875
|
-
['generation_complete'],
|
876
|
-
getv(from_object, ['generationComplete']),
|
877
|
-
)
|
878
|
-
if getv(from_object, ['inputTranscription']) is not None:
|
879
|
-
setv(
|
880
|
-
to_object,
|
881
|
-
['input_transcription'],
|
882
|
-
getv(from_object, ['inputTranscription']),
|
883
|
-
)
|
884
|
-
if getv(from_object, ['outputTranscription']) is not None:
|
885
|
-
setv(
|
886
|
-
to_object,
|
887
|
-
['output_transcription'],
|
888
|
-
getv(from_object, ['outputTranscription']),
|
889
|
-
)
|
890
|
-
if getv(from_object, ['interrupted']) is not None:
|
891
|
-
setv(to_object, ['interrupted'], getv(from_object, ['interrupted']))
|
892
|
-
return to_object
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
def _LiveToolCall_from_mldev(
|
897
|
-
api_client: BaseApiClient,
|
898
|
-
from_object: Union[dict, object],
|
899
|
-
) -> Dict[str, Any]:
|
900
|
-
to_object: dict[str, Any] = {}
|
901
|
-
if getv(from_object, ['functionCalls']) is not None:
|
902
|
-
setv(
|
903
|
-
to_object,
|
904
|
-
['function_calls'],
|
905
|
-
getv(from_object, ['functionCalls']),
|
906
|
-
)
|
907
|
-
return to_object
|
908
|
-
|
909
|
-
def _LiveToolCall_from_vertex(
|
910
|
-
api_client: BaseApiClient,
|
911
|
-
from_object: Union[dict, object],
|
912
|
-
) -> Dict[str, Any]:
|
913
|
-
to_object: dict[str, Any] = {}
|
914
|
-
if getv(from_object, ['functionCalls']) is not None:
|
915
|
-
setv(
|
916
|
-
to_object,
|
917
|
-
['function_calls'],
|
918
|
-
getv(from_object, ['functionCalls']),
|
919
|
-
)
|
920
|
-
return to_object
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
def _ModalityTokenCount_from_mldev(
|
925
|
-
api_client: BaseApiClient,
|
926
|
-
from_object: Union[dict, object],
|
927
|
-
) -> Dict[str, Any]:
|
928
|
-
to_object: Dict[str, Any] = {}
|
929
|
-
if getv(from_object, ['modality']) is not None:
|
930
|
-
setv(to_object, ['modality'], getv(from_object, ['modality']))
|
931
|
-
if getv(from_object, ['tokenCount']) is not None:
|
932
|
-
setv(to_object, ['token_count'], getv(from_object, ['tokenCount']))
|
933
|
-
return to_object
|
934
|
-
|
935
|
-
|
936
|
-
def _ModalityTokenCount_from_vertex(
|
937
|
-
api_client: BaseApiClient,
|
938
|
-
from_object: Union[dict, object],
|
939
|
-
) -> Dict[str, Any]:
|
940
|
-
to_object: Dict[str, Any] = {}
|
941
|
-
if getv(from_object, ['modality']) is not None:
|
942
|
-
setv(to_object, ['modality'], getv(from_object, ['modality']))
|
943
|
-
if getv(from_object, ['tokenCount']) is not None:
|
944
|
-
setv(to_object, ['token_count'], getv(from_object, ['tokenCount']))
|
945
|
-
return to_object
|
946
|
-
|
947
|
-
|
948
|
-
def _UsageMetadata_from_mldev(
|
949
|
-
api_client: BaseApiClient,
|
950
|
-
from_object: Union[dict, object],
|
951
|
-
) -> Dict[str, Any]:
|
952
|
-
to_object: dict[str, Any] = {}
|
953
|
-
if getv(from_object, ['promptTokenCount']) is not None:
|
954
|
-
setv(
|
955
|
-
to_object,
|
956
|
-
['prompt_token_count'],
|
957
|
-
getv(from_object, ['promptTokenCount']),
|
958
|
-
)
|
959
|
-
if getv(from_object, ['cachedContentTokenCount']) is not None:
|
960
|
-
setv(
|
961
|
-
to_object,
|
962
|
-
['cached_content_token_count'],
|
963
|
-
getv(from_object, ['cachedContentTokenCount']),
|
964
|
-
)
|
965
|
-
if getv(from_object, ['responseTokenCount']) is not None:
|
966
|
-
setv(
|
967
|
-
to_object,
|
968
|
-
['response_token_count'],
|
969
|
-
getv(from_object, ['responseTokenCount']),
|
970
|
-
)
|
971
|
-
if getv(from_object, ['toolUsePromptTokenCount']) is not None:
|
972
|
-
setv(
|
973
|
-
to_object,
|
974
|
-
['tool_use_prompt_token_count'],
|
975
|
-
getv(from_object, ['toolUsePromptTokenCount']),
|
976
|
-
)
|
977
|
-
if getv(from_object, ['thoughtsTokenCount']) is not None:
|
978
|
-
setv(
|
979
|
-
to_object,
|
980
|
-
['thoughts_token_count'],
|
981
|
-
getv(from_object, ['thoughtsTokenCount']),
|
982
|
-
)
|
983
|
-
if getv(from_object, ['totalTokenCount']) is not None:
|
984
|
-
setv(
|
985
|
-
to_object,
|
986
|
-
['total_token_count'],
|
987
|
-
getv(from_object, ['totalTokenCount']),
|
988
|
-
)
|
989
|
-
if getv(from_object, ['promptTokensDetails']) is not None:
|
990
|
-
setv(
|
991
|
-
to_object,
|
992
|
-
['prompt_tokens_details'],
|
993
|
-
[
|
994
|
-
_ModalityTokenCount_from_mldev(api_client,item)
|
995
|
-
for item in getv(from_object, ['promptTokensDetails'])
|
996
|
-
],
|
997
|
-
)
|
998
|
-
if getv(from_object, ['cacheTokensDetails']) is not None:
|
999
|
-
setv(
|
1000
|
-
to_object,
|
1001
|
-
['cache_tokens_details'],
|
1002
|
-
[
|
1003
|
-
_ModalityTokenCount_from_mldev(api_client,item)
|
1004
|
-
for item in getv(from_object, ['cacheTokensDetails'])
|
1005
|
-
],
|
1006
|
-
)
|
1007
|
-
if getv(from_object, ['responseTokensDetails']) is not None:
|
1008
|
-
setv(
|
1009
|
-
to_object,
|
1010
|
-
['response_tokens_details'],
|
1011
|
-
[
|
1012
|
-
_ModalityTokenCount_from_mldev(api_client,item)
|
1013
|
-
for item in getv(from_object, ['responseTokensDetails'])
|
1014
|
-
],
|
1015
|
-
)
|
1016
|
-
if getv(from_object, ['toolUsePromptTokensDetails']) is not None:
|
1017
|
-
setv(
|
1018
|
-
to_object,
|
1019
|
-
['tool_use_prompt_tokens_details'],
|
1020
|
-
[
|
1021
|
-
_ModalityTokenCount_from_mldev(api_client,item)
|
1022
|
-
for item in getv(from_object, ['toolUsePromptTokensDetails'])
|
1023
|
-
],
|
1024
|
-
)
|
1025
|
-
return to_object
|
1026
|
-
|
1027
|
-
|
1028
|
-
def _UsageMetadata_from_vertex(
|
1029
|
-
api_client: BaseApiClient,
|
1030
|
-
from_object: Union[dict, object],
|
1031
|
-
) -> Dict[str, Any]:
|
1032
|
-
to_object: dict[str, Any] = {}
|
1033
|
-
if getv(from_object, ['promptTokenCount']) is not None:
|
1034
|
-
setv(
|
1035
|
-
to_object,
|
1036
|
-
['prompt_token_count'],
|
1037
|
-
getv(from_object, ['promptTokenCount']),
|
1038
|
-
)
|
1039
|
-
if getv(from_object, ['cachedContentTokenCount']) is not None:
|
1040
|
-
setv(
|
1041
|
-
to_object,
|
1042
|
-
['cached_content_token_count'],
|
1043
|
-
getv(from_object, ['cachedContentTokenCount']),
|
1044
|
-
)
|
1045
|
-
if getv(from_object, ['candidatesTokenCount']) is not None:
|
1046
|
-
setv(
|
1047
|
-
to_object,
|
1048
|
-
['response_token_count'],
|
1049
|
-
getv(from_object, ['candidatesTokenCount']),
|
1050
|
-
)
|
1051
|
-
if getv(from_object, ['toolUsePromptTokenCount']) is not None:
|
1052
|
-
setv(
|
1053
|
-
to_object,
|
1054
|
-
['tool_use_prompt_token_count'],
|
1055
|
-
getv(from_object, ['toolUsePromptTokenCount']),
|
1056
|
-
)
|
1057
|
-
if getv(from_object, ['thoughtsTokenCount']) is not None:
|
1058
|
-
setv(
|
1059
|
-
to_object,
|
1060
|
-
['thoughts_token_count'],
|
1061
|
-
getv(from_object, ['thoughtsTokenCount']),
|
1062
|
-
)
|
1063
|
-
if getv(from_object, ['totalTokenCount']) is not None:
|
1064
|
-
setv(
|
1065
|
-
to_object,
|
1066
|
-
['total_token_count'],
|
1067
|
-
getv(from_object, ['totalTokenCount']),
|
1068
|
-
)
|
1069
|
-
if getv(from_object, ['promptTokensDetails']) is not None:
|
1070
|
-
setv(
|
1071
|
-
to_object,
|
1072
|
-
['prompt_tokens_details'],
|
1073
|
-
[
|
1074
|
-
_ModalityTokenCount_from_vertex(api_client,item)
|
1075
|
-
for item in getv(from_object, ['promptTokensDetails'])
|
1076
|
-
],
|
1077
|
-
)
|
1078
|
-
if getv(from_object, ['cacheTokensDetails']) is not None:
|
1079
|
-
setv(
|
1080
|
-
to_object,
|
1081
|
-
['cache_tokens_details'],
|
1082
|
-
[
|
1083
|
-
_ModalityTokenCount_from_vertex(api_client,item)
|
1084
|
-
for item in getv(from_object, ['cacheTokensDetails'])
|
1085
|
-
],
|
1086
|
-
)
|
1087
|
-
if getv(from_object, ['toolUsePromptTokensDetails']) is not None:
|
1088
|
-
setv(
|
1089
|
-
to_object,
|
1090
|
-
['tool_use_prompt_tokens_details'],
|
1091
|
-
[
|
1092
|
-
_ModalityTokenCount_from_vertex(api_client,item)
|
1093
|
-
for item in getv(from_object, ['toolUsePromptTokensDetails'])
|
1094
|
-
],
|
1095
|
-
)
|
1096
|
-
if getv(from_object, ['candidatesTokensDetails']) is not None:
|
1097
|
-
setv(
|
1098
|
-
to_object,
|
1099
|
-
['response_tokens_details'],
|
1100
|
-
[
|
1101
|
-
_ModalityTokenCount_from_vertex(api_client,item)
|
1102
|
-
for item in getv(from_object, ['candidatesTokensDetails'])
|
1103
|
-
],
|
1104
|
-
)
|
1105
|
-
if getv(from_object, ['trafficType']) is not None:
|
1106
|
-
setv(
|
1107
|
-
to_object,
|
1108
|
-
['traffic_type'],
|
1109
|
-
getv(from_object, ['trafficType']),
|
1110
|
-
)
|
1111
|
-
return to_object
|
1112
|
-
|
1113
|
-
|
1114
|
-
def _LiveServerGoAway_from_mldev(
|
1115
|
-
api_client: BaseApiClient,
|
1116
|
-
from_object: Union[dict, object],
|
1117
|
-
parent_object: Optional[dict] = None,
|
1118
|
-
) -> dict:
|
1119
|
-
to_object: dict[str, Any] = {}
|
1120
|
-
if getv(from_object, ['timeLeft']) is not None:
|
1121
|
-
setv(to_object, ['time_left'], getv(from_object, ['timeLeft']))
|
1122
|
-
|
1123
|
-
return to_object
|
1124
|
-
|
1125
|
-
|
1126
|
-
def _LiveServerGoAway_from_vertex(
|
1127
|
-
api_client: BaseApiClient,
|
1128
|
-
from_object: Union[dict, object],
|
1129
|
-
) -> dict:
|
1130
|
-
to_object: dict[str, Any] = {}
|
1131
|
-
if getv(from_object, ['timeLeft']) is not None:
|
1132
|
-
setv(to_object, ['time_left'], getv(from_object, ['timeLeft']))
|
1133
|
-
|
1134
|
-
return to_object
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
def _LiveServerSessionResumptionUpdate_from_mldev(
|
1139
|
-
api_client: BaseApiClient,
|
1140
|
-
from_object: Union[dict, object],
|
1141
|
-
parent_object: Optional[dict] = None,
|
1142
|
-
) -> dict:
|
1143
|
-
to_object: dict[str, Any] = {}
|
1144
|
-
if getv(from_object, ['newHandle']) is not None:
|
1145
|
-
setv(to_object, ['new_handle'], getv(from_object, ['newHandle']))
|
1146
|
-
|
1147
|
-
if getv(from_object, ['resumable']) is not None:
|
1148
|
-
setv(to_object, ['resumable'], getv(from_object, ['resumable']))
|
1149
|
-
|
1150
|
-
if getv(from_object, ['lastConsumedClientMessageIndex']) is not None:
|
1151
|
-
setv(
|
1152
|
-
to_object,
|
1153
|
-
['last_consumed_client_message_index'],
|
1154
|
-
getv(from_object, ['lastConsumedClientMessageIndex']),
|
1155
|
-
)
|
1156
|
-
|
1157
|
-
return to_object
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
def _LiveServerSessionResumptionUpdate_from_vertex(
|
1164
|
-
api_client: BaseApiClient,
|
1165
|
-
from_object: Union[dict, object],
|
1166
|
-
) -> dict:
|
1167
|
-
to_object: dict[str, Any] = {}
|
1168
|
-
if getv(from_object, ['newHandle']) is not None:
|
1169
|
-
setv(to_object, ['new_handle'], getv(from_object, ['newHandle']))
|
1170
|
-
|
1171
|
-
if getv(from_object, ['resumable']) is not None:
|
1172
|
-
setv(to_object, ['resumable'], getv(from_object, ['resumable']))
|
1173
|
-
|
1174
|
-
if getv(from_object, ['lastConsumedClientMessageIndex']) is not None:
|
1175
|
-
setv(
|
1176
|
-
to_object,
|
1177
|
-
['last_consumed_client_message_index'],
|
1178
|
-
getv(from_object, ['lastConsumedClientMessageIndex']),
|
1179
|
-
)
|
1180
|
-
|
1181
|
-
return to_object
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
def _LiveServerMessage_from_mldev(
|
1186
|
-
api_client: BaseApiClient,
|
1187
|
-
from_object: Union[dict, object],
|
1188
|
-
) -> Dict[str, Any]:
|
1189
|
-
to_object: dict[str, Any] = {}
|
1190
|
-
if getv(from_object, ['serverContent']) is not None:
|
1191
|
-
setv(
|
1192
|
-
to_object,
|
1193
|
-
['server_content'],
|
1194
|
-
_LiveServerContent_from_mldev(api_client,
|
1195
|
-
getv(from_object, ['serverContent'])
|
1196
|
-
),
|
1197
|
-
)
|
1198
|
-
if getv(from_object, ['toolCall']) is not None:
|
1199
|
-
setv(
|
1200
|
-
to_object,
|
1201
|
-
['tool_call'],
|
1202
|
-
_LiveToolCall_from_mldev(api_client,getv(from_object, ['toolCall'])),
|
1203
|
-
)
|
1204
|
-
if getv(from_object, ['toolCallCancellation']) is not None:
|
1205
|
-
setv(
|
1206
|
-
to_object,
|
1207
|
-
['tool_call_cancellation'],
|
1208
|
-
getv(from_object, ['toolCallCancellation']),
|
1209
|
-
)
|
1210
|
-
|
1211
|
-
if getv(from_object, ['goAway']) is not None:
|
1212
|
-
setv(
|
1213
|
-
to_object,
|
1214
|
-
['go_away'],
|
1215
|
-
_LiveServerGoAway_from_mldev(api_client,
|
1216
|
-
getv(from_object, ['goAway']), to_object
|
1217
|
-
),
|
1218
|
-
)
|
1219
|
-
|
1220
|
-
if getv(from_object, ['sessionResumptionUpdate']) is not None:
|
1221
|
-
setv(
|
1222
|
-
to_object,
|
1223
|
-
['session_resumption_update'],
|
1224
|
-
_LiveServerSessionResumptionUpdate_from_mldev(api_client,
|
1225
|
-
getv(from_object, ['sessionResumptionUpdate']),
|
1226
|
-
to_object,
|
1227
|
-
),
|
1228
|
-
)
|
1229
|
-
if getv(from_object, ['sessionResumptionUpdate']) is not None:
|
1230
|
-
setv(
|
1231
|
-
to_object,
|
1232
|
-
['session_resumption_update'],
|
1233
|
-
_LiveServerSessionResumptionUpdate_from_mldev(api_client,
|
1234
|
-
getv(from_object, ['sessionResumptionUpdate']),
|
1235
|
-
to_object,
|
1236
|
-
),
|
1237
|
-
)
|
1238
|
-
|
1239
|
-
if getv(from_object, ['usageMetadata']) is not None:
|
1240
|
-
setv(
|
1241
|
-
to_object,
|
1242
|
-
['usage_metadata'],
|
1243
|
-
_UsageMetadata_from_mldev(api_client,getv(from_object, ['usageMetadata'])),
|
1244
|
-
)
|
1245
|
-
return to_object
|
1246
|
-
|
1247
|
-
|
1248
|
-
def _LiveServerMessage_from_vertex(
|
1249
|
-
api_client: BaseApiClient,
|
1250
|
-
from_object: Union[dict, object],
|
1251
|
-
) -> Dict[str, Any]:
|
1252
|
-
to_object: dict[str, Any] = {}
|
1253
|
-
if getv(from_object, ['serverContent']) is not None:
|
1254
|
-
setv(
|
1255
|
-
to_object,
|
1256
|
-
['server_content'],
|
1257
|
-
_LiveServerContent_from_vertex(api_client,
|
1258
|
-
getv(from_object, ['serverContent'])
|
1259
|
-
),
|
1260
|
-
)
|
1261
|
-
if getv(from_object, ['toolCall']) is not None:
|
1262
|
-
setv(
|
1263
|
-
to_object,
|
1264
|
-
['tool_call'],
|
1265
|
-
_LiveToolCall_from_vertex(api_client,getv(from_object, ['toolCall'])),
|
1266
|
-
)
|
1267
|
-
if getv(from_object, ['toolCallCancellation']) is not None:
|
1268
|
-
setv(
|
1269
|
-
to_object,
|
1270
|
-
['tool_call_cancellation'],
|
1271
|
-
getv(from_object, ['toolCallCancellation']),
|
1272
|
-
)
|
1273
|
-
|
1274
|
-
if getv(from_object, ['goAway']) is not None:
|
1275
|
-
setv(
|
1276
|
-
to_object,
|
1277
|
-
['go_away'],
|
1278
|
-
_LiveServerGoAway_from_vertex(api_client,
|
1279
|
-
getv(from_object, ['goAway'])
|
1280
|
-
),
|
1281
|
-
)
|
1282
|
-
|
1283
|
-
if getv(from_object, ['sessionResumptionUpdate']) is not None:
|
1284
|
-
setv(
|
1285
|
-
to_object,
|
1286
|
-
['session_resumption_update'],
|
1287
|
-
_LiveServerSessionResumptionUpdate_from_vertex(api_client,
|
1288
|
-
getv(from_object, ['sessionResumptionUpdate']),
|
1289
|
-
),
|
1290
|
-
)
|
1291
|
-
|
1292
|
-
if getv(from_object, ['usageMetadata']) is not None:
|
1293
|
-
setv(
|
1294
|
-
to_object,
|
1295
|
-
['usage_metadata'],
|
1296
|
-
_UsageMetadata_from_vertex(api_client,getv(from_object, ['usageMetadata'])),
|
1297
|
-
)
|
1298
|
-
return to_object
|