From 1e7c386a940da12ee351f8f037725767b628f88a Mon Sep 17 00:00:00 2001 From: Ayush Agrawal Date: Mon, 15 Jun 2026 11:16:06 -0700 Subject: [PATCH] chore: internal change PiperOrigin-RevId: 932565662 --- google/genai/_live_converters.py | 232 ++-- google/genai/_tokens_converters.py | 72 +- google/genai/batches.py | 139 +-- google/genai/caches.py | 164 +-- google/genai/models.py | 205 ++-- google/genai/tunings.py | 162 +-- google/genai/types.py | 1632 ++++++++++++++-------------- 7 files changed, 1304 insertions(+), 1302 deletions(-) diff --git a/google/genai/_live_converters.py b/google/genai/_live_converters.py index cf8331dd8..a81fb3f00 100644 --- a/google/genai/_live_converters.py +++ b/google/genai/_live_converters.py @@ -142,6 +142,13 @@ def _ComputerUse_to_vertex( parent_object: Optional[dict[str, Any]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} + 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, ['environment']) is not None: setv(to_object, ['environment'], getv(from_object, ['environment'])) @@ -152,13 +159,6 @@ def _ComputerUse_to_vertex( 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' @@ -255,12 +255,12 @@ def _FunctionCall_to_mldev( parent_object: Optional[dict[str, Any]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['id']) is not None: - setv(to_object, ['id'], getv(from_object, ['id'])) - if getv(from_object, ['args']) is not None: setv(to_object, ['args'], getv(from_object, ['args'])) + if getv(from_object, ['id']) is not None: + setv(to_object, ['id'], getv(from_object, ['id'])) + if getv(from_object, ['name']) is not None: setv(to_object, ['name'], getv(from_object, ['name'])) @@ -422,9 +422,6 @@ def _GoogleSearch_to_mldev( parent_object: Optional[dict[str, Any]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['search_types']) is not None: - setv(to_object, ['searchTypes'], getv(from_object, ['search_types'])) - if getv(from_object, ['blocking_confidence']) is not None: raise ValueError( 'blocking_confidence parameter is only supported in Gemini Enterprise' @@ -437,6 +434,9 @@ def _GoogleSearch_to_mldev( ' Platform mode, not in Gemini Developer API mode.' ) + if getv(from_object, ['search_types']) is not None: + setv(to_object, ['searchTypes'], getv(from_object, ['search_types'])) + if getv(from_object, ['time_range_filter']) is not None: setv( to_object, ['timeRangeFilter'], getv(from_object, ['time_range_filter']) @@ -717,15 +717,15 @@ def _LiveClientSetup_to_mldev( if getv(from_object, ['proactivity']) is not None: setv(to_object, ['proactivity'], getv(from_object, ['proactivity'])) + if getv(from_object, ['history_config']) is not None: + setv(to_object, ['historyConfig'], getv(from_object, ['history_config'])) + if getv(from_object, ['explicit_vad_signal']) is not None: raise ValueError( '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: - setv(to_object, ['historyConfig'], getv(from_object, ['history_config'])) - if getv(from_object, ['avatar_config']) is not None: setv(to_object, ['avatarConfig'], getv(from_object, ['avatar_config'])) @@ -810,6 +810,9 @@ def _LiveClientSetup_to_vertex( if getv(from_object, ['proactivity']) is not None: setv(to_object, ['proactivity'], getv(from_object, ['proactivity'])) + if getv(from_object, ['history_config']) is not None: + setv(to_object, ['historyConfig'], getv(from_object, ['history_config'])) + if getv(from_object, ['explicit_vad_signal']) is not None: setv( to_object, @@ -817,9 +820,6 @@ def _LiveClientSetup_to_vertex( getv(from_object, ['explicit_vad_signal']), ) - if getv(from_object, ['history_config']) is not None: - setv(to_object, ['historyConfig'], getv(from_object, ['history_config'])) - if getv(from_object, ['avatar_config']) is not None: setv(to_object, ['avatarConfig'], getv(from_object, ['avatar_config'])) @@ -984,12 +984,6 @@ def _LiveConnectConfig_to_mldev( getv(from_object, ['proactivity']), ) - if getv(from_object, ['explicit_vad_signal']) is not None: - raise ValueError( - '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: setv( parent_object, @@ -997,6 +991,12 @@ def _LiveConnectConfig_to_mldev( getv(from_object, ['history_config']), ) + if getv(from_object, ['explicit_vad_signal']) is not None: + raise ValueError( + 'explicit_vad_signal parameter is only supported in Gemini Enterprise' + ' Agent Platform mode, not in Gemini Developer API mode.' + ) + if getv(from_object, ['avatar_config']) is not None: setv( parent_object, @@ -1174,18 +1174,18 @@ def _LiveConnectConfig_to_vertex( getv(from_object, ['proactivity']), ) - if getv(from_object, ['explicit_vad_signal']) is not None: + if getv(from_object, ['history_config']) is not None: setv( parent_object, - ['setup', 'explicitVadSignal'], - getv(from_object, ['explicit_vad_signal']), + ['setup', 'historyConfig'], + getv(from_object, ['history_config']), ) - if getv(from_object, ['history_config']) is not None: + if getv(from_object, ['explicit_vad_signal']) is not None: setv( parent_object, - ['setup', 'historyConfig'], - getv(from_object, ['history_config']), + ['setup', 'explicitVadSignal'], + getv(from_object, ['explicit_vad_signal']), ) if getv(from_object, ['avatar_config']) is not None: @@ -1613,6 +1613,12 @@ def _Part_to_mldev( to_object, ['mediaResolution'], getv(from_object, ['media_resolution']) ) + if getv(from_object, ['tool_call']) is not None: + setv(to_object, ['toolCall'], getv(from_object, ['tool_call'])) + + if getv(from_object, ['tool_response']) is not None: + setv(to_object, ['toolResponse'], getv(from_object, ['tool_response'])) + if getv(from_object, ['code_execution_result']) is not None: setv( to_object, @@ -1667,12 +1673,6 @@ def _Part_to_mldev( if getv(from_object, ['video_metadata']) is not None: setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata'])) - if getv(from_object, ['tool_call']) is not None: - setv(to_object, ['toolCall'], getv(from_object, ['tool_call'])) - - if getv(from_object, ['tool_response']) is not None: - setv(to_object, ['toolResponse'], getv(from_object, ['tool_response'])) - if getv(from_object, ['part_metadata']) is not None: setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata'])) @@ -1689,6 +1689,18 @@ def _Part_to_vertex( to_object, ['mediaResolution'], getv(from_object, ['media_resolution']) ) + if getv(from_object, ['tool_call']) is not None: + raise ValueError( + '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 only supported in Gemini Developer API' + ' mode, not in Gemini Enterprise Agent Platform mode.' + ) + if getv(from_object, ['code_execution_result']) is not None: setv( to_object, @@ -1739,18 +1751,6 @@ def _Part_to_vertex( if getv(from_object, ['video_metadata']) is not None: setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata'])) - if getv(from_object, ['tool_call']) is not None: - raise ValueError( - '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 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 only supported in Gemini Developer API' @@ -1883,29 +1883,26 @@ def _Tool_to_mldev( ' 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'])) - - if getv(from_object, ['file_search']) is not None: - setv(to_object, ['fileSearch'], getv(from_object, ['file_search'])) - - if getv(from_object, ['google_search']) is not None: + if getv(from_object, ['google_maps']) is not None: setv( to_object, - ['googleSearch'], - _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object), + ['googleMaps'], + _GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object), ) - if getv(from_object, ['google_maps']) is not None: + if getv(from_object, ['mcp_servers']) is not None: setv( to_object, - ['googleMaps'], - _GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object), + ['mcpServers'], + [item for item in getv(from_object, ['mcp_servers'])], ) if getv(from_object, ['code_execution']) is not None: setv(to_object, ['codeExecution'], getv(from_object, ['code_execution'])) + if getv(from_object, ['computer_use']) is not None: + setv(to_object, ['computerUse'], getv(from_object, ['computer_use'])) + if getv(from_object, ['enterprise_web_search']) is not None: raise ValueError( 'enterprise_web_search parameter is only supported in Gemini Enterprise' @@ -1919,6 +1916,13 @@ def _Tool_to_mldev( [item for item in getv(from_object, ['function_declarations'])], ) + if getv(from_object, ['google_search']) is not None: + setv( + to_object, + ['googleSearch'], + _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object), + ) + if getv(from_object, ['google_search_retrieval']) is not None: setv( to_object, @@ -1935,12 +1939,8 @@ def _Tool_to_mldev( 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'], - [item for item in getv(from_object, ['mcp_servers'])], - ) + if getv(from_object, ['file_search']) is not None: + setv(to_object, ['fileSearch'], getv(from_object, ['file_search'])) return to_object @@ -1953,28 +1953,29 @@ def _Tool_to_vertex( 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: + if getv(from_object, ['google_maps']) is not None: + setv(to_object, ['googleMaps'], getv(from_object, ['google_maps'])) + + if getv(from_object, ['mcp_servers']) is not None: setv( to_object, - ['computerUse'], - _ComputerUse_to_vertex(getv(from_object, ['computer_use']), to_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.' + ['mcpServers'], + [ + _McpServer_to_vertex(item, to_object) + for item in getv(from_object, ['mcp_servers']) + ], ) - 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, ['computer_use']) is not None: + setv( + to_object, + ['computerUse'], + _ComputerUse_to_vertex(getv(from_object, ['computer_use']), to_object), + ) + if getv(from_object, ['enterprise_web_search']) is not None: setv( to_object, @@ -1989,6 +1990,9 @@ def _Tool_to_vertex( [item for item in getv(from_object, ['function_declarations'])], ) + if getv(from_object, ['google_search']) is not None: + setv(to_object, ['googleSearch'], getv(from_object, ['google_search'])) + if getv(from_object, ['google_search_retrieval']) is not None: setv( to_object, @@ -2006,14 +2010,10 @@ def _Tool_to_vertex( 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) - for item in getv(from_object, ['mcp_servers']) - ], + 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.' ) return to_object @@ -2024,44 +2024,39 @@ def _UsageMetadata_from_vertex( parent_object: Optional[dict[str, Any]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['promptTokenCount']) is not None: + if getv(from_object, ['candidatesTokenCount']) is not None: setv( to_object, - ['prompt_token_count'], - getv(from_object, ['promptTokenCount']), + ['response_token_count'], + getv(from_object, ['candidatesTokenCount']), ) - if getv(from_object, ['cachedContentTokenCount']) is not None: + if getv(from_object, ['candidatesTokensDetails']) is not None: setv( to_object, - ['cached_content_token_count'], - getv(from_object, ['cachedContentTokenCount']), + ['response_tokens_details'], + [item for item in getv(from_object, ['candidatesTokensDetails'])], ) - if getv(from_object, ['candidatesTokenCount']) is not None: + if getv(from_object, ['cacheTokensDetails']) is not None: setv( to_object, - ['response_token_count'], - getv(from_object, ['candidatesTokenCount']), + ['cache_tokens_details'], + [item for item in getv(from_object, ['cacheTokensDetails'])], ) - if getv(from_object, ['toolUsePromptTokenCount']) is not None: + if getv(from_object, ['cachedContentTokenCount']) is not None: setv( to_object, - ['tool_use_prompt_token_count'], - getv(from_object, ['toolUsePromptTokenCount']), + ['cached_content_token_count'], + getv(from_object, ['cachedContentTokenCount']), ) - if getv(from_object, ['thoughtsTokenCount']) is not None: + if getv(from_object, ['promptTokenCount']) is not None: setv( to_object, - ['thoughts_token_count'], - getv(from_object, ['thoughtsTokenCount']), - ) - - if getv(from_object, ['totalTokenCount']) is not None: - setv( - to_object, ['total_token_count'], getv(from_object, ['totalTokenCount']) + ['prompt_token_count'], + getv(from_object, ['promptTokenCount']), ) if getv(from_object, ['promptTokensDetails']) is not None: @@ -2071,18 +2066,18 @@ def _UsageMetadata_from_vertex( [item for item in getv(from_object, ['promptTokensDetails'])], ) - if getv(from_object, ['cacheTokensDetails']) is not None: + if getv(from_object, ['thoughtsTokenCount']) is not None: setv( to_object, - ['cache_tokens_details'], - [item for item in getv(from_object, ['cacheTokensDetails'])], + ['thoughts_token_count'], + getv(from_object, ['thoughtsTokenCount']), ) - if getv(from_object, ['candidatesTokensDetails']) is not None: + if getv(from_object, ['toolUsePromptTokenCount']) is not None: setv( to_object, - ['response_tokens_details'], - [item for item in getv(from_object, ['candidatesTokensDetails'])], + ['tool_use_prompt_token_count'], + getv(from_object, ['toolUsePromptTokenCount']), ) if getv(from_object, ['toolUsePromptTokensDetails']) is not None: @@ -2092,6 +2087,11 @@ def _UsageMetadata_from_vertex( [item for item in getv(from_object, ['toolUsePromptTokensDetails'])], ) + if getv(from_object, ['totalTokenCount']) is not None: + setv( + to_object, ['total_token_count'], getv(from_object, ['totalTokenCount']) + ) + if getv(from_object, ['trafficType']) is not None: setv(to_object, ['traffic_type'], getv(from_object, ['trafficType'])) diff --git a/google/genai/_tokens_converters.py b/google/genai/_tokens_converters.py index d125fa5cd..a8fdee2e5 100644 --- a/google/genai/_tokens_converters.py +++ b/google/genai/_tokens_converters.py @@ -236,12 +236,12 @@ def _FunctionCall_to_mldev( parent_object: Optional[dict[str, Any]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['id']) is not None: - setv(to_object, ['id'], getv(from_object, ['id'])) - if getv(from_object, ['args']) is not None: setv(to_object, ['args'], getv(from_object, ['args'])) + if getv(from_object, ['id']) is not None: + setv(to_object, ['id'], getv(from_object, ['id'])) + if getv(from_object, ['name']) is not None: setv(to_object, ['name'], getv(from_object, ['name'])) @@ -283,9 +283,6 @@ def _GoogleSearch_to_mldev( parent_object: Optional[dict[str, Any]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['search_types']) is not None: - setv(to_object, ['searchTypes'], getv(from_object, ['search_types'])) - if getv(from_object, ['blocking_confidence']) is not None: raise ValueError( 'blocking_confidence parameter is only supported in Gemini Enterprise' @@ -298,6 +295,9 @@ def _GoogleSearch_to_mldev( ' Platform mode, not in Gemini Developer API mode.' ) + if getv(from_object, ['search_types']) is not None: + setv(to_object, ['searchTypes'], getv(from_object, ['search_types'])) + if getv(from_object, ['time_range_filter']) is not None: setv( to_object, ['timeRangeFilter'], getv(from_object, ['time_range_filter']) @@ -457,12 +457,6 @@ def _LiveConnectConfig_to_mldev( getv(from_object, ['proactivity']), ) - if getv(from_object, ['explicit_vad_signal']) is not None: - raise ValueError( - '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: setv( parent_object, @@ -470,6 +464,12 @@ def _LiveConnectConfig_to_mldev( getv(from_object, ['history_config']), ) + if getv(from_object, ['explicit_vad_signal']) is not None: + raise ValueError( + 'explicit_vad_signal parameter is only supported in Gemini Enterprise' + ' Agent Platform mode, not in Gemini Developer API mode.' + ) + if getv(from_object, ['avatar_config']) is not None: setv( parent_object, @@ -532,6 +532,12 @@ def _Part_to_mldev( to_object, ['mediaResolution'], getv(from_object, ['media_resolution']) ) + if getv(from_object, ['tool_call']) is not None: + setv(to_object, ['toolCall'], getv(from_object, ['tool_call'])) + + if getv(from_object, ['tool_response']) is not None: + setv(to_object, ['toolResponse'], getv(from_object, ['tool_response'])) + if getv(from_object, ['code_execution_result']) is not None: setv( to_object, @@ -586,12 +592,6 @@ def _Part_to_mldev( if getv(from_object, ['video_metadata']) is not None: setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata'])) - if getv(from_object, ['tool_call']) is not None: - setv(to_object, ['toolCall'], getv(from_object, ['tool_call'])) - - if getv(from_object, ['tool_response']) is not None: - setv(to_object, ['toolResponse'], getv(from_object, ['tool_response'])) - if getv(from_object, ['part_metadata']) is not None: setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata'])) @@ -646,29 +646,26 @@ def _Tool_to_mldev( ' 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'])) - - if getv(from_object, ['file_search']) is not None: - setv(to_object, ['fileSearch'], getv(from_object, ['file_search'])) - - if getv(from_object, ['google_search']) is not None: + if getv(from_object, ['google_maps']) is not None: setv( to_object, - ['googleSearch'], - _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object), + ['googleMaps'], + _GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object), ) - if getv(from_object, ['google_maps']) is not None: + if getv(from_object, ['mcp_servers']) is not None: setv( to_object, - ['googleMaps'], - _GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object), + ['mcpServers'], + [item for item in getv(from_object, ['mcp_servers'])], ) if getv(from_object, ['code_execution']) is not None: setv(to_object, ['codeExecution'], getv(from_object, ['code_execution'])) + if getv(from_object, ['computer_use']) is not None: + setv(to_object, ['computerUse'], getv(from_object, ['computer_use'])) + if getv(from_object, ['enterprise_web_search']) is not None: raise ValueError( 'enterprise_web_search parameter is only supported in Gemini Enterprise' @@ -682,6 +679,13 @@ def _Tool_to_mldev( [item for item in getv(from_object, ['function_declarations'])], ) + if getv(from_object, ['google_search']) is not None: + setv( + to_object, + ['googleSearch'], + _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object), + ) + if getv(from_object, ['google_search_retrieval']) is not None: setv( to_object, @@ -698,11 +702,7 @@ def _Tool_to_mldev( 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'], - [item for item in getv(from_object, ['mcp_servers'])], - ) + if getv(from_object, ['file_search']) is not None: + setv(to_object, ['fileSearch'], getv(from_object, ['file_search'])) return to_object diff --git a/google/genai/batches.py b/google/genai/batches.py index 79eb668b8..b3f66ae2b 100644 --- a/google/genai/batches.py +++ b/google/genai/batches.py @@ -177,6 +177,15 @@ def _BatchJobDestination_to_vertex( getv(from_object, ['bigquery_uri']), ) + if getv(from_object, ['vertex_dataset']) is not None: + setv( + to_object, + ['vertexMultimodalDatasetDestination'], + _VertexMultimodalDatasetDestination_to_vertex( + getv(from_object, ['vertex_dataset']), to_object + ), + ) + if getv(from_object, ['file_name']) is not None: raise ValueError( 'file_name parameter is only supported in Gemini Developer API mode,' @@ -195,15 +204,6 @@ def _BatchJobDestination_to_vertex( ' Developer API mode, not in Gemini Enterprise Agent Platform mode.' ) - if getv(from_object, ['vertex_dataset']) is not None: - setv( - to_object, - ['vertexMultimodalDatasetDestination'], - _VertexMultimodalDatasetDestination_to_vertex( - getv(from_object, ['vertex_dataset']), to_object - ), - ) - return to_object @@ -262,6 +262,12 @@ def _BatchJobSource_to_mldev( ' Platform mode, not in Gemini Developer API mode.' ) + if getv(from_object, ['vertex_dataset_name']) is not None: + raise ValueError( + 'vertex_dataset_name parameter is only supported in Gemini Enterprise' + ' Agent Platform mode, not in Gemini Developer API mode.' + ) + if getv(from_object, ['file_name']) is not None: setv(to_object, ['fileName'], getv(from_object, ['file_name'])) @@ -275,12 +281,6 @@ def _BatchJobSource_to_mldev( ], ) - if getv(from_object, ['vertex_dataset_name']) is not None: - raise ValueError( - 'vertex_dataset_name parameter is only supported in Gemini Enterprise' - ' Agent Platform mode, not in Gemini Developer API mode.' - ) - return to_object @@ -302,6 +302,13 @@ def _BatchJobSource_to_vertex( getv(from_object, ['bigquery_uri']), ) + if getv(from_object, ['vertex_dataset_name']) is not None: + setv( + to_object, + ['vertexMultimodalDatasetSource', 'datasetName'], + getv(from_object, ['vertex_dataset_name']), + ) + if getv(from_object, ['file_name']) is not None: raise ValueError( 'file_name parameter is only supported in Gemini Developer API mode,' @@ -314,13 +321,6 @@ def _BatchJobSource_to_vertex( ' mode, not in Gemini Enterprise Agent Platform mode.' ) - if getv(from_object, ['vertex_dataset_name']) is not None: - setv( - to_object, - ['vertexMultimodalDatasetSource', 'datasetName'], - getv(from_object, ['vertex_dataset_name']), - ) - return to_object @@ -432,14 +432,14 @@ def _BatchJob_from_vertex( ), ) + if getv(from_object, ['outputInfo']) is not None: + setv(to_object, ['output_info'], getv(from_object, ['outputInfo'])) + if getv(from_object, ['completionStats']) is not None: setv( to_object, ['completion_stats'], getv(from_object, ['completionStats']) ) - if getv(from_object, ['outputInfo']) is not None: - setv(to_object, ['output_info'], getv(from_object, ['outputInfo'])) - return to_object @@ -857,6 +857,7 @@ def _EmbedContentConfig_to_mldev( parent_object: Optional[dict[str, Any]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} + if getv(from_object, ['task_type']) is not None: setv( parent_object, @@ -947,12 +948,12 @@ def _FunctionCall_to_mldev( parent_object: Optional[dict[str, Any]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['id']) is not None: - setv(to_object, ['id'], getv(from_object, ['id'])) - if getv(from_object, ['args']) is not None: setv(to_object, ['args'], getv(from_object, ['args'])) + if getv(from_object, ['id']) is not None: + setv(to_object, ['id'], getv(from_object, ['id'])) + if getv(from_object, ['name']) is not None: setv(to_object, ['name'], getv(from_object, ['name'])) @@ -1002,6 +1003,9 @@ def _GenerateContentConfig_to_mldev( ) -> dict[str, Any]: to_object: dict[str, Any] = {} + if getv(from_object, ['service_tier']) is not None: + setv(parent_object, ['serviceTier'], getv(from_object, ['service_tier'])) + if getv(from_object, ['system_instruction']) is not None: setv( parent_object, @@ -1179,9 +1183,6 @@ def _GenerateContentConfig_to_mldev( ' Agent Platform mode, not in Gemini Developer API mode.' ) - if getv(from_object, ['service_tier']) is not None: - setv(parent_object, ['serviceTier'], getv(from_object, ['service_tier'])) - return to_object @@ -1278,9 +1279,6 @@ def _GoogleSearch_to_mldev( parent_object: Optional[dict[str, Any]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['search_types']) is not None: - setv(to_object, ['searchTypes'], getv(from_object, ['search_types'])) - if getv(from_object, ['blocking_confidence']) is not None: raise ValueError( 'blocking_confidence parameter is only supported in Gemini Enterprise' @@ -1293,6 +1291,9 @@ def _GoogleSearch_to_mldev( ' Platform mode, not in Gemini Developer API mode.' ) + if getv(from_object, ['search_types']) is not None: + setv(to_object, ['searchTypes'], getv(from_object, ['search_types'])) + if getv(from_object, ['time_range_filter']) is not None: setv( to_object, ['timeRangeFilter'], getv(from_object, ['time_range_filter']) @@ -1318,12 +1319,6 @@ def _ImageConfig_to_mldev( ' Agent Platform mode, not in Gemini Developer API mode.' ) - if getv(from_object, ['prominent_people']) is not None: - raise ValueError( - 'prominent_people parameter is only supported in Gemini Enterprise' - ' Agent Platform mode, not in Gemini Developer API mode.' - ) - if getv(from_object, ['output_mime_type']) is not None: raise ValueError( 'output_mime_type parameter is only supported in Gemini Enterprise' @@ -1342,6 +1337,12 @@ def _ImageConfig_to_mldev( ' Agent Platform mode, not in Gemini Developer API mode.' ) + if getv(from_object, ['prominent_people']) is not None: + raise ValueError( + 'prominent_people parameter is only supported in Gemini Enterprise' + ' Agent Platform mode, not in Gemini Developer API mode.' + ) + return to_object @@ -1543,6 +1544,12 @@ def _Part_to_mldev( to_object, ['mediaResolution'], getv(from_object, ['media_resolution']) ) + if getv(from_object, ['tool_call']) is not None: + setv(to_object, ['toolCall'], getv(from_object, ['tool_call'])) + + if getv(from_object, ['tool_response']) is not None: + setv(to_object, ['toolResponse'], getv(from_object, ['tool_response'])) + if getv(from_object, ['code_execution_result']) is not None: setv( to_object, @@ -1597,12 +1604,6 @@ def _Part_to_mldev( if getv(from_object, ['video_metadata']) is not None: setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata'])) - if getv(from_object, ['tool_call']) is not None: - setv(to_object, ['toolCall'], getv(from_object, ['tool_call'])) - - if getv(from_object, ['tool_response']) is not None: - setv(to_object, ['toolResponse'], getv(from_object, ['tool_response'])) - if getv(from_object, ['part_metadata']) is not None: setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata'])) @@ -1634,11 +1635,6 @@ def _ToolConfig_to_mldev( parent_object: Optional[dict[str, Any]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['retrieval_config']) is not None: - setv( - to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config']) - ) - if getv(from_object, ['function_calling_config']) is not None: setv( to_object, @@ -1648,6 +1644,11 @@ def _ToolConfig_to_mldev( ), ) + if getv(from_object, ['retrieval_config']) is not None: + setv( + to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config']) + ) + if getv(from_object, ['include_server_side_tool_invocations']) is not None: setv( to_object, @@ -1669,29 +1670,26 @@ def _Tool_to_mldev( ' 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'])) - - if getv(from_object, ['file_search']) is not None: - setv(to_object, ['fileSearch'], getv(from_object, ['file_search'])) - - if getv(from_object, ['google_search']) is not None: + if getv(from_object, ['google_maps']) is not None: setv( to_object, - ['googleSearch'], - _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object), + ['googleMaps'], + _GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object), ) - if getv(from_object, ['google_maps']) is not None: + if getv(from_object, ['mcp_servers']) is not None: setv( to_object, - ['googleMaps'], - _GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object), + ['mcpServers'], + [item for item in getv(from_object, ['mcp_servers'])], ) if getv(from_object, ['code_execution']) is not None: setv(to_object, ['codeExecution'], getv(from_object, ['code_execution'])) + if getv(from_object, ['computer_use']) is not None: + setv(to_object, ['computerUse'], getv(from_object, ['computer_use'])) + if getv(from_object, ['enterprise_web_search']) is not None: raise ValueError( 'enterprise_web_search parameter is only supported in Gemini Enterprise' @@ -1705,6 +1703,13 @@ def _Tool_to_mldev( [item for item in getv(from_object, ['function_declarations'])], ) + if getv(from_object, ['google_search']) is not None: + setv( + to_object, + ['googleSearch'], + _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object), + ) + if getv(from_object, ['google_search_retrieval']) is not None: setv( to_object, @@ -1721,12 +1726,8 @@ def _Tool_to_mldev( 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'], - [item for item in getv(from_object, ['mcp_servers'])], - ) + if getv(from_object, ['file_search']) is not None: + setv(to_object, ['fileSearch'], getv(from_object, ['file_search'])) return to_object diff --git a/google/genai/caches.py b/google/genai/caches.py index ea1f30f66..0378b1f38 100644 --- a/google/genai/caches.py +++ b/google/genai/caches.py @@ -124,6 +124,13 @@ def _ComputerUse_to_vertex( parent_object: Optional[dict[str, Any]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} + 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, ['environment']) is not None: setv(to_object, ['environment'], getv(from_object, ['environment'])) @@ -134,13 +141,6 @@ def _ComputerUse_to_vertex( 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' @@ -458,12 +458,12 @@ def _FunctionCall_to_mldev( parent_object: Optional[dict[str, Any]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['id']) is not None: - setv(to_object, ['id'], getv(from_object, ['id'])) - if getv(from_object, ['args']) is not None: setv(to_object, ['args'], getv(from_object, ['args'])) + if getv(from_object, ['id']) is not None: + setv(to_object, ['id'], getv(from_object, ['id'])) + if getv(from_object, ['name']) is not None: setv(to_object, ['name'], getv(from_object, ['name'])) @@ -561,9 +561,6 @@ def _GoogleSearch_to_mldev( parent_object: Optional[dict[str, Any]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['search_types']) is not None: - setv(to_object, ['searchTypes'], getv(from_object, ['search_types'])) - if getv(from_object, ['blocking_confidence']) is not None: raise ValueError( 'blocking_confidence parameter is only supported in Gemini Enterprise' @@ -576,6 +573,9 @@ def _GoogleSearch_to_mldev( ' Platform mode, not in Gemini Developer API mode.' ) + if getv(from_object, ['search_types']) is not None: + setv(to_object, ['searchTypes'], getv(from_object, ['search_types'])) + if getv(from_object, ['time_range_filter']) is not None: setv( to_object, ['timeRangeFilter'], getv(from_object, ['time_range_filter']) @@ -726,6 +726,12 @@ def _Part_to_mldev( to_object, ['mediaResolution'], getv(from_object, ['media_resolution']) ) + if getv(from_object, ['tool_call']) is not None: + setv(to_object, ['toolCall'], getv(from_object, ['tool_call'])) + + if getv(from_object, ['tool_response']) is not None: + setv(to_object, ['toolResponse'], getv(from_object, ['tool_response'])) + if getv(from_object, ['code_execution_result']) is not None: setv( to_object, @@ -780,12 +786,6 @@ def _Part_to_mldev( if getv(from_object, ['video_metadata']) is not None: setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata'])) - if getv(from_object, ['tool_call']) is not None: - setv(to_object, ['toolCall'], getv(from_object, ['tool_call'])) - - if getv(from_object, ['tool_response']) is not None: - setv(to_object, ['toolResponse'], getv(from_object, ['tool_response'])) - if getv(from_object, ['part_metadata']) is not None: setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata'])) @@ -802,6 +802,18 @@ def _Part_to_vertex( to_object, ['mediaResolution'], getv(from_object, ['media_resolution']) ) + if getv(from_object, ['tool_call']) is not None: + raise ValueError( + '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 only supported in Gemini Developer API' + ' mode, not in Gemini Enterprise Agent Platform mode.' + ) + if getv(from_object, ['code_execution_result']) is not None: setv( to_object, @@ -852,18 +864,6 @@ def _Part_to_vertex( if getv(from_object, ['video_metadata']) is not None: setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata'])) - if getv(from_object, ['tool_call']) is not None: - raise ValueError( - '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 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 only supported in Gemini Developer API' @@ -878,11 +878,6 @@ def _ToolConfig_to_mldev( parent_object: Optional[dict[str, Any]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['retrieval_config']) is not None: - setv( - to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config']) - ) - if getv(from_object, ['function_calling_config']) is not None: setv( to_object, @@ -892,6 +887,11 @@ def _ToolConfig_to_mldev( ), ) + if getv(from_object, ['retrieval_config']) is not None: + setv( + to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config']) + ) + if getv(from_object, ['include_server_side_tool_invocations']) is not None: setv( to_object, @@ -907,11 +907,6 @@ def _ToolConfig_to_vertex( parent_object: Optional[dict[str, Any]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['retrieval_config']) is not None: - setv( - to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config']) - ) - if getv(from_object, ['function_calling_config']) is not None: setv( to_object, @@ -919,6 +914,11 @@ def _ToolConfig_to_vertex( getv(from_object, ['function_calling_config']), ) + if getv(from_object, ['retrieval_config']) is not None: + setv( + to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config']) + ) + if getv(from_object, ['include_server_side_tool_invocations']) is not None: raise ValueError( 'include_server_side_tool_invocations parameter is only supported in' @@ -940,29 +940,26 @@ def _Tool_to_mldev( ' 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'])) - - if getv(from_object, ['file_search']) is not None: - setv(to_object, ['fileSearch'], getv(from_object, ['file_search'])) - - if getv(from_object, ['google_search']) is not None: + if getv(from_object, ['google_maps']) is not None: setv( to_object, - ['googleSearch'], - _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object), + ['googleMaps'], + _GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object), ) - if getv(from_object, ['google_maps']) is not None: + if getv(from_object, ['mcp_servers']) is not None: setv( to_object, - ['googleMaps'], - _GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object), + ['mcpServers'], + [item for item in getv(from_object, ['mcp_servers'])], ) if getv(from_object, ['code_execution']) is not None: setv(to_object, ['codeExecution'], getv(from_object, ['code_execution'])) + if getv(from_object, ['computer_use']) is not None: + setv(to_object, ['computerUse'], getv(from_object, ['computer_use'])) + if getv(from_object, ['enterprise_web_search']) is not None: raise ValueError( 'enterprise_web_search parameter is only supported in Gemini Enterprise' @@ -976,6 +973,13 @@ def _Tool_to_mldev( [item for item in getv(from_object, ['function_declarations'])], ) + if getv(from_object, ['google_search']) is not None: + setv( + to_object, + ['googleSearch'], + _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object), + ) + if getv(from_object, ['google_search_retrieval']) is not None: setv( to_object, @@ -992,12 +996,8 @@ def _Tool_to_mldev( 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'], - [item for item in getv(from_object, ['mcp_servers'])], - ) + if getv(from_object, ['file_search']) is not None: + setv(to_object, ['fileSearch'], getv(from_object, ['file_search'])) return to_object @@ -1010,28 +1010,29 @@ def _Tool_to_vertex( 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: + if getv(from_object, ['google_maps']) is not None: + setv(to_object, ['googleMaps'], getv(from_object, ['google_maps'])) + + if getv(from_object, ['mcp_servers']) is not None: setv( to_object, - ['computerUse'], - _ComputerUse_to_vertex(getv(from_object, ['computer_use']), to_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.' + ['mcpServers'], + [ + _McpServer_to_vertex(item, to_object) + for item in getv(from_object, ['mcp_servers']) + ], ) - 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, ['computer_use']) is not None: + setv( + to_object, + ['computerUse'], + _ComputerUse_to_vertex(getv(from_object, ['computer_use']), to_object), + ) + if getv(from_object, ['enterprise_web_search']) is not None: setv( to_object, @@ -1046,6 +1047,9 @@ def _Tool_to_vertex( [item for item in getv(from_object, ['function_declarations'])], ) + if getv(from_object, ['google_search']) is not None: + setv(to_object, ['googleSearch'], getv(from_object, ['google_search'])) + if getv(from_object, ['google_search_retrieval']) is not None: setv( to_object, @@ -1063,14 +1067,10 @@ def _Tool_to_vertex( 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) - for item in getv(from_object, ['mcp_servers']) - ], + 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.' ) return to_object diff --git a/google/genai/models.py b/google/genai/models.py index 9ff421480..b2a3e8b4c 100644 --- a/google/genai/models.py +++ b/google/genai/models.py @@ -280,6 +280,13 @@ def _ComputerUse_to_vertex( root_object: Optional[Union[dict[str, Any], object]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} + 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, ['environment']) is not None: setv(to_object, ['environment'], getv(from_object, ['environment'])) @@ -290,13 +297,6 @@ def _ComputerUse_to_vertex( 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' @@ -826,6 +826,7 @@ def _EmbedContentConfig_to_mldev( root_object: Optional[Union[dict[str, Any], object]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} + if getv(from_object, ['task_type']) is not None: setv( parent_object, @@ -1209,12 +1210,12 @@ def _FunctionCall_to_mldev( root_object: Optional[Union[dict[str, Any], object]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['id']) is not None: - setv(to_object, ['id'], getv(from_object, ['id'])) - if getv(from_object, ['args']) is not None: setv(to_object, ['args'], getv(from_object, ['args'])) + if getv(from_object, ['id']) is not None: + setv(to_object, ['id'], getv(from_object, ['id'])) + if getv(from_object, ['name']) is not None: setv(to_object, ['name'], getv(from_object, ['name'])) @@ -1266,6 +1267,9 @@ def _GenerateContentConfig_to_mldev( ) -> dict[str, Any]: to_object: dict[str, Any] = {} + if getv(from_object, ['service_tier']) is not None: + setv(parent_object, ['serviceTier'], getv(from_object, ['service_tier'])) + if getv(from_object, ['system_instruction']) is not None: setv( parent_object, @@ -1449,9 +1453,6 @@ def _GenerateContentConfig_to_mldev( ' Agent Platform mode, not in Gemini Developer API mode.' ) - if getv(from_object, ['service_tier']) is not None: - setv(parent_object, ['serviceTier'], getv(from_object, ['service_tier'])) - return to_object @@ -1463,6 +1464,9 @@ def _GenerateContentConfig_to_vertex( ) -> dict[str, Any]: to_object: dict[str, Any] = {} + if getv(from_object, ['service_tier']) is not None: + setv(parent_object, ['serviceTier'], getv(from_object, ['service_tier'])) + if getv(from_object, ['system_instruction']) is not None: setv( parent_object, @@ -1639,9 +1643,6 @@ def _GenerateContentConfig_to_vertex( getv(from_object, ['model_armor_config']), ) - if getv(from_object, ['service_tier']) is not None: - setv(parent_object, ['serviceTier'], getv(from_object, ['service_tier'])) - return to_object @@ -3040,9 +3041,6 @@ def _GoogleSearch_to_mldev( root_object: Optional[Union[dict[str, Any], object]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['search_types']) is not None: - setv(to_object, ['searchTypes'], getv(from_object, ['search_types'])) - if getv(from_object, ['blocking_confidence']) is not None: raise ValueError( 'blocking_confidence parameter is only supported in Gemini Enterprise' @@ -3055,6 +3053,9 @@ def _GoogleSearch_to_mldev( ' Platform mode, not in Gemini Developer API mode.' ) + if getv(from_object, ['search_types']) is not None: + setv(to_object, ['searchTypes'], getv(from_object, ['search_types'])) + if getv(from_object, ['time_range_filter']) is not None: setv( to_object, ['timeRangeFilter'], getv(from_object, ['time_range_filter']) @@ -3081,12 +3082,6 @@ def _ImageConfig_to_mldev( ' Agent Platform mode, not in Gemini Developer API mode.' ) - if getv(from_object, ['prominent_people']) is not None: - raise ValueError( - 'prominent_people parameter is only supported in Gemini Enterprise' - ' Agent Platform mode, not in Gemini Developer API mode.' - ) - if getv(from_object, ['output_mime_type']) is not None: raise ValueError( 'output_mime_type parameter is only supported in Gemini Enterprise' @@ -3105,6 +3100,12 @@ def _ImageConfig_to_mldev( ' Agent Platform mode, not in Gemini Developer API mode.' ) + if getv(from_object, ['prominent_people']) is not None: + raise ValueError( + 'prominent_people parameter is only supported in Gemini Enterprise' + ' Agent Platform mode, not in Gemini Developer API mode.' + ) + return to_object @@ -3127,11 +3128,6 @@ def _ImageConfig_to_vertex( getv(from_object, ['person_generation']), ) - if getv(from_object, ['prominent_people']) is not None: - setv( - to_object, ['prominentPeople'], getv(from_object, ['prominent_people']) - ) - if getv(from_object, ['output_mime_type']) is not None: setv( to_object, @@ -3153,6 +3149,11 @@ def _ImageConfig_to_vertex( getv(from_object, ['image_output_options']), ) + if getv(from_object, ['prominent_people']) is not None: + setv( + to_object, ['prominentPeople'], getv(from_object, ['prominent_people']) + ) + return to_object @@ -3581,6 +3582,12 @@ def _Part_to_mldev( to_object, ['mediaResolution'], getv(from_object, ['media_resolution']) ) + if getv(from_object, ['tool_call']) is not None: + setv(to_object, ['toolCall'], getv(from_object, ['tool_call'])) + + if getv(from_object, ['tool_response']) is not None: + setv(to_object, ['toolResponse'], getv(from_object, ['tool_response'])) + if getv(from_object, ['code_execution_result']) is not None: setv( to_object, @@ -3641,12 +3648,6 @@ def _Part_to_mldev( if getv(from_object, ['video_metadata']) is not None: setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata'])) - if getv(from_object, ['tool_call']) is not None: - setv(to_object, ['toolCall'], getv(from_object, ['tool_call'])) - - if getv(from_object, ['tool_response']) is not None: - setv(to_object, ['toolResponse'], getv(from_object, ['tool_response'])) - if getv(from_object, ['part_metadata']) is not None: setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata'])) @@ -3664,6 +3665,18 @@ def _Part_to_vertex( to_object, ['mediaResolution'], getv(from_object, ['media_resolution']) ) + if getv(from_object, ['tool_call']) is not None: + raise ValueError( + '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 only supported in Gemini Developer API' + ' mode, not in Gemini Enterprise Agent Platform mode.' + ) + if getv(from_object, ['code_execution_result']) is not None: setv( to_object, @@ -3714,18 +3727,6 @@ def _Part_to_vertex( if getv(from_object, ['video_metadata']) is not None: setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata'])) - if getv(from_object, ['tool_call']) is not None: - raise ValueError( - '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 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 only supported in Gemini Developer API' @@ -4262,11 +4263,6 @@ def _ToolConfig_to_mldev( root_object: Optional[Union[dict[str, Any], object]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['retrieval_config']) is not None: - setv( - to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config']) - ) - if getv(from_object, ['function_calling_config']) is not None: setv( to_object, @@ -4278,6 +4274,11 @@ def _ToolConfig_to_mldev( ), ) + if getv(from_object, ['retrieval_config']) is not None: + setv( + to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config']) + ) + if getv(from_object, ['include_server_side_tool_invocations']) is not None: setv( to_object, @@ -4294,11 +4295,6 @@ def _ToolConfig_to_vertex( root_object: Optional[Union[dict[str, Any], object]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['retrieval_config']) is not None: - setv( - to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config']) - ) - if getv(from_object, ['function_calling_config']) is not None: setv( to_object, @@ -4306,6 +4302,11 @@ def _ToolConfig_to_vertex( getv(from_object, ['function_calling_config']), ) + if getv(from_object, ['retrieval_config']) is not None: + setv( + to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config']) + ) + if getv(from_object, ['include_server_side_tool_invocations']) is not None: raise ValueError( 'include_server_side_tool_invocations parameter is only supported in' @@ -4328,21 +4329,6 @@ def _Tool_to_mldev( ' 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'])) - - if getv(from_object, ['file_search']) is not None: - setv(to_object, ['fileSearch'], getv(from_object, ['file_search'])) - - if getv(from_object, ['google_search']) is not None: - setv( - to_object, - ['googleSearch'], - _GoogleSearch_to_mldev( - getv(from_object, ['google_search']), to_object, root_object - ), - ) - if getv(from_object, ['google_maps']) is not None: setv( to_object, @@ -4352,9 +4338,19 @@ def _Tool_to_mldev( ), ) + if getv(from_object, ['mcp_servers']) is not None: + setv( + to_object, + ['mcpServers'], + [item for item in getv(from_object, ['mcp_servers'])], + ) + if getv(from_object, ['code_execution']) is not None: setv(to_object, ['codeExecution'], getv(from_object, ['code_execution'])) + if getv(from_object, ['computer_use']) is not None: + setv(to_object, ['computerUse'], getv(from_object, ['computer_use'])) + if getv(from_object, ['enterprise_web_search']) is not None: raise ValueError( 'enterprise_web_search parameter is only supported in Gemini Enterprise' @@ -4368,6 +4364,15 @@ def _Tool_to_mldev( [item for item in getv(from_object, ['function_declarations'])], ) + if getv(from_object, ['google_search']) is not None: + setv( + to_object, + ['googleSearch'], + _GoogleSearch_to_mldev( + getv(from_object, ['google_search']), to_object, root_object + ), + ) + if getv(from_object, ['google_search_retrieval']) is not None: setv( to_object, @@ -4384,12 +4389,8 @@ def _Tool_to_mldev( 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'], - [item for item in getv(from_object, ['mcp_servers'])], - ) + if getv(from_object, ['file_search']) is not None: + setv(to_object, ['fileSearch'], getv(from_object, ['file_search'])) return to_object @@ -4403,6 +4404,22 @@ def _Tool_to_vertex( if getv(from_object, ['retrieval']) is not None: setv(to_object, ['retrieval'], getv(from_object, ['retrieval'])) + if getv(from_object, ['google_maps']) is not None: + setv(to_object, ['googleMaps'], getv(from_object, ['google_maps'])) + + 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, ['code_execution']) is not None: + setv(to_object, ['codeExecution'], getv(from_object, ['code_execution'])) + if getv(from_object, ['computer_use']) is not None: setv( to_object, @@ -4412,21 +4429,6 @@ def _Tool_to_vertex( ), ) - 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, @@ -4441,6 +4443,9 @@ def _Tool_to_vertex( [item for item in getv(from_object, ['function_declarations'])], ) + if getv(from_object, ['google_search']) is not None: + setv(to_object, ['googleSearch'], getv(from_object, ['google_search'])) + if getv(from_object, ['google_search_retrieval']) is not None: setv( to_object, @@ -4458,14 +4463,10 @@ def _Tool_to_vertex( 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, ['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.' ) return to_object diff --git a/google/genai/tunings.py b/google/genai/tunings.py index 8f14e96b9..a92d80cb8 100644 --- a/google/genai/tunings.py +++ b/google/genai/tunings.py @@ -390,12 +390,6 @@ def _CreateTuningJobConfig_to_mldev( ' Platform mode, not in Gemini Developer API mode.' ) - if getv(from_object, ['encryption_spec']) is not None: - raise ValueError( - 'encryption_spec parameter is only supported in Gemini Enterprise Agent' - ' Platform mode, not in Gemini Developer API mode.' - ) - if getv(from_object, ['reward_config']) is not None: raise ValueError( 'reward_config parameter is only supported in Gemini Enterprise Agent' @@ -444,6 +438,12 @@ def _CreateTuningJobConfig_to_mldev( ' Enterprise Agent Platform mode, not in Gemini Developer API mode.' ) + if getv(from_object, ['encryption_spec']) is not None: + raise ValueError( + 'encryption_spec parameter is only supported in Gemini Enterprise Agent' + ' Platform mode, not in Gemini Developer API mode.' + ) + return to_object @@ -766,13 +766,6 @@ def _CreateTuningJobConfig_to_vertex( if getv(from_object, ['output_uri']) is not None: setv(parent_object, ['outputUri'], getv(from_object, ['output_uri'])) - if getv(from_object, ['encryption_spec']) is not None: - setv( - parent_object, - ['encryptionSpec'], - getv(from_object, ['encryption_spec']), - ) - if getv(from_object, ['reward_config']) is not None: setv( parent_object, @@ -835,6 +828,13 @@ def _CreateTuningJobConfig_to_vertex( getv(from_object, ['validation_dataset_uri']), ) + if getv(from_object, ['encryption_spec']) is not None: + setv( + parent_object, + ['encryptionSpec'], + getv(from_object, ['encryption_spec']), + ) + return to_object @@ -894,9 +894,6 @@ def _DistillationHyperParameters_from_vertex( root_object: Optional[Union[dict[str, Any], object]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['adapterSize']) is not None: - setv(to_object, ['adapter_size'], getv(from_object, ['adapterSize'])) - if getv(from_object, ['epochCount']) is not None: setv(to_object, ['epoch_count'], getv(from_object, ['epochCount'])) @@ -907,6 +904,15 @@ def _DistillationHyperParameters_from_vertex( getv(from_object, ['learningRateMultiplier']), ) + if getv(from_object, ['adapterSize']) is not None: + setv(to_object, ['adapter_size'], getv(from_object, ['adapterSize'])) + + if getv(from_object, ['batchSize']) is not None: + setv(to_object, ['batch_size'], getv(from_object, ['batchSize'])) + + if getv(from_object, ['learningRate']) is not None: + setv(to_object, ['learning_rate'], getv(from_object, ['learningRate'])) + if getv(from_object, ['generationConfig']) is not None: setv( to_object, @@ -916,12 +922,6 @@ def _DistillationHyperParameters_from_vertex( ), ) - if getv(from_object, ['learningRate']) is not None: - setv(to_object, ['learning_rate'], getv(from_object, ['learningRate'])) - - if getv(from_object, ['batchSize']) is not None: - setv(to_object, ['batch_size'], getv(from_object, ['batchSize'])) - return to_object @@ -931,32 +931,32 @@ def _DistillationSamplingSpec_from_vertex( root_object: Optional[Union[dict[str, Any], object]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['baseTeacherModel']) is not None: + if getv(from_object, ['promptDatasetUri']) is not None: setv( to_object, - ['base_teacher_model'], - getv(from_object, ['baseTeacherModel']), + ['prompt_dataset_uri'], + getv(from_object, ['promptDatasetUri']), ) - if getv(from_object, ['tunedTeacherModelSource']) is not None: + if getv(from_object, ['validationDatasetUri']) is not None: setv( to_object, - ['tuned_teacher_model_source'], - getv(from_object, ['tunedTeacherModelSource']), + ['validation_dataset_uri'], + getv(from_object, ['validationDatasetUri']), ) - if getv(from_object, ['validationDatasetUri']) is not None: + if getv(from_object, ['baseTeacherModel']) is not None: setv( to_object, - ['validation_dataset_uri'], - getv(from_object, ['validationDatasetUri']), + ['base_teacher_model'], + getv(from_object, ['baseTeacherModel']), ) - if getv(from_object, ['promptDatasetUri']) is not None: + if getv(from_object, ['tunedTeacherModelSource']) is not None: setv( to_object, - ['prompt_dataset_uri'], - getv(from_object, ['promptDatasetUri']), + ['tuned_teacher_model_source'], + getv(from_object, ['tunedTeacherModelSource']), ) if getv(from_object, ['hyperparameters']) is not None: @@ -977,13 +977,6 @@ def _DistillationSpec_from_vertex( root_object: Optional[Union[dict[str, Any], object]] = None, ) -> dict[str, Any]: to_object: dict[str, Any] = {} - if getv(from_object, ['promptDatasetUri']) is not None: - setv( - to_object, - ['prompt_dataset_uri'], - getv(from_object, ['promptDatasetUri']), - ) - if getv(from_object, ['baseTeacherModel']) is not None: setv( to_object, @@ -1007,6 +1000,13 @@ def _DistillationSpec_from_vertex( getv(from_object, ['pipelineRootDirectory']), ) + if getv(from_object, ['promptDatasetUri']) is not None: + setv( + to_object, + ['prompt_dataset_uri'], + getv(from_object, ['promptDatasetUri']), + ) + if getv(from_object, ['studentModel']) is not None: setv(to_object, ['student_model'], getv(from_object, ['studentModel'])) @@ -1024,6 +1024,9 @@ def _DistillationSpec_from_vertex( getv(from_object, ['tunedTeacherModelSource']), ) + if getv(from_object, ['tuningMode']) is not None: + setv(to_object, ['tuning_mode'], getv(from_object, ['tuningMode'])) + if getv(from_object, ['validationDatasetUri']) is not None: setv( to_object, @@ -1031,9 +1034,6 @@ def _DistillationSpec_from_vertex( getv(from_object, ['validationDatasetUri']), ) - if getv(from_object, ['tuningMode']) is not None: - setv(to_object, ['tuning_mode'], getv(from_object, ['tuningMode'])) - return to_object @@ -1478,6 +1478,18 @@ def _Part_to_vertex( to_object, ['mediaResolution'], getv(from_object, ['media_resolution']) ) + if getv(from_object, ['tool_call']) is not None: + raise ValueError( + '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 only supported in Gemini Developer API' + ' mode, not in Gemini Enterprise Agent Platform mode.' + ) + if getv(from_object, ['code_execution_result']) is not None: setv( to_object, @@ -1528,18 +1540,6 @@ def _Part_to_vertex( if getv(from_object, ['video_metadata']) is not None: setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata'])) - if getv(from_object, ['tool_call']) is not None: - raise ValueError( - '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 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 only supported in Gemini Developer API' @@ -1683,6 +1683,15 @@ def _ReinforcementTuningSpec_from_vertex( ), ) + if getv(from_object, ['singleRewardConfig']) is not None: + setv( + to_object, + ['single_reward_config'], + _SingleReinforcementTuningRewardConfig_from_vertex( + getv(from_object, ['singleRewardConfig']), to_object, root_object + ), + ) + if getv(from_object, ['trainingDatasetUri']) is not None: setv( to_object, @@ -1702,15 +1711,6 @@ def _ReinforcementTuningSpec_from_vertex( to_object, ['hyper_parameters'], getv(from_object, ['hyperParameters']) ) - if getv(from_object, ['singleRewardConfig']) is not None: - setv( - to_object, - ['single_reward_config'], - _SingleReinforcementTuningRewardConfig_from_vertex( - getv(from_object, ['singleRewardConfig']), to_object, root_object - ), - ) - return to_object @@ -2140,6 +2140,17 @@ def _TuningJob_from_vertex( getv(from_object, ['preferenceOptimizationSpec']), ) + if getv(from_object, ['distillationSamplingSpec']) is not None: + setv( + to_object, + ['distillation_sampling_spec'], + _DistillationSamplingSpec_from_vertex( + getv(from_object, ['distillationSamplingSpec']), + to_object, + root_object, + ), + ) + if getv(from_object, ['distillationSpec']) is not None: setv( to_object, @@ -2225,12 +2236,6 @@ def _TuningJob_from_vertex( getv(from_object, ['tunedModelDisplayName']), ) - if getv(from_object, ['tuningJobState']) is not None: - setv(to_object, ['tuning_job_state'], getv(from_object, ['tuningJobState'])) - - if getv(from_object, ['veoTuningSpec']) is not None: - setv(to_object, ['veo_tuning_spec'], getv(from_object, ['veoTuningSpec'])) - if getv(from_object, ['tuningJobMetadata']) is not None: setv( to_object, @@ -2238,6 +2243,9 @@ def _TuningJob_from_vertex( getv(from_object, ['tuningJobMetadata']), ) + if getv(from_object, ['tuningJobState']) is not None: + setv(to_object, ['tuning_job_state'], getv(from_object, ['tuningJobState'])) + if getv(from_object, ['veoLoraTuningSpec']) is not None: setv( to_object, @@ -2245,16 +2253,8 @@ def _TuningJob_from_vertex( getv(from_object, ['veoLoraTuningSpec']), ) - if getv(from_object, ['distillationSamplingSpec']) is not None: - setv( - to_object, - ['distillation_sampling_spec'], - _DistillationSamplingSpec_from_vertex( - getv(from_object, ['distillationSamplingSpec']), - to_object, - root_object, - ), - ) + if getv(from_object, ['veoTuningSpec']) is not None: + setv(to_object, ['veo_tuning_spec'], getv(from_object, ['veoTuningSpec'])) return to_object diff --git a/google/genai/types.py b/google/genai/types.py index 35269bcdf..625504833 100644 --- a/google/genai/types.py +++ b/google/genai/types.py @@ -776,6 +776,20 @@ class PairwiseChoice(_common.CaseInSensitiveEnum): """Winner cannot be determined""" +class VideoOrientation(_common.CaseInSensitiveEnum): + """The orientation of the video. + + Defaults to LANDSCAPE. This enum is not supported in Gemini API. + """ + + VIDEO_ORIENTATION_UNSPECIFIED = 'VIDEO_ORIENTATION_UNSPECIFIED' + """Unspecified video orientation. Defaults to landscape.""" + LANDSCAPE = 'LANDSCAPE' + """Landscape orientation (e.g. 16:9, 1280x720).""" + PORTRAIT = 'PORTRAIT' + """Portrait orientation (e.g. 9:16, 720x1280).""" + + class TuningSpeed(_common.CaseInSensitiveEnum): """The speed of the tuning job. @@ -803,20 +817,6 @@ class TuningTask(_common.CaseInSensitiveEnum): """Tuning task for reference to video.""" -class VideoOrientation(_common.CaseInSensitiveEnum): - """The orientation of the video. - - Defaults to LANDSCAPE. This enum is not supported in Gemini API. - """ - - VIDEO_ORIENTATION_UNSPECIFIED = 'VIDEO_ORIENTATION_UNSPECIFIED' - """Unspecified video orientation. Defaults to landscape.""" - LANDSCAPE = 'LANDSCAPE' - """Landscape orientation (e.g. 16:9, 1280x720).""" - PORTRAIT = 'PORTRAIT' - """Portrait orientation (e.g. 9:16, 720x1280).""" - - class DocumentState(_common.CaseInSensitiveEnum): """Output only. @@ -1657,14 +1657,14 @@ class PartialArgDict(TypedDict, total=False): class FunctionCall(_common.BaseModel): """A predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name and a structured JSON object containing the parameters and their values.""" - id: Optional[str] = Field( - default=None, - description="""Optional. The unique id of the function call. If populated, the client to execute the `function_call` and return the response with the matching `id`.""", - ) args: Optional[dict[str, Any]] = Field( default=None, description="""Optional. The function parameters and values in JSON object format. See FunctionDeclaration.parameters for parameter details.""", ) + id: Optional[str] = Field( + default=None, + description="""Optional. The unique id of the function call. If populated, the client to execute the `function_call` and return the response with the matching `id`.""", + ) name: Optional[str] = Field( default=None, description="""Optional. The name of the function to call. Matches FunctionDeclaration.name.""", @@ -1682,12 +1682,12 @@ class FunctionCall(_common.BaseModel): class FunctionCallDict(TypedDict, total=False): """A predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name and a structured JSON object containing the parameters and their values.""" - id: Optional[str] - """Optional. The unique id of the function call. If populated, the client to execute the `function_call` and return the response with the matching `id`.""" - args: Optional[dict[str, Any]] """Optional. The function parameters and values in JSON object format. See FunctionDeclaration.parameters for parameter details.""" + id: Optional[str] + """Optional. The unique id of the function call. If populated, the client to execute the `function_call` and return the response with the matching `id`.""" + name: Optional[str] """Optional. The name of the function to call. Matches FunctionDeclaration.name.""" @@ -1701,83 +1701,83 @@ class FunctionCallDict(TypedDict, total=False): FunctionCallOrDict = Union[FunctionCall, FunctionCallDict] -class FunctionResponseBlob(_common.BaseModel): - """Raw media bytes for function response. +class FunctionResponseFileData(_common.BaseModel): + """URI based data for function response. - Text should not be sent as raw bytes, use the 'text' field. + This data type is not supported in Gemini API. """ - mime_type: Optional[str] = Field( + display_name: Optional[str] = Field( default=None, - description="""Required. The IANA standard MIME type of the source data.""", + description="""Optional. Display name of the file data. Used to provide a label or filename to distinguish file datas. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled.""", ) - data: Optional[bytes] = Field( - default=None, description="""Required. Raw bytes.""" + file_uri: Optional[str] = Field( + default=None, description="""Required. URI.""" ) - display_name: Optional[str] = Field( + mime_type: Optional[str] = Field( default=None, - description="""Optional. 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 currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled. This field is not supported in Gemini API.""", + description="""Required. The IANA standard MIME type of the source data.""", ) -class FunctionResponseBlobDict(TypedDict, total=False): - """Raw media bytes for function response. +class FunctionResponseFileDataDict(TypedDict, total=False): + """URI based data for function response. - Text should not be sent as raw bytes, use the 'text' field. + This data type is not supported in Gemini API. """ - mime_type: Optional[str] - """Required. The IANA standard MIME type of the source data.""" + display_name: Optional[str] + """Optional. Display name of the file data. Used to provide a label or filename to distinguish file datas. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled.""" - data: Optional[bytes] - """Required. Raw bytes.""" + file_uri: Optional[str] + """Required. URI.""" - display_name: Optional[str] - """Optional. 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 currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled. This field is not supported in Gemini API.""" + mime_type: Optional[str] + """Required. The IANA standard MIME type of the source data.""" -FunctionResponseBlobOrDict = Union[ - FunctionResponseBlob, FunctionResponseBlobDict +FunctionResponseFileDataOrDict = Union[ + FunctionResponseFileData, FunctionResponseFileDataDict ] -class FunctionResponseFileData(_common.BaseModel): - """URI based data for function response. +class FunctionResponseBlob(_common.BaseModel): + """Raw media bytes for function response. - This data type is not supported in Gemini API. + Text should not be sent as raw bytes, use the 'text' field. """ - file_uri: Optional[str] = Field( - default=None, description="""Required. URI.""" + data: Optional[bytes] = Field( + default=None, description="""Required. Raw bytes.""" ) - mime_type: Optional[str] = Field( + display_name: Optional[str] = Field( default=None, - description="""Required. The IANA standard MIME type of the source data.""", + description="""Optional. 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 currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled. This field is not supported in Gemini API.""", ) - display_name: Optional[str] = Field( + mime_type: Optional[str] = Field( default=None, - description="""Optional. Display name of the file data. Used to provide a label or filename to distinguish file datas. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled.""", + description="""Required. The IANA standard MIME type of the source data.""", ) -class FunctionResponseFileDataDict(TypedDict, total=False): - """URI based data for function response. +class FunctionResponseBlobDict(TypedDict, total=False): + """Raw media bytes for function response. - This data type is not supported in Gemini API. + Text should not be sent as raw bytes, use the 'text' field. """ - file_uri: Optional[str] - """Required. URI.""" + data: Optional[bytes] + """Required. Raw bytes.""" + + display_name: Optional[str] + """Optional. 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 currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled. This field is not supported in Gemini API.""" mime_type: Optional[str] """Required. The IANA standard MIME type of the source data.""" - display_name: Optional[str] - """Optional. Display name of the file data. Used to provide a label or filename to distinguish file datas. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled.""" - -FunctionResponseFileDataOrDict = Union[ - FunctionResponseFileData, FunctionResponseFileDataDict +FunctionResponseBlobOrDict = Union[ + FunctionResponseBlob, FunctionResponseBlobDict ] @@ -1791,13 +1791,13 @@ class FunctionResponsePart(_common.BaseModel): field is filled with raw bytes. """ - inline_data: Optional[FunctionResponseBlob] = Field( - default=None, description="""Inline media bytes.""" - ) file_data: Optional[FunctionResponseFileData] = Field( default=None, description="""URI based data. This field is not supported in Gemini API.""", ) + inline_data: Optional[FunctionResponseBlob] = Field( + default=None, description="""Inline media bytes.""" + ) @classmethod def from_bytes(cls, *, data: bytes, mime_type: str) -> 'FunctionResponsePart': @@ -1844,12 +1844,12 @@ class FunctionResponsePartDict(TypedDict, total=False): field is filled with raw bytes. """ - inline_data: Optional[FunctionResponseBlobDict] - """Inline media bytes.""" - file_data: Optional[FunctionResponseFileDataDict] """URI based data. This field is not supported in Gemini API.""" + inline_data: Optional[FunctionResponseBlobDict] + """Inline media bytes.""" + FunctionResponsePartOrDict = Union[ FunctionResponsePart, FunctionResponsePartDict @@ -1863,29 +1863,29 @@ class FunctionResponse(_common.BaseModel): prediction. """ - will_continue: Optional[bool] = Field( + id: Optional[str] = Field( default=None, - description="""Optional. Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty `response` with `will_continue=False` to signal that the function call is finished. This may still trigger the model generation. To avoid triggering the generation and finish the function call, additionally set `scheduling` to `SILENT`. This field is not supported in Vertex AI.""", + description="""Optional. The id of the function call this response is for. Populated by the client to match the corresponding function call `id`.""", ) - scheduling: Optional[FunctionResponseScheduling] = Field( + name: Optional[str] = Field( default=None, - description="""Optional. Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE.""", + description="""Required. The name of the function to call. Matches FunctionDeclaration.name and FunctionCall.name.""", ) parts: Optional[list[FunctionResponsePart]] = Field( default=None, description="""Optional. Ordered `Parts` that constitute a function response. Parts may have different IANA MIME types.""", ) - id: Optional[str] = Field( + response: Optional[dict[str, Any]] = Field( default=None, - description="""Optional. The id of the function call this response is for. Populated by the client to match the corresponding function call `id`.""", + description="""Required. The function response in JSON object format. Use "output" key to specify function output and "error" key to specify error details (if any). If "output" and "error" keys are not specified, then whole "response" is treated as function output.""", ) - name: Optional[str] = Field( + scheduling: Optional[FunctionResponseScheduling] = Field( default=None, - description="""Required. The name of the function to call. Matches FunctionDeclaration.name and FunctionCall.name.""", + description="""Optional. Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE.""", ) - response: Optional[dict[str, Any]] = Field( + will_continue: Optional[bool] = Field( default=None, - description="""Required. The function response in JSON object format. Use "output" key to specify function output and "error" key to specify error details (if any). If "output" and "error" keys are not specified, then whole "response" is treated as function output.""", + description="""Optional. Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty `response` with `will_continue=False` to signal that the function call is finished. This may still trigger the model generation. To avoid triggering the generation and finish the function call, additionally set `scheduling` to `SILENT`. This field is not supported in Vertex AI.""", ) @classmethod @@ -1911,24 +1911,24 @@ class FunctionResponseDict(TypedDict, total=False): prediction. """ - will_continue: Optional[bool] - """Optional. Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty `response` with `will_continue=False` to signal that the function call is finished. This may still trigger the model generation. To avoid triggering the generation and finish the function call, additionally set `scheduling` to `SILENT`. This field is not supported in Vertex AI.""" - - scheduling: Optional[FunctionResponseScheduling] - """Optional. Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE.""" - - parts: Optional[list[FunctionResponsePartDict]] - """Optional. Ordered `Parts` that constitute a function response. Parts may have different IANA MIME types.""" - id: Optional[str] """Optional. The id of the function call this response is for. Populated by the client to match the corresponding function call `id`.""" name: Optional[str] """Required. The name of the function to call. Matches FunctionDeclaration.name and FunctionCall.name.""" + parts: Optional[list[FunctionResponsePartDict]] + """Optional. Ordered `Parts` that constitute a function response. Parts may have different IANA MIME types.""" + response: Optional[dict[str, Any]] """Required. The function response in JSON object format. Use "output" key to specify function output and "error" key to specify error details (if any). If "output" and "error" keys are not specified, then whole "response" is treated as function output.""" + scheduling: Optional[FunctionResponseScheduling] + """Optional. Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE.""" + + will_continue: Optional[bool] + """Optional. Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty `response` with `will_continue=False` to signal that the function call is finished. This may still trigger the model generation. To avoid triggering the generation and finish the function call, additionally set `scheduling` to `SILENT`. This field is not supported in Vertex AI.""" + FunctionResponseOrDict = Union[FunctionResponse, FunctionResponseDict] @@ -2030,6 +2030,14 @@ class Part(_common.BaseModel): description="""Media resolution for the input media. """, ) + tool_call: Optional[ToolCall] = Field( + default=None, + description="""Server-side tool call. This field is populated when the model predicts a tool invocation that should be executed on the server. The client is expected to echo this message back to the API.""", + ) + tool_response: Optional[ToolResponse] = Field( + default=None, + description="""The output from a server-side ToolCall execution. This field is populated by the client with the results of executing the corresponding ToolCall.""", + ) code_execution_result: Optional[CodeExecutionResult] = Field( default=None, description="""Optional. The result of executing the ExecutableCode.""", @@ -2070,14 +2078,6 @@ class Part(_common.BaseModel): default=None, description="""Optional. Video metadata. The metadata should only be specified while the video data is presented in inline_data or file_data.""", ) - tool_call: Optional[ToolCall] = Field( - default=None, - description="""Server-side tool call. This field is populated when the model predicts a tool invocation that should be executed on the server. The client is expected to echo this message back to the API.""", - ) - tool_response: Optional[ToolResponse] = Field( - default=None, - description="""The output from a server-side ToolCall execution. This field is populated by the client with the results of executing the corresponding ToolCall.""", - ) part_metadata: Optional[dict[str, Any]] = Field( default=None, description="""Custom metadata associated with the Part. Agents using genai.Part as content representation may need to keep track of the additional information. For example it can be name of a file/source from which the Part originates or a way to multiplex multiple Part streams. This field is not supported in Vertex AI.""", @@ -2274,6 +2274,12 @@ class PartDict(TypedDict, total=False): """Media resolution for the input media. """ + tool_call: Optional[ToolCallDict] + """Server-side tool call. This field is populated when the model predicts a tool invocation that should be executed on the server. The client is expected to echo this message back to the API.""" + + tool_response: Optional[ToolResponseDict] + """The output from a server-side ToolCall execution. This field is populated by the client with the results of executing the corresponding ToolCall.""" + code_execution_result: Optional[CodeExecutionResultDict] """Optional. The result of executing the ExecutableCode.""" @@ -2304,12 +2310,6 @@ class PartDict(TypedDict, total=False): video_metadata: Optional[VideoMetadataDict] """Optional. Video metadata. The metadata should only be specified while the video data is presented in inline_data or file_data.""" - tool_call: Optional[ToolCallDict] - """Server-side tool call. This field is populated when the model predicts a tool invocation that should be executed on the server. The client is expected to echo this message back to the API.""" - - tool_response: Optional[ToolResponseDict] - """The output from a server-side ToolCall execution. This field is populated by the client with the results of executing the corresponding ToolCall.""" - part_metadata: Optional[dict[str, Any]] """Custom metadata associated with the Part. Agents using genai.Part as content representation may need to keep track of the additional information. For example it can be name of a file/source from which the Part originates or a way to multiplex multiple Part streams. This field is not supported in Vertex AI.""" @@ -4180,251 +4180,152 @@ class RetrievalDict(TypedDict, total=False): RetrievalOrDict = Union[Retrieval, RetrievalDict] -class ComputerUse(_common.BaseModel): - """Tool to support computer use.""" +class StreamableHttpTransport(_common.BaseModel): + """A transport that can stream HTTP requests and responses. - environment: Optional[Environment] = Field( - default=None, description="""Required. The environment being operated.""" - ) - excluded_predefined_functions: Optional[list[str]] = Field( + Next ID: 6. This data type is not supported in Vertex AI. + """ + + headers: Optional[dict[str, str]] = Field( default=None, - description="""Optional. By default, [predefined functions](https://cloud.google.com/vertex-ai/generative-ai/docs/computer-use#supported-actions) are included in the final model call. Some of them can be explicitly excluded from being automatically included. This can serve two purposes: 1. Using a more restricted / different action space. 2. Improving the definitions / instructions of predefined functions.""", + description="""Optional: Fields for authentication headers, timeouts, etc., if needed.""", ) - enable_prompt_injection_detection: Optional[bool] = Field( + sse_read_timeout: Optional[str] = Field( + default=None, description="""Timeout for SSE read operations.""" + ) + terminate_on_close: Optional[bool] = Field( default=None, - description="""Optional. Enables the prompt injection detection check on computer-use request.""", + description="""Whether to close the client session when the transport closes.""", ) - disabled_safety_policies: Optional[list[SafetyPolicy]] = Field( + timeout: Optional[str] = Field( + default=None, description="""HTTP timeout for regular operations.""" + ) + url: Optional[str] = Field( default=None, - description="""Optional. Disabled safety policies for computer use. This field is not supported in Vertex AI.""", + description="""The full URL for the MCPServer endpoint. Example: "https://api.example.com/mcp".""", ) -class ComputerUseDict(TypedDict, total=False): - """Tool to support computer use.""" +class StreamableHttpTransportDict(TypedDict, total=False): + """A transport that can stream HTTP requests and responses. - environment: Optional[Environment] - """Required. The environment being operated.""" + Next ID: 6. This data type is not supported in Vertex AI. + """ - excluded_predefined_functions: Optional[list[str]] - """Optional. By default, [predefined functions](https://cloud.google.com/vertex-ai/generative-ai/docs/computer-use#supported-actions) are included in the final model call. Some of them can be explicitly excluded from being automatically included. This can serve two purposes: 1. Using a more restricted / different action space. 2. Improving the definitions / instructions of predefined functions.""" + headers: Optional[dict[str, str]] + """Optional: Fields for authentication headers, timeouts, etc., if needed.""" - enable_prompt_injection_detection: Optional[bool] - """Optional. Enables the prompt injection detection check on computer-use request.""" + sse_read_timeout: Optional[str] + """Timeout for SSE read operations.""" - disabled_safety_policies: Optional[list[SafetyPolicy]] - """Optional. Disabled safety policies for computer use. This field is not supported in Vertex AI.""" + terminate_on_close: Optional[bool] + """Whether to close the client session when the transport closes.""" + timeout: Optional[str] + """HTTP timeout for regular operations.""" -ComputerUseOrDict = Union[ComputerUse, ComputerUseDict] + url: Optional[str] + """The full URL for the MCPServer endpoint. Example: "https://api.example.com/mcp".""" -class FileSearch(_common.BaseModel): - """The FileSearch tool that retrieves knowledge from Semantic Retrieval corpora. +StreamableHttpTransportOrDict = Union[ + StreamableHttpTransport, StreamableHttpTransportDict +] - Files are imported to Semantic Retrieval corpora using the ImportFile API. - This data type is not supported in Vertex AI. + +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 + not supported in Vertex AI. """ - file_search_store_names: Optional[list[str]] = Field( - default=None, - description="""Required. The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`""", - ) - top_k: Optional[int] = Field( - default=None, - description="""Optional. The number of semantic retrieval chunks to retrieve.""", + name: Optional[str] = Field( + default=None, description="""The name of the MCPServer.""" ) - metadata_filter: Optional[str] = Field( + streamable_http_transport: Optional[StreamableHttpTransport] = Field( default=None, - description="""Optional. Metadata filter to apply to the semantic retrieval documents and chunks.""", + description="""A transport that can stream HTTP requests and responses.""", ) -class FileSearchDict(TypedDict, total=False): - """The FileSearch tool that retrieves knowledge from Semantic Retrieval corpora. +class McpServerDict(TypedDict, total=False): + """A MCPServer is a server that can be called by the model to perform actions. - Files are imported to Semantic Retrieval corpora using the ImportFile API. - This data type is not supported in Vertex AI. + It is a server that implements the MCP protocol. Next ID: 6. This data type is + not supported in Vertex AI. """ - file_search_store_names: Optional[list[str]] - """Required. The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`""" - - top_k: Optional[int] - """Optional. The number of semantic retrieval chunks to retrieve.""" + name: Optional[str] + """The name of the MCPServer.""" - metadata_filter: Optional[str] - """Optional. Metadata filter to apply to the semantic retrieval documents and chunks.""" + streamable_http_transport: Optional[StreamableHttpTransportDict] + """A transport that can stream HTTP requests and responses.""" -FileSearchOrDict = Union[FileSearch, FileSearchDict] +McpServerOrDict = Union[McpServer, McpServerDict] -class WebSearch(_common.BaseModel): - """Standard web search for grounding and related configurations. +class ToolCodeExecution(_common.BaseModel): + """Tool that executes code generated by the model, and automatically returns the result to the model. - Only text results are returned. + See also ExecutableCode and CodeExecutionResult, which are input and output to + this tool. This data type is not supported in Gemini API. """ pass -class WebSearchDict(TypedDict, total=False): - """Standard web search for grounding and related configurations. +class ToolCodeExecutionDict(TypedDict, total=False): + """Tool that executes code generated by the model, and automatically returns the result to the model. - Only text results are returned. + See also ExecutableCode and CodeExecutionResult, which are input and output to + this tool. This data type is not supported in Gemini API. """ pass -WebSearchOrDict = Union[WebSearch, WebSearchDict] - - -class ImageSearch(_common.BaseModel): - """Image search for grounding and related configurations.""" - - pass - - -class ImageSearchDict(TypedDict, total=False): - """Image search for grounding and related configurations.""" - - pass - - -ImageSearchOrDict = Union[ImageSearch, ImageSearchDict] - - -class SearchTypes(_common.BaseModel): - """Different types of search that can be enabled on the GoogleSearch tool.""" - - web_search: Optional[WebSearch] = Field( - default=None, - description="""Optional. Setting this field enables web search. Only text results are returned.""", - ) - image_search: Optional[ImageSearch] = Field( - default=None, - description="""Optional. Setting this field enables image search. Image bytes are returned.""", - ) - - -class SearchTypesDict(TypedDict, total=False): - """Different types of search that can be enabled on the GoogleSearch tool.""" - - web_search: Optional[WebSearchDict] - """Optional. Setting this field enables web search. Only text results are returned.""" - - image_search: Optional[ImageSearchDict] - """Optional. Setting this field enables image search. Image bytes are returned.""" - - -SearchTypesOrDict = Union[SearchTypes, SearchTypesDict] - - -class Interval(_common.BaseModel): - """Represents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive). - - The start must be less than or equal to the end. When the start equals the - end, the interval is empty (matches no time). When both start and end are - unspecified, the interval matches any time. - """ - - end_time: Optional[datetime.datetime] = Field( - default=None, - description="""Optional. Exclusive end of the interval. If specified, a Timestamp matching this interval will have to be before the end.""", - ) - start_time: Optional[datetime.datetime] = Field( - default=None, - description="""Optional. Inclusive start of the interval. If specified, a Timestamp matching this interval will have to be the same or after the start.""", - ) - - -class IntervalDict(TypedDict, total=False): - """Represents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive). - - The start must be less than or equal to the end. When the start equals the - end, the interval is empty (matches no time). When both start and end are - unspecified, the interval matches any time. - """ - - end_time: Optional[datetime.datetime] - """Optional. Exclusive end of the interval. If specified, a Timestamp matching this interval will have to be before the end.""" - - start_time: Optional[datetime.datetime] - """Optional. Inclusive start of the interval. If specified, a Timestamp matching this interval will have to be the same or after the start.""" - - -IntervalOrDict = Union[Interval, IntervalDict] - +ToolCodeExecutionOrDict = Union[ToolCodeExecution, ToolCodeExecutionDict] -class GoogleSearch(_common.BaseModel): - """GoogleSearch tool type. - Tool to support Google Search in Model. Powered by Google. - """ +class ComputerUse(_common.BaseModel): + """Tool to support computer use.""" - search_types: Optional[SearchTypes] = Field( + enable_prompt_injection_detection: Optional[bool] = Field( default=None, - description="""Optional. The set of search types to enable. If not set, web search is enabled by default.""", + description="""Optional. Enables the prompt injection detection check on computer-use request.""", ) - blocking_confidence: Optional[PhishBlockThreshold] = Field( - default=None, - description="""Optional. Sites with confidence level chosen & above this value will be blocked from the search results. This field is not supported in Gemini API.""", + environment: Optional[Environment] = Field( + default=None, description="""Required. The environment being operated.""" ) - exclude_domains: Optional[list[str]] = Field( + excluded_predefined_functions: Optional[list[str]] = Field( default=None, - description="""Optional. List of domains to be excluded from the search results. The default limit is 2000 domains. Example: ["amazon.com", "facebook.com"]. This field is not supported in Gemini API.""", + description="""Optional. By default, [predefined functions](https://cloud.google.com/vertex-ai/generative-ai/docs/computer-use#supported-actions) are included in the final model call. Some of them can be explicitly excluded from being automatically included. This can serve two purposes: 1. Using a more restricted / different action space. 2. Improving the definitions / instructions of predefined functions.""", ) - time_range_filter: Optional[Interval] = Field( + disabled_safety_policies: Optional[list[SafetyPolicy]] = Field( default=None, - description="""Optional. Filter search results to a specific time range. If customers set a start time, they must set an end time (and vice versa). This field is not supported in Vertex AI.""", + description="""Optional. Disabled safety policies for computer use. This field is not supported in Vertex AI.""", ) -class GoogleSearchDict(TypedDict, total=False): - """GoogleSearch tool type. - - Tool to support Google Search in Model. Powered by Google. - """ - - search_types: Optional[SearchTypesDict] - """Optional. The set of search types to enable. If not set, web search is enabled by default.""" - - blocking_confidence: Optional[PhishBlockThreshold] - """Optional. Sites with confidence level chosen & above this value will be blocked from the search results. This field is not supported in Gemini API.""" - - exclude_domains: Optional[list[str]] - """Optional. List of domains to be excluded from the search results. The default limit is 2000 domains. Example: ["amazon.com", "facebook.com"]. This field is not supported in Gemini API.""" - - time_range_filter: Optional[IntervalDict] - """Optional. Filter search results to a specific time range. If customers set a start time, they must set an end time (and vice versa). This field is not supported in Vertex AI.""" - - -GoogleSearchOrDict = Union[GoogleSearch, GoogleSearchDict] - - -class ToolCodeExecution(_common.BaseModel): - """Tool that executes code generated by the model, and automatically returns the result to the model. - - See also ExecutableCode and CodeExecutionResult, which are input and output to - this tool. This data type is not supported in Gemini API. - """ - - pass +class ComputerUseDict(TypedDict, total=False): + """Tool to support computer use.""" + enable_prompt_injection_detection: Optional[bool] + """Optional. Enables the prompt injection detection check on computer-use request.""" -class ToolCodeExecutionDict(TypedDict, total=False): - """Tool that executes code generated by the model, and automatically returns the result to the model. + environment: Optional[Environment] + """Required. The environment being operated.""" - See also ExecutableCode and CodeExecutionResult, which are input and output to - this tool. This data type is not supported in Gemini API. - """ + excluded_predefined_functions: Optional[list[str]] + """Optional. By default, [predefined functions](https://cloud.google.com/vertex-ai/generative-ai/docs/computer-use#supported-actions) are included in the final model call. Some of them can be explicitly excluded from being automatically included. This can serve two purposes: 1. Using a more restricted / different action space. 2. Improving the definitions / instructions of predefined functions.""" - pass + disabled_safety_policies: Optional[list[SafetyPolicy]] + """Optional. Disabled safety policies for computer use. This field is not supported in Vertex AI.""" -ToolCodeExecutionOrDict = Union[ToolCodeExecution, ToolCodeExecutionDict] +ComputerUseOrDict = Union[ComputerUse, ComputerUseDict] class EnterpriseWebSearch(_common.BaseModel): @@ -4671,55 +4572,199 @@ def from_callable( ) -> 'FunctionDeclaration': """Converts a Callable to a FunctionDeclaration based on the client. - Note: For best results prefer - [Google-style - docstring](https://google.github.io/styleguide/pyguide.html#383-functions-and-methods) - when describing arguments. This function does **not** parse argument - descriptions into the property description slots of the resulting structure. - Instead it sends the whole docstring in the top-level function description. - Google-style docstring are closest to what the model is trained on. - """ - if client.vertexai: - return cls.from_callable_with_api_option( - callable=callable, api_option='VERTEX_AI', behavior=behavior - ) - else: - return cls.from_callable_with_api_option( - callable=callable, api_option='GEMINI_API', behavior=behavior - ) + Note: For best results prefer + [Google-style + docstring](https://google.github.io/styleguide/pyguide.html#383-functions-and-methods) + when describing arguments. This function does **not** parse argument + descriptions into the property description slots of the resulting structure. + Instead it sends the whole docstring in the top-level function description. + Google-style docstring are closest to what the model is trained on. + """ + if client.vertexai: + return cls.from_callable_with_api_option( + callable=callable, api_option='VERTEX_AI', behavior=behavior + ) + else: + return cls.from_callable_with_api_option( + callable=callable, api_option='GEMINI_API', behavior=behavior + ) + + +class FunctionDeclarationDict(TypedDict, total=False): + """Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). + + Included in this declaration are the function name, description, parameters + and response type. This FunctionDeclaration is a representation of a block of + code that can be used as a `Tool` by the model and executed by the client. + """ + + description: Optional[str] + """Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function.""" + + name: Optional[str] + """Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots, colons and dashes, with a maximum length of 128.""" + + parameters: Optional[SchemaDict] + """Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. Parameter names must start with a letter or an underscore and must only contain chars a-z, A-Z, 0-9, or underscores with a maximum length of 64. Example with 1 required and 1 optional parameter: type: OBJECT properties: param1: type: STRING param2: type: INTEGER required: - param1""" + + parameters_json_schema: Optional[Any] + """Optional. Describes the parameters to the function in JSON Schema format. The schema must describe an object where the properties are the parameters to the function. For example: ``` { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }, "additionalProperties": false, "required": ["name", "age"], "propertyOrdering": ["name", "age"] } ``` This field is mutually exclusive with `parameters`.""" + + response: Optional[SchemaDict] + """Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function.""" + + response_json_schema: Optional[Any] + """Optional. Describes the output from this function in JSON Schema format. The value specified by the schema is the response value of the function. This field is mutually exclusive with `response`.""" + + behavior: Optional[Behavior] + """Optional. Specifies the function Behavior. Currently only non-blocking functions are supported. If not specified, the system keeps the current function call behavior. This field is currently only supported by the BidiGenerateContent method.""" + + +FunctionDeclarationOrDict = Union[FunctionDeclaration, FunctionDeclarationDict] + + +class ImageSearch(_common.BaseModel): + """Image search for grounding and related configurations.""" + + pass + + +class ImageSearchDict(TypedDict, total=False): + """Image search for grounding and related configurations.""" + + pass + + +ImageSearchOrDict = Union[ImageSearch, ImageSearchDict] + + +class WebSearch(_common.BaseModel): + """Standard web search for grounding and related configurations. + + Only text results are returned. + """ + + pass + + +class WebSearchDict(TypedDict, total=False): + """Standard web search for grounding and related configurations. + + Only text results are returned. + """ + + pass + + +WebSearchOrDict = Union[WebSearch, WebSearchDict] + + +class SearchTypes(_common.BaseModel): + """Different types of search that can be enabled on the GoogleSearch tool.""" + + image_search: Optional[ImageSearch] = Field( + default=None, + description="""Optional. Setting this field enables image search. Image bytes are returned.""", + ) + web_search: Optional[WebSearch] = Field( + default=None, + description="""Optional. Setting this field enables web search. Only text results are returned.""", + ) + + +class SearchTypesDict(TypedDict, total=False): + """Different types of search that can be enabled on the GoogleSearch tool.""" + + image_search: Optional[ImageSearchDict] + """Optional. Setting this field enables image search. Image bytes are returned.""" + + web_search: Optional[WebSearchDict] + """Optional. Setting this field enables web search. Only text results are returned.""" + + +SearchTypesOrDict = Union[SearchTypes, SearchTypesDict] + + +class Interval(_common.BaseModel): + """Represents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive). + + The start must be less than or equal to the end. When the start equals the + end, the interval is empty (matches no time). When both start and end are + unspecified, the interval matches any time. + """ + + end_time: Optional[datetime.datetime] = Field( + default=None, + description="""Optional. Exclusive end of the interval. If specified, a Timestamp matching this interval will have to be before the end.""", + ) + start_time: Optional[datetime.datetime] = Field( + default=None, + description="""Optional. Inclusive start of the interval. If specified, a Timestamp matching this interval will have to be the same or after the start.""", + ) + + +class IntervalDict(TypedDict, total=False): + """Represents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive). + + The start must be less than or equal to the end. When the start equals the + end, the interval is empty (matches no time). When both start and end are + unspecified, the interval matches any time. + """ + + end_time: Optional[datetime.datetime] + """Optional. Exclusive end of the interval. If specified, a Timestamp matching this interval will have to be before the end.""" + + start_time: Optional[datetime.datetime] + """Optional. Inclusive start of the interval. If specified, a Timestamp matching this interval will have to be the same or after the start.""" + +IntervalOrDict = Union[Interval, IntervalDict] -class FunctionDeclarationDict(TypedDict, total=False): - """Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). - Included in this declaration are the function name, description, parameters - and response type. This FunctionDeclaration is a representation of a block of - code that can be used as a `Tool` by the model and executed by the client. +class GoogleSearch(_common.BaseModel): + """GoogleSearch tool type. + + Tool to support Google Search in Model. Powered by Google. """ - description: Optional[str] - """Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function.""" + blocking_confidence: Optional[PhishBlockThreshold] = Field( + default=None, + description="""Optional. Sites with confidence level chosen & above this value will be blocked from the search results. This field is not supported in Gemini API.""", + ) + exclude_domains: Optional[list[str]] = Field( + default=None, + description="""Optional. List of domains to be excluded from the search results. The default limit is 2000 domains. Example: ["amazon.com", "facebook.com"]. This field is not supported in Gemini API.""", + ) + search_types: Optional[SearchTypes] = Field( + default=None, + description="""Optional. The set of search types to enable. If not set, web search is enabled by default.""", + ) + time_range_filter: Optional[Interval] = Field( + default=None, + description="""Optional. Filter search results to a specific time range. If customers set a start time, they must set an end time (and vice versa). This field is not supported in Vertex AI.""", + ) - name: Optional[str] - """Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots, colons and dashes, with a maximum length of 128.""" - parameters: Optional[SchemaDict] - """Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. Parameter names must start with a letter or an underscore and must only contain chars a-z, A-Z, 0-9, or underscores with a maximum length of 64. Example with 1 required and 1 optional parameter: type: OBJECT properties: param1: type: STRING param2: type: INTEGER required: - param1""" +class GoogleSearchDict(TypedDict, total=False): + """GoogleSearch tool type. - parameters_json_schema: Optional[Any] - """Optional. Describes the parameters to the function in JSON Schema format. The schema must describe an object where the properties are the parameters to the function. For example: ``` { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }, "additionalProperties": false, "required": ["name", "age"], "propertyOrdering": ["name", "age"] } ``` This field is mutually exclusive with `parameters`.""" + Tool to support Google Search in Model. Powered by Google. + """ - response: Optional[SchemaDict] - """Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function.""" + blocking_confidence: Optional[PhishBlockThreshold] + """Optional. Sites with confidence level chosen & above this value will be blocked from the search results. This field is not supported in Gemini API.""" - response_json_schema: Optional[Any] - """Optional. Describes the output from this function in JSON Schema format. The value specified by the schema is the response value of the function. This field is mutually exclusive with `response`.""" + exclude_domains: Optional[list[str]] + """Optional. List of domains to be excluded from the search results. The default limit is 2000 domains. Example: ["amazon.com", "facebook.com"]. This field is not supported in Gemini API.""" - behavior: Optional[Behavior] - """Optional. Specifies the function Behavior. Currently only non-blocking functions are supported. If not specified, the system keeps the current function call behavior. This field is currently only supported by the BidiGenerateContent method.""" + search_types: Optional[SearchTypesDict] + """Optional. The set of search types to enable. If not set, web search is enabled by default.""" + + time_range_filter: Optional[IntervalDict] + """Optional. Filter search results to a specific time range. If customers set a start time, they must set an end time (and vice versa). This field is not supported in Vertex AI.""" -FunctionDeclarationOrDict = Union[FunctionDeclaration, FunctionDeclarationDict] +GoogleSearchOrDict = Union[GoogleSearch, GoogleSearchDict] class DynamicRetrievalConfig(_common.BaseModel): @@ -4822,90 +4867,45 @@ class UrlContextDict(TypedDict, total=False): UrlContextOrDict = Union[UrlContext, UrlContextDict] -class StreamableHttpTransport(_common.BaseModel): - """A transport that can stream HTTP requests and responses. +class FileSearch(_common.BaseModel): + """The FileSearch tool that retrieves knowledge from Semantic Retrieval corpora. - Next ID: 6. This data type is not supported in Vertex AI. + Files are imported to Semantic Retrieval corpora using the ImportFile API. + This data type is not supported in Vertex AI. """ - headers: Optional[dict[str, str]] = Field( + file_search_store_names: Optional[list[str]] = Field( default=None, - description="""Optional: Fields for authentication headers, timeouts, etc., if needed.""", - ) - sse_read_timeout: Optional[str] = Field( - default=None, description="""Timeout for SSE read operations.""" + description="""Required. The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`""", ) - terminate_on_close: Optional[bool] = Field( + metadata_filter: Optional[str] = Field( default=None, - description="""Whether to close the client session when the transport closes.""", - ) - timeout: Optional[str] = Field( - default=None, description="""HTTP timeout for regular operations.""" + description="""Optional. Metadata filter to apply to the semantic retrieval documents and chunks.""", ) - url: Optional[str] = Field( + top_k: Optional[int] = Field( default=None, - description="""The full URL for the MCPServer endpoint. Example: "https://api.example.com/mcp".""", + description="""Optional. The number of semantic retrieval chunks to retrieve.""", ) -class StreamableHttpTransportDict(TypedDict, total=False): - """A transport that can stream HTTP requests and responses. - - Next ID: 6. This data type is not supported in Vertex AI. - """ - - headers: Optional[dict[str, str]] - """Optional: Fields for authentication headers, timeouts, etc., if needed.""" - - sse_read_timeout: Optional[str] - """Timeout for SSE read operations.""" - - terminate_on_close: Optional[bool] - """Whether to close the client session when the transport closes.""" - - timeout: Optional[str] - """HTTP timeout for regular operations.""" - - url: Optional[str] - """The full URL for the MCPServer endpoint. Example: "https://api.example.com/mcp".""" - - -StreamableHttpTransportOrDict = Union[ - StreamableHttpTransport, StreamableHttpTransportDict -] - - -class McpServer(_common.BaseModel): - """A MCPServer is a server that can be called by the model to perform actions. +class FileSearchDict(TypedDict, total=False): + """The FileSearch tool that retrieves knowledge from Semantic Retrieval corpora. - It is a server that implements the MCP protocol. Next ID: 6. This data type is - not supported in Vertex AI. + Files are imported to Semantic Retrieval corpora using the ImportFile API. + This data type is not supported in Vertex AI. """ - name: Optional[str] = Field( - default=None, description="""The name of the MCPServer.""" - ) - streamable_http_transport: Optional[StreamableHttpTransport] = Field( - default=None, - description="""A transport that can stream HTTP requests and responses.""", - ) - - -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 - not supported in Vertex AI. - """ + file_search_store_names: Optional[list[str]] + """Required. The names of the file_search_stores to retrieve from. Example: `fileSearchStores/my-file-search-store-123`""" - name: Optional[str] - """The name of the MCPServer.""" + metadata_filter: Optional[str] + """Optional. Metadata filter to apply to the semantic retrieval documents and chunks.""" - streamable_http_transport: Optional[StreamableHttpTransportDict] - """A transport that can stream HTTP requests and responses.""" + top_k: Optional[int] + """Optional. The number of semantic retrieval chunks to retrieve.""" -McpServerOrDict = Union[McpServer, McpServerDict] +FileSearchOrDict = Union[FileSearch, FileSearchDict] class Tool(_common.BaseModel): @@ -4915,27 +4915,23 @@ class Tool(_common.BaseModel): default=None, description="""Optional. Retrieval tool type. System will always execute the provided retrieval tool(s) to get external knowledge to answer the prompt. Retrieval results are presented to the model for generation. This field is not supported in Gemini API.""", ) - computer_use: Optional[ComputerUse] = Field( - default=None, - description="""Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.""", - ) - file_search: Optional[FileSearch] = Field( - default=None, - description="""Optional. FileSearch tool type. Tool to retrieve knowledge from Semantic Retrieval corpora. This field is not supported in Vertex AI.""", - ) - google_search: Optional[GoogleSearch] = Field( - default=None, - description="""Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.""", - ) google_maps: Optional[GoogleMaps] = Field( default=None, description="""Optional. Tool that allows grounding the model's response with geospatial context related to the user's query.""", ) + mcp_servers: Optional[list[McpServer]] = Field( + default=None, + description="""Optional. MCP Servers to connect to. This field is not supported in Vertex AI.""", + ) code_execution: Optional[ToolCodeExecution] = Field( default=None, description="""Optional. CodeExecution tool type. Enables the model to execute code as part of generation.""", ) + computer_use: Optional[ComputerUse] = Field( + default=None, + description="""Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.""", + ) enterprise_web_search: Optional[EnterpriseWebSearch] = Field( default=None, description="""Optional. Tool to support searching public web data, powered by Vertex AI Search and Sec4 compliance. This field is not supported in Gemini API.""", @@ -4944,6 +4940,10 @@ class Tool(_common.BaseModel): default=None, description="""Optional. Function tool type. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating FunctionCall in the response. User should provide a FunctionResponse for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 512 function declarations can be provided.""", ) + google_search: Optional[GoogleSearch] = Field( + default=None, + description="""Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.""", + ) google_search_retrieval: Optional[GoogleSearchRetrieval] = Field( default=None, description="""Optional. Specialized retrieval tool that is powered by Google Search.""", @@ -4956,9 +4956,9 @@ class Tool(_common.BaseModel): default=None, description="""Optional. Tool to support URL context retrieval.""", ) - mcp_servers: Optional[list[McpServer]] = Field( + file_search: Optional[FileSearch] = Field( default=None, - description="""Optional. MCP Servers to connect to. This field is not supported in Vertex AI.""", + description="""Optional. FileSearch tool type. Tool to retrieve knowledge from Semantic Retrieval corpora. This field is not supported in Vertex AI.""", ) @@ -4968,28 +4968,28 @@ class ToolDict(TypedDict, total=False): retrieval: Optional[RetrievalDict] """Optional. Retrieval tool type. System will always execute the provided retrieval tool(s) to get external knowledge to answer the prompt. Retrieval results are presented to the model for generation. This field is not supported in Gemini API.""" - computer_use: Optional[ComputerUseDict] - """Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.""" - - file_search: Optional[FileSearchDict] - """Optional. FileSearch tool type. Tool to retrieve knowledge from Semantic Retrieval corpora. This field is not supported in Vertex AI.""" - - google_search: Optional[GoogleSearchDict] - """Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.""" - google_maps: Optional[GoogleMapsDict] """Optional. Tool that allows grounding the model's response with geospatial context related to the user's query.""" + mcp_servers: Optional[list[McpServerDict]] + """Optional. MCP Servers to connect to. This field is not supported in Vertex AI.""" + code_execution: Optional[ToolCodeExecutionDict] """Optional. CodeExecution tool type. Enables the model to execute code as part of generation.""" + computer_use: Optional[ComputerUseDict] + """Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations.""" + enterprise_web_search: Optional[EnterpriseWebSearchDict] """Optional. Tool to support searching public web data, powered by Vertex AI Search and Sec4 compliance. This field is not supported in Gemini API.""" function_declarations: Optional[list[FunctionDeclarationDict]] """Optional. Function tool type. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating FunctionCall in the response. User should provide a FunctionResponse for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 512 function declarations can be provided.""" + google_search: Optional[GoogleSearchDict] + """Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.""" + google_search_retrieval: Optional[GoogleSearchRetrievalDict] """Optional. Specialized retrieval tool that is powered by Google Search.""" @@ -4999,8 +4999,8 @@ class ToolDict(TypedDict, total=False): url_context: Optional[UrlContextDict] """Optional. Tool to support URL context retrieval.""" - mcp_servers: Optional[list[McpServerDict]] - """Optional. MCP Servers to connect to. This field is not supported in Vertex AI.""" + file_search: Optional[FileSearchDict] + """Optional. FileSearch tool type. Tool to retrieve knowledge from Semantic Retrieval corpora. This field is not supported in Vertex AI.""" ToolOrDict = Union[Tool, ToolDict] @@ -5383,10 +5383,6 @@ class ImageConfig(_common.BaseModel): description="""Controls the generation of people. Supported values are: ALLOW_ALL, ALLOW_ADULT, ALLOW_NONE.""", ) - prominent_people: Optional[ProminentPeople] = Field( - default=None, - description="""Optional. Controls whether prominent people (celebrities) generation is allowed. If used with personGeneration, personGeneration enum would take precedence. For instance, if ALLOW_NONE is set, all person generation would be blocked. If this field is unspecified, the default behavior is to allow prominent people. This field is not supported in Gemini API.""", - ) output_mime_type: Optional[str] = Field( default=None, description="""MIME type of the generated image. This field is not @@ -5401,6 +5397,10 @@ class ImageConfig(_common.BaseModel): default=None, description="""Optional. The image output format for generated images. This field is not supported in Gemini API.""", ) + prominent_people: Optional[ProminentPeople] = Field( + default=None, + description="""Optional. Controls whether prominent people (celebrities) generation is allowed. If used with personGeneration, personGeneration enum would take precedence. For instance, if ALLOW_NONE is set, all person generation would be blocked. If this field is unspecified, the default behavior is to allow prominent people. This field is not supported in Gemini API.""", + ) class ImageConfigDict(TypedDict, total=False): @@ -5419,9 +5419,6 @@ class ImageConfigDict(TypedDict, total=False): """Controls the generation of people. Supported values are: ALLOW_ALL, ALLOW_ADULT, ALLOW_NONE.""" - prominent_people: Optional[ProminentPeople] - """Optional. Controls whether prominent people (celebrities) generation is allowed. If used with personGeneration, personGeneration enum would take precedence. For instance, if ALLOW_NONE is set, all person generation would be blocked. If this field is unspecified, the default behavior is to allow prominent people. This field is not supported in Gemini API.""" - output_mime_type: Optional[str] """MIME type of the generated image. This field is not supported in Gemini API.""" @@ -5433,6 +5430,9 @@ class ImageConfigDict(TypedDict, total=False): image_output_options: Optional[ImageConfigImageOutputOptionsDict] """Optional. The image output format for generated images. This field is not supported in Gemini API.""" + prominent_people: Optional[ProminentPeople] + """Optional. Controls whether prominent people (celebrities) generation is allowed. If used with personGeneration, personGeneration enum would take precedence. For instance, if ALLOW_NONE is set, all person generation would be blocked. If this field is unspecified, the default behavior is to allow prominent people. This field is not supported in Gemini API.""" + ImageConfigOrDict = Union[ImageConfig, ImageConfigDict] @@ -5715,23 +5715,57 @@ class SafetySetting(_common.BaseModel): ) -class SafetySettingDict(TypedDict, total=False): - """A safety setting that affects the safety-blocking behavior. +class SafetySettingDict(TypedDict, total=False): + """A safety setting that affects the safety-blocking behavior. + + A SafetySetting consists of a harm category and a threshold for that category. + """ + + category: Optional[HarmCategory] + """Required. The harm category to be blocked.""" + + method: Optional[HarmBlockMethod] + """Optional. The method for blocking content. If not specified, the default behavior is to use the probability score. This field is not supported in Gemini API.""" + + threshold: Optional[HarmBlockThreshold] + """Required. The threshold for blocking content. If the harm probability exceeds this threshold, the content will be blocked.""" + + +SafetySettingOrDict = Union[SafetySetting, SafetySettingDict] + + +class FunctionCallingConfig(_common.BaseModel): + """Function calling config.""" + + allowed_function_names: Optional[list[str]] = Field( + default=None, + description="""Optional. Function names to call. Only set when the Mode is ANY. Function names should match FunctionDeclaration.name. With mode set to ANY, model will predict a function call from the set of function names provided.""", + ) + mode: Optional[FunctionCallingConfigMode] = Field( + default=None, description="""Optional. Function calling mode.""" + ) + stream_function_call_arguments: Optional[bool] = Field( + default=None, + description="""Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the `FunctionCall.partial_args` field. This field is not supported in Gemini API.""", + ) + - A SafetySetting consists of a harm category and a threshold for that category. - """ +class FunctionCallingConfigDict(TypedDict, total=False): + """Function calling config.""" - category: Optional[HarmCategory] - """Required. The harm category to be blocked.""" + allowed_function_names: Optional[list[str]] + """Optional. Function names to call. Only set when the Mode is ANY. Function names should match FunctionDeclaration.name. With mode set to ANY, model will predict a function call from the set of function names provided.""" - method: Optional[HarmBlockMethod] - """Optional. The method for blocking content. If not specified, the default behavior is to use the probability score. This field is not supported in Gemini API.""" + mode: Optional[FunctionCallingConfigMode] + """Optional. Function calling mode.""" - threshold: Optional[HarmBlockThreshold] - """Required. The threshold for blocking content. If the harm probability exceeds this threshold, the content will be blocked.""" + stream_function_call_arguments: Optional[bool] + """Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the `FunctionCall.partial_args` field. This field is not supported in Gemini API.""" -SafetySettingOrDict = Union[SafetySetting, SafetySettingDict] +FunctionCallingConfigOrDict = Union[ + FunctionCallingConfig, FunctionCallingConfigDict +] class LatLng(_common.BaseModel): @@ -5773,59 +5807,25 @@ class LatLngDict(TypedDict, total=False): class RetrievalConfig(_common.BaseModel): """Retrieval config.""" - lat_lng: Optional[LatLng] = Field( - default=None, description="""The location of the user.""" - ) language_code: Optional[str] = Field( default=None, description="""The language code of the user.""" ) + lat_lng: Optional[LatLng] = Field( + default=None, description="""The location of the user.""" + ) class RetrievalConfigDict(TypedDict, total=False): """Retrieval config.""" - lat_lng: Optional[LatLngDict] - """The location of the user.""" - language_code: Optional[str] """The language code of the user.""" - -RetrievalConfigOrDict = Union[RetrievalConfig, RetrievalConfigDict] - - -class FunctionCallingConfig(_common.BaseModel): - """Function calling config.""" - - allowed_function_names: Optional[list[str]] = Field( - default=None, - description="""Optional. Function names to call. Only set when the Mode is ANY. Function names should match FunctionDeclaration.name. With mode set to ANY, model will predict a function call from the set of function names provided.""", - ) - mode: Optional[FunctionCallingConfigMode] = Field( - default=None, description="""Optional. Function calling mode.""" - ) - stream_function_call_arguments: Optional[bool] = Field( - default=None, - description="""Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the `FunctionCall.partial_args` field. This field is not supported in Gemini API.""", - ) - - -class FunctionCallingConfigDict(TypedDict, total=False): - """Function calling config.""" - - allowed_function_names: Optional[list[str]] - """Optional. Function names to call. Only set when the Mode is ANY. Function names should match FunctionDeclaration.name. With mode set to ANY, model will predict a function call from the set of function names provided.""" - - mode: Optional[FunctionCallingConfigMode] - """Optional. Function calling mode.""" - - stream_function_call_arguments: Optional[bool] - """Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the `FunctionCall.partial_args` field. This field is not supported in Gemini API.""" + lat_lng: Optional[LatLngDict] + """The location of the user.""" -FunctionCallingConfigOrDict = Union[ - FunctionCallingConfig, FunctionCallingConfigDict -] +RetrievalConfigOrDict = Union[RetrievalConfig, RetrievalConfigDict] class ToolConfig(_common.BaseModel): @@ -5834,12 +5834,12 @@ class ToolConfig(_common.BaseModel): This config is shared for all tools provided in the request. """ - retrieval_config: Optional[RetrievalConfig] = Field( - default=None, description="""Optional. Retrieval config.""" - ) function_calling_config: Optional[FunctionCallingConfig] = Field( default=None, description="""Optional. Function calling config.""" ) + retrieval_config: Optional[RetrievalConfig] = Field( + default=None, description="""Optional. Retrieval config.""" + ) include_server_side_tool_invocations: Optional[bool] = Field( default=None, description="""Optional. If true, the API response will include the server-side tool calls and responses within the `Content` message. This allows clients to observe the server's tool interactions. This field is not supported in Vertex AI.""", @@ -5852,12 +5852,12 @@ class ToolConfigDict(TypedDict, total=False): This config is shared for all tools provided in the request. """ - retrieval_config: Optional[RetrievalConfigDict] - """Optional. Retrieval config.""" - function_calling_config: Optional[FunctionCallingConfigDict] """Optional. Function calling config.""" + retrieval_config: Optional[RetrievalConfigDict] + """Optional. Retrieval config.""" + include_server_side_tool_invocations: Optional[bool] """Optional. If true, the API response will include the server-side tool calls and responses within the `Content` message. This allows clients to observe the server's tool interactions. This field is not supported in Vertex AI.""" @@ -5923,6 +5923,10 @@ class GenerateContentConfig(_common.BaseModel): default=None, description=""" If true, the raw HTTP response will be returned in the 'sdk_http_response' field.""", ) + service_tier: Optional[ServiceTier] = Field( + default=None, + description="""The service tier to use for the request. For example, ServiceTier.FLEX.""", + ) system_instruction: Optional[ContentUnion] = Field( default=None, description="""Instructions for the model to steer it toward better performance. @@ -6130,10 +6134,6 @@ class GenerateContentConfig(_common.BaseModel): service. If supplied, safety_settings must not be supplied. """, ) - service_tier: Optional[ServiceTier] = Field( - default=None, - description="""The service tier to use for the request. For example, ServiceTier.FLEX.""", - ) @pydantic.field_validator('response_schema', mode='before') @classmethod @@ -6172,6 +6172,9 @@ class GenerateContentConfigDict(TypedDict, total=False): should_return_http_response: Optional[bool] """ If true, the raw HTTP response will be returned in the 'sdk_http_response' field.""" + service_tier: Optional[ServiceTier] + """The service tier to use for the request. For example, ServiceTier.FLEX.""" + system_instruction: Optional[ContentUnionDict] """Instructions for the model to steer it toward better performance. For example, "Answer as concisely as possible" or "Don't use technical @@ -6348,9 +6351,6 @@ class GenerateContentConfigDict(TypedDict, total=False): service. If supplied, safety_settings must not be supplied. """ - service_tier: Optional[ServiceTier] - """The service tier to use for the request. For example, ServiceTier.FLEX.""" - GenerateContentConfigOrDict = Union[ GenerateContentConfig, GenerateContentConfigDict @@ -6846,19 +6846,19 @@ class GroundingChunkImage(_common.BaseModel): is used to provide the user with a link to the source of the information. """ - source_uri: Optional[str] = Field( - default=None, description="""The URI of the image search result page.""" + domain: Optional[str] = Field( + default=None, + description="""The domain of the image search result page.""", ) image_uri: Optional[str] = Field( default=None, description="""The URI of the image.""" ) + source_uri: Optional[str] = Field( + default=None, description="""The URI of the image search result page.""" + ) title: Optional[str] = Field( default=None, description="""The title of the image search result page.""" ) - domain: Optional[str] = Field( - default=None, - description="""The domain of the image search result page.""", - ) class GroundingChunkImageDict(TypedDict, total=False): @@ -6868,18 +6868,18 @@ class GroundingChunkImageDict(TypedDict, total=False): is used to provide the user with a link to the source of the information. """ - source_uri: Optional[str] - """The URI of the image search result page.""" + domain: Optional[str] + """The domain of the image search result page.""" image_uri: Optional[str] """The URI of the image.""" + source_uri: Optional[str] + """The URI of the image search result page.""" + title: Optional[str] """The title of the image search result page.""" - domain: Optional[str] - """The domain of the image search result page.""" - GroundingChunkImageOrDict = Union[GroundingChunkImage, GroundingChunkImageDict] @@ -6922,13 +6922,6 @@ class RagChunk(_common.BaseModel): This data type is not supported in Gemini API. """ - page_span: Optional[RagChunkPageSpan] = Field( - default=None, - description="""If populated, represents where the chunk starts and ends in the document.""", - ) - text: Optional[str] = Field( - default=None, description="""The content of the chunk.""" - ) chunk_id: Optional[str] = Field( default=None, description="""The ID of the chunk.""" ) @@ -6936,6 +6929,13 @@ class RagChunk(_common.BaseModel): default=None, description="""The ID of the file that the chunk belongs to.""", ) + page_span: Optional[RagChunkPageSpan] = Field( + default=None, + description="""If populated, represents where the chunk starts and ends in the document.""", + ) + text: Optional[str] = Field( + default=None, description="""The content of the chunk.""" + ) class RagChunkDict(TypedDict, total=False): @@ -6944,18 +6944,18 @@ class RagChunkDict(TypedDict, total=False): This data type is not supported in Gemini API. """ - page_span: Optional[RagChunkPageSpanDict] - """If populated, represents where the chunk starts and ends in the document.""" - - text: Optional[str] - """The content of the chunk.""" - chunk_id: Optional[str] """The ID of the chunk.""" file_id: Optional[str] """The ID of the file that the chunk belongs to.""" + page_span: Optional[RagChunkPageSpanDict] + """If populated, represents where the chunk starts and ends in the document.""" + + text: Optional[str] + """The content of the chunk.""" + RagChunkOrDict = Union[RagChunk, RagChunkDict] @@ -7059,14 +7059,14 @@ class GroundingChunkRetrievedContext(_common.BaseModel): default=None, description="""Optional. Name of the `FileSearchStore` containing the document. Example: `fileSearchStores/123`. This field is not supported in Vertex AI.""", ) - page_number: Optional[int] = Field( - default=None, - description="""Optional. Page number of the retrieved context, if applicable. This field is not supported in Vertex AI.""", - ) media_id: Optional[str] = Field( default=None, description="""Optional. The media blob resource name for multimodal file search results. Format: fileSearchStores/{file_search_store_id}/media/{blob_id}. This field is not supported in Vertex AI.""", ) + page_number: Optional[int] = Field( + default=None, + description="""Optional. Page number of the retrieved context, if applicable. This field is not supported in Vertex AI.""", + ) class GroundingChunkRetrievedContextDict(TypedDict, total=False): @@ -7097,12 +7097,12 @@ class GroundingChunkRetrievedContextDict(TypedDict, total=False): file_search_store: Optional[str] """Optional. Name of the `FileSearchStore` containing the document. Example: `fileSearchStores/123`. This field is not supported in Vertex AI.""" - page_number: Optional[int] - """Optional. Page number of the retrieved context, if applicable. This field is not supported in Vertex AI.""" - media_id: Optional[str] """Optional. The media blob resource name for multimodal file search results. Format: fileSearchStores/{file_search_store_id}/media/{blob_id}. This field is not supported in Vertex AI.""" + page_number: Optional[int] + """Optional. Page number of the retrieved context, if applicable. This field is not supported in Vertex AI.""" + GroundingChunkRetrievedContextOrDict = Union[ GroundingChunkRetrievedContext, GroundingChunkRetrievedContextDict @@ -7160,10 +7160,6 @@ class GroundingChunk(_common.BaseModel): the source of the information. """ - image: Optional[GroundingChunkImage] = Field( - default=None, - description="""A grounding chunk from an image search result. See the `Image` message for details.""", - ) maps: Optional[GroundingChunkMaps] = Field( default=None, description="""A `Maps` chunk is a piece of evidence that comes from Google Maps. @@ -7172,6 +7168,10 @@ class GroundingChunk(_common.BaseModel): reviews. This is used to provide the user with rich, location-based information.""", ) + image: Optional[GroundingChunkImage] = Field( + default=None, + description="""A grounding chunk from an image search result. See the `Image` message for details.""", + ) retrieved_context: Optional[GroundingChunkRetrievedContext] = Field( default=None, description="""A grounding chunk from a data source retrieved by a retrieval tool, such as Vertex AI Search. See the `RetrievedContext` message for details""", @@ -7190,9 +7190,6 @@ class GroundingChunkDict(TypedDict, total=False): the source of the information. """ - image: Optional[GroundingChunkImageDict] - """A grounding chunk from an image search result. See the `Image` message for details.""" - maps: Optional[GroundingChunkMapsDict] """A `Maps` chunk is a piece of evidence that comes from Google Maps. @@ -7200,6 +7197,9 @@ class GroundingChunkDict(TypedDict, total=False): reviews. This is used to provide the user with rich, location-based information.""" + image: Optional[GroundingChunkImageDict] + """A grounding chunk from an image search result. See the `Image` message for details.""" + retrieved_context: Optional[GroundingChunkRetrievedContextDict] """A grounding chunk from a data source retrieved by a retrieval tool, such as Vertex AI Search. See the `RetrievedContext` message for details""" @@ -7409,10 +7409,6 @@ class GroundingMetadataSourceFlaggingUriDict(TypedDict, total=False): class GroundingMetadata(_common.BaseModel): """Information for various kinds of grounding.""" - image_search_queries: Optional[list[str]] = Field( - default=None, - description="""Optional. The image search queries that were used to generate the content. This field is populated only when the grounding source is Google Search with the Image Search search_type enabled.""", - ) grounding_chunks: Optional[list[GroundingChunk]] = Field( default=None, description="""A list of supporting references retrieved from the grounding @@ -7440,6 +7436,10 @@ class GroundingMetadata(_common.BaseModel): default=None, description="""Optional. Output only. A token that can be used to render a Google Maps widget with the contextual data. This field is populated only when the grounding source is Google Maps.""", ) + image_search_queries: Optional[list[str]] = Field( + default=None, + description="""Optional. The image search queries that were used to generate the content. This field is populated only when the grounding source is Google Search with the Image Search search_type enabled.""", + ) retrieval_queries: Optional[list[str]] = Field( default=None, description="""Optional. The queries that were executed by the retrieval tools. This field is populated only when the grounding source is a retrieval tool, such as Vertex AI Search. This field is not supported in Gemini API.""", @@ -7455,9 +7455,6 @@ class GroundingMetadata(_common.BaseModel): class GroundingMetadataDict(TypedDict, total=False): """Information for various kinds of grounding.""" - image_search_queries: Optional[list[str]] - """Optional. The image search queries that were used to generate the content. This field is populated only when the grounding source is Google Search with the Image Search search_type enabled.""" - grounding_chunks: Optional[list[GroundingChunkDict]] """A list of supporting references retrieved from the grounding source. This field is populated when the grounding source is Google @@ -7480,6 +7477,9 @@ class GroundingMetadataDict(TypedDict, total=False): google_maps_widget_context_token: Optional[str] """Optional. Output only. A token that can be used to render a Google Maps widget with the contextual data. This field is populated only when the grounding source is Google Maps.""" + image_search_queries: Optional[list[str]] + """Optional. The image search queries that were used to generate the content. This field is populated only when the grounding source is Google Search with the Image Search search_type enabled.""" + retrieval_queries: Optional[list[str]] """Optional. The queries that were executed by the retrieval tools. This field is populated only when the grounding source is a retrieval tool, such as Vertex AI Search. This field is not supported in Gemini API.""" @@ -8397,6 +8397,9 @@ class GenerateContentResponseDict(TypedDict, total=False): class EmbedContentConfig(_common.BaseModel): """Optional parameters for the embed_content method.""" + http_options: Optional[HttpOptions] = Field( + default=None, description="""Used to override HTTP request options.""" + ) task_type: Optional[str] = Field( default=None, description="""Type of task for which the embedding will be used. @@ -8440,14 +8443,14 @@ class EmbedContentConfig(_common.BaseModel): Only applicable to Gemini Embedding 2 models. """, ) - http_options: Optional[HttpOptions] = Field( - default=None, description="""Used to override HTTP request options.""" - ) class EmbedContentConfigDict(TypedDict, total=False): """Optional parameters for the embed_content method.""" + http_options: Optional[HttpOptionsDict] + """Used to override HTTP request options.""" + task_type: Optional[str] """Type of task for which the embedding will be used. """ @@ -8484,9 +8487,6 @@ class EmbedContentConfigDict(TypedDict, total=False): Only applicable to Gemini Embedding 2 models. """ - http_options: Optional[HttpOptionsDict] - """Used to override HTTP request options.""" - EmbedContentConfigOrDict = Union[EmbedContentConfig, EmbedContentConfigDict] @@ -11970,10 +11970,6 @@ class PreferenceOptimizationSpecDict(TypedDict, total=False): class DistillationHyperParameters(_common.BaseModel): """Distillation hyperparameters for tuning.""" - adapter_size: Optional[AdapterSize] = Field( - default=None, - description="""The size of the adapter. Can be 'small', 'medium', or 'large'.""", - ) epoch_count: Optional[int] = Field( default=None, description="""Number of complete passes the model makes over the entire training dataset @@ -11983,6 +11979,18 @@ class DistillationHyperParameters(_common.BaseModel): default=None, description="""Multiplier for adjusting the default learning rate.""", ) + adapter_size: Optional[AdapterSize] = Field( + default=None, + description="""The size of the adapter. Can be 'small', 'medium', or 'large'.""", + ) + batch_size: Optional[int] = Field( + default=None, + description="""Batch size for tuning. This feature is only available for open + source models.""", + ) + learning_rate: Optional[float] = Field( + default=None, description="""The learning rate for distillation tuning.""" + ) generation_config: Optional[GenerationConfig] = Field( default=None, description="""Generation config for Distillation teacher model sampling. Only the @@ -11993,22 +12001,11 @@ class DistillationHyperParameters(_common.BaseModel): - candidate_count - thinking_config""", ) - learning_rate: Optional[float] = Field( - default=None, description="""The learning rate for distillation tuning.""" - ) - batch_size: Optional[int] = Field( - default=None, - description="""Batch size for tuning. This feature is only available for open - source models.""", - ) class DistillationHyperParametersDict(TypedDict, total=False): """Distillation hyperparameters for tuning.""" - adapter_size: Optional[AdapterSize] - """The size of the adapter. Can be 'small', 'medium', or 'large'.""" - epoch_count: Optional[int] """Number of complete passes the model makes over the entire training dataset during training.""" @@ -12016,6 +12013,16 @@ class DistillationHyperParametersDict(TypedDict, total=False): learning_rate_multiplier: Optional[float] """Multiplier for adjusting the default learning rate.""" + adapter_size: Optional[AdapterSize] + """The size of the adapter. Can be 'small', 'medium', or 'large'.""" + + batch_size: Optional[int] + """Batch size for tuning. This feature is only available for open + source models.""" + + learning_rate: Optional[float] + """The learning rate for distillation tuning.""" + generation_config: Optional[GenerationConfigDict] """Generation config for Distillation teacher model sampling. Only the following fields are supported for distillation teacher samplings: @@ -12025,13 +12032,6 @@ class DistillationHyperParametersDict(TypedDict, total=False): - candidate_count - thinking_config""" - learning_rate: Optional[float] - """The learning rate for distillation tuning.""" - - batch_size: Optional[int] - """Batch size for tuning. This feature is only available for open - source models.""" - DistillationHyperParametersOrDict = Union[ DistillationHyperParameters, DistillationHyperParametersDict @@ -12041,25 +12041,25 @@ class DistillationHyperParametersDict(TypedDict, total=False): class DistillationSamplingSpec(_common.BaseModel): """Distillation sampling spec for tuning.""" - base_teacher_model: Optional[str] = Field( - default=None, - description="""The base teacher model that is being distilled. See [Supported - models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models).""", - ) - tuned_teacher_model_source: Optional[str] = Field( + prompt_dataset_uri: Optional[str] = Field( default=None, - description="""The resource name of the Tuned teacher model. Format: - `projects/{project}/locations/{location}/models/{model}`.""", + description="""Cloud Storage path to file containing prompt dataset for distillation. + The dataset must be formatted as a JSONL file.""", ) validation_dataset_uri: Optional[str] = Field( default=None, description="""Cloud Storage path to file containing validation dataset for distillation. The dataset must be formatted as a JSONL file.""", ) - prompt_dataset_uri: Optional[str] = Field( + base_teacher_model: Optional[str] = Field( + default=None, + description="""The base teacher model that is being distilled. See [Supported + models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models).""", + ) + tuned_teacher_model_source: Optional[str] = Field( default=None, - description="""Cloud Storage path to file containing prompt dataset for distillation. - The dataset must be formatted as a JSONL file.""", + description="""The resource name of the Tuned teacher model. Format: + `projects/{project}/locations/{location}/models/{model}`.""", ) hyperparameters: Optional[DistillationHyperParameters] = Field( default=None, description="""Hyperparameters for distillation tuning.""" @@ -12069,6 +12069,14 @@ class DistillationSamplingSpec(_common.BaseModel): class DistillationSamplingSpecDict(TypedDict, total=False): """Distillation sampling spec for tuning.""" + prompt_dataset_uri: Optional[str] + """Cloud Storage path to file containing prompt dataset for distillation. + The dataset must be formatted as a JSONL file.""" + + validation_dataset_uri: Optional[str] + """Cloud Storage path to file containing validation dataset for distillation. + The dataset must be formatted as a JSONL file.""" + base_teacher_model: Optional[str] """The base teacher model that is being distilled. See [Supported models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models).""" @@ -12077,14 +12085,6 @@ class DistillationSamplingSpecDict(TypedDict, total=False): """The resource name of the Tuned teacher model. Format: `projects/{project}/locations/{location}/models/{model}`.""" - validation_dataset_uri: Optional[str] - """Cloud Storage path to file containing validation dataset for distillation. - The dataset must be formatted as a JSONL file.""" - - prompt_dataset_uri: Optional[str] - """Cloud Storage path to file containing prompt dataset for distillation. - The dataset must be formatted as a JSONL file.""" - hyperparameters: Optional[DistillationHyperParametersDict] """Hyperparameters for distillation tuning.""" @@ -12097,10 +12097,6 @@ class DistillationSamplingSpecDict(TypedDict, total=False): class DistillationSpec(_common.BaseModel): """Distillation tuning spec for tuning.""" - prompt_dataset_uri: Optional[str] = Field( - default=None, - description="""Optional. Cloud Storage path to file containing prompt dataset for distillation. The dataset must be formatted as a JSONL file.""", - ) base_teacher_model: Optional[str] = Field( default=None, description="""The base teacher model that is being distilled. See [Supported models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models).""", @@ -12113,6 +12109,10 @@ class DistillationSpec(_common.BaseModel): default=None, description="""Deprecated. A path in a Cloud Storage bucket, which will be treated as the root output directory of the distillation pipeline. It is used by the system to generate the paths of output artifacts.""", ) + prompt_dataset_uri: Optional[str] = Field( + default=None, + description="""Optional. Cloud Storage path to file containing prompt dataset for distillation. The dataset must be formatted as a JSONL file.""", + ) student_model: Optional[str] = Field( default=None, description="""The student model that is being tuned, e.g., "google/gemma-2b-1.1-it". Deprecated. Use base_model instead.""", @@ -12125,22 +12125,19 @@ class DistillationSpec(_common.BaseModel): default=None, description="""The resource name of the Tuned teacher model. Format: `projects/{project}/locations/{location}/models/{model}`.""", ) - validation_dataset_uri: Optional[str] = Field( - default=None, - description="""Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.""", - ) tuning_mode: Optional[TuningMode] = Field( default=None, description="""Optional. Specifies the tuning mode for distillation (sft part). This feature is only available for open source models.""", ) + validation_dataset_uri: Optional[str] = Field( + default=None, + description="""Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.""", + ) class DistillationSpecDict(TypedDict, total=False): """Distillation tuning spec for tuning.""" - prompt_dataset_uri: Optional[str] - """Optional. Cloud Storage path to file containing prompt dataset for distillation. The dataset must be formatted as a JSONL file.""" - base_teacher_model: Optional[str] """The base teacher model that is being distilled. See [Supported models](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/tuning#supported_models).""" @@ -12150,6 +12147,9 @@ class DistillationSpecDict(TypedDict, total=False): pipeline_root_directory: Optional[str] """Deprecated. A path in a Cloud Storage bucket, which will be treated as the root output directory of the distillation pipeline. It is used by the system to generate the paths of output artifacts.""" + prompt_dataset_uri: Optional[str] + """Optional. Cloud Storage path to file containing prompt dataset for distillation. The dataset must be formatted as a JSONL file.""" + student_model: Optional[str] """The student model that is being tuned, e.g., "google/gemma-2b-1.1-it". Deprecated. Use base_model instead.""" @@ -12159,12 +12159,12 @@ class DistillationSpecDict(TypedDict, total=False): tuned_teacher_model_source: Optional[str] """The resource name of the Tuned teacher model. Format: `projects/{project}/locations/{location}/models/{model}`.""" - validation_dataset_uri: Optional[str] - """Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.""" - tuning_mode: Optional[TuningMode] """Optional. Specifies the tuning mode for distillation (sft part). This feature is only available for open source models.""" + validation_dataset_uri: Optional[str] + """Optional. Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.""" + DistillationSpecOrDict = Union[DistillationSpec, DistillationSpecDict] @@ -12751,6 +12751,10 @@ class ReinforcementTuningSpec(_common.BaseModel): composite_reward_config: Optional[ CompositeReinforcementTuningRewardConfig ] = Field(default=None, description="""""") + single_reward_config: Optional[SingleReinforcementTuningRewardConfig] = Field( + default=None, + description="""Single reward function configuration for reinforcement tuning.""", + ) training_dataset_uri: Optional[str] = Field( default=None, description="""Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.""", @@ -12763,10 +12767,6 @@ class ReinforcementTuningSpec(_common.BaseModel): default=None, description="""Additional hyper-parameters to use during tuning.""", ) - single_reward_config: Optional[SingleReinforcementTuningRewardConfig] = Field( - default=None, - description="""Single reward function configuration for reinforcement tuning.""", - ) class ReinforcementTuningSpecDict(TypedDict, total=False): @@ -12777,6 +12777,9 @@ class ReinforcementTuningSpecDict(TypedDict, total=False): ] """""" + single_reward_config: Optional[SingleReinforcementTuningRewardConfigDict] + """Single reward function configuration for reinforcement tuning.""" + training_dataset_uri: Optional[str] """Cloud Storage path to file containing training dataset for tuning. The dataset must be formatted as a JSONL file.""" @@ -12786,9 +12789,6 @@ class ReinforcementTuningSpecDict(TypedDict, total=False): hyper_parameters: Optional[ReinforcementTuningHyperParametersDict] """Additional hyper-parameters to use during tuning.""" - single_reward_config: Optional[SingleReinforcementTuningRewardConfigDict] - """Single reward function configuration for reinforcement tuning.""" - ReinforcementTuningSpecOrDict = Union[ ReinforcementTuningSpec, ReinforcementTuningSpecDict @@ -14241,9 +14241,39 @@ class FullFineTuningSpecDict(TypedDict, total=False): FullFineTuningSpecOrDict = Union[FullFineTuningSpec, FullFineTuningSpecDict] +class TuningJobMetadata(_common.BaseModel): + """Tuning job metadata. This data type is not supported in Gemini API.""" + + completed_epoch_count: Optional[int] = Field( + default=None, + description="""Output only. The number of epochs that have been completed.""", + ) + completed_step_count: Optional[int] = Field( + default=None, + description="""Output only. The number of steps that have been completed. Set for Multi-Step RL.""", + ) + + +class TuningJobMetadataDict(TypedDict, total=False): + """Tuning job metadata. This data type is not supported in Gemini API.""" + + completed_epoch_count: Optional[int] + """Output only. The number of epochs that have been completed.""" + + completed_step_count: Optional[int] + """Output only. The number of steps that have been completed. Set for Multi-Step RL.""" + + +TuningJobMetadataOrDict = Union[TuningJobMetadata, TuningJobMetadataDict] + + class VeoHyperParameters(_common.BaseModel): """Hyperparameters for Veo. This data type is not supported in Gemini API.""" + adapter_size: Optional[AdapterSize] = Field( + default=None, + description="""Optional. The adapter size for LoRA tuning.""", + ) epoch_count: Optional[int] = Field( default=None, description="""Optional. Number of complete passes the model makes over the entire training dataset during training.""", @@ -14252,6 +14282,10 @@ class VeoHyperParameters(_common.BaseModel): default=None, description="""Optional. Multiplier for adjusting the default learning rate.""", ) + tuning_speed: Optional[TuningSpeed] = Field( + default=None, + description="""The speed of the tuning job. Only supported for Veo 3.0 models.""", + ) tuning_task: Optional[TuningTask] = Field( default=None, description="""The tuning task for Veo.""" ) @@ -14259,49 +14293,41 @@ class VeoHyperParameters(_common.BaseModel): default=None, description="""Optional. The ratio of Google internal dataset to use in the training mixture, in range of `[0, 1)`. If `0.2`, it means 20% of Google internal dataset and 80% of user dataset will be used for training. If not set, the default value is 0.1.""", ) - adapter_size: Optional[AdapterSize] = Field( - default=None, - description="""Optional. The adapter size for LoRA tuning.""", - ) - tuning_speed: Optional[TuningSpeed] = Field( - default=None, - description="""The speed of the tuning job. Only supported for Veo 3.0 models.""", - ) class VeoHyperParametersDict(TypedDict, total=False): """Hyperparameters for Veo. This data type is not supported in Gemini API.""" + adapter_size: Optional[AdapterSize] + """Optional. The adapter size for LoRA tuning.""" + epoch_count: Optional[int] """Optional. Number of complete passes the model makes over the entire training dataset during training.""" learning_rate_multiplier: Optional[float] """Optional. Multiplier for adjusting the default learning rate.""" + tuning_speed: Optional[TuningSpeed] + """The speed of the tuning job. Only supported for Veo 3.0 models.""" + tuning_task: Optional[TuningTask] """The tuning task for Veo.""" veo_data_mixture_ratio: Optional[float] """Optional. The ratio of Google internal dataset to use in the training mixture, in range of `[0, 1)`. If `0.2`, it means 20% of Google internal dataset and 80% of user dataset will be used for training. If not set, the default value is 0.1.""" - adapter_size: Optional[AdapterSize] - """Optional. The adapter size for LoRA tuning.""" - - tuning_speed: Optional[TuningSpeed] - """The speed of the tuning job. Only supported for Veo 3.0 models.""" - VeoHyperParametersOrDict = Union[VeoHyperParameters, VeoHyperParametersDict] -class VeoTuningSpec(_common.BaseModel): - """Tuning Spec for Veo Model Tuning. +class VeoLoraTuningSpec(_common.BaseModel): + """Tuning Spec for Veo LoRA Model Tuning. This data type is not supported in Gemini API. """ hyper_parameters: Optional[VeoHyperParameters] = Field( - default=None, description="""Optional. Hyperparameters for Veo.""" + default=None, description="""Optional. Hyperparameters for Veo LoRA.""" ) training_dataset_uri: Optional[str] = Field( default=None, @@ -14311,16 +14337,20 @@ class VeoTuningSpec(_common.BaseModel): default=None, description="""Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""", ) + video_orientation: Optional[VideoOrientation] = Field( + default=None, + description="""Optional. The orientation of the video. Defaults to LANDSCAPE.""", + ) -class VeoTuningSpecDict(TypedDict, total=False): - """Tuning Spec for Veo Model Tuning. +class VeoLoraTuningSpecDict(TypedDict, total=False): + """Tuning Spec for Veo LoRA Model Tuning. This data type is not supported in Gemini API. """ hyper_parameters: Optional[VeoHyperParametersDict] - """Optional. Hyperparameters for Veo.""" + """Optional. Hyperparameters for Veo LoRA.""" training_dataset_uri: Optional[str] """Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""" @@ -14328,44 +14358,21 @@ class VeoTuningSpecDict(TypedDict, total=False): validation_dataset_uri: Optional[str] """Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""" - -VeoTuningSpecOrDict = Union[VeoTuningSpec, VeoTuningSpecDict] - - -class TuningJobMetadata(_common.BaseModel): - """Tuning job metadata. This data type is not supported in Gemini API.""" - - completed_epoch_count: Optional[int] = Field( - default=None, - description="""Output only. The number of epochs that have been completed.""", - ) - completed_step_count: Optional[int] = Field( - default=None, - description="""Output only. The number of steps that have been completed. Set for Multi-Step RL.""", - ) - - -class TuningJobMetadataDict(TypedDict, total=False): - """Tuning job metadata. This data type is not supported in Gemini API.""" - - completed_epoch_count: Optional[int] - """Output only. The number of epochs that have been completed.""" - - completed_step_count: Optional[int] - """Output only. The number of steps that have been completed. Set for Multi-Step RL.""" + video_orientation: Optional[VideoOrientation] + """Optional. The orientation of the video. Defaults to LANDSCAPE.""" -TuningJobMetadataOrDict = Union[TuningJobMetadata, TuningJobMetadataDict] +VeoLoraTuningSpecOrDict = Union[VeoLoraTuningSpec, VeoLoraTuningSpecDict] -class VeoLoraTuningSpec(_common.BaseModel): - """Tuning Spec for Veo LoRA Model Tuning. +class VeoTuningSpec(_common.BaseModel): + """Tuning Spec for Veo Model Tuning. This data type is not supported in Gemini API. """ hyper_parameters: Optional[VeoHyperParameters] = Field( - default=None, description="""Optional. Hyperparameters for Veo LoRA.""" + default=None, description="""Optional. Hyperparameters for Veo.""" ) training_dataset_uri: Optional[str] = Field( default=None, @@ -14375,20 +14382,16 @@ class VeoLoraTuningSpec(_common.BaseModel): default=None, description="""Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""", ) - video_orientation: Optional[VideoOrientation] = Field( - default=None, - description="""Optional. The orientation of the video. Defaults to LANDSCAPE.""", - ) -class VeoLoraTuningSpecDict(TypedDict, total=False): - """Tuning Spec for Veo LoRA Model Tuning. +class VeoTuningSpecDict(TypedDict, total=False): + """Tuning Spec for Veo Model Tuning. This data type is not supported in Gemini API. """ hyper_parameters: Optional[VeoHyperParametersDict] - """Optional. Hyperparameters for Veo LoRA.""" + """Optional. Hyperparameters for Veo.""" training_dataset_uri: Optional[str] """Required. Training dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""" @@ -14396,11 +14399,8 @@ class VeoLoraTuningSpecDict(TypedDict, total=False): validation_dataset_uri: Optional[str] """Optional. Validation dataset used for tuning. The dataset can be specified as either a Cloud Storage path to a JSONL file or as the resource name of a Vertex Multimodal Dataset.""" - video_orientation: Optional[VideoOrientation] - """Optional. The orientation of the video. Defaults to LANDSCAPE.""" - -VeoLoraTuningSpecOrDict = Union[VeoLoraTuningSpec, VeoLoraTuningSpecDict] +VeoTuningSpecOrDict = Union[VeoTuningSpec, VeoTuningSpecDict] class TuningJob(_common.BaseModel): @@ -14458,6 +14458,9 @@ class TuningJob(_common.BaseModel): preference_optimization_spec: Optional[PreferenceOptimizationSpec] = Field( default=None, description="""Tuning Spec for Preference Optimization.""" ) + distillation_sampling_spec: Optional[DistillationSamplingSpec] = Field( + default=None, description="""""" + ) distillation_spec: Optional[DistillationSpec] = Field( default=None, description="""Tuning Spec for Distillation.""" ) @@ -14514,21 +14517,18 @@ class TuningJob(_common.BaseModel): default=None, description="""Optional. The display name of the TunedModel. The name can be up to 128 characters long and can consist of any UTF-8 characters. For continuous tuning, tuned_model_display_name will by default use the same display name as the pre-tuned model. If a new display name is provided, the tuning job will create a new model instead of a new version.""", ) + tuning_job_metadata: Optional[TuningJobMetadata] = Field( + default=None, description="""Output only. Tuning Job metadata.""" + ) tuning_job_state: Optional[TuningJobState] = Field( default=None, description="""Output only. The detail state of the tuning job (while the overall `JobState` is running).""", ) - veo_tuning_spec: Optional[VeoTuningSpec] = Field( - default=None, description="""Tuning Spec for Veo Tuning.""" - ) - tuning_job_metadata: Optional[TuningJobMetadata] = Field( - default=None, description="""Output only. Tuning Job metadata.""" - ) veo_lora_tuning_spec: Optional[VeoLoraTuningSpec] = Field( default=None, description="""Tuning Spec for Veo LoRA Tuning.""" ) - distillation_sampling_spec: Optional[DistillationSamplingSpec] = Field( - default=None, description="""""" + veo_tuning_spec: Optional[VeoTuningSpec] = Field( + default=None, description="""Tuning Spec for Veo Tuning.""" ) @property @@ -14587,6 +14587,9 @@ class TuningJobDict(TypedDict, total=False): preference_optimization_spec: Optional[PreferenceOptimizationSpecDict] """Tuning Spec for Preference Optimization.""" + distillation_sampling_spec: Optional[DistillationSamplingSpecDict] + """""" + distillation_spec: Optional[DistillationSpecDict] """Tuning Spec for Distillation.""" @@ -14632,20 +14635,17 @@ class TuningJobDict(TypedDict, total=False): tuned_model_display_name: Optional[str] """Optional. The display name of the TunedModel. The name can be up to 128 characters long and can consist of any UTF-8 characters. For continuous tuning, tuned_model_display_name will by default use the same display name as the pre-tuned model. If a new display name is provided, the tuning job will create a new model instead of a new version.""" - tuning_job_state: Optional[TuningJobState] - """Output only. The detail state of the tuning job (while the overall `JobState` is running).""" - - veo_tuning_spec: Optional[VeoTuningSpecDict] - """Tuning Spec for Veo Tuning.""" - tuning_job_metadata: Optional[TuningJobMetadataDict] """Output only. Tuning Job metadata.""" + tuning_job_state: Optional[TuningJobState] + """Output only. The detail state of the tuning job (while the overall `JobState` is running).""" + veo_lora_tuning_spec: Optional[VeoLoraTuningSpecDict] """Tuning Spec for Veo LoRA Tuning.""" - distillation_sampling_spec: Optional[DistillationSamplingSpecDict] - """""" + veo_tuning_spec: Optional[VeoTuningSpecDict] + """Tuning Spec for Veo Tuning.""" TuningJobOrDict = Union[TuningJob, TuningJobDict] @@ -14973,10 +14973,6 @@ class CreateTuningJobConfig(_common.BaseModel): default=None, description="""The Google Cloud Storage location where the tuning job outputs are written.""", ) - encryption_spec: Optional[EncryptionSpec] = Field( - default=None, - description="""The encryption spec of the tuning job. Customer-managed encryption key options for a TuningJob. If this is set, then all resources created by the TuningJob will be encrypted with provided encryption key.""", - ) reward_config: Optional[SingleReinforcementTuningRewardConfig] = Field( default=None, description="""Reward function configuration for reinforcement tuning. Reinforcement tuning only.""", @@ -15011,6 +15007,10 @@ class CreateTuningJobConfig(_common.BaseModel): default=None, description="""Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file. If no validation dataset is provided, by default the API splits 25% of the training dataset or 50 examples, whichever is larger, as the validation dataset. Reinforcement tuning only.""", ) + encryption_spec: Optional[EncryptionSpec] = Field( + default=None, + description="""The encryption spec of the tuning job. Customer-managed encryption key options for a TuningJob. If this is set, then all resources created by the TuningJob will be encrypted with provided encryption key.""", + ) class CreateTuningJobConfigDict(TypedDict, total=False): @@ -15079,9 +15079,6 @@ class CreateTuningJobConfigDict(TypedDict, total=False): output_uri: Optional[str] """The Google Cloud Storage location where the tuning job outputs are written.""" - encryption_spec: Optional[EncryptionSpecDict] - """The encryption spec of the tuning job. Customer-managed encryption key options for a TuningJob. If this is set, then all resources created by the TuningJob will be encrypted with provided encryption key.""" - reward_config: Optional[SingleReinforcementTuningRewardConfigDict] """Reward function configuration for reinforcement tuning. Reinforcement tuning only.""" @@ -15108,6 +15105,9 @@ class CreateTuningJobConfigDict(TypedDict, total=False): validation_dataset_uri: Optional[str] """Cloud Storage path to file containing validation dataset for tuning. The dataset must be formatted as a JSONL file. If no validation dataset is provided, by default the API splits 25% of the training dataset or 50 examples, whichever is larger, as the validation dataset. Reinforcement tuning only.""" + encryption_spec: Optional[EncryptionSpecDict] + """The encryption spec of the tuning job. Customer-managed encryption key options for a TuningJob. If this is set, then all resources created by the TuningJob will be encrypted with provided encryption key.""" + CreateTuningJobConfigOrDict = Union[ CreateTuningJobConfig, CreateTuningJobConfigDict @@ -16030,33 +16030,33 @@ class CustomMetadataDict(TypedDict, total=False): class Document(_common.BaseModel): """A Document is a collection of Chunks.""" - name: Optional[str] = Field( - default=None, - description="""Immutable. Identifier. The `Document` resource name. The ID (name excluding the "fileSearchStores/*/documents/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `fileSearchStores/{file_search_store_id}/documents/my-awesome-doc-123a456b789c`""", - ) - display_name: Optional[str] = Field( + create_time: Optional[datetime.datetime] = Field( default=None, - description="""Optional. The human-readable display name for the `Document`. The display name must be no more than 512 characters in length, including spaces. Example: "Semantic Retriever Documentation".""", + description="""Output only. The Timestamp of when the `Document` was created.""", ) - state: Optional[DocumentState] = Field( + custom_metadata: Optional[list[CustomMetadata]] = Field( default=None, - description="""Output only. Current state of the `Document`.""", + description="""Optional. User provided custom metadata stored as key-value pairs used for querying. A `Document` can have a maximum of 20 `CustomMetadata`.""", ) - size_bytes: Optional[int] = Field( + display_name: Optional[str] = Field( default=None, - description="""Output only. The size of raw bytes ingested into the Document.""", + description="""Optional. The human-readable display name for the `Document`. The display name must be no more than 512 characters in length, including spaces. Example: "Semantic Retriever Documentation".""", ) mime_type: Optional[str] = Field( default=None, description="""Output only. The mime type of the Document.""", ) - create_time: Optional[datetime.datetime] = Field( + name: Optional[str] = Field( default=None, - description="""Output only. The Timestamp of when the `Document` was created.""", + description="""Immutable. Identifier. The `Document` resource name. The ID (name excluding the "fileSearchStores/*/documents/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `fileSearchStores/{file_search_store_id}/documents/my-awesome-doc-123a456b789c`""", ) - custom_metadata: Optional[list[CustomMetadata]] = Field( + size_bytes: Optional[int] = Field( + default=None, + description="""Output only. The size of raw bytes ingested into the Document.""", + ) + state: Optional[DocumentState] = Field( default=None, - description="""Optional. User provided custom metadata stored as key-value pairs used for querying. A `Document` can have a maximum of 20 `CustomMetadata`.""", + description="""Output only. Current state of the `Document`.""", ) update_time: Optional[datetime.datetime] = Field( default=None, @@ -16067,26 +16067,26 @@ class Document(_common.BaseModel): class DocumentDict(TypedDict, total=False): """A Document is a collection of Chunks.""" - name: Optional[str] - """Immutable. Identifier. The `Document` resource name. The ID (name excluding the "fileSearchStores/*/documents/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `fileSearchStores/{file_search_store_id}/documents/my-awesome-doc-123a456b789c`""" + create_time: Optional[datetime.datetime] + """Output only. The Timestamp of when the `Document` was created.""" + + custom_metadata: Optional[list[CustomMetadataDict]] + """Optional. User provided custom metadata stored as key-value pairs used for querying. A `Document` can have a maximum of 20 `CustomMetadata`.""" display_name: Optional[str] """Optional. The human-readable display name for the `Document`. The display name must be no more than 512 characters in length, including spaces. Example: "Semantic Retriever Documentation".""" - state: Optional[DocumentState] - """Output only. Current state of the `Document`.""" - - size_bytes: Optional[int] - """Output only. The size of raw bytes ingested into the Document.""" - mime_type: Optional[str] """Output only. The mime type of the Document.""" - create_time: Optional[datetime.datetime] - """Output only. The Timestamp of when the `Document` was created.""" + name: Optional[str] + """Immutable. Identifier. The `Document` resource name. The ID (name excluding the "fileSearchStores/*/documents/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `fileSearchStores/{file_search_store_id}/documents/my-awesome-doc-123a456b789c`""" - custom_metadata: Optional[list[CustomMetadataDict]] - """Optional. User provided custom metadata stored as key-value pairs used for querying. A `Document` can have a maximum of 20 `CustomMetadata`.""" + size_bytes: Optional[int] + """Output only. The size of raw bytes ingested into the Document.""" + + state: Optional[DocumentState] + """Output only. Current state of the `Document`.""" update_time: Optional[datetime.datetime] """Output only. The Timestamp of when the `Document` was last updated.""" @@ -16307,73 +16307,73 @@ class _CreateFileSearchStoreParametersDict(TypedDict, total=False): class FileSearchStore(_common.BaseModel): """A collection of Documents.""" - name: Optional[str] = Field( + embedding_model: Optional[str] = Field( default=None, - description="""Output only. Immutable. Identifier. The `FileSearchStore` resource name. It is an ID (name excluding the "fileSearchStores/" prefix) that can contain up to 40 characters that are lowercase alphanumeric or dashes (-). It is output only. The unique name will be derived from `display_name` along with a 12 character random suffix. Example: `fileSearchStores/my-awesome-file-search-store-123a456b789c` If `display_name` is not provided, the name will be randomly generated.""", + description="""The embedding model used by the FileSearchStore.""", ) - display_name: Optional[str] = Field( + active_documents_count: Optional[int] = Field( default=None, - description="""Optional. The human-readable display name for the `FileSearchStore`. The display name must be no more than 512 characters in length, including spaces. Example: "Docs on Semantic Retriever".""", + description="""Output only. The number of documents in the `FileSearchStore` that are active and ready for retrieval.""", ) create_time: Optional[datetime.datetime] = Field( default=None, description="""Output only. The Timestamp of when the `FileSearchStore` was created.""", ) - update_time: Optional[datetime.datetime] = Field( + display_name: Optional[str] = Field( default=None, - description="""Output only. The Timestamp of when the `FileSearchStore` was last updated.""", + description="""Optional. The human-readable display name for the `FileSearchStore`. The display name must be no more than 512 characters in length, including spaces. Example: "Docs on Semantic Retriever".""", ) - active_documents_count: Optional[int] = Field( + failed_documents_count: Optional[int] = Field( default=None, - description="""Output only. The number of documents in the `FileSearchStore` that are active and ready for retrieval.""", + description="""Output only. The number of documents in the `FileSearchStore` that have failed processing.""", ) - pending_documents_count: Optional[int] = Field( + name: Optional[str] = Field( default=None, - description="""Output only. The number of documents in the `FileSearchStore` that are being processed.""", + description="""Output only. Immutable. Identifier. The `FileSearchStore` resource name. It is an ID (name excluding the "fileSearchStores/" prefix) that can contain up to 40 characters that are lowercase alphanumeric or dashes (-). It is output only. The unique name will be derived from `display_name` along with a 12 character random suffix. Example: `fileSearchStores/my-awesome-file-search-store-123a456b789c` If `display_name` is not provided, the name will be randomly generated.""", ) - failed_documents_count: Optional[int] = Field( + pending_documents_count: Optional[int] = Field( default=None, - description="""Output only. The number of documents in the `FileSearchStore` that have failed processing.""", + description="""Output only. The number of documents in the `FileSearchStore` that are being processed.""", ) size_bytes: Optional[int] = Field( default=None, description="""Output only. The size of raw bytes ingested into the `FileSearchStore`. This is the total size of all the documents in the `FileSearchStore`.""", ) - embedding_model: Optional[str] = Field( + update_time: Optional[datetime.datetime] = Field( default=None, - description="""The embedding model used by the FileSearchStore.""", + description="""Output only. The Timestamp of when the `FileSearchStore` was last updated.""", ) class FileSearchStoreDict(TypedDict, total=False): """A collection of Documents.""" - name: Optional[str] - """Output only. Immutable. Identifier. The `FileSearchStore` resource name. It is an ID (name excluding the "fileSearchStores/" prefix) that can contain up to 40 characters that are lowercase alphanumeric or dashes (-). It is output only. The unique name will be derived from `display_name` along with a 12 character random suffix. Example: `fileSearchStores/my-awesome-file-search-store-123a456b789c` If `display_name` is not provided, the name will be randomly generated.""" + embedding_model: Optional[str] + """The embedding model used by the FileSearchStore.""" - display_name: Optional[str] - """Optional. The human-readable display name for the `FileSearchStore`. The display name must be no more than 512 characters in length, including spaces. Example: "Docs on Semantic Retriever".""" + active_documents_count: Optional[int] + """Output only. The number of documents in the `FileSearchStore` that are active and ready for retrieval.""" create_time: Optional[datetime.datetime] """Output only. The Timestamp of when the `FileSearchStore` was created.""" - update_time: Optional[datetime.datetime] - """Output only. The Timestamp of when the `FileSearchStore` was last updated.""" + display_name: Optional[str] + """Optional. The human-readable display name for the `FileSearchStore`. The display name must be no more than 512 characters in length, including spaces. Example: "Docs on Semantic Retriever".""" - active_documents_count: Optional[int] - """Output only. The number of documents in the `FileSearchStore` that are active and ready for retrieval.""" + failed_documents_count: Optional[int] + """Output only. The number of documents in the `FileSearchStore` that have failed processing.""" + + name: Optional[str] + """Output only. Immutable. Identifier. The `FileSearchStore` resource name. It is an ID (name excluding the "fileSearchStores/" prefix) that can contain up to 40 characters that are lowercase alphanumeric or dashes (-). It is output only. The unique name will be derived from `display_name` along with a 12 character random suffix. Example: `fileSearchStores/my-awesome-file-search-store-123a456b789c` If `display_name` is not provided, the name will be randomly generated.""" pending_documents_count: Optional[int] """Output only. The number of documents in the `FileSearchStore` that are being processed.""" - failed_documents_count: Optional[int] - """Output only. The number of documents in the `FileSearchStore` that have failed processing.""" - size_bytes: Optional[int] """Output only. The size of raw bytes ingested into the `FileSearchStore`. This is the total size of all the documents in the `FileSearchStore`.""" - embedding_model: Optional[str] - """The embedding model used by the FileSearchStore.""" + update_time: Optional[datetime.datetime] + """Output only. The Timestamp of when the `FileSearchStore` was last updated.""" FileSearchStoreOrDict = Union[FileSearchStore, FileSearchStoreDict] @@ -17239,6 +17239,11 @@ class BatchJobSource(_common.BaseModel): description="""The BigQuery URI to input table. """, ) + vertex_dataset_name: Optional[str] = Field( + default=None, + description="""This field is experimental and may change in future versions. The Vertex AI dataset resource name to use as input. Must be of type multimodal. + """, + ) file_name: Optional[str] = Field( default=None, description="""The Gemini Developer API's file resource name of the input data @@ -17250,11 +17255,6 @@ class BatchJobSource(_common.BaseModel): description="""The Gemini Developer API's inlined input data to run batch job. """, ) - vertex_dataset_name: Optional[str] = Field( - default=None, - description="""This field is experimental and may change in future versions. The Vertex AI dataset resource name to use as input. Must be of type multimodal. - """, - ) class BatchJobSourceDict(TypedDict, total=False): @@ -17273,6 +17273,10 @@ class BatchJobSourceDict(TypedDict, total=False): """The BigQuery URI to input table. """ + vertex_dataset_name: Optional[str] + """This field is experimental and may change in future versions. The Vertex AI dataset resource name to use as input. Must be of type multimodal. + """ + file_name: Optional[str] """The Gemini Developer API's file resource name of the input data (e.g. "files/12345"). @@ -17282,10 +17286,6 @@ class BatchJobSourceDict(TypedDict, total=False): """The Gemini Developer API's inlined input data to run batch job. """ - vertex_dataset_name: Optional[str] - """This field is experimental and may change in future versions. The Vertex AI dataset resource name to use as input. Must be of type multimodal. - """ - BatchJobSourceOrDict = Union[BatchJobSource, BatchJobSourceDict] @@ -17476,6 +17476,11 @@ class BatchJobDestination(_common.BaseModel): description="""The BigQuery URI to the output table. """, ) + vertex_dataset: Optional[VertexMultimodalDatasetDestination] = Field( + default=None, + description="""This field is experimental and may change in future versions. The Vertex AI dataset destination. + """, + ) file_name: Optional[str] = Field( default=None, description="""The Gemini Developer API's file resource name of the output data @@ -17501,11 +17506,6 @@ class BatchJobDestination(_common.BaseModel): the input requests. """, ) - vertex_dataset: Optional[VertexMultimodalDatasetDestination] = Field( - default=None, - description="""This field is experimental and may change in future versions. The Vertex AI dataset destination. - """, - ) class BatchJobDestinationDict(TypedDict, total=False): @@ -17524,6 +17524,10 @@ class BatchJobDestinationDict(TypedDict, total=False): """The BigQuery URI to the output table. """ + vertex_dataset: Optional[VertexMultimodalDatasetDestinationDict] + """This field is experimental and may change in future versions. The Vertex AI dataset destination. + """ + file_name: Optional[str] """The Gemini Developer API's file resource name of the output data (e.g. "files/12345"). The file will be a JSONL file with a single response @@ -17546,10 +17550,6 @@ class BatchJobDestinationDict(TypedDict, total=False): the input requests. """ - vertex_dataset: Optional[VertexMultimodalDatasetDestinationDict] - """This field is experimental and may change in future versions. The Vertex AI dataset destination. - """ - BatchJobDestinationOrDict = Union[BatchJobDestination, BatchJobDestinationDict] @@ -17667,10 +17667,6 @@ class _CreateBatchJobParametersDict(TypedDict, total=False): class BatchJobOutputInfo(_common.BaseModel): """Represents the `output_info` field in batch jobs.""" - vertex_multimodal_dataset_name: Optional[str] = Field( - default=None, - description="""This field is experimental and may change in future versions. The Vertex AI dataset name containing the output data.""", - ) gcs_output_directory: Optional[str] = Field( default=None, description="""The full path of the Cloud Storage directory created, into which the prediction output is written.""", @@ -17679,20 +17675,24 @@ class BatchJobOutputInfo(_common.BaseModel): default=None, description="""The name of the BigQuery table created, in `predictions_TIMESTAMP` format, into which the prediction output is written.""", ) + vertex_multimodal_dataset_name: Optional[str] = Field( + default=None, + description="""This field is experimental and may change in future versions. The Vertex AI dataset name containing the output data.""", + ) class BatchJobOutputInfoDict(TypedDict, total=False): """Represents the `output_info` field in batch jobs.""" - vertex_multimodal_dataset_name: Optional[str] - """This field is experimental and may change in future versions. The Vertex AI dataset name containing the output data.""" - gcs_output_directory: Optional[str] """The full path of the Cloud Storage directory created, into which the prediction output is written.""" bigquery_output_table: Optional[str] """The name of the BigQuery table created, in `predictions_TIMESTAMP` format, into which the prediction output is written.""" + vertex_multimodal_dataset_name: Optional[str] + """This field is experimental and may change in future versions. The Vertex AI dataset name containing the output data.""" + BatchJobOutputInfoOrDict = Union[BatchJobOutputInfo, BatchJobOutputInfoDict] @@ -17799,14 +17799,14 @@ class BatchJob(_common.BaseModel): description="""Configuration for the output data. """, ) - completion_stats: Optional[CompletionStats] = Field( + output_info: Optional[BatchJobOutputInfo] = Field( default=None, - description="""Statistics on completed and failed prediction instances. This field is for Gemini Enterprise Agent Platform only. + description="""Information further describing the output of this job. Output only. """, ) - output_info: Optional[BatchJobOutputInfo] = Field( + completion_stats: Optional[CompletionStats] = Field( default=None, - description="""Information further describing the output of this job. Output only. + description="""Statistics on completed and failed prediction instances. This field is for Gemini Enterprise Agent Platform only. """, ) @@ -17882,14 +17882,14 @@ class BatchJobDict(TypedDict, total=False): """Configuration for the output data. """ - completion_stats: Optional[CompletionStatsDict] - """Statistics on completed and failed prediction instances. This field is for Gemini Enterprise Agent Platform only. - """ - output_info: Optional[BatchJobOutputInfoDict] """Information further describing the output of this job. Output only. """ + completion_stats: Optional[CompletionStatsDict] + """Statistics on completed and failed prediction instances. This field is for Gemini Enterprise Agent Platform only. + """ + BatchJobOrDict = Union[BatchJob, BatchJobDict] @@ -19340,6 +19340,10 @@ class LiveServerContent(_common.BaseModel): turn which means it doesn’t imply any ordering between transcription and model turn.""", ) + interim_input_transcription: Optional[Transcription] = Field( + default=None, + description="""Low latency transcription updated while the user is speaking.""", + ) output_transcription: Optional[Transcription] = Field( default=None, description="""Output transcription. The transcription is independent to the model @@ -19360,10 +19364,6 @@ class LiveServerContent(_common.BaseModel): it is waiting for more input from the user, e.g. because it expects the user to continue talking.""", ) - interim_input_transcription: Optional[Transcription] = Field( - default=None, - description="""Low latency transcription updated while the user is speaking.""", - ) class LiveServerContentDict(TypedDict, total=False): @@ -19400,6 +19400,9 @@ class LiveServerContentDict(TypedDict, total=False): turn which means it doesn’t imply any ordering between transcription and model turn.""" + interim_input_transcription: Optional[TranscriptionDict] + """Low latency transcription updated while the user is speaking.""" + output_transcription: Optional[TranscriptionDict] """Output transcription. The transcription is independent to the model turn which means it doesn’t imply any ordering between transcription and @@ -19417,9 +19420,6 @@ class LiveServerContentDict(TypedDict, total=False): it is waiting for more input from the user, e.g. because it expects the user to continue talking.""" - interim_input_transcription: Optional[TranscriptionDict] - """Low latency transcription updated while the user is speaking.""" - LiveServerContentOrDict = Union[LiveServerContent, LiveServerContentDict] @@ -19475,46 +19475,46 @@ class LiveServerToolCallCancellationDict(TypedDict, total=False): class UsageMetadata(_common.BaseModel): """Usage metadata about response(s).""" - prompt_token_count: Optional[int] = Field( - default=None, - description="""The total number of tokens in the prompt. This includes any text, images, or other media provided in the request. When `cached_content` is set, this also includes the number of tokens in the cached content.""", - ) - cached_content_token_count: Optional[int] = Field( - default=None, - description="""Output only. The number of tokens in the cached content that was used for this request.""", - ) response_token_count: Optional[int] = Field( default=None, description="""Total number of tokens across all the generated response candidates.""", ) - tool_use_prompt_token_count: Optional[int] = Field( + response_tokens_details: Optional[list[ModalityTokenCount]] = Field( default=None, - description="""Output only. The number of tokens in the results from tool executions, which are provided back to the model as input, if applicable.""", + description="""List of modalities that were returned in the response.""", ) - thoughts_token_count: Optional[int] = Field( + cache_tokens_details: Optional[list[ModalityTokenCount]] = Field( default=None, - description="""Output only. The number of tokens that were part of the model's generated "thoughts" output, if applicable.""", + description="""Output only. A detailed breakdown of the token count for each modality in the cached content.""", ) - total_token_count: Optional[int] = Field( + cached_content_token_count: Optional[int] = Field( default=None, - description="""The total number of tokens for the entire request. This is the sum of `prompt_token_count`, `candidates_token_count`, `tool_use_prompt_token_count`, and `thoughts_token_count`.""", + description="""Output only. The number of tokens in the cached content that was used for this request.""", + ) + prompt_token_count: Optional[int] = Field( + default=None, + description="""The total number of tokens in the prompt. This includes any text, images, or other media provided in the request. When `cached_content` is set, this also includes the number of tokens in the cached content.""", ) prompt_tokens_details: Optional[list[ModalityTokenCount]] = Field( default=None, description="""Output only. A detailed breakdown of the token count for each modality in the prompt.""", ) - cache_tokens_details: Optional[list[ModalityTokenCount]] = Field( + thoughts_token_count: Optional[int] = Field( default=None, - description="""Output only. A detailed breakdown of the token count for each modality in the cached content.""", + description="""Output only. The number of tokens that were part of the model's generated "thoughts" output, if applicable.""", ) - response_tokens_details: Optional[list[ModalityTokenCount]] = Field( + tool_use_prompt_token_count: Optional[int] = Field( default=None, - description="""List of modalities that were returned in the response.""", + description="""Output only. The number of tokens in the results from tool executions, which are provided back to the model as input, if applicable.""", ) tool_use_prompt_tokens_details: Optional[list[ModalityTokenCount]] = Field( default=None, description="""Output only. A detailed breakdown by modality of the token counts from the results of tool executions, which are provided back to the model as input.""", ) + total_token_count: Optional[int] = Field( + default=None, + description="""The total number of tokens for the entire request. This is the sum of `prompt_token_count`, `candidates_token_count`, `tool_use_prompt_token_count`, and `thoughts_token_count`.""", + ) traffic_type: Optional[TrafficType] = Field( default=None, description="""Output only. The traffic type for this request. This field is not supported in Gemini API.""", @@ -19528,36 +19528,36 @@ class UsageMetadata(_common.BaseModel): class UsageMetadataDict(TypedDict, total=False): """Usage metadata about response(s).""" - prompt_token_count: Optional[int] - """The total number of tokens in the prompt. This includes any text, images, or other media provided in the request. When `cached_content` is set, this also includes the number of tokens in the cached content.""" - - cached_content_token_count: Optional[int] - """Output only. The number of tokens in the cached content that was used for this request.""" - response_token_count: Optional[int] """Total number of tokens across all the generated response candidates.""" - tool_use_prompt_token_count: Optional[int] - """Output only. The number of tokens in the results from tool executions, which are provided back to the model as input, if applicable.""" + response_tokens_details: Optional[list[ModalityTokenCountDict]] + """List of modalities that were returned in the response.""" - thoughts_token_count: Optional[int] - """Output only. The number of tokens that were part of the model's generated "thoughts" output, if applicable.""" + cache_tokens_details: Optional[list[ModalityTokenCountDict]] + """Output only. A detailed breakdown of the token count for each modality in the cached content.""" - total_token_count: Optional[int] - """The total number of tokens for the entire request. This is the sum of `prompt_token_count`, `candidates_token_count`, `tool_use_prompt_token_count`, and `thoughts_token_count`.""" + cached_content_token_count: Optional[int] + """Output only. The number of tokens in the cached content that was used for this request.""" + + prompt_token_count: Optional[int] + """The total number of tokens in the prompt. This includes any text, images, or other media provided in the request. When `cached_content` is set, this also includes the number of tokens in the cached content.""" prompt_tokens_details: Optional[list[ModalityTokenCountDict]] """Output only. A detailed breakdown of the token count for each modality in the prompt.""" - cache_tokens_details: Optional[list[ModalityTokenCountDict]] - """Output only. A detailed breakdown of the token count for each modality in the cached content.""" + thoughts_token_count: Optional[int] + """Output only. The number of tokens that were part of the model's generated "thoughts" output, if applicable.""" - response_tokens_details: Optional[list[ModalityTokenCountDict]] - """List of modalities that were returned in the response.""" + tool_use_prompt_token_count: Optional[int] + """Output only. The number of tokens in the results from tool executions, which are provided back to the model as input, if applicable.""" tool_use_prompt_tokens_details: Optional[list[ModalityTokenCountDict]] """Output only. A detailed breakdown by modality of the token counts from the results of tool executions, which are provided back to the model as input.""" + total_token_count: Optional[int] + """The total number of tokens for the entire request. This is the sum of `prompt_token_count`, `candidates_token_count`, `tool_use_prompt_token_count`, and `thoughts_token_count`.""" + traffic_type: Optional[TrafficType] """Output only. The traffic type for this request. This field is not supported in Gemini API.""" @@ -20172,16 +20172,16 @@ class LiveClientSetup(_common.BaseModel): description="""Configures the proactivity of the model. This allows the model to respond proactively to the input and to ignore irrelevant input.""", ) + history_config: Optional[HistoryConfig] = Field( + default=None, + description="""Configures the exchange of history between the client and the server.""", + ) explicit_vad_signal: Optional[bool] = Field( default=None, description="""Configures the explicit VAD signal. If enabled, the client will send vad_signal to indicate the start and end of speech. This allows the server to process the audio more efficiently.""", ) - history_config: Optional[HistoryConfig] = Field( - default=None, - description="""Configures the exchange of history between the client and the server.""", - ) avatar_config: Optional[AvatarConfig] = Field( default=None, description="""Configures the avatar model behavior.""" ) @@ -20242,14 +20242,14 @@ class LiveClientSetupDict(TypedDict, total=False): """Configures the proactivity of the model. This allows the model to respond proactively to the input and to ignore irrelevant input.""" + history_config: Optional[HistoryConfigDict] + """Configures the exchange of history between the client and the server.""" + explicit_vad_signal: Optional[bool] """Configures the explicit VAD signal. If enabled, the client will send vad_signal to indicate the start and end of speech. This allows the server to process the audio more efficiently.""" - history_config: Optional[HistoryConfigDict] - """Configures the exchange of history between the client and the server.""" - avatar_config: Optional[AvatarConfigDict] """Configures the avatar model behavior.""" @@ -20778,16 +20778,16 @@ class LiveConnectConfig(_common.BaseModel): description="""Configures the proactivity of the model. This allows the model to respond proactively to the input and to ignore irrelevant input.""", ) + history_config: Optional[HistoryConfig] = Field( + default=None, + description="""Configures the exchange of history between the client and the server.""", + ) explicit_vad_signal: Optional[bool] = Field( default=None, description="""Configures the explicit VAD signal. If enabled, the client will send vad_signal to indicate the start and end of speech. This allows the server to process the audio more efficiently.""", ) - history_config: Optional[HistoryConfig] = Field( - default=None, - description="""Configures the exchange of history between the client and the server.""", - ) avatar_config: Optional[AvatarConfig] = Field( default=None, description="""Configures the avatar model behavior.""" ) @@ -20902,14 +20902,14 @@ class LiveConnectConfigDict(TypedDict, total=False): """Configures the proactivity of the model. This allows the model to respond proactively to the input and to ignore irrelevant input.""" + history_config: Optional[HistoryConfigDict] + """Configures the exchange of history between the client and the server.""" + explicit_vad_signal: Optional[bool] """Configures the explicit VAD signal. If enabled, the client will send vad_signal to indicate the start and end of speech. This allows the server to process the audio more efficiently.""" - history_config: Optional[HistoryConfigDict] - """Configures the exchange of history between the client and the server.""" - avatar_config: Optional[AvatarConfigDict] """Configures the avatar model behavior."""