diff --git a/google/genai/_live_converters.py b/google/genai/_live_converters.py index b53370506..20465ac87 100644 --- a/google/genai/_live_converters.py +++ b/google/genai/_live_converters.py @@ -70,26 +70,6 @@ def _AuthConfig_to_mldev( return to_object -def _Blob_to_mldev( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['data']) is not None: - setv(to_object, ['data'], getv(from_object, ['data'])) - - if getv(from_object, ['display_name']) is not None: - 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'])) - - return to_object - - def _ComputerUse_to_vertex( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -163,26 +143,6 @@ def _Content_to_vertex( return to_object -def _FileData_to_mldev( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['display_name']) is not None: - 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'])) - - if getv(from_object, ['mime_type']) is not None: - setv(to_object, ['mimeType'], getv(from_object, ['mime_type'])) - - return to_object - - def _FunctionCall_to_mldev( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -337,9 +297,12 @@ def _GenerationConfig_to_vertex( ) if getv(from_object, ['translation_config']) is not None: - raise ValueError( - 'translation_config parameter is only supported in Gemini Developer API' - ' mode, not in Gemini Enterprise Agent Platform mode.' + setv( + to_object, + ['translationConfig'], + _TranslationConfig_to_vertex( + getv(from_object, ['translation_config']), to_object + ), ) if getv(from_object, ['audio_transcription_config']) is not None: @@ -471,13 +434,7 @@ def _LiveClientMessage_to_mldev( ) if getv(from_object, ['realtime_input']) is not None: - setv( - to_object, - ['realtimeInput'], - _LiveClientRealtimeInput_to_mldev( - getv(from_object, ['realtime_input']), to_object - ), - ) + setv(to_object, ['realtimeInput'], getv(from_object, ['realtime_input'])) if getv(from_object, ['tool_response']) is not None: setv(to_object, ['toolResponse'], getv(from_object, ['tool_response'])) @@ -524,50 +481,6 @@ def _LiveClientMessage_to_vertex( return to_object -def _LiveClientRealtimeInput_to_mldev( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['media_chunks']) is not None: - setv( - to_object, - ['mediaChunks'], - [ - _Blob_to_mldev(item, to_object) - for item in getv(from_object, ['media_chunks']) - ], - ) - - if getv(from_object, ['audio']) is not None: - setv( - to_object, - ['audio'], - _Blob_to_mldev(getv(from_object, ['audio']), to_object), - ) - - if getv(from_object, ['audio_stream_end']) is not None: - setv(to_object, ['audioStreamEnd'], getv(from_object, ['audio_stream_end'])) - - if getv(from_object, ['video']) is not None: - setv( - to_object, - ['video'], - _Blob_to_mldev(getv(from_object, ['video']), to_object), - ) - - if getv(from_object, ['text']) is not None: - setv(to_object, ['text'], getv(from_object, ['text'])) - - if getv(from_object, ['activity_start']) is not None: - setv(to_object, ['activityStart'], getv(from_object, ['activity_start'])) - - if getv(from_object, ['activity_end']) is not None: - setv(to_object, ['activityEnd'], getv(from_object, ['activity_end'])) - - return to_object - - def _LiveClientRealtimeInput_to_vertex( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -1341,28 +1254,17 @@ def _LiveSendRealtimeInputParameters_to_mldev( setv( to_object, ['mediaChunks'], - [ - _Blob_to_mldev(item, to_object) - for item in t.t_blobs(getv(from_object, ['media'])) - ], + [item for item in t.t_blobs(getv(from_object, ['media']))], ) if getv(from_object, ['audio']) is not None: - setv( - to_object, - ['audio'], - _Blob_to_mldev(t.t_audio_blob(getv(from_object, ['audio'])), to_object), - ) + setv(to_object, ['audio'], t.t_audio_blob(getv(from_object, ['audio']))) if getv(from_object, ['audio_stream_end']) is not None: setv(to_object, ['audioStreamEnd'], getv(from_object, ['audio_stream_end'])) if getv(from_object, ['video']) is not None: - setv( - to_object, - ['video'], - _Blob_to_mldev(t.t_image_blob(getv(from_object, ['video'])), to_object), - ) + setv(to_object, ['video'], t.t_image_blob(getv(from_object, ['video']))) if getv(from_object, ['text']) is not None: setv(to_object, ['text'], getv(from_object, ['text'])) @@ -1580,11 +1482,7 @@ def _Part_to_mldev( setv(to_object, ['executableCode'], getv(from_object, ['executable_code'])) if getv(from_object, ['file_data']) is not None: - setv( - to_object, - ['fileData'], - _FileData_to_mldev(getv(from_object, ['file_data']), to_object), - ) + setv(to_object, ['fileData'], getv(from_object, ['file_data'])) if getv(from_object, ['function_call']) is not None: setv( @@ -1601,11 +1499,7 @@ def _Part_to_mldev( ) if getv(from_object, ['inline_data']) is not None: - setv( - to_object, - ['inlineData'], - _Blob_to_mldev(getv(from_object, ['inline_data']), to_object), - ) + setv(to_object, ['inlineData'], getv(from_object, ['inline_data'])) if getv(from_object, ['text']) is not None: setv(to_object, ['text'], getv(from_object, ['text'])) diff --git a/google/genai/_tokens_converters.py b/google/genai/_tokens_converters.py index 045c1b4a9..f72b65ad4 100644 --- a/google/genai/_tokens_converters.py +++ b/google/genai/_tokens_converters.py @@ -70,26 +70,6 @@ def _AuthConfig_to_mldev( return to_object -def _Blob_to_mldev( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['data']) is not None: - setv(to_object, ['data'], getv(from_object, ['data'])) - - if getv(from_object, ['display_name']) is not None: - 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'])) - - return to_object - - def _Content_to_mldev( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -184,26 +164,6 @@ def _CreateAuthTokenParameters_to_vertex( return to_object -def _FileData_to_mldev( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['display_name']) is not None: - 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'])) - - if getv(from_object, ['mime_type']) is not None: - setv(to_object, ['mimeType'], getv(from_object, ['mime_type'])) - - return to_object - - def _FunctionCall_to_mldev( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -520,11 +480,7 @@ def _Part_to_mldev( setv(to_object, ['executableCode'], getv(from_object, ['executable_code'])) if getv(from_object, ['file_data']) is not None: - setv( - to_object, - ['fileData'], - _FileData_to_mldev(getv(from_object, ['file_data']), to_object), - ) + setv(to_object, ['fileData'], getv(from_object, ['file_data'])) if getv(from_object, ['function_call']) is not None: setv( @@ -541,11 +497,7 @@ def _Part_to_mldev( ) if getv(from_object, ['inline_data']) is not None: - setv( - to_object, - ['inlineData'], - _Blob_to_mldev(getv(from_object, ['inline_data']), to_object), - ) + setv(to_object, ['inlineData'], getv(from_object, ['inline_data'])) if getv(from_object, ['text']) is not None: setv(to_object, ['text'], getv(from_object, ['text'])) diff --git a/google/genai/batches.py b/google/genai/batches.py index 1e8a424ff..30e3890ad 100644 --- a/google/genai/batches.py +++ b/google/genai/batches.py @@ -443,26 +443,6 @@ def _BatchJob_from_vertex( return to_object -def _Blob_to_mldev( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['data']) is not None: - setv(to_object, ['data'], getv(from_object, ['data'])) - - if getv(from_object, ['display_name']) is not None: - 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'])) - - return to_object - - def _CancelBatchJobParameters_to_mldev( api_client: BaseApiClient, from_object: Union[dict[str, Any], object], @@ -922,26 +902,6 @@ def _EmbeddingsBatchJobSource_to_mldev( return to_object -def _FileData_to_mldev( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['display_name']) is not None: - 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'])) - - if getv(from_object, ['mime_type']) is not None: - setv(to_object, ['mimeType'], getv(from_object, ['mime_type'])) - - return to_object - - def _FunctionCall_to_mldev( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -1567,11 +1527,7 @@ def _Part_to_mldev( setv(to_object, ['executableCode'], getv(from_object, ['executable_code'])) if getv(from_object, ['file_data']) is not None: - setv( - to_object, - ['fileData'], - _FileData_to_mldev(getv(from_object, ['file_data']), to_object), - ) + setv(to_object, ['fileData'], getv(from_object, ['file_data'])) if getv(from_object, ['function_call']) is not None: setv( @@ -1588,11 +1544,7 @@ def _Part_to_mldev( ) if getv(from_object, ['inline_data']) is not None: - setv( - to_object, - ['inlineData'], - _Blob_to_mldev(getv(from_object, ['inline_data']), to_object), - ) + setv(to_object, ['inlineData'], getv(from_object, ['inline_data'])) if getv(from_object, ['text']) is not None: setv(to_object, ['text'], getv(from_object, ['text'])) diff --git a/google/genai/caches.py b/google/genai/caches.py index b6ac7adb2..dbf3509e2 100644 --- a/google/genai/caches.py +++ b/google/genai/caches.py @@ -79,26 +79,6 @@ def _AuthConfig_to_mldev( return to_object -def _Blob_to_mldev( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['data']) is not None: - setv(to_object, ['data'], getv(from_object, ['data'])) - - if getv(from_object, ['display_name']) is not None: - 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'])) - - return to_object - - def _ComputerUse_to_vertex( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -393,26 +373,6 @@ def _DeleteCachedContentResponse_from_vertex( return to_object -def _FileData_to_mldev( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['display_name']) is not None: - 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'])) - - if getv(from_object, ['mime_type']) is not None: - setv(to_object, ['mimeType'], getv(from_object, ['mime_type'])) - - return to_object - - def _FunctionCall_to_mldev( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -703,11 +663,7 @@ def _Part_to_mldev( setv(to_object, ['executableCode'], getv(from_object, ['executable_code'])) if getv(from_object, ['file_data']) is not None: - setv( - to_object, - ['fileData'], - _FileData_to_mldev(getv(from_object, ['file_data']), to_object), - ) + setv(to_object, ['fileData'], getv(from_object, ['file_data'])) if getv(from_object, ['function_call']) is not None: setv( @@ -724,11 +680,7 @@ def _Part_to_mldev( ) if getv(from_object, ['inline_data']) is not None: - setv( - to_object, - ['inlineData'], - _Blob_to_mldev(getv(from_object, ['inline_data']), to_object), - ) + setv(to_object, ['inlineData'], getv(from_object, ['inline_data'])) if getv(from_object, ['text']) is not None: setv(to_object, ['text'], getv(from_object, ['text'])) diff --git a/google/genai/models.py b/google/genai/models.py index f9cca3614..fdea72ddd 100644 --- a/google/genai/models.py +++ b/google/genai/models.py @@ -97,27 +97,6 @@ def _AuthConfig_to_mldev( return to_object -def _Blob_to_mldev( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, - root_object: Optional[Union[dict[str, Any], object]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['data']) is not None: - setv(to_object, ['data'], getv(from_object, ['data'])) - - if getv(from_object, ['display_name']) is not None: - 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'])) - - return to_object - - def _Candidate_from_mldev( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -1135,27 +1114,6 @@ def _Endpoint_from_vertex( return to_object -def _FileData_to_mldev( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, - root_object: Optional[Union[dict[str, Any], object]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['display_name']) is not None: - 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'])) - - if getv(from_object, ['mime_type']) is not None: - setv(to_object, ['mimeType'], getv(from_object, ['mime_type'])) - - return to_object - - def _FunctionCall_to_mldev( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -2730,9 +2688,12 @@ def _GenerationConfig_to_vertex( ) if getv(from_object, ['translation_config']) is not None: - raise ValueError( - 'translation_config parameter is only supported in Gemini Developer API' - ' mode, not in Gemini Enterprise Agent Platform mode.' + setv( + to_object, + ['translationConfig'], + _TranslationConfig_to_vertex( + getv(from_object, ['translation_config']), to_object, root_object + ), ) if getv(from_object, ['audio_transcription_config']) is not None: @@ -3344,13 +3305,7 @@ def _Part_to_mldev( setv(to_object, ['executableCode'], getv(from_object, ['executable_code'])) if getv(from_object, ['file_data']) is not None: - setv( - to_object, - ['fileData'], - _FileData_to_mldev( - getv(from_object, ['file_data']), to_object, root_object - ), - ) + setv(to_object, ['fileData'], getv(from_object, ['file_data'])) if getv(from_object, ['function_call']) is not None: setv( @@ -3369,13 +3324,7 @@ def _Part_to_mldev( ) if getv(from_object, ['inline_data']) is not None: - setv( - to_object, - ['inlineData'], - _Blob_to_mldev( - getv(from_object, ['inline_data']), to_object, root_object - ), - ) + setv(to_object, ['inlineData'], getv(from_object, ['inline_data'])) if getv(from_object, ['text']) is not None: setv(to_object, ['text'], getv(from_object, ['text'])) @@ -4224,6 +4173,29 @@ def _Tool_to_vertex( return to_object +def _TranslationConfig_to_vertex( + from_object: Union[dict[str, Any], object], + parent_object: Optional[dict[str, Any]] = None, + root_object: Optional[Union[dict[str, Any], object]] = None, +) -> dict[str, Any]: + to_object: dict[str, Any] = {} + if getv(from_object, ['echo_target_language']) is not None: + setv( + to_object, + ['echoTargetLanguage'], + getv(from_object, ['echo_target_language']), + ) + + if getv(from_object, ['target_language_code']) is not None: + setv( + to_object, + ['targetLanguageCode'], + getv(from_object, ['target_language_code']), + ) + + return to_object + + def _TunedModelInfo_from_vertex( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, diff --git a/google/genai/tunings.py b/google/genai/tunings.py index 4422f7457..a270085d6 100644 --- a/google/genai/tunings.py +++ b/google/genai/tunings.py @@ -222,6 +222,38 @@ def _CompositeReinforcementTuningRewardConfig_to_vertex( return to_object +def _ComputerUse_to_vertex( + from_object: Union[dict[str, Any], object], + parent_object: Optional[dict[str, Any]] = None, + root_object: Optional[Union[dict[str, Any], object]] = None, +) -> dict[str, Any]: + to_object: dict[str, Any] = {} + if getv(from_object, ['environment']) is not None: + setv(to_object, ['environment'], getv(from_object, ['environment'])) + + if getv(from_object, ['excluded_predefined_functions']) is not None: + setv( + to_object, + ['excludedPredefinedFunctions'], + getv(from_object, ['excluded_predefined_functions']), + ) + + if getv(from_object, ['enable_prompt_injection_detection']) is not None: + setv( + to_object, + ['enablePromptInjectionDetection'], + getv(from_object, ['enable_prompt_injection_detection']), + ) + + if getv(from_object, ['disabled_safety_policies']) is not None: + raise ValueError( + 'disabled_safety_policies parameter is only supported in Gemini' + ' Developer API mode, not in Gemini Enterprise Agent Platform mode.' + ) + + return to_object + + def _Content_to_vertex( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -1200,6 +1232,15 @@ def _GenerationConfig_from_vertex( [item for item in getv(from_object, ['responseFormat'])], ) + if getv(from_object, ['translationConfig']) is not None: + setv( + to_object, + ['translation_config'], + _TranslationConfig_from_vertex( + getv(from_object, ['translationConfig']), to_object, root_object + ), + ) + if getv(from_object, ['audioTranscriptionConfig']) is not None: setv( to_object, @@ -1336,9 +1377,12 @@ def _GenerationConfig_to_vertex( ) if getv(from_object, ['translation_config']) is not None: - raise ValueError( - 'translation_config parameter is only supported in Gemini Developer API' - ' mode, not in Gemini Enterprise Agent Platform mode.' + setv( + to_object, + ['translationConfig'], + _TranslationConfig_to_vertex( + getv(from_object, ['translation_config']), to_object, root_object + ), ) if getv(from_object, ['audio_transcription_config']) is not None: @@ -1441,6 +1485,27 @@ def _ListTuningJobsResponse_from_vertex( return to_object +def _McpServer_to_vertex( + from_object: Union[dict[str, Any], object], + parent_object: Optional[dict[str, Any]] = None, + root_object: Optional[Union[dict[str, Any], object]] = None, +) -> dict[str, Any]: + to_object: dict[str, Any] = {} + if getv(from_object, ['name']) is not None: + raise ValueError( + 'name parameter is only supported in Gemini Developer API mode, not in' + ' Gemini Enterprise Agent Platform mode.' + ) + + if getv(from_object, ['streamable_http_transport']) is not None: + raise ValueError( + 'streamable_http_transport parameter is only supported in Gemini' + ' Developer API mode, not in Gemini Enterprise Agent Platform mode.' + ) + + return to_object + + def _MultiSpeakerVoiceConfig_to_vertex( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -1662,6 +1727,16 @@ def _ReinforcementTuningExample_to_vertex( ), ) + if getv(from_object, ['tools']) is not None: + setv( + to_object, + ['tools'], + [ + _Tool_to_vertex(item, to_object, root_object) + for item in getv(from_object, ['tools']) + ], + ) + return to_object @@ -1893,6 +1968,132 @@ def _SpeechConfig_to_vertex( return to_object +def _Tool_to_vertex( + from_object: Union[dict[str, Any], object], + parent_object: Optional[dict[str, Any]] = None, + root_object: Optional[Union[dict[str, Any], object]] = None, +) -> dict[str, Any]: + to_object: dict[str, Any] = {} + if getv(from_object, ['retrieval']) is not None: + setv(to_object, ['retrieval'], getv(from_object, ['retrieval'])) + + if getv(from_object, ['computer_use']) is not None: + setv( + to_object, + ['computerUse'], + _ComputerUse_to_vertex( + getv(from_object, ['computer_use']), to_object, root_object + ), + ) + + if getv(from_object, ['file_search']) is not None: + raise ValueError( + '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: + setv(to_object, ['googleSearch'], getv(from_object, ['google_search'])) + + if getv(from_object, ['google_maps']) is not None: + setv(to_object, ['googleMaps'], getv(from_object, ['google_maps'])) + + if getv(from_object, ['code_execution']) is not None: + setv(to_object, ['codeExecution'], getv(from_object, ['code_execution'])) + + if getv(from_object, ['enterprise_web_search']) is not None: + setv( + to_object, + ['enterpriseWebSearch'], + getv(from_object, ['enterprise_web_search']), + ) + + if getv(from_object, ['function_declarations']) is not None: + setv( + to_object, + ['functionDeclarations'], + [item for item in getv(from_object, ['function_declarations'])], + ) + + if getv(from_object, ['google_search_retrieval']) is not None: + setv( + to_object, + ['googleSearchRetrieval'], + getv(from_object, ['google_search_retrieval']), + ) + + if getv(from_object, ['parallel_ai_search']) is not None: + setv( + to_object, + ['parallelAiSearch'], + getv(from_object, ['parallel_ai_search']), + ) + + if getv(from_object, ['url_context']) is not None: + setv(to_object, ['urlContext'], getv(from_object, ['url_context'])) + + if getv(from_object, ['mcp_servers']) is not None: + setv( + to_object, + ['mcpServers'], + [ + _McpServer_to_vertex(item, to_object, root_object) + for item in getv(from_object, ['mcp_servers']) + ], + ) + + if getv(from_object, ['exa_ai_search']) is not None: + setv(to_object, ['exaAiSearch'], getv(from_object, ['exa_ai_search'])) + + return to_object + + +def _TranslationConfig_from_vertex( + from_object: Union[dict[str, Any], object], + parent_object: Optional[dict[str, Any]] = None, + root_object: Optional[Union[dict[str, Any], object]] = None, +) -> dict[str, Any]: + to_object: dict[str, Any] = {} + if getv(from_object, ['echoTargetLanguage']) is not None: + setv( + to_object, + ['echo_target_language'], + getv(from_object, ['echoTargetLanguage']), + ) + + if getv(from_object, ['targetLanguageCode']) is not None: + setv( + to_object, + ['target_language_code'], + getv(from_object, ['targetLanguageCode']), + ) + + return to_object + + +def _TranslationConfig_to_vertex( + from_object: Union[dict[str, Any], object], + parent_object: Optional[dict[str, Any]] = None, + root_object: Optional[Union[dict[str, Any], object]] = None, +) -> dict[str, Any]: + to_object: dict[str, Any] = {} + if getv(from_object, ['echo_target_language']) is not None: + setv( + to_object, + ['echoTargetLanguage'], + getv(from_object, ['echo_target_language']), + ) + + if getv(from_object, ['target_language_code']) is not None: + setv( + to_object, + ['targetLanguageCode'], + getv(from_object, ['target_language_code']), + ) + + return to_object + + def _TunedModel_from_mldev( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, diff --git a/google/genai/types.py b/google/genai/types.py index 24d739ee8..a6041d8e9 100644 --- a/google/genai/types.py +++ b/google/genai/types.py @@ -173,6 +173,17 @@ def __getattr__(name: str) -> Any: MetricSubclass = typing.TypeVar('MetricSubclass', bound='Metric') +class MediaProcessing(_common.CaseInSensitiveEnum): + """How the model processes input media for understanding.""" + + MEDIA_PROCESSING_UNSPECIFIED = 'MEDIA_PROCESSING_UNSPECIFIED' + """Default. Uses model-specific processing""" + STATIC = 'STATIC' + """Fixed-rate frame extraction. All frames placed in context.""" + AGENTIC = 'AGENTIC' + """Model-driven dynamic navigation. Recommended for most use cases.""" + + class Outcome(_common.CaseInSensitiveEnum): """Outcome of the code execution.""" @@ -485,6 +496,25 @@ class FunctionCallingConfigMode(_common.CaseInSensitiveEnum): """Model is constrained to predict either function calls or natural language response. If "allowed_function_names" are set, the predicted function calls will be limited to any one of "allowed_function_names", else the predicted function calls will be any one of the provided "function_declarations".""" +class Mode(_common.CaseInSensitiveEnum): + """Configures transcription mode. + + Supported values: `VERBATIM`, `SMART`. If unspecified, defaults to `VERBATIM` + transcription. In `SMART` mode, the model performs disfluency removal + (eliminating filler words, repetitions, and false starts), light grammatical + cleanup, automatic formatting (paragraphs, bullet points, numbered lists), and + minor user edits (inline self-corrections). Timestamps and diarization are + incompatible with mode `SMART`. This enum is not supported in Vertex AI. + """ + + MODE_UNSPECIFIED = 'MODE_UNSPECIFIED' + """Unspecified transcription mode.""" + VERBATIM = 'VERBATIM' + """Verbatim transcription mode.""" + SMART = 'SMART' + """Smart transcription mode.""" + + class FinishReason(_common.CaseInSensitiveEnum): """Output only. The reason why the model stopped generating tokens. @@ -613,6 +643,8 @@ class TrafficType(_common.CaseInSensitiveEnum): """Type for Priority Pay-As-You-Go traffic.""" ON_DEMAND_FLEX = 'ON_DEMAND_FLEX' """Type for Flex traffic.""" + ON_DEMAND_OFFPEAK = 'ON_DEMAND_OFFPEAK' + """Type for Off-Peak Pay-As-You-Go traffic.""" PROVISIONED_THROUGHPUT = 'PROVISIONED_THROUGHPUT' """Type for Provisioned Throughput traffic.""" @@ -1013,17 +1045,6 @@ class ComputationBasedMetricType(_common.CaseInSensitiveEnum): """ROUGE metric.""" -class MediaProcessing(_common.CaseInSensitiveEnum): - """How the model processes input media for understanding.""" - - MEDIA_PROCESSING_UNSPECIFIED = 'MEDIA_PROCESSING_UNSPECIFIED' - """Default. Uses model-specific processing""" - STATIC = 'STATIC' - """Fixed-rate frame extraction. All frames placed in context.""" - AGENTIC = 'AGENTIC' - """Model-driven dynamic navigation. Recommended for most use cases.""" - - class PartMediaResolutionLevel(_common.CaseInSensitiveEnum): """The tokenization quality used for given media.""" @@ -1704,7 +1725,7 @@ class FileData(_common.BaseModel): display_name: Optional[str] = Field( default=None, - description="""Optional. The display name of the file. Used to provide a label or filename to distinguish files. This field is only returned in `PromptMessage` for prompt management. It is used in the Gemini calls only when server side tools (`code_execution`, `google_search`, and `url_context`) are enabled. This field is not supported in Gemini API.""", + description="""Optional. The display name of the file. Used to provide a label or filename to distinguish files. This field is only returned in `PromptMessage` for prompt management. It is used in the Gemini calls only when server side tools (`code_execution`, `google_search`, and `url_context`) are enabled.""", ) file_uri: Optional[str] = Field( default=None, @@ -1725,7 +1746,7 @@ class FileDataDict(TypedDict, total=False): """ display_name: Optional[str] - """Optional. The display name of the file. Used to provide a label or filename to distinguish files. This field is only returned in `PromptMessage` for prompt management. It is used in the Gemini calls only when server side tools (`code_execution`, `google_search`, and `url_context`) are enabled. This field is not supported in Gemini API.""" + """Optional. The display name of the file. Used to provide a label or filename to distinguish files. This field is only returned in `PromptMessage` for prompt management. It is used in the Gemini calls only when server side tools (`code_execution`, `google_search`, and `url_context`) are enabled.""" file_uri: Optional[str] """Required. The URI of the file in Google Cloud Storage.""" @@ -2087,7 +2108,7 @@ class Blob(_common.BaseModel): ) display_name: Optional[str] = Field( default=None, - description="""Optional. The display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in `PromptMessage` for prompt management. It is used in the Gemini calls only when server-side tools (`code_execution`, `google_search`, and `url_context`) are enabled. This field is not supported in Gemini API.""", + description="""Optional. The display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in `PromptMessage` for prompt management. It is used in the Gemini calls only when server-side tools (`code_execution`, `google_search`, and `url_context`) are enabled.""", ) mime_type: Optional[str] = Field( default=None, @@ -2119,7 +2140,7 @@ class BlobDict(TypedDict, total=False): """Required. The raw bytes of the data.""" display_name: Optional[str] - """Optional. The display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in `PromptMessage` for prompt management. It is used in the Gemini calls only when server-side tools (`code_execution`, `google_search`, and `url_context`) are enabled. This field is not supported in Gemini API.""" + """Optional. The display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in `PromptMessage` for prompt management. It is used in the Gemini calls only when server-side tools (`code_execution`, `google_search`, and `url_context`) are enabled.""" mime_type: Optional[str] """Required. The IANA standard MIME type of the source data.""" @@ -5241,7 +5262,7 @@ class StreamableHttpTransportDict(TypedDict, total=False): class McpServer(_common.BaseModel): """A MCPServer is a server that can be called by the model to perform actions. - It is a server that implements the MCP protocol. Next ID: 6. This data type is + It is a server that implements the MCP protocol. Next ID: 7. This data type is not supported in Vertex AI. """ @@ -5257,7 +5278,7 @@ class McpServer(_common.BaseModel): class McpServerDict(TypedDict, total=False): """A MCPServer is a server that can be called by the model to perform actions. - It is a server that implements the MCP protocol. Next ID: 6. This data type is + It is a server that implements the MCP protocol. Next ID: 7. This data type is not supported in Vertex AI. """ @@ -6374,7 +6395,7 @@ class AudioTranscriptionConfig(_common.BaseModel): language_codes: Optional[list[str]] = Field( default=None, - description="""BCP-47 language codes providing hints about the languages present in the audio. If omitted or empty, defaults to automatic language detection.""", + description="""Optional. BCP-47 language codes providing hints about the languages present in the audio. If omitted or empty, defaults to automatic language detection.""", ) language_auto: Optional[LanguageAuto] = Field( default=None, @@ -6412,7 +6433,7 @@ class AudioTranscriptionConfigDict(TypedDict, total=False): """The audio transcription configuration in Setup.""" language_codes: Optional[list[str]] - """BCP-47 language codes providing hints about the languages present in the audio. If omitted or empty, defaults to automatic language detection.""" + """Optional. BCP-47 language codes providing hints about the languages present in the audio. If omitted or empty, defaults to automatic language detection.""" language_auto: Optional[LanguageAutoDict] """Deprecated: Auto-detection is now the default when language_codes is omitted. This field will be removed in a future version.""" @@ -11324,6 +11345,10 @@ class VideoResponseFormat(_common.BaseModel): default=None, description="""Optional. The Google Cloud Storage URI to store the video output. Required for Vertex if delivery is URI.""", ) + resolution: Optional[str] = Field( + default=None, + description="""Optional. The video output resolution. Supported values: "360p", "720p", "1080p", "4k".""", + ) class VideoResponseFormatDict(TypedDict, total=False): @@ -11344,6 +11369,9 @@ class VideoResponseFormatDict(TypedDict, total=False): gcs_uri: Optional[str] """Optional. The Google Cloud Storage URI to store the video output. Required for Vertex if delivery is URI.""" + resolution: Optional[str] + """Optional. The video output resolution. Supported values: "360p", "720p", "1080p", "4k".""" + VideoResponseFormatOrDict = Union[VideoResponseFormat, VideoResponseFormatDict] @@ -11516,8 +11544,7 @@ class GenerationConfig(_common.BaseModel): description="""Optional. New response format field for the model to configure output formatting and delivery.""", ) translation_config: Optional[TranslationConfig] = Field( - default=None, - description="""Optional. Config for translation. This field is not supported in Vertex AI.""", + default=None, description="""Optional. Config for translation.""" ) audio_transcription_config: Optional[AudioTranscriptionConfig] = Field( default=None, @@ -11604,7 +11631,7 @@ class GenerationConfigDict(TypedDict, total=False): """Optional. New response format field for the model to configure output formatting and delivery.""" translation_config: Optional[TranslationConfigDict] - """Optional. Config for translation. This field is not supported in Vertex AI.""" + """Optional. Config for translation.""" audio_transcription_config: Optional[AudioTranscriptionConfigDict] """Optional. Configuration for audio transcription (speech recognition). @@ -14062,6 +14089,10 @@ class ReinforcementTuningExample(_common.BaseModel): default=None, description="""Corresponds to system_instruction in user-facing GenerateContentRequest.""", ) + tools: Optional[list[Tool]] = Field( + default=None, + description="""Optional. Corresponds to tools in user-facing GenerateContentRequest.""", + ) class ReinforcementTuningExampleDict(TypedDict, total=False): @@ -14076,6 +14107,9 @@ class ReinforcementTuningExampleDict(TypedDict, total=False): system_instruction: Optional[ContentDict] """Corresponds to system_instruction in user-facing GenerateContentRequest.""" + tools: Optional[list[ToolDict]] + """Optional. Corresponds to tools in user-facing GenerateContentRequest.""" + ReinforcementTuningExampleOrDict = Union[ ReinforcementTuningExample, ReinforcementTuningExampleDict @@ -16364,6 +16398,10 @@ class ReinforcementTuningRewardInfo(_common.BaseModel): default=None, description="""Output only. The user-requested auxiliary info for the reward function. This field is set only if the Cloud Run reward function configured by user returns a "user_requested_aux_info". Refer to ReinforcementTuningCloudRunRewardScorer for more details.""", ) + error_status: Optional[GoogleRpcStatus] = Field( + default=None, + description="""Output only. In case of an error for this reward, this field will be populated with a detailed error status.""", + ) class ReinforcementTuningRewardInfoDict(TypedDict, total=False): @@ -16375,6 +16413,9 @@ class ReinforcementTuningRewardInfoDict(TypedDict, total=False): user_requested_aux_info: Optional[str] """Output only. The user-requested auxiliary info for the reward function. This field is set only if the Cloud Run reward function configured by user returns a "user_requested_aux_info". Refer to ReinforcementTuningCloudRunRewardScorer for more details.""" + error_status: Optional[GoogleRpcStatusDict] + """Output only. In case of an error for this reward, this field will be populated with a detailed error status.""" + ReinforcementTuningRewardInfoOrDict = Union[ ReinforcementTuningRewardInfo, ReinforcementTuningRewardInfoDict @@ -23094,6 +23135,10 @@ class EvaluationParserConfigCustomCodeParserConfig(_common.BaseModel): default=None, description="""Required. Python function for parsing results. The function should be defined within this string. The function takes a list of strings (LLM responses) and should return either a list of dictionaries (for rubrics) or a single dictionary (for a metric result). Example function signature: def parse(responses: list[str]) -> list[dict[str, Any]] | dict[str, Any]: When parsing rubrics, return a list of dictionaries, where each dictionary represents a Rubric. Example for rubrics: [ { "content": {"property": {"description": "The response is factual."}}, "type": "FACTUALITY", "importance": "HIGH" }, { "content": {"property": {"description": "The response is fluent."}}, "type": "FLUENCY", "importance": "MEDIUM" } ] When parsing critique results, return a dictionary representing a MetricResult. Example for a metric result: { "score": 0.8, "explanation": "The model followed most instructions.", "rubric_verdicts": [...] } ... code for result extraction and aggregation""", ) + code_execution_region: Optional[str] = Field( + default=None, + description="""Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. Supported regions: northamerica-northeast1, southamerica-east1, us-central1, us-east1, us-east4, us-west1, us-west4, europe-central2, europe-north1, europe-southwest1, europe-west1, europe-west2, europe-west3, europe-west4, europe-west6, europe-west8, europe-west9, me-west1, asia-east1, asia-east2, asia-northeast1, asia-northeast3, asia-south1, asia-south2, asia-southeast1, australia-southeast2. If unset, the request's originating region is used.""", + ) class EvaluationParserConfigCustomCodeParserConfigDict(TypedDict, total=False): @@ -23105,6 +23150,9 @@ class EvaluationParserConfigCustomCodeParserConfigDict(TypedDict, total=False): parsing_function: Optional[str] """Required. Python function for parsing results. The function should be defined within this string. The function takes a list of strings (LLM responses) and should return either a list of dictionaries (for rubrics) or a single dictionary (for a metric result). Example function signature: def parse(responses: list[str]) -> list[dict[str, Any]] | dict[str, Any]: When parsing rubrics, return a list of dictionaries, where each dictionary represents a Rubric. Example for rubrics: [ { "content": {"property": {"description": "The response is factual."}}, "type": "FACTUALITY", "importance": "HIGH" }, { "content": {"property": {"description": "The response is fluent."}}, "type": "FLUENCY", "importance": "MEDIUM" } ] When parsing critique results, return a dictionary representing a MetricResult. Example for a metric result: { "score": 0.8, "explanation": "The model followed most instructions.", "rubric_verdicts": [...] } ... code for result extraction and aggregation""" + code_execution_region: Optional[str] + """Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. Supported regions: northamerica-northeast1, southamerica-east1, us-central1, us-east1, us-east4, us-west1, us-west4, europe-central2, europe-north1, europe-southwest1, europe-west1, europe-west2, europe-west3, europe-west4, europe-west6, europe-west8, europe-west9, me-west1, asia-east1, asia-east2, asia-northeast1, asia-northeast3, asia-south1, asia-south2, asia-southeast1, australia-southeast2. If unset, the request's originating region is used.""" + EvaluationParserConfigCustomCodeParserConfigOrDict = Union[ EvaluationParserConfigCustomCodeParserConfig, @@ -23228,6 +23276,10 @@ def evaluate(instance: dict[str, Any]) -> float: Instance is the evaluation instance, any fields populated in the instance are available to the function as instance[field_name].""", ) + code_execution_region: Optional[str] = Field( + default=None, + description="""Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. Supported regions: northamerica-northeast1, southamerica-east1, us-central1, us-east1, us-east4, us-west1, us-west4, europe-central2, europe-north1, europe-southwest1, europe-west1, europe-west2, europe-west3, europe-west4, europe-west6, europe-west8, europe-west9, me-west1, asia-east1, asia-east2, asia-northeast1, asia-northeast3, asia-south1, asia-south2, asia-southeast1, australia-southeast2. If unset, the request's originating region is used; requests from regions where the sandbox is unavailable will fail with UNIMPLEMENTED.""", + ) class CustomCodeExecutionSpecDict(TypedDict, total=False): @@ -23241,6 +23293,9 @@ def evaluate(instance: dict[str, Any]) -> float: Instance is the evaluation instance, any fields populated in the instance are available to the function as instance[field_name].""" + code_execution_region: Optional[str] + """Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. Supported regions: northamerica-northeast1, southamerica-east1, us-central1, us-east1, us-east4, us-west1, us-west4, europe-central2, europe-north1, europe-southwest1, europe-west1, europe-west2, europe-west3, europe-west4, europe-west6, europe-west8, europe-west9, me-west1, asia-east1, asia-east2, asia-northeast1, asia-northeast3, asia-south1, asia-south2, asia-southeast1, australia-southeast2. If unset, the request's originating region is used; requests from regions where the sandbox is unavailable will fail with UNIMPLEMENTED.""" + CustomCodeExecutionSpecOrDict = Union[ CustomCodeExecutionSpec, CustomCodeExecutionSpecDict