Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 102 additions & 57 deletions google/genai/_live_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ def _AudioTranscriptionConfig_to_mldev(
) -> dict[str, Any]:
to_object: dict[str, Any] = {}
if getv(from_object, ['language_codes']) is not None:
raise ValueError('language_codes parameter is not supported in Gemini API.')
raise ValueError(
'language_codes parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

return to_object

Expand All @@ -43,27 +46,40 @@ def _AuthConfig_to_mldev(
setv(to_object, ['apiKey'], getv(from_object, ['api_key']))

if getv(from_object, ['api_key_config']) is not None:
raise ValueError('api_key_config parameter is not supported in Gemini API.')
raise ValueError(
'api_key_config parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['auth_type']) is not None:
raise ValueError('auth_type parameter is not supported in Gemini API.')
raise ValueError(
'auth_type parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['google_service_account_config']) is not None:
raise ValueError(
'google_service_account_config parameter is not supported in Gemini'
' API.'
'google_service_account_config parameter is only supported in Gemini'
' Enterprise Agent Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['http_basic_auth_config']) is not None:
raise ValueError(
'http_basic_auth_config parameter is not supported in Gemini API.'
'http_basic_auth_config parameter is only supported in Gemini'
' Enterprise Agent Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['oauth_config']) is not None:
raise ValueError('oauth_config parameter is not supported in Gemini API.')
raise ValueError(
'oauth_config parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['oidc_config']) is not None:
raise ValueError('oidc_config parameter is not supported in Gemini API.')
raise ValueError(
'oidc_config parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

return to_object

Expand All @@ -77,7 +93,10 @@ def _Blob_to_mldev(
setv(to_object, ['data'], getv(from_object, ['data']))

if getv(from_object, ['display_name']) is not None:
raise ValueError('display_name parameter is not supported in Gemini API.')
raise ValueError(
'display_name parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['mime_type']) is not None:
setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
Expand Down Expand Up @@ -133,7 +152,10 @@ def _FileData_to_mldev(
) -> dict[str, Any]:
to_object: dict[str, Any] = {}
if getv(from_object, ['display_name']) is not None:
raise ValueError('display_name parameter is not supported in Gemini API.')
raise ValueError(
'display_name parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['file_uri']) is not None:
setv(to_object, ['fileUri'], getv(from_object, ['file_uri']))
Expand All @@ -159,10 +181,16 @@ def _FunctionCall_to_mldev(
setv(to_object, ['name'], getv(from_object, ['name']))

if getv(from_object, ['partial_args']) is not None:
raise ValueError('partial_args parameter is not supported in Gemini API.')
raise ValueError(
'partial_args parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['will_continue']) is not None:
raise ValueError('will_continue parameter is not supported in Gemini API.')
raise ValueError(
'will_continue parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

return to_object

Expand Down Expand Up @@ -200,8 +228,8 @@ def _FunctionDeclaration_to_vertex(

if getv(from_object, ['behavior']) is not None:
raise ValueError(
'behavior parameter is not supported in Gemini Enterprise Agent'
' Platform.'
'behavior parameter is only supported in Gemini Developer API mode, not'
' in Gemini Enterprise Agent Platform mode.'
)

return to_object
Expand Down Expand Up @@ -320,8 +348,8 @@ def _GenerationConfig_to_vertex(

if getv(from_object, ['enable_enhanced_civic_answers']) is not None:
raise ValueError(
'enable_enhanced_civic_answers parameter is not supported in Gemini'
' Enterprise Agent Platform.'
'enable_enhanced_civic_answers parameter is only supported in Gemini'
' Developer API mode, not in Gemini Enterprise Agent Platform mode.'
)

return to_object
Expand Down Expand Up @@ -355,12 +383,14 @@ def _GoogleSearch_to_mldev(

if getv(from_object, ['blocking_confidence']) is not None:
raise ValueError(
'blocking_confidence parameter is not supported in Gemini API.'
'blocking_confidence parameter is only supported in Gemini Enterprise'
' Agent Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['exclude_domains']) is not None:
raise ValueError(
'exclude_domains parameter is not supported in Gemini API.'
'exclude_domains parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['time_range_filter']) is not None:
Expand Down Expand Up @@ -552,8 +582,8 @@ def _LiveClientRealtimeInput_to_vertex(

if getv(from_object, ['audio_stream_end']) is not None:
raise ValueError(
'audio_stream_end parameter is not supported in Gemini Enterprise Agent'
' Platform.'
'audio_stream_end parameter is only supported in Gemini Developer API'
' mode, not in Gemini Enterprise Agent Platform mode.'
)

if getv(from_object, ['video']) is not None:
Expand Down Expand Up @@ -645,7 +675,8 @@ def _LiveClientSetup_to_mldev(

if getv(from_object, ['explicit_vad_signal']) is not None:
raise ValueError(
'explicit_vad_signal parameter is not supported in Gemini API.'
'explicit_vad_signal parameter is only supported in Gemini Enterprise'
' Agent Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['history_config']) is not None:
Expand Down Expand Up @@ -744,8 +775,8 @@ def _LiveClientSetup_to_vertex(

if getv(from_object, ['history_config']) is not None:
raise ValueError(
'history_config parameter is not supported in Gemini Enterprise Agent'
' Platform.'
'history_config parameter is only supported in Gemini Developer API'
' mode, not in Gemini Enterprise Agent Platform mode.'
)

if getv(from_object, ['avatar_config']) is not None:
Expand Down Expand Up @@ -914,7 +945,8 @@ def _LiveConnectConfig_to_mldev(

if getv(from_object, ['explicit_vad_signal']) is not None:
raise ValueError(
'explicit_vad_signal parameter is not supported in Gemini API.'
'explicit_vad_signal parameter is only supported in Gemini Enterprise'
' Agent Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['history_config']) is not None:
Expand Down Expand Up @@ -1103,8 +1135,8 @@ def _LiveConnectConfig_to_vertex(

if getv(from_object, ['history_config']) is not None:
raise ValueError(
'history_config parameter is not supported in Gemini Enterprise Agent'
' Platform.'
'history_config parameter is only supported in Gemini Developer API'
' mode, not in Gemini Enterprise Agent Platform mode.'
)

if getv(from_object, ['avatar_config']) is not None:
Expand Down Expand Up @@ -1181,25 +1213,26 @@ def _LiveMusicClientMessage_to_vertex(
to_object: dict[str, Any] = {}
if getv(from_object, ['setup']) is not None:
raise ValueError(
'setup parameter is not supported in Gemini Enterprise Agent Platform.'
'setup parameter is only supported in Gemini Developer API mode, not in'
' Gemini Enterprise Agent Platform mode.'
)

if getv(from_object, ['client_content']) is not None:
raise ValueError(
'client_content parameter is not supported in Gemini Enterprise Agent'
' Platform.'
'client_content parameter is only supported in Gemini Developer API'
' mode, not in Gemini Enterprise Agent Platform mode.'
)

if getv(from_object, ['music_generation_config']) is not None:
raise ValueError(
'music_generation_config parameter is not supported in Gemini'
' Enterprise Agent Platform.'
'music_generation_config parameter is only supported in Gemini'
' Developer API mode, not in Gemini Enterprise Agent Platform mode.'
)

if getv(from_object, ['playback_control']) is not None:
raise ValueError(
'playback_control parameter is not supported in Gemini Enterprise Agent'
' Platform.'
'playback_control parameter is only supported in Gemini Developer API'
' mode, not in Gemini Enterprise Agent Platform mode.'
)

return to_object
Expand All @@ -1223,7 +1256,8 @@ def _LiveMusicConnectParameters_to_vertex(
to_object: dict[str, Any] = {}
if getv(from_object, ['model']) is not None:
raise ValueError(
'model parameter is not supported in Gemini Enterprise Agent Platform.'
'model parameter is only supported in Gemini Developer API mode, not in'
' Gemini Enterprise Agent Platform mode.'
)

return to_object
Expand Down Expand Up @@ -1251,8 +1285,8 @@ def _LiveMusicSetConfigParameters_to_vertex(
to_object: dict[str, Any] = {}
if getv(from_object, ['music_generation_config']) is not None:
raise ValueError(
'music_generation_config parameter is not supported in Gemini'
' Enterprise Agent Platform.'
'music_generation_config parameter is only supported in Gemini'
' Developer API mode, not in Gemini Enterprise Agent Platform mode.'
)

return to_object
Expand Down Expand Up @@ -1280,8 +1314,8 @@ def _LiveMusicSetWeightedPromptsParameters_to_vertex(
to_object: dict[str, Any] = {}
if getv(from_object, ['weighted_prompts']) is not None:
raise ValueError(
'weighted_prompts parameter is not supported in Gemini Enterprise Agent'
' Platform.'
'weighted_prompts parameter is only supported in Gemini Developer API'
' mode, not in Gemini Enterprise Agent Platform mode.'
)

return to_object
Expand Down Expand Up @@ -1624,20 +1658,20 @@ def _Part_to_vertex(

if getv(from_object, ['tool_call']) is not None:
raise ValueError(
'tool_call parameter is not supported in Gemini Enterprise Agent'
' Platform.'
'tool_call parameter is only supported in Gemini Developer API mode,'
' not in Gemini Enterprise Agent Platform mode.'
)

if getv(from_object, ['tool_response']) is not None:
raise ValueError(
'tool_response parameter is not supported in Gemini Enterprise Agent'
' Platform.'
'tool_response parameter is only supported in Gemini Developer API'
' mode, not in Gemini Enterprise Agent Platform mode.'
)

if getv(from_object, ['part_metadata']) is not None:
raise ValueError(
'part_metadata parameter is not supported in Gemini Enterprise Agent'
' Platform.'
'part_metadata parameter is only supported in Gemini Developer API'
' mode, not in Gemini Enterprise Agent Platform mode.'
)

return to_object
Expand All @@ -1660,14 +1694,14 @@ def _ReplicatedVoiceConfig_to_vertex(

if getv(from_object, ['consent_audio']) is not None:
raise ValueError(
'consent_audio parameter is not supported in Gemini Enterprise Agent'
' Platform.'
'consent_audio parameter is only supported in Gemini Developer API'
' mode, not in Gemini Enterprise Agent Platform mode.'
)

if getv(from_object, ['voice_consent_signature']) is not None:
raise ValueError(
'voice_consent_signature parameter is not supported in Gemini'
' Enterprise Agent Platform.'
'voice_consent_signature parameter is only supported in Gemini'
' Developer API mode, not in Gemini Enterprise Agent Platform mode.'
)

return to_object
Expand All @@ -1682,7 +1716,10 @@ def _SafetySetting_to_mldev(
setv(to_object, ['category'], getv(from_object, ['category']))

if getv(from_object, ['method']) is not None:
raise ValueError('method parameter is not supported in Gemini API.')
raise ValueError(
'method parameter is only supported in Gemini Enterprise Agent Platform'
' mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['threshold']) is not None:
setv(to_object, ['threshold'], getv(from_object, ['threshold']))
Expand All @@ -1699,7 +1736,10 @@ def _SessionResumptionConfig_to_mldev(
setv(to_object, ['handle'], getv(from_object, ['handle']))

if getv(from_object, ['transparent']) is not None:
raise ValueError('transparent parameter is not supported in Gemini API.')
raise ValueError(
'transparent parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

return to_object

Expand Down Expand Up @@ -1755,7 +1795,10 @@ def _Tool_to_mldev(
) -> dict[str, Any]:
to_object: dict[str, Any] = {}
if getv(from_object, ['retrieval']) is not None:
raise ValueError('retrieval parameter is not supported in Gemini API.')
raise ValueError(
'retrieval parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['computer_use']) is not None:
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
Expand All @@ -1782,7 +1825,8 @@ def _Tool_to_mldev(

if getv(from_object, ['enterprise_web_search']) is not None:
raise ValueError(
'enterprise_web_search parameter is not supported in Gemini API.'
'enterprise_web_search parameter is only supported in Gemini Enterprise'
' Agent Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['function_declarations']) is not None:
Expand All @@ -1801,7 +1845,8 @@ def _Tool_to_mldev(

if getv(from_object, ['parallel_ai_search']) is not None:
raise ValueError(
'parallel_ai_search parameter is not supported in Gemini API.'
'parallel_ai_search parameter is only supported in Gemini Enterprise'
' Agent Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['url_context']) is not None:
Expand Down Expand Up @@ -1830,8 +1875,8 @@ def _Tool_to_vertex(

if getv(from_object, ['file_search']) is not None:
raise ValueError(
'file_search parameter is not supported in Gemini Enterprise Agent'
' Platform.'
'file_search parameter is only supported in Gemini Developer API mode,'
' not in Gemini Enterprise Agent Platform mode.'
)

if getv(from_object, ['google_search']) is not None:
Expand Down Expand Up @@ -1879,8 +1924,8 @@ def _Tool_to_vertex(

if getv(from_object, ['mcp_servers']) is not None:
raise ValueError(
'mcp_servers parameter is not supported in Gemini Enterprise Agent'
' Platform.'
'mcp_servers parameter is only supported in Gemini Developer API mode,'
' not in Gemini Enterprise Agent Platform mode.'
)

return to_object
Expand Down
Loading
Loading