Skip to content

Commit d8fdcb0

Browse files
jscudcopybara-github
authored andcommitted
feat: Update data types from discovery doc.
PiperOrigin-RevId: 840900705
1 parent e16706a commit d8fdcb0

File tree

8 files changed

+2629
-884
lines changed

8 files changed

+2629
-884
lines changed

google/genai/_live_converters.py

Lines changed: 245 additions & 36 deletions
Large diffs are not rendered by default.

google/genai/_tokens_converters.py

Lines changed: 140 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,40 @@
2323
from ._common import set_value_by_path as setv
2424

2525

26+
def _AuthConfig_to_mldev(
27+
from_object: Union[dict[str, Any], object],
28+
parent_object: Optional[dict[str, Any]] = None,
29+
) -> dict[str, Any]:
30+
to_object: dict[str, Any] = {}
31+
if getv(from_object, ['api_key']) is not None:
32+
setv(to_object, ['apiKey'], getv(from_object, ['api_key']))
33+
34+
if getv(from_object, ['api_key_config']) is not None:
35+
raise ValueError('api_key_config parameter is not supported in Gemini API.')
36+
37+
if getv(from_object, ['auth_type']) is not None:
38+
raise ValueError('auth_type parameter is not supported in Gemini API.')
39+
40+
if getv(from_object, ['google_service_account_config']) is not None:
41+
raise ValueError(
42+
'google_service_account_config parameter is not supported in Gemini'
43+
' API.'
44+
)
45+
46+
if getv(from_object, ['http_basic_auth_config']) is not None:
47+
raise ValueError(
48+
'http_basic_auth_config parameter is not supported in Gemini API.'
49+
)
50+
51+
if getv(from_object, ['oauth_config']) is not None:
52+
raise ValueError('oauth_config parameter is not supported in Gemini API.')
53+
54+
if getv(from_object, ['oidc_config']) is not None:
55+
raise ValueError('oidc_config parameter is not supported in Gemini API.')
56+
57+
return to_object
58+
59+
2660
def _Blob_to_mldev(
2761
from_object: Union[dict[str, Any], object],
2862
parent_object: Optional[dict[str, Any]] = None,
@@ -177,7 +211,11 @@ def _GoogleMaps_to_mldev(
177211
) -> dict[str, Any]:
178212
to_object: dict[str, Any] = {}
179213
if getv(from_object, ['auth_config']) is not None:
180-
raise ValueError('auth_config parameter is not supported in Gemini API.')
214+
setv(
215+
to_object,
216+
['authConfig'],
217+
_AuthConfig_to_mldev(getv(from_object, ['auth_config']), to_object),
218+
)
181219

182220
if getv(from_object, ['enable_widget']) is not None:
183221
setv(to_object, ['enableWidget'], getv(from_object, ['enable_widget']))
@@ -190,14 +228,14 @@ def _GoogleSearch_to_mldev(
190228
parent_object: Optional[dict[str, Any]] = None,
191229
) -> dict[str, Any]:
192230
to_object: dict[str, Any] = {}
193-
if getv(from_object, ['exclude_domains']) is not None:
231+
if getv(from_object, ['blocking_confidence']) is not None:
194232
raise ValueError(
195-
'exclude_domains parameter is not supported in Gemini API.'
233+
'blocking_confidence parameter is not supported in Gemini API.'
196234
)
197235

198-
if getv(from_object, ['blocking_confidence']) is not None:
236+
if getv(from_object, ['exclude_domains']) is not None:
199237
raise ValueError(
200-
'blocking_confidence parameter is not supported in Gemini API.'
238+
'exclude_domains parameter is not supported in Gemini API.'
201239
)
202240

203241
if getv(from_object, ['time_range_filter']) is not None:
@@ -275,7 +313,10 @@ def _LiveConnectConfig_to_mldev(
275313
setv(
276314
parent_object,
277315
['setup', 'generationConfig', 'speechConfig'],
278-
t.t_live_speech_config(getv(from_object, ['speech_config'])),
316+
_SpeechConfig_to_mldev(
317+
t.t_live_speech_config(getv(from_object, ['speech_config'])),
318+
to_object,
319+
),
279320
)
280321

281322
if getv(from_object, ['thinking_config']) is not None:
@@ -383,6 +424,24 @@ def _LiveConnectConstraints_to_mldev(
383424
return to_object
384425

385426

427+
def _MultiSpeakerVoiceConfig_to_mldev(
428+
from_object: Union[dict[str, Any], object],
429+
parent_object: Optional[dict[str, Any]] = None,
430+
) -> dict[str, Any]:
431+
to_object: dict[str, Any] = {}
432+
if getv(from_object, ['speaker_voice_configs']) is not None:
433+
setv(
434+
to_object,
435+
['speakerVoiceConfigs'],
436+
[
437+
_SpeakerVoiceConfig_to_mldev(item, to_object)
438+
for item in getv(from_object, ['speaker_voice_configs'])
439+
],
440+
)
441+
442+
return to_object
443+
444+
386445
def _Part_to_mldev(
387446
from_object: Union[dict[str, Any], object],
388447
parent_object: Optional[dict[str, Any]] = None,
@@ -447,6 +506,9 @@ def _Part_to_mldev(
447506
if getv(from_object, ['video_metadata']) is not None:
448507
setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
449508

509+
if getv(from_object, ['part_metadata']) is not None:
510+
setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata']))
511+
450512
return to_object
451513

452514

@@ -464,6 +526,51 @@ def _SessionResumptionConfig_to_mldev(
464526
return to_object
465527

466528

529+
def _SpeakerVoiceConfig_to_mldev(
530+
from_object: Union[dict[str, Any], object],
531+
parent_object: Optional[dict[str, Any]] = None,
532+
) -> dict[str, Any]:
533+
to_object: dict[str, Any] = {}
534+
if getv(from_object, ['speaker']) is not None:
535+
setv(to_object, ['speaker'], getv(from_object, ['speaker']))
536+
537+
if getv(from_object, ['voice_config']) is not None:
538+
setv(
539+
to_object,
540+
['voiceConfig'],
541+
_VoiceConfig_to_mldev(getv(from_object, ['voice_config']), to_object),
542+
)
543+
544+
return to_object
545+
546+
547+
def _SpeechConfig_to_mldev(
548+
from_object: Union[dict[str, Any], object],
549+
parent_object: Optional[dict[str, Any]] = None,
550+
) -> dict[str, Any]:
551+
to_object: dict[str, Any] = {}
552+
if getv(from_object, ['language_code']) is not None:
553+
setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
554+
555+
if getv(from_object, ['multi_speaker_voice_config']) is not None:
556+
setv(
557+
to_object,
558+
['multiSpeakerVoiceConfig'],
559+
_MultiSpeakerVoiceConfig_to_mldev(
560+
getv(from_object, ['multi_speaker_voice_config']), to_object
561+
),
562+
)
563+
564+
if getv(from_object, ['voice_config']) is not None:
565+
setv(
566+
to_object,
567+
['voiceConfig'],
568+
_VoiceConfig_to_mldev(getv(from_object, ['voice_config']), to_object),
569+
)
570+
571+
return to_object
572+
573+
467574
def _Tool_to_mldev(
468575
from_object: Union[dict[str, Any], object],
469576
parent_object: Optional[dict[str, Any]] = None,
@@ -492,6 +599,13 @@ def _Tool_to_mldev(
492599
if getv(from_object, ['file_search']) is not None:
493600
setv(to_object, ['fileSearch'], getv(from_object, ['file_search']))
494601

602+
if getv(from_object, ['google_maps']) is not None:
603+
setv(
604+
to_object,
605+
['googleMaps'],
606+
_GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
607+
)
608+
495609
if getv(from_object, ['code_execution']) is not None:
496610
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
497611

@@ -500,13 +614,6 @@ def _Tool_to_mldev(
500614
'enterprise_web_search parameter is not supported in Gemini API.'
501615
)
502616

503-
if getv(from_object, ['google_maps']) is not None:
504-
setv(
505-
to_object,
506-
['googleMaps'],
507-
_GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
508-
)
509-
510617
if getv(from_object, ['google_search']) is not None:
511618
setv(
512619
to_object,
@@ -518,3 +625,23 @@ def _Tool_to_mldev(
518625
setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
519626

520627
return to_object
628+
629+
630+
def _VoiceConfig_to_mldev(
631+
from_object: Union[dict[str, Any], object],
632+
parent_object: Optional[dict[str, Any]] = None,
633+
) -> dict[str, Any]:
634+
to_object: dict[str, Any] = {}
635+
if getv(from_object, ['prebuilt_voice_config']) is not None:
636+
setv(
637+
to_object,
638+
['prebuiltVoiceConfig'],
639+
getv(from_object, ['prebuilt_voice_config']),
640+
)
641+
642+
if getv(from_object, ['replicated_voice_config']) is not None:
643+
raise ValueError(
644+
'replicated_voice_config parameter is not supported in Gemini API.'
645+
)
646+
647+
return to_object

0 commit comments

Comments
 (0)