diff --git a/google/genai/_live_converters.py b/google/genai/_live_converters.py index 5512f3876..63130d80a 100644 --- a/google/genai/_live_converters.py +++ b/google/genai/_live_converters.py @@ -90,26 +90,6 @@ def _Blob_to_mldev( return to_object -def _CodeExecutionResult_to_vertex( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['outcome']) is not None: - setv(to_object, ['outcome'], getv(from_object, ['outcome'])) - - if getv(from_object, ['output']) is not None: - setv(to_object, ['output'], getv(from_object, ['output'])) - - if getv(from_object, ['id']) is not None: - raise ValueError( - 'id parameter is only supported in Gemini Developer API mode, not in' - ' Gemini Enterprise Agent Platform mode.' - ) - - return to_object - - def _ComputerUse_to_vertex( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -183,26 +163,6 @@ def _Content_to_vertex( return to_object -def _ExecutableCode_to_vertex( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['code']) is not None: - setv(to_object, ['code'], getv(from_object, ['code'])) - - if getv(from_object, ['language']) is not None: - setv(to_object, ['language'], getv(from_object, ['language'])) - - if getv(from_object, ['id']) is not None: - raise ValueError( - 'id parameter is only supported in Gemini Developer API mode, not in' - ' Gemini Enterprise Agent Platform mode.' - ) - - return to_object - - def _FileData_to_mldev( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -1691,19 +1651,11 @@ def _Part_to_vertex( setv( to_object, ['codeExecutionResult'], - _CodeExecutionResult_to_vertex( - getv(from_object, ['code_execution_result']), to_object - ), + getv(from_object, ['code_execution_result']), ) if getv(from_object, ['executable_code']) is not None: - setv( - to_object, - ['executableCode'], - _ExecutableCode_to_vertex( - getv(from_object, ['executable_code']), to_object - ), - ) + setv(to_object, ['executableCode'], getv(from_object, ['executable_code'])) if getv(from_object, ['file_data']) is not None: setv(to_object, ['fileData'], getv(from_object, ['file_data'])) diff --git a/google/genai/caches.py b/google/genai/caches.py index 90c77e897..a8c4c2c46 100644 --- a/google/genai/caches.py +++ b/google/genai/caches.py @@ -99,26 +99,6 @@ def _Blob_to_mldev( return to_object -def _CodeExecutionResult_to_vertex( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['outcome']) is not None: - setv(to_object, ['outcome'], getv(from_object, ['outcome'])) - - if getv(from_object, ['output']) is not None: - setv(to_object, ['output'], getv(from_object, ['output'])) - - if getv(from_object, ['id']) is not None: - raise ValueError( - 'id parameter is only supported in Gemini Developer API mode, not in' - ' Gemini Enterprise Agent Platform mode.' - ) - - return to_object - - def _ComputerUse_to_vertex( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -413,26 +393,6 @@ def _DeleteCachedContentResponse_from_vertex( return to_object -def _ExecutableCode_to_vertex( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['code']) is not None: - setv(to_object, ['code'], getv(from_object, ['code'])) - - if getv(from_object, ['language']) is not None: - setv(to_object, ['language'], getv(from_object, ['language'])) - - if getv(from_object, ['id']) is not None: - raise ValueError( - 'id parameter is only supported in Gemini Developer API mode, not in' - ' Gemini Enterprise Agent Platform mode.' - ) - - return to_object - - def _FileData_to_mldev( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -819,19 +779,11 @@ def _Part_to_vertex( setv( to_object, ['codeExecutionResult'], - _CodeExecutionResult_to_vertex( - getv(from_object, ['code_execution_result']), to_object - ), + getv(from_object, ['code_execution_result']), ) if getv(from_object, ['executable_code']) is not None: - setv( - to_object, - ['executableCode'], - _ExecutableCode_to_vertex( - getv(from_object, ['executable_code']), to_object - ), - ) + setv(to_object, ['executableCode'], getv(from_object, ['executable_code'])) if getv(from_object, ['file_data']) is not None: setv(to_object, ['fileData'], getv(from_object, ['file_data'])) diff --git a/google/genai/models.py b/google/genai/models.py index e0c417b71..45b20c724 100644 --- a/google/genai/models.py +++ b/google/genai/models.py @@ -207,27 +207,6 @@ def _CitationMetadata_from_mldev( return to_object -def _CodeExecutionResult_to_vertex( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, - root_object: Optional[Union[dict[str, Any], object]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['outcome']) is not None: - setv(to_object, ['outcome'], getv(from_object, ['outcome'])) - - if getv(from_object, ['output']) is not None: - setv(to_object, ['output'], getv(from_object, ['output'])) - - if getv(from_object, ['id']) is not None: - raise ValueError( - 'id parameter is only supported in Gemini Developer API mode, not in' - ' Gemini Enterprise Agent Platform mode.' - ) - - return to_object - - def _ComputeTokensParameters_to_vertex( api_client: BaseApiClient, from_object: Union[dict[str, Any], object], @@ -1172,27 +1151,6 @@ def _Endpoint_from_vertex( return to_object -def _ExecutableCode_to_vertex( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, - root_object: Optional[Union[dict[str, Any], object]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['code']) is not None: - setv(to_object, ['code'], getv(from_object, ['code'])) - - if getv(from_object, ['language']) is not None: - setv(to_object, ['language'], getv(from_object, ['language'])) - - if getv(from_object, ['id']) is not None: - raise ValueError( - 'id parameter is only supported in Gemini Developer API mode, not in' - ' Gemini Enterprise Agent Platform mode.' - ) - - return to_object - - def _FileData_to_mldev( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -3726,19 +3684,11 @@ def _Part_to_vertex( setv( to_object, ['codeExecutionResult'], - _CodeExecutionResult_to_vertex( - getv(from_object, ['code_execution_result']), to_object, root_object - ), + getv(from_object, ['code_execution_result']), ) if getv(from_object, ['executable_code']) is not None: - setv( - to_object, - ['executableCode'], - _ExecutableCode_to_vertex( - getv(from_object, ['executable_code']), to_object, root_object - ), - ) + setv(to_object, ['executableCode'], getv(from_object, ['executable_code'])) if getv(from_object, ['file_data']) is not None: setv(to_object, ['fileData'], getv(from_object, ['file_data'])) diff --git a/google/genai/tunings.py b/google/genai/tunings.py index 13d9283e6..8ef516b3e 100644 --- a/google/genai/tunings.py +++ b/google/genai/tunings.py @@ -138,27 +138,6 @@ def _CancelTuningJobResponse_from_vertex( return to_object -def _CodeExecutionResult_to_vertex( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, - root_object: Optional[Union[dict[str, Any], object]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['outcome']) is not None: - setv(to_object, ['outcome'], getv(from_object, ['outcome'])) - - if getv(from_object, ['output']) is not None: - setv(to_object, ['output'], getv(from_object, ['output'])) - - if getv(from_object, ['id']) is not None: - raise ValueError( - 'id parameter is only supported in Gemini Developer API mode, not in' - ' Gemini Enterprise Agent Platform mode.' - ) - - return to_object - - def _CompositeReinforcementTuningRewardConfigWeightedRewardConfig_from_vertex( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -1108,27 +1087,6 @@ def _EvaluationConfig_to_vertex( return to_object -def _ExecutableCode_to_vertex( - from_object: Union[dict[str, Any], object], - parent_object: Optional[dict[str, Any]] = None, - root_object: Optional[Union[dict[str, Any], object]] = None, -) -> dict[str, Any]: - to_object: dict[str, Any] = {} - if getv(from_object, ['code']) is not None: - setv(to_object, ['code'], getv(from_object, ['code'])) - - if getv(from_object, ['language']) is not None: - setv(to_object, ['language'], getv(from_object, ['language'])) - - if getv(from_object, ['id']) is not None: - raise ValueError( - 'id parameter is only supported in Gemini Developer API mode, not in' - ' Gemini Enterprise Agent Platform mode.' - ) - - return to_object - - def _GenerationConfig_from_vertex( from_object: Union[dict[str, Any], object], parent_object: Optional[dict[str, Any]] = None, @@ -1517,19 +1475,11 @@ def _Part_to_vertex( setv( to_object, ['codeExecutionResult'], - _CodeExecutionResult_to_vertex( - getv(from_object, ['code_execution_result']), to_object, root_object - ), + getv(from_object, ['code_execution_result']), ) if getv(from_object, ['executable_code']) is not None: - setv( - to_object, - ['executableCode'], - _ExecutableCode_to_vertex( - getv(from_object, ['executable_code']), to_object, root_object - ), - ) + setv(to_object, ['executableCode'], getv(from_object, ['executable_code'])) if getv(from_object, ['file_data']) is not None: setv(to_object, ['fileData'], getv(from_object, ['file_data'])) diff --git a/google/genai/types.py b/google/genai/types.py index 78266988b..474117fdf 100644 --- a/google/genai/types.py +++ b/google/genai/types.py @@ -419,6 +419,8 @@ class HarmCategory(_common.CaseInSensitiveEnum): """Content that promotes, facilitates, or enables dangerous activities.""" HARM_CATEGORY_CIVIC_INTEGRITY = 'HARM_CATEGORY_CIVIC_INTEGRITY' """Deprecated: Election filter is not longer supported. The harm category is civic integrity.""" + HARM_CATEGORY_JAILBREAK = 'HARM_CATEGORY_JAILBREAK' + """Prompts designed to bypass safety filters.""" HARM_CATEGORY_IMAGE_HATE = 'HARM_CATEGORY_IMAGE_HATE' """Images that contain hate speech. This enum value is not supported in Gemini API.""" HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT = ( @@ -431,8 +433,6 @@ class HarmCategory(_common.CaseInSensitiveEnum): 'HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT' ) """Images that contain sexually explicit content. This enum value is not supported in Gemini API.""" - HARM_CATEGORY_JAILBREAK = 'HARM_CATEGORY_JAILBREAK' - """Prompts designed to bypass safety filters. This enum value is not supported in Gemini API.""" class HarmBlockMethod(_common.CaseInSensitiveEnum): @@ -1603,7 +1603,7 @@ class CodeExecutionResult(_common.BaseModel): ) id: Optional[str] = Field( default=None, - description="""Optional. The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id. This field is not supported in Vertex AI.""", + description="""Optional. The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id.""", ) @@ -1620,7 +1620,7 @@ class CodeExecutionResultDict(TypedDict, total=False): """Optional. Contains stdout when code execution is successful, stderr or other description otherwise.""" id: Optional[str] - """Optional. The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id. This field is not supported in Vertex AI.""" + """Optional. The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id.""" CodeExecutionResultOrDict = Union[CodeExecutionResult, CodeExecutionResultDict] @@ -1643,7 +1643,7 @@ class ExecutableCode(_common.BaseModel): ) id: Optional[str] = Field( default=None, - description="""Optional. Unique identifier of the `ExecutableCode` part. The server returns the `CodeExecutionResult` with the matching `id`. This field is not supported in Vertex AI.""", + description="""Optional. Unique identifier of the `ExecutableCode` part. The server returns the `CodeExecutionResult` with the matching `id`.""", ) @@ -1662,7 +1662,7 @@ class ExecutableCodeDict(TypedDict, total=False): """Required. Programming language of the `code`.""" id: Optional[str] - """Optional. Unique identifier of the `ExecutableCode` part. The server returns the `CodeExecutionResult` with the matching `id`. This field is not supported in Vertex AI.""" + """Optional. Unique identifier of the `ExecutableCode` part. The server returns the `CodeExecutionResult` with the matching `id`.""" ExecutableCodeOrDict = Union[ExecutableCode, ExecutableCodeDict] @@ -3876,7 +3876,7 @@ class GoogleMaps(_common.BaseModel): ) grounding_types: Optional[GoogleMapsGroundingTypes] = Field( default=None, - description="""Optional. Specifies the types of Google Maps grounding to enable. This field is not supported in Gemini API.""", + description="""Optional. Specifies the types of Google Maps grounding to enable. Defaults to `places` when unset. This field is not supported in Gemini API.""", ) @@ -3890,7 +3890,7 @@ class GoogleMapsDict(TypedDict, total=False): """Deprecated. The Google Maps contextual widget behavior in Grounding with Google Maps is being deprecated; this field is planned for removal and no longer has any effect once removed. Optional. Whether to return a widget context token in the GroundingMetadata of the response.""" grounding_types: Optional[GoogleMapsGroundingTypesDict] - """Optional. Specifies the types of Google Maps grounding to enable. This field is not supported in Gemini API.""" + """Optional. Specifies the types of Google Maps grounding to enable. Defaults to `places` when unset. This field is not supported in Gemini API.""" GoogleMapsOrDict = Union[GoogleMaps, GoogleMapsDict] @@ -5102,6 +5102,14 @@ class ToolParallelAiSearch(_common.BaseModel): default=None, description="""Optional. Custom configs for ParallelAiSearch. This field can be used to pass any parameter from the Parallel.ai Search API. See the Parallel.ai documentation for the full list of available parameters and their usage: https://docs.parallel.ai/api-reference/search-beta/search Currently only `source_policy`, `excerpts`, `max_results`, `mode`, `fetch_policy` can be set via this field. For example: { "source_policy": { "include_domains": ["google.com", "wikipedia.org"], "exclude_domains": ["example.com"] }, "fetch_policy": { "max_age_seconds": 3600 } }""", ) + enable_data_retention: Optional[bool] = Field( + default=None, + description="""Optional. Deprecated: Use `enable_zero_data_retention` instead. Instructs Vertex Grounding to use Parallel's Zero Data Retention Marketplace product. If this value is "false" or omitted, the Parallel Web Search for Grounding standard subscription will be used. If this value is "true", the Parallel Web Search for Grounding - ZDR subscription will be used.""", + ) + enable_zero_data_retention: Optional[bool] = Field( + default=None, + description="""Optional. Instructs Vertex Grounding to use Parallel's Zero Data Retention Marketplace product. If this value is "false" or omitted, the Parallel Web Search for Grounding standard subscription will be used. If this value is "true", the Parallel Web Search for Grounding - ZDR subscription will be used.""", + ) class ToolParallelAiSearchDict(TypedDict, total=False): @@ -5117,6 +5125,12 @@ class ToolParallelAiSearchDict(TypedDict, total=False): custom_configs: Optional[dict[str, Any]] """Optional. Custom configs for ParallelAiSearch. This field can be used to pass any parameter from the Parallel.ai Search API. See the Parallel.ai documentation for the full list of available parameters and their usage: https://docs.parallel.ai/api-reference/search-beta/search Currently only `source_policy`, `excerpts`, `max_results`, `mode`, `fetch_policy` can be set via this field. For example: { "source_policy": { "include_domains": ["google.com", "wikipedia.org"], "exclude_domains": ["example.com"] }, "fetch_policy": { "max_age_seconds": 3600 } }""" + enable_data_retention: Optional[bool] + """Optional. Deprecated: Use `enable_zero_data_retention` instead. Instructs Vertex Grounding to use Parallel's Zero Data Retention Marketplace product. If this value is "false" or omitted, the Parallel Web Search for Grounding standard subscription will be used. If this value is "true", the Parallel Web Search for Grounding - ZDR subscription will be used.""" + + enable_zero_data_retention: Optional[bool] + """Optional. Instructs Vertex Grounding to use Parallel's Zero Data Retention Marketplace product. If this value is "false" or omitted, the Parallel Web Search for Grounding standard subscription will be used. If this value is "true", the Parallel Web Search for Grounding - ZDR subscription will be used.""" + ToolParallelAiSearchOrDict = Union[ ToolParallelAiSearch, ToolParallelAiSearchDict @@ -11384,7 +11398,7 @@ class GenerationConfig(_common.BaseModel): ) enable_affective_dialog: Optional[bool] = Field( default=None, - description="""Optional. If enabled, the model will detect emotions and adapt its responses accordingly. For example, if the model detects that the user is frustrated, it may provide a more empathetic response. This field is not supported in Gemini API.""", + description="""Optional. If enabled, the model will detect emotions and adapt its responses accordingly. For example, if the model detects that the user is frustrated, it may provide a more empathetic response.""", ) frequency_penalty: Optional[float] = Field( default=None, @@ -11490,7 +11504,7 @@ class GenerationConfigDict(TypedDict, total=False): """Optional. The number of candidate responses to generate. A higher `candidate_count` can provide more options to choose from, but it also consumes more resources. This can be useful for generating a variety of responses and selecting the best one.""" enable_affective_dialog: Optional[bool] - """Optional. If enabled, the model will detect emotions and adapt its responses accordingly. For example, if the model detects that the user is frustrated, it may provide a more empathetic response. This field is not supported in Gemini API.""" + """Optional. If enabled, the model will detect emotions and adapt its responses accordingly. For example, if the model detects that the user is frustrated, it may provide a more empathetic response.""" frequency_penalty: Optional[float] """Optional. Penalizes tokens based on their frequency in the generated text. A positive value helps to reduce the repetition of words and phrases. Valid values can range from [-2.0, 2.0].""" @@ -13609,6 +13623,10 @@ class ReinforcementTuningHyperParameters(_common.BaseModel): default=None, description="""Optional. The thinking budget for the tuning job to optimize for (Gemini 2.5 only). * -1 means dynamic thinking * 0 means no thinking * > 0 means thinking budget in tokens If not set, default to -1 (dynamic thinking).""", ) + step_count: Optional[int] = Field( + default=None, + description="""Optional. Number of steps for the tuning job (mutually exclusive with epoch_count).""", + ) class ReinforcementTuningHyperParametersDict(TypedDict, total=False): @@ -13644,6 +13662,9 @@ class ReinforcementTuningHyperParametersDict(TypedDict, total=False): thinking_budget: Optional[int] """Optional. The thinking budget for the tuning job to optimize for (Gemini 2.5 only). * -1 means dynamic thinking * 0 means no thinking * > 0 means thinking budget in tokens If not set, default to -1 (dynamic thinking).""" + step_count: Optional[int] + """Optional. Number of steps for the tuning job (mutually exclusive with epoch_count).""" + ReinforcementTuningHyperParametersOrDict = Union[ ReinforcementTuningHyperParameters, ReinforcementTuningHyperParametersDict @@ -22338,6 +22359,18 @@ class AuthToken(_common.BaseModel): name: Optional[str] = Field( default=None, description="""The name of the auth token.""" ) + expire_time: Optional[str] = Field( + default=None, + description="""Optional. Input only. Immutable. An optional time after which, when using the resulting token, messages in BidiGenerateContent sessions will be rejected. (Gemini may preemptively close the session after this time.) If not set then this defaults to 30 minutes in the future. If set, this value must be less than 20 hours in the future.""", + ) + new_session_expire_time: Optional[str] = Field( + default=None, + description="""Optional. Input only. Immutable. The time after which new Live API sessions using the token resulting from this request will be rejected. If not set this defaults to 60 seconds in the future. If set, this value must be less than 20 hours in the future.""", + ) + uses: Optional[int] = Field( + default=None, + description="""Optional. Input only. Immutable. The number of times the token can be used. If this value is zero then no limit is applied. Resuming a Live API session does not count as a use. If unspecified, the default is 1.""", + ) class AuthTokenDict(TypedDict, total=False): @@ -22346,6 +22379,15 @@ class AuthTokenDict(TypedDict, total=False): name: Optional[str] """The name of the auth token.""" + expire_time: Optional[str] + """Optional. Input only. Immutable. An optional time after which, when using the resulting token, messages in BidiGenerateContent sessions will be rejected. (Gemini may preemptively close the session after this time.) If not set then this defaults to 30 minutes in the future. If set, this value must be less than 20 hours in the future.""" + + new_session_expire_time: Optional[str] + """Optional. Input only. Immutable. The time after which new Live API sessions using the token resulting from this request will be rejected. If not set this defaults to 60 seconds in the future. If set, this value must be less than 20 hours in the future.""" + + uses: Optional[int] + """Optional. Input only. Immutable. The number of times the token can be used. If this value is zero then no limit is applied. Resuming a Live API session does not count as a use. If unspecified, the default is 1.""" + AuthTokenOrDict = Union[AuthToken, AuthTokenDict]