diff --git a/google/genai/_live_converters.py b/google/genai/_live_converters.py index cf8331dd8..d0241225a 100644 --- a/google/genai/_live_converters.py +++ b/google/genai/_live_converters.py @@ -396,6 +396,19 @@ def _GenerationConfig_to_vertex( ' Developer API mode, not in Gemini Enterprise Agent Platform mode.' ) + if getv(from_object, ['response_format']) is not None: + setv( + to_object, + ['responseFormat'], + [item for item in getv(from_object, ['response_format'])], + ) + + if getv(from_object, ['translation_config']) is not None: + raise ValueError( + 'translation_config parameter is only supported in Gemini Developer API' + ' mode, not in Gemini Enterprise Agent Platform mode.' + ) + return to_object @@ -1942,6 +1955,12 @@ def _Tool_to_mldev( [item for item in getv(from_object, ['mcp_servers'])], ) + if getv(from_object, ['exa_ai_search']) is not None: + raise ValueError( + 'exa_ai_search parameter is only supported in Gemini Enterprise Agent' + ' Platform mode, not in Gemini Developer API mode.' + ) + return to_object @@ -2016,6 +2035,9 @@ def _Tool_to_vertex( ], ) + if getv(from_object, ['exa_ai_search']) is not None: + setv(to_object, ['exaAiSearch'], getv(from_object, ['exa_ai_search'])) + return to_object diff --git a/google/genai/_tokens_converters.py b/google/genai/_tokens_converters.py index d125fa5cd..3abec3e53 100644 --- a/google/genai/_tokens_converters.py +++ b/google/genai/_tokens_converters.py @@ -705,4 +705,10 @@ def _Tool_to_mldev( [item for item in getv(from_object, ['mcp_servers'])], ) + if getv(from_object, ['exa_ai_search']) is not None: + raise ValueError( + 'exa_ai_search parameter is only supported in Gemini Enterprise Agent' + ' Platform mode, not in Gemini Developer API mode.' + ) + return to_object diff --git a/google/genai/batches.py b/google/genai/batches.py index 79eb668b8..aa4dd36ee 100644 --- a/google/genai/batches.py +++ b/google/genai/batches.py @@ -1728,6 +1728,12 @@ def _Tool_to_mldev( [item for item in getv(from_object, ['mcp_servers'])], ) + if getv(from_object, ['exa_ai_search']) is not None: + raise ValueError( + 'exa_ai_search parameter is only supported in Gemini Enterprise Agent' + ' Platform mode, not in Gemini Developer API mode.' + ) + return to_object diff --git a/google/genai/caches.py b/google/genai/caches.py index ea1f30f66..9c441447e 100644 --- a/google/genai/caches.py +++ b/google/genai/caches.py @@ -999,6 +999,12 @@ def _Tool_to_mldev( [item for item in getv(from_object, ['mcp_servers'])], ) + if getv(from_object, ['exa_ai_search']) is not None: + raise ValueError( + 'exa_ai_search parameter is only supported in Gemini Enterprise Agent' + ' Platform mode, not in Gemini Developer API mode.' + ) + return to_object @@ -1073,6 +1079,9 @@ def _Tool_to_vertex( ], ) + if getv(from_object, ['exa_ai_search']) is not None: + setv(to_object, ['exaAiSearch'], getv(from_object, ['exa_ai_search'])) + return to_object diff --git a/google/genai/models.py b/google/genai/models.py index 9ff421480..d6c1ead83 100644 --- a/google/genai/models.py +++ b/google/genai/models.py @@ -2976,6 +2976,19 @@ def _GenerationConfig_to_vertex( ' Developer API mode, not in Gemini Enterprise Agent Platform mode.' ) + if getv(from_object, ['response_format']) is not None: + setv( + to_object, + ['responseFormat'], + [item for item in getv(from_object, ['response_format'])], + ) + + if getv(from_object, ['translation_config']) is not None: + raise ValueError( + 'translation_config parameter is only supported in Gemini Developer API' + ' mode, not in Gemini Enterprise Agent Platform mode.' + ) + return to_object @@ -4391,6 +4404,12 @@ def _Tool_to_mldev( [item for item in getv(from_object, ['mcp_servers'])], ) + if getv(from_object, ['exa_ai_search']) is not None: + raise ValueError( + 'exa_ai_search parameter is only supported in Gemini Enterprise Agent' + ' Platform mode, not in Gemini Developer API mode.' + ) + return to_object @@ -4468,6 +4487,9 @@ def _Tool_to_vertex( ], ) + if getv(from_object, ['exa_ai_search']) is not None: + setv(to_object, ['exaAiSearch'], getv(from_object, ['exa_ai_search'])) + return to_object diff --git a/google/genai/tunings.py b/google/genai/tunings.py index 8f14e96b9..f1e4e6843 100644 --- a/google/genai/tunings.py +++ b/google/genai/tunings.py @@ -1234,6 +1234,13 @@ def _GenerationConfig_from_vertex( if getv(from_object, ['topP']) is not None: setv(to_object, ['top_p'], getv(from_object, ['topP'])) + if getv(from_object, ['responseFormat']) is not None: + setv( + to_object, + ['response_format'], + [item for item in getv(from_object, ['responseFormat'])], + ) + return to_object @@ -1355,6 +1362,19 @@ def _GenerationConfig_to_vertex( ' Developer API mode, not in Gemini Enterprise Agent Platform mode.' ) + if getv(from_object, ['response_format']) is not None: + setv( + to_object, + ['responseFormat'], + [item for item in getv(from_object, ['response_format'])], + ) + + if getv(from_object, ['translation_config']) is not None: + raise ValueError( + 'translation_config parameter is only supported in Gemini Developer API' + ' mode, not in Gemini Enterprise Agent Platform mode.' + ) + return to_object diff --git a/google/genai/types.py b/google/genai/types.py index 35269bcdf..eb4cc590b 100644 --- a/google/genai/types.py +++ b/google/genai/types.py @@ -306,9 +306,8 @@ class PhishBlockThreshold(_common.CaseInSensitiveEnum): class Behavior(_common.CaseInSensitiveEnum): """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. + If not specified, the system keeps the current function call behavior. This + field is currently only supported by the BidiGenerateContent method. """ UNSPECIFIED = 'UNSPECIFIED' @@ -651,6 +650,67 @@ class Modality(_common.CaseInSensitiveEnum): """Indicates the model should return video.""" +class Delivery(_common.CaseInSensitiveEnum): + """Delivery mode for the generated content.""" + + DELIVERY_UNSPECIFIED = 'DELIVERY_UNSPECIFIED' + """Default value. This value is unused.""" + INLINE = 'INLINE' + """Generated bytes are returned inline in the response.""" + URI = 'URI' + """Generated content is stored and a URI is returned.""" + + +class AspectRatio(_common.CaseInSensitiveEnum): + """The aspect ratio for the image output.""" + + ASPECT_RATIO_UNSPECIFIED = 'ASPECT_RATIO_UNSPECIFIED' + """Default value. This value is unused.""" + ASPECT_RATIO_ONE_BY_ONE = 'ASPECT_RATIO_ONE_BY_ONE' + """1:1 aspect ratio.""" + ASPECT_RATIO_TWO_BY_THREE = 'ASPECT_RATIO_TWO_BY_THREE' + """2:3 aspect ratio.""" + ASPECT_RATIO_THREE_BY_TWO = 'ASPECT_RATIO_THREE_BY_TWO' + """3:2 aspect ratio.""" + ASPECT_RATIO_THREE_BY_FOUR = 'ASPECT_RATIO_THREE_BY_FOUR' + """3:4 aspect ratio.""" + ASPECT_RATIO_FOUR_BY_THREE = 'ASPECT_RATIO_FOUR_BY_THREE' + """4:3 aspect ratio.""" + ASPECT_RATIO_FOUR_BY_FIVE = 'ASPECT_RATIO_FOUR_BY_FIVE' + """4:5 aspect ratio.""" + ASPECT_RATIO_FIVE_BY_FOUR = 'ASPECT_RATIO_FIVE_BY_FOUR' + """5:4 aspect ratio.""" + ASPECT_RATIO_NINE_BY_SIXTEEN = 'ASPECT_RATIO_NINE_BY_SIXTEEN' + """9:16 aspect ratio.""" + ASPECT_RATIO_SIXTEEN_BY_NINE = 'ASPECT_RATIO_SIXTEEN_BY_NINE' + """16:9 aspect ratio.""" + ASPECT_RATIO_TWENTY_ONE_BY_NINE = 'ASPECT_RATIO_TWENTY_ONE_BY_NINE' + """21:9 aspect ratio.""" + ASPECT_RATIO_ONE_BY_EIGHT = 'ASPECT_RATIO_ONE_BY_EIGHT' + """1:8 aspect ratio.""" + ASPECT_RATIO_EIGHT_BY_ONE = 'ASPECT_RATIO_EIGHT_BY_ONE' + """8:1 aspect ratio.""" + ASPECT_RATIO_ONE_BY_FOUR = 'ASPECT_RATIO_ONE_BY_FOUR' + """1:4 aspect ratio.""" + ASPECT_RATIO_FOUR_BY_ONE = 'ASPECT_RATIO_FOUR_BY_ONE' + """4:1 aspect ratio.""" + + +class ImageSize(_common.CaseInSensitiveEnum): + """The size of the image output.""" + + IMAGE_SIZE_UNSPECIFIED = 'IMAGE_SIZE_UNSPECIFIED' + """Default value. This value is unused.""" + IMAGE_SIZE_FIVE_TWELVE = 'IMAGE_SIZE_FIVE_TWELVE' + """512px image size.""" + IMAGE_SIZE_ONE_K = 'IMAGE_SIZE_ONE_K' + """1K image size.""" + IMAGE_SIZE_TWO_K = 'IMAGE_SIZE_TWO_K' + """2K image size.""" + IMAGE_SIZE_FOUR_K = 'IMAGE_SIZE_FOUR_K' + """4K image size.""" + + class TuningMode(_common.CaseInSensitiveEnum): """Tuning mode. This enum is not supported in Gemini API.""" @@ -681,6 +741,49 @@ class AdapterSize(_common.CaseInSensitiveEnum): """Adapter size 32.""" +class ResponseParseType(_common.CaseInSensitiveEnum): + """Defines the type for parsing sample response. + + This enum is not supported in Gemini API. + """ + + RESPONSE_PARSE_TYPE_UNSPECIFIED = 'RESPONSE_PARSE_TYPE_UNSPECIFIED' + """Default value. Fallback to IDENTITY""" + IDENTITY = 'IDENTITY' + """Returns the sample response as is.""" + REGEX_EXTRACT = 'REGEX_EXTRACT' + """Uses regex to extract the important part of sample response. Similar to [GoogleSQL](https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#regexp_extract) `REGEX_EXTRACT(response, regex_extract_expression)`, but different in that if there are multiple matches, the last match will be returned.""" + + +class MatchOperation(_common.CaseInSensitiveEnum): + """Match operation to use for evaluating rewards. + + This enum is not supported in Gemini API. + """ + + MATCH_OPERATION_UNSPECIFIED = 'MATCH_OPERATION_UNSPECIFIED' + """Default value. A user error will be returned if not set.""" + REGEX_CONTAINS = 'REGEX_CONTAINS' + """Equivalent to [GoogleSQL](https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#regexp_contains) `REGEX_CONTAINS(target, expression)`.""" + PARTIAL_MATCH = 'PARTIAL_MATCH' + """The match operation returns `true` if expression is a substring of the target.""" + EXACT_MATCH = 'EXACT_MATCH' + """The match operation returns `true` expression is an exact match of the target.""" + + +class ReinforcementTuningThinkingLevel(_common.CaseInSensitiveEnum): + """Represents how much to think for the tuning job.""" + + REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED = ( + 'REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED' + ) + """Unspecified thinking level.""" + MINIMAL = 'MINIMAL' + """Little to no thinking.""" + HIGH = 'HIGH' + """High thinking level.""" + + class JobState(_common.CaseInSensitiveEnum): """Job state.""" @@ -1088,43 +1191,6 @@ class ImageResizeMode(_common.CaseInSensitiveEnum): any parts of the image in the process).""" -class ResponseParseType(_common.CaseInSensitiveEnum): - """Defines how to parse sample response.""" - - RESPONSE_PARSE_TYPE_UNSPECIFIED = 'RESPONSE_PARSE_TYPE_UNSPECIFIED' - """Default value. This value is unused.""" - IDENTITY = 'IDENTITY' - """Use the sample response as is.""" - REGEX_EXTRACT = 'REGEX_EXTRACT' - """Use regex to extract the important part of sample response.""" - - -class MatchOperation(_common.CaseInSensitiveEnum): - """Match operation to use for evaluation.""" - - MATCH_OPERATION_UNSPECIFIED = 'MATCH_OPERATION_UNSPECIFIED' - """Default value. This value is unused.""" - REGEX_CONTAINS = 'REGEX_CONTAINS' - """Equivalent to GoogleSQL `REGEX_CONTAINS(target, expression)`.""" - PARTIAL_MATCH = 'PARTIAL_MATCH' - """`expression` is a substring of target.""" - EXACT_MATCH = 'EXACT_MATCH' - """`expression` is an exact match of target.""" - - -class ReinforcementTuningThinkingLevel(_common.CaseInSensitiveEnum): - """Represents how much to think for the tuning job.""" - - REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED = ( - 'REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED' - ) - """Unspecified thinking level.""" - MINIMAL = 'MINIMAL' - """Little to no thinking.""" - HIGH = 'HIGH' - """High thinking level.""" - - class TuningMethod(_common.CaseInSensitiveEnum): """Enum representing the tuning method.""" @@ -4493,7 +4559,7 @@ class FunctionDeclaration(_common.BaseModel): ) behavior: Optional[Behavior] = Field( default=None, - description="""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.""", + description="""Optional. Specifies the function Behavior. If not specified, the system keeps the current function call behavior. This field is currently only supported by the BidiGenerateContent method.""", ) @classmethod @@ -4716,7 +4782,7 @@ class FunctionDeclarationDict(TypedDict, total=False): """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.""" + """Optional. Specifies the function Behavior. 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] @@ -4908,6 +4974,39 @@ class McpServerDict(TypedDict, total=False): McpServerOrDict = Union[McpServer, McpServerDict] +class ToolExaAiSearch(_common.BaseModel): + """ExaAiSearch tool type. + + A tool that uses the Exa.ai search engine for grounding. This data type is not + supported in Gemini API. + """ + + api_key: Optional[str] = Field( + default=None, description="""Required. The API key for ExaAiSearch.""" + ) + custom_configs: Optional[dict[str, Any]] = Field( + default=None, + description="""Optional. This field can be used to pass any parameter from the Exa.ai Search API.""", + ) + + +class ToolExaAiSearchDict(TypedDict, total=False): + """ExaAiSearch tool type. + + A tool that uses the Exa.ai search engine for grounding. This data type is not + supported in Gemini API. + """ + + api_key: Optional[str] + """Required. The API key for ExaAiSearch.""" + + custom_configs: Optional[dict[str, Any]] + """Optional. This field can be used to pass any parameter from the Exa.ai Search API.""" + + +ToolExaAiSearchOrDict = Union[ToolExaAiSearch, ToolExaAiSearchDict] + + class Tool(_common.BaseModel): """Tool details of a tool that the model may use to generate a response.""" @@ -4960,6 +5059,10 @@ class Tool(_common.BaseModel): default=None, description="""Optional. MCP Servers to connect to. This field is not supported in Vertex AI.""", ) + exa_ai_search: Optional[ToolExaAiSearch] = Field( + default=None, + description="""Optional. Uses Exa.ai to search for information to answer user queries. The search results will be grounded on Exa.ai and presented to the model for response generation. This field is not supported in Gemini API.""", + ) class ToolDict(TypedDict, total=False): @@ -5002,6 +5105,9 @@ class ToolDict(TypedDict, total=False): mcp_servers: Optional[list[McpServerDict]] """Optional. MCP Servers to connect to. This field is not supported in Vertex AI.""" + exa_ai_search: Optional[ToolExaAiSearchDict] + """Optional. Uses Exa.ai to search for information to answer user queries. The search results will be grounded on Exa.ai and presented to the model for response generation. This field is not supported in Gemini API.""" + ToolOrDict = Union[Tool, ToolDict] if _is_mcp_imported: @@ -7438,7 +7544,7 @@ class GroundingMetadata(_common.BaseModel): ) google_maps_widget_context_token: Optional[str] = Field( 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.""", + description="""Optional. Output only. Deprecated: The Google Maps contextual widget behavior in Grounding with Google Maps is being deprecated; this field is planned for removal and will no longer be populated once removed. 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.""", ) retrieval_queries: Optional[list[str]] = Field( default=None, @@ -7478,7 +7584,7 @@ class GroundingMetadataDict(TypedDict, total=False): """Web search queries for the following-up web search.""" 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.""" + """Optional. Output only. Deprecated: The Google Maps contextual widget behavior in Grounding with Google Maps is being deprecated; this field is planned for removal and will no longer be populated once removed. 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.""" 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.""" @@ -10645,6 +10751,221 @@ class DeleteModelResponseDict(TypedDict, total=False): DeleteModelResponseOrDict = Union[DeleteModelResponse, DeleteModelResponseDict] +class AudioResponseFormat(_common.BaseModel): + """Configuration for audio-specific output formatting.""" + + bit_rate: Optional[int] = Field( + default=None, + description="""Optional. Bit rate in bits per second (bps). Only applicable for compressed formats (MP3, Opus).""", + ) + delivery: Optional[Delivery] = Field( + default=None, + description="""Optional. Delivery mode for the generated content.""", + ) + mime_type: Optional[str] = Field( + default=None, + description="""Optional. The MIME type of the audio output.""", + ) + sample_rate: Optional[int] = Field( + default=None, + description="""Optional. Sample rate for the generated audio in Hertz.""", + ) + + +class AudioResponseFormatDict(TypedDict, total=False): + """Configuration for audio-specific output formatting.""" + + bit_rate: Optional[int] + """Optional. Bit rate in bits per second (bps). Only applicable for compressed formats (MP3, Opus).""" + + delivery: Optional[Delivery] + """Optional. Delivery mode for the generated content.""" + + mime_type: Optional[str] + """Optional. The MIME type of the audio output.""" + + sample_rate: Optional[int] + """Optional. Sample rate for the generated audio in Hertz.""" + + +AudioResponseFormatOrDict = Union[AudioResponseFormat, AudioResponseFormatDict] + + +class ImageResponseFormat(_common.BaseModel): + """Configuration for image-specific output formatting.""" + + aspect_ratio: Optional[AspectRatio] = Field( + default=None, + description="""Optional. The aspect ratio for the image output.""", + ) + delivery: Optional[Delivery] = Field( + default=None, + description="""Optional. Delivery mode for the generated content.""", + ) + image_size: Optional[ImageSize] = Field( + default=None, description="""Optional. The size of the image output.""" + ) + mime_type: Optional[str] = Field( + default=None, + description="""Optional. The MIME type of the image output.""", + ) + + +class ImageResponseFormatDict(TypedDict, total=False): + """Configuration for image-specific output formatting.""" + + aspect_ratio: Optional[AspectRatio] + """Optional. The aspect ratio for the image output.""" + + delivery: Optional[Delivery] + """Optional. Delivery mode for the generated content.""" + + image_size: Optional[ImageSize] + """Optional. The size of the image output.""" + + mime_type: Optional[str] + """Optional. The MIME type of the image output.""" + + +ImageResponseFormatOrDict = Union[ImageResponseFormat, ImageResponseFormatDict] + + +class TextResponseFormat(_common.BaseModel): + """Configuration for text-specific output formatting.""" + + mime_type: Optional[str] = Field( + default=None, + description="""Optional. The IANA standard MIME type of the response.""", + ) + schema: Optional[Any] = Field(default=None, description="""Optional. The JSON schema that the output should conform to. Only applicable when mime_type is APPLICATION_JSON.""") # type: ignore[assignment] + + +class TextResponseFormatDict(TypedDict, total=False): + """Configuration for text-specific output formatting.""" + + mime_type: Optional[str] + """Optional. The IANA standard MIME type of the response.""" + + schema: Optional[Any] + """Optional. The JSON schema that the output should conform to. Only applicable when mime_type is APPLICATION_JSON.""" + + +TextResponseFormatOrDict = Union[TextResponseFormat, TextResponseFormatDict] + + +class VideoResponseFormat(_common.BaseModel): + """Configuration for video-specific output formatting. + + This data type is not supported in Gemini API. + """ + + aspect_ratio: Optional[AspectRatio] = Field( + default=None, description="""The aspect ratio for the video output.""" + ) + delivery: Optional[Delivery] = Field( + default=None, + description="""Optional. Delivery mode for the generated content.""", + ) + duration: Optional[str] = Field( + default=None, + description="""Optional. The duration for the video output.""", + ) + gcs_uri: Optional[str] = Field( + default=None, + description="""Optional. The Google Cloud Storage URI to store the video output. Required for Vertex if delivery is URI.""", + ) + + +class VideoResponseFormatDict(TypedDict, total=False): + """Configuration for video-specific output formatting. + + This data type is not supported in Gemini API. + """ + + aspect_ratio: Optional[AspectRatio] + """The aspect ratio for the video output.""" + + delivery: Optional[Delivery] + """Optional. Delivery mode for the generated content.""" + + duration: Optional[str] + """Optional. The duration for the video output.""" + + gcs_uri: Optional[str] + """Optional. The Google Cloud Storage URI to store the video output. Required for Vertex if delivery is URI.""" + + +VideoResponseFormatOrDict = Union[VideoResponseFormat, VideoResponseFormatDict] + + +class ResponseFormat(_common.BaseModel): + """Configuration for the model to configure output formatting and delivery. + + This data type is not supported in Gemini API. + """ + + audio: Optional[AudioResponseFormat] = Field( + default=None, description="""Audio output format.""" + ) + image: Optional[ImageResponseFormat] = Field( + default=None, description="""Image output format.""" + ) + text: Optional[TextResponseFormat] = Field( + default=None, description="""Text output format.""" + ) + video: Optional[VideoResponseFormat] = Field( + default=None, description="""Video output format.""" + ) + + +class ResponseFormatDict(TypedDict, total=False): + """Configuration for the model to configure output formatting and delivery. + + This data type is not supported in Gemini API. + """ + + audio: Optional[AudioResponseFormatDict] + """Audio output format.""" + + image: Optional[ImageResponseFormatDict] + """Image output format.""" + + text: Optional[TextResponseFormatDict] + """Text output format.""" + + video: Optional[VideoResponseFormatDict] + """Video output format.""" + + +ResponseFormatOrDict = Union[ResponseFormat, ResponseFormatDict] + + +class TranslationConfig(_common.BaseModel): + """Config for stream translation.""" + + echo_target_language: Optional[bool] = Field( + default=None, + description="""Optional. If true, the model will generate audio when the target language is spoken, essentially it will parrot the input. If false, we will not produce audio for the target language.""", + ) + target_language_code: Optional[str] = Field( + default=None, + description="""Required. The target language for translation. Supported values are BCP-47 language codes (e.g. "en", "es", "fr").""", + ) + + +class TranslationConfigDict(TypedDict, total=False): + """Config for stream translation.""" + + echo_target_language: Optional[bool] + """Optional. If true, the model will generate audio when the target language is spoken, essentially it will parrot the input. If false, we will not produce audio for the target language.""" + + target_language_code: Optional[str] + """Required. The target language for translation. Supported values are BCP-47 language codes (e.g. "en", "es", "fr").""" + + +TranslationConfigOrDict = Union[TranslationConfig, TranslationConfigDict] + + class GenerationConfig(_common.BaseModel): """Generation config.""" @@ -10695,7 +11016,7 @@ class GenerationConfig(_common.BaseModel): ) response_mime_type: Optional[str] = Field( default=None, - description="""Optional. The IANA standard MIME type of the response. The model will generate output that conforms to this MIME type. Supported values include 'text/plain' (default) and 'application/json'. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined.""", + description="""Optional. The IANA standard MIME type of the response. The model will generate output that conforms to this MIME type. Supported values include 'text/plain' (default) and 'application/json'. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. Deprecated: Use `response_format` instead.""", ) response_modalities: Optional[list[Modality]] = Field( default=None, @@ -10703,7 +11024,7 @@ class GenerationConfig(_common.BaseModel): ) response_schema: Optional[Schema] = Field( default=None, - description="""Optional. Lets you to specify a schema for the model's response, ensuring that the output conforms to a particular structure. This is useful for generating structured data such as JSON. The schema is a subset of the [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema) object. When this field is set, you must also set the `response_mime_type` to `application/json`.""", + description="""Optional. Lets you to specify a schema for the model's response, ensuring that the output conforms to a particular structure. This is useful for generating structured data such as JSON. The schema is a subset of the [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema) object. When this field is set, you must also set the `response_mime_type` to `application/json`. Deprecated: Use `response_format` instead.""", ) routing_config: Optional[GenerationConfigRoutingConfig] = Field( default=None, @@ -10740,6 +11061,14 @@ class GenerationConfig(_common.BaseModel): default=None, description="""Optional. Enables enhanced civic answers. It may not be available for all models. This field is not supported in Vertex AI.""", ) + response_format: Optional[list[ResponseFormat]] = Field( + default=None, + description="""Optional. New response format field for the model to configure output formatting and delivery.""", + ) + translation_config: Optional[TranslationConfig] = Field( + default=None, + description="""Optional. Config for translation. This field is not supported in Vertex AI.""", + ) class GenerationConfigDict(TypedDict, total=False): @@ -10781,13 +11110,13 @@ class GenerationConfigDict(TypedDict, total=False): """Optional. If set to true, the log probabilities of the output tokens are returned. Log probabilities are the logarithm of the probability of a token appearing in the output. A higher log probability means the token is more likely to be generated. This can be useful for analyzing the model's confidence in its own output and for debugging.""" response_mime_type: Optional[str] - """Optional. The IANA standard MIME type of the response. The model will generate output that conforms to this MIME type. Supported values include 'text/plain' (default) and 'application/json'. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined.""" + """Optional. The IANA standard MIME type of the response. The model will generate output that conforms to this MIME type. Supported values include 'text/plain' (default) and 'application/json'. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. Deprecated: Use `response_format` instead.""" response_modalities: Optional[list[Modality]] """Optional. The modalities of the response. The model will generate a response that includes all the specified modalities. For example, if this is set to `[TEXT, IMAGE]`, the response will include both text and an image.""" response_schema: Optional[SchemaDict] - """Optional. Lets you to specify a schema for the model's response, ensuring that the output conforms to a particular structure. This is useful for generating structured data such as JSON. The schema is a subset of the [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema) object. When this field is set, you must also set the `response_mime_type` to `application/json`.""" + """Optional. Lets you to specify a schema for the model's response, ensuring that the output conforms to a particular structure. This is useful for generating structured data such as JSON. The schema is a subset of the [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema) object. When this field is set, you must also set the `response_mime_type` to `application/json`. Deprecated: Use `response_format` instead.""" routing_config: Optional[GenerationConfigRoutingConfigDict] """Optional. Routing configuration. This field is not supported in Gemini API.""" @@ -10816,6 +11145,12 @@ class GenerationConfigDict(TypedDict, total=False): enable_enhanced_civic_answers: Optional[bool] """Optional. Enables enhanced civic answers. It may not be available for all models. This field is not supported in Vertex AI.""" + response_format: Optional[list[ResponseFormatDict]] + """Optional. New response format field for the model to configure output formatting and delivery.""" + + translation_config: Optional[TranslationConfigDict] + """Optional. Config for translation. This field is not supported in Vertex AI.""" + GenerationConfigOrDict = Union[GenerationConfig, GenerationConfigDict] @@ -12238,25 +12573,46 @@ class AutoraterConfigDict(TypedDict, total=False): class ReinforcementTuningParseResponseConfig(_common.BaseModel): - """Defines how to parse sample response for reinforcement tuning.""" + """Defines how to parse sample response config for reinforcement tuning. + + The parsed response (i.e., substring) will be passed to the reward functions. + For example, the input prompt might be: > "Perform step-by-step thoughts first + to problem A, finally output answer in the block." The sample + response from the model under tuning might look like: > "Yes" Here, + users can define the following parse config: ``` { "parseType": + "REGEX_EXTRACT", "regexExtractExpression": ".*(.*?)" } ``` The resulting + parsed response would be `"Yes"` and will be passed to the reward functions + for evaluating rewards. This data type is not supported in Gemini API. + """ parse_type: Optional[ResponseParseType] = Field( - default=None, description="""Defines how to parse sample response.""" + default=None, + description="""Defines the type for parsing sample response.""", ) regex_extract_expression: Optional[str] = Field( default=None, - description="""Defines the regex to extract the important part of sample response. This field is only used when `parse_type` is `REGEX_EXTRACT`.""", + description="""Defines the regex for extracting the important part of sample response. This field is only used when parse_type is ResponseParseType.REGEX_EXTRACT.""", ) class ReinforcementTuningParseResponseConfigDict(TypedDict, total=False): - """Defines how to parse sample response for reinforcement tuning.""" + """Defines how to parse sample response config for reinforcement tuning. + + The parsed response (i.e., substring) will be passed to the reward functions. + For example, the input prompt might be: > "Perform step-by-step thoughts first + to problem A, finally output answer in the block." The sample + response from the model under tuning might look like: > "Yes" Here, + users can define the following parse config: ``` { "parseType": + "REGEX_EXTRACT", "regexExtractExpression": ".*(.*?)" } ``` The resulting + parsed response would be `"Yes"` and will be passed to the reward functions + for evaluating rewards. This data type is not supported in Gemini API. + """ parse_type: Optional[ResponseParseType] - """Defines how to parse sample response.""" + """Defines the type for parsing sample response.""" regex_extract_expression: Optional[str] - """Defines the regex to extract the important part of sample response. This field is only used when `parse_type` is `REGEX_EXTRACT`.""" + """Defines the regex for extracting the important part of sample response. This field is only used when parse_type is ResponseParseType.REGEX_EXTRACT.""" ReinforcementTuningParseResponseConfigOrDict = Union[ @@ -12268,7 +12624,11 @@ class ReinforcementTuningParseResponseConfigDict(TypedDict, total=False): class ReinforcementTuningAutoraterScorerParsedResponseConversionScorer( _common.BaseModel ): - """Scores responses by directly converting parsed autorater response to float reward (reward is clipped to be within [-1, 1]).""" + """Scores responses by directly converting the parsed autorater response to a float reward. + + Note: Reward is clipped to be within `[-1, 1]`, i.e., `reward = + max(min(reward, 1.0), -1.0)`. This data type is not supported in Gemini API. + """ pass @@ -12276,7 +12636,11 @@ class ReinforcementTuningAutoraterScorerParsedResponseConversionScorer( class ReinforcementTuningAutoraterScorerParsedResponseConversionScorerDict( TypedDict, total=False ): - """Scores responses by directly converting parsed autorater response to float reward (reward is clipped to be within [-1, 1]).""" + """Scores responses by directly converting the parsed autorater response to a float reward. + + Note: Reward is clipped to be within `[-1, 1]`, i.e., `reward = + max(min(reward, 1.0), -1.0)`. This data type is not supported in Gemini API. + """ pass @@ -12288,35 +12652,41 @@ class ReinforcementTuningAutoraterScorerParsedResponseConversionScorerDict( class ReinforcementTuningAutoraterScorerExactMatchScorer(_common.BaseModel): - """Scores autorater responses by using exact string match reward scorer.""" + """Scores autorater responses by using exact string match reward scorer. + + This data type is not supported in Gemini API. + """ correct_answer_reward: Optional[float] = Field( default=None, - description="""Assigns this reward score if parsed response string equals the expression.""", + description="""Assigns this reward score if the parsed response string equals the expression.""", ) wrong_answer_reward: Optional[float] = Field( default=None, - description="""Assigns this reward score if parsed reward value does not equal the expression.""", + description="""Assigns this reward score if the parsed reward value does not equal the expression.""", ) expression: Optional[str] = Field( default=None, - description="""The string expression to match against. Supports substitution in the format of `references.reference` (wrapped in double curly braces) before matching. No regex support.""", + description="""The string expression to match against for scoring. This field supports placeholders in the format of {{references.key}} that will be replaced before matching. Regex is not supported for this expression. For example, users can define an ExactMatchScorer as follows: { "correctAnswerReward": 1.0, "wrongAnswerReward": -1.0, "expression": "{{references.concise_answer}}" } When evaluating the reward for each parsed autorater response, if the prompt references in the training/validation dataset has the following fields: ``` { "example": ..., "references": { "concise_ansser": "Yes", "verbose_answer": "The answer is Yes" } } ``` The above ExactMatchScorer will be replaced as follows for scoring: ``` { "correctAnswerReward": 1.0, "wrongAnswerReward": -1.0, "expression": "Yes" } ``` If the *parsed* autorater response is equal to the string `"Yes"`, then the reward is `1.0`, otherwise the reward is `-1.0`.""", ) class ReinforcementTuningAutoraterScorerExactMatchScorerDict( TypedDict, total=False ): - """Scores autorater responses by using exact string match reward scorer.""" + """Scores autorater responses by using exact string match reward scorer. + + This data type is not supported in Gemini API. + """ correct_answer_reward: Optional[float] - """Assigns this reward score if parsed response string equals the expression.""" + """Assigns this reward score if the parsed response string equals the expression.""" wrong_answer_reward: Optional[float] - """Assigns this reward score if parsed reward value does not equal the expression.""" + """Assigns this reward score if the parsed reward value does not equal the expression.""" expression: Optional[str] - """The string expression to match against. Supports substitution in the format of `references.reference` (wrapped in double curly braces) before matching. No regex support.""" + """The string expression to match against for scoring. This field supports placeholders in the format of {{references.key}} that will be replaced before matching. Regex is not supported for this expression. For example, users can define an ExactMatchScorer as follows: { "correctAnswerReward": 1.0, "wrongAnswerReward": -1.0, "expression": "{{references.concise_answer}}" } When evaluating the reward for each parsed autorater response, if the prompt references in the training/validation dataset has the following fields: ``` { "example": ..., "references": { "concise_ansser": "Yes", "verbose_answer": "The answer is Yes" } } ``` The above ExactMatchScorer will be replaced as follows for scoring: ``` { "correctAnswerReward": 1.0, "wrongAnswerReward": -1.0, "expression": "Yes" } ``` If the *parsed* autorater response is equal to the string `"Yes"`, then the reward is `1.0`, otherwise the reward is `-1.0`.""" ReinforcementTuningAutoraterScorerExactMatchScorerOrDict = Union[ @@ -12333,22 +12703,25 @@ class ReinforcementTuningAutoraterScorer(_common.BaseModel): ) autorater_prompt: Optional[str] = Field( default=None, - description="""Allows substituting `prompt`, `response`, `system_instruction` and `references.reference` (each wrapped in double curly braces) into the autorater prompt.""", + description="""The prompt for an autorater to scorer the parsed sample response. This field supports the following placeholders that will be replaced before scoring: - {{prompt}} - {{response}} - {{system_instruction}} - {{references.key}} """, ) autorater_response_parse_config: Optional[ ReinforcementTuningParseResponseConfig - ] = Field(default=None, description="""Parses autorater returned response.""") + ] = Field( + default=None, + description="""Parses autorater returned response for scoring. For example, if the autorater response has reward stored in the `2.0` block, defining a parsing response config using regex `".*(.*?)"` will return a score `"2.0"`.""", + ) parsed_response_conversion_scorer: Optional[ ReinforcementTuningAutoraterScorerParsedResponseConversionScorer ] = Field( default=None, - description="""Scores autorater responses by directly converting parsed autorater response to float reward.""", + description="""Scores autorater responses by directly converting parsed autorater response to a float reward. Note: Reward is clipped to be within `[-1, 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`.""", ) exact_match_scorer: Optional[ ReinforcementTuningAutoraterScorerExactMatchScorer ] = Field( default=None, - description="""Scores autorater responses by using exact string match reward scorer.""", + description="""Scores autorater responses by using string match reward scorer.""", ) @@ -12359,22 +12732,22 @@ class ReinforcementTuningAutoraterScorerDict(TypedDict, total=False): """Autorater config for evaluation.""" autorater_prompt: Optional[str] - """Allows substituting `prompt`, `response`, `system_instruction` and `references.reference` (each wrapped in double curly braces) into the autorater prompt.""" + """The prompt for an autorater to scorer the parsed sample response. This field supports the following placeholders that will be replaced before scoring: - {{prompt}} - {{response}} - {{system_instruction}} - {{references.key}} """ autorater_response_parse_config: Optional[ ReinforcementTuningParseResponseConfigDict ] - """Parses autorater returned response.""" + """Parses autorater returned response for scoring. For example, if the autorater response has reward stored in the `2.0` block, defining a parsing response config using regex `".*(.*?)"` will return a score `"2.0"`.""" parsed_response_conversion_scorer: Optional[ ReinforcementTuningAutoraterScorerParsedResponseConversionScorerDict ] - """Scores autorater responses by directly converting parsed autorater response to float reward.""" + """Scores autorater responses by directly converting parsed autorater response to a float reward. Note: Reward is clipped to be within `[-1, 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`.""" exact_match_scorer: Optional[ ReinforcementTuningAutoraterScorerExactMatchScorerDict ] - """Scores autorater responses by using exact string match reward scorer.""" + """Scores autorater responses by using string match reward scorer.""" ReinforcementTuningAutoraterScorerOrDict = Union[ @@ -12383,19 +12756,47 @@ class ReinforcementTuningAutoraterScorerDict(TypedDict, total=False): class ReinforcementTuningCodeExecutionRewardScorer(_common.BaseModel): - """Scores parsed responses for code execution use cases.""" + """ReinforcementTuningCodeExecutionRewardScorer allows users to implement a function to evaluate rewards for the sample response. + + The function signature is as follows: ``` def evaluate(example: dict[str, + Any], response: dict[str, Any]) -> float: ... ``` `example` is a + ReinforcementTuningExample in ProtoJSON format, (i.e., the format is the same + as as one line in the training/validation dataset except that the keys must be + in camel case). System instructions (i.e., `example.get("systemInstruction")`) + and references (i.e., `example.get("references")`) are also included in the + `example` provided that they are set in the training/validation dataset. + `response` is a Content in ProtoJSON format (i.e., keys must be in camel + case), which is the same as the Online Prediction response for Gemini models. + Note: Reward output by the `evaluate` function is clipped to be within `[-1, + 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`. This data type is not + supported in Gemini API. + """ python_code_snippet: Optional[str] = Field( default=None, - description="""Example python code snippet which assigns reward of 1 to answer matching user provided reference answer in per prompt references map.""", + description="""The python code snippet as a string for evaluating rewards. The following is an example python code snippet that returns a reward `1.0` for a parsed response matching the user-provided reference answer in per prompt references map. ``` def evaluate(example, response) -> float: response_str = response.get("parts", [])0 references = example.get("references", {}) if response_str == references.get("concise_answer"): return 1.0 return -1.0 ``` Note: Reward output by the evaluate function is clipped to be within `[-1, 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`.""", ) class ReinforcementTuningCodeExecutionRewardScorerDict(TypedDict, total=False): - """Scores parsed responses for code execution use cases.""" + """ReinforcementTuningCodeExecutionRewardScorer allows users to implement a function to evaluate rewards for the sample response. + + The function signature is as follows: ``` def evaluate(example: dict[str, + Any], response: dict[str, Any]) -> float: ... ``` `example` is a + ReinforcementTuningExample in ProtoJSON format, (i.e., the format is the same + as as one line in the training/validation dataset except that the keys must be + in camel case). System instructions (i.e., `example.get("systemInstruction")`) + and references (i.e., `example.get("references")`) are also included in the + `example` provided that they are set in the training/validation dataset. + `response` is a Content in ProtoJSON format (i.e., keys must be in camel + case), which is the same as the Online Prediction response for Gemini models. + Note: Reward output by the `evaluate` function is clipped to be within `[-1, + 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`. This data type is not + supported in Gemini API. + """ python_code_snippet: Optional[str] - """Example python code snippet which assigns reward of 1 to answer matching user provided reference answer in per prompt references map.""" + """The python code snippet as a string for evaluating rewards. The following is an example python code snippet that returns a reward `1.0` for a parsed response matching the user-provided reference answer in per prompt references map. ``` def evaluate(example, response) -> float: response_str = response.get("parts", [])0 references = example.get("references", {}) if response_str == references.get("concise_answer"): return 1.0 return -1.0 ``` Note: Reward output by the evaluate function is clipped to be within `[-1, 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`.""" ReinforcementTuningCodeExecutionRewardScorerOrDict = Union[ @@ -12407,27 +12808,36 @@ class ReinforcementTuningCodeExecutionRewardScorerDict(TypedDict, total=False): class ReinforcementTuningStringMatchRewardScorerStringMatchExpression( _common.BaseModel ): - """Evaluates parsed response using match type against expression.""" + """Evaluates parsed response using match type against the expression. + + Returns `true` if `MatchOperation(target, expression)` evaluates to `true`, + and `false` otherwise. This data type is not supported in Gemini API. + """ match_operation: Optional[MatchOperation] = Field( - default=None, description="""Match operation to use for evaluation.""" + default=None, + description="""Match operation to use for evaluating rewards.""", ) expression: Optional[str] = Field( default=None, - description="""String or regular expression to match against. Customer can also provide a references map (key/value pairs) whose value will be substituted into the expression by referencing `references.key_name` (wrapped in double curly braces).""", + description="""A string or a regular expression to match against for evaluating rewards. Users can also provide a references map of `{key: value}` whose `value` will be used to replace the placeholder {{references.key}} in the expression. For example, if the following `references` are defined in the training / validation dataset: ``` { "systemInstruction": ..., "contents": ..., "references": { "concise_answer": "Yes", "verbose_answer": "The answer is Yes" } } ``` and if users define the following StringMatchExpression: { "matchOperation": "REGEX_CONTAINS", "expression": ".*{{references.concise_answer}}.*" } On evaluating the reward for each sample response, this StringMatchExpression will be substituted as: ``` { "matchOperation": "REGEX_CONTAINS", "expression": ".*Yes.*" } ```""", ) class ReinforcementTuningStringMatchRewardScorerStringMatchExpressionDict( TypedDict, total=False ): - """Evaluates parsed response using match type against expression.""" + """Evaluates parsed response using match type against the expression. + + Returns `true` if `MatchOperation(target, expression)` evaluates to `true`, + and `false` otherwise. This data type is not supported in Gemini API. + """ match_operation: Optional[MatchOperation] - """Match operation to use for evaluation.""" + """Match operation to use for evaluating rewards.""" expression: Optional[str] - """String or regular expression to match against. Customer can also provide a references map (key/value pairs) whose value will be substituted into the expression by referencing `references.key_name` (wrapped in double curly braces).""" + """A string or a regular expression to match against for evaluating rewards. Users can also provide a references map of `{key: value}` whose `value` will be used to replace the placeholder {{references.key}} in the expression. For example, if the following `references` are defined in the training / validation dataset: ``` { "systemInstruction": ..., "contents": ..., "references": { "concise_answer": "Yes", "verbose_answer": "The answer is Yes" } } ``` and if users define the following StringMatchExpression: { "matchOperation": "REGEX_CONTAINS", "expression": ".*{{references.concise_answer}}.*" } On evaluating the reward for each sample response, this StringMatchExpression will be substituted as: ``` { "matchOperation": "REGEX_CONTAINS", "expression": ".*Yes.*" } ```""" ReinforcementTuningStringMatchRewardScorerStringMatchExpressionOrDict = Union[ @@ -12439,32 +12849,38 @@ class ReinforcementTuningStringMatchRewardScorerStringMatchExpressionDict( class ReinforcementTuningStringMatchRewardScorerJsonMatchExpression( _common.BaseModel ): - """Converts parsed responses to JSON format, finds the first-level matching key, then performs StringMatchExpression on the value.""" + """JsonMatchExpression supports converting the parsed responses to JSON format, finding the value in the JSON response that matches the key_name in the first level, and performing StringMatchExpression operation on the matched JSON value. + + This data type is not supported in Gemini API. + """ key_name: Optional[str] = Field( default=None, - description="""Json key name to find the value to match against.""", + description="""The key name to find the value in the parsed response that's in JSON format. Only first-level key matching is supported.""", ) value_string_match_expression: Optional[ ReinforcementTuningStringMatchRewardScorerStringMatchExpression ] = Field( default=None, - description="""String match expression to match against the value of json key.""", + description="""String match expression to match against the extracted value from the JSON representation of the parsed response.""", ) class ReinforcementTuningStringMatchRewardScorerJsonMatchExpressionDict( TypedDict, total=False ): - """Converts parsed responses to JSON format, finds the first-level matching key, then performs StringMatchExpression on the value.""" + """JsonMatchExpression supports converting the parsed responses to JSON format, finding the value in the JSON response that matches the key_name in the first level, and performing StringMatchExpression operation on the matched JSON value. + + This data type is not supported in Gemini API. + """ key_name: Optional[str] - """Json key name to find the value to match against.""" + """The key name to find the value in the parsed response that's in JSON format. Only first-level key matching is supported.""" value_string_match_expression: Optional[ ReinforcementTuningStringMatchRewardScorerStringMatchExpressionDict ] - """String match expression to match against the value of json key.""" + """String match expression to match against the extracted value from the JSON representation of the parsed response.""" ReinforcementTuningStringMatchRewardScorerJsonMatchExpressionOrDict = Union[ @@ -12474,15 +12890,22 @@ class ReinforcementTuningStringMatchRewardScorerJsonMatchExpressionDict( class ReinforcementTuningStringMatchRewardScorer(_common.BaseModel): - """Scores parsed responses for string matching use cases.""" + """ReinforcementTuningStringMatchRewardScorer is used to score parsed responses for string matching use cases. + + For example, for math problems, users can use string match scorer to check if + the correct exact answer is generated. Note: Reward returned by the string + match reward function is clipped to be within `[-1, 1]` if wrongAnswerReward + or correctAnswerReward are beyond the range, i.e., `reward = max(min(reward, + 1.0), -1.0)`. This data type is not supported in Gemini API. + """ wrong_answer_reward: Optional[float] = Field( default=None, - description="""Wrong answer reward is returned if evaluator evaluates to `false`. All wrong answers get the same reward.""", + description="""Wrong answer reward is returned if the parsed response is evaluated as `false`. All wrong answers get the same reward.""", ) correct_answer_reward: Optional[float] = Field( default=None, - description="""Correct answer reward is returned if evaluator evaluates to `true`. All correct answers get the same reward.""", + description="""Correct answer rewawrd is returned if the parsed response is evaluated as `true`. All correct answers get the same reward.""", ) string_match_expression: Optional[ ReinforcementTuningStringMatchRewardScorerStringMatchExpression @@ -12499,13 +12922,20 @@ class ReinforcementTuningStringMatchRewardScorer(_common.BaseModel): class ReinforcementTuningStringMatchRewardScorerDict(TypedDict, total=False): - """Scores parsed responses for string matching use cases.""" + """ReinforcementTuningStringMatchRewardScorer is used to score parsed responses for string matching use cases. + + For example, for math problems, users can use string match scorer to check if + the correct exact answer is generated. Note: Reward returned by the string + match reward function is clipped to be within `[-1, 1]` if wrongAnswerReward + or correctAnswerReward are beyond the range, i.e., `reward = max(min(reward, + 1.0), -1.0)`. This data type is not supported in Gemini API. + """ wrong_answer_reward: Optional[float] - """Wrong answer reward is returned if evaluator evaluates to `false`. All wrong answers get the same reward.""" + """Wrong answer reward is returned if the parsed response is evaluated as `false`. All wrong answers get the same reward.""" correct_answer_reward: Optional[float] - """Correct answer reward is returned if evaluator evaluates to `true`. All correct answers get the same reward.""" + """Correct answer rewawrd is returned if the parsed response is evaluated as `true`. All correct answers get the same reward.""" string_match_expression: Optional[ ReinforcementTuningStringMatchRewardScorerStringMatchExpressionDict @@ -12525,19 +12955,77 @@ class ReinforcementTuningStringMatchRewardScorerDict(TypedDict, total=False): class ReinforcementTuningCloudRunRewardScorer(_common.BaseModel): - """Scores parsed responses by calling a Cloud Run service.""" + """ReinforcementTuningCloudRunRewardScorer allows users to implement a reward function through GCP Cloud Run. + + Comparing with ReinforcementTuningCodeExecutionRewardScorer that runs in a + Sandbox and has no internet access, Cloud Run reward scorer is fully + controlled by users. The Cloud Run service should implement the following HTTP + API: HTTP method: `POST` HTTP request body: ``` { "example": + ReinforcementTuningExample, "response": Content, "metadata": { "step": int + "tuning_job_id": int64 } } ``` * `example` is a ReinforcementTuningExample in + ProtoJSON format, (i.e., the format is the same as as one line in the + training/validation dataset except that the keys must be in camel case). + System instructions (i.e., `example.get("systemInstruction")`) and references + (i.e., `example.get("references")`) are also included in the `example` + provided that they are set in the training/validation dataset. * `response` is + a Content in ProtoJSON format (i.e., keys must be in camel case), which is the + same as the Online Prediction response for Gemini models. HTTP response body: + { "reward": float, "user_requested_aux_info": str // Optional } where the + field "user_requested_aux_info" is any (optional) string provided by users for + assisting debugging. It's in snake case. This field is mostly useful when + calling the GenAiTuningService.ValidateReinforcementTuningReward API, where + the proto field (not Cloud Run HTTP response body) userRequestedAuxInfo will + be populated if the Cloud Run reward function sets this field in the HTTP + response. The following are examples for the HTTP request and response body. + Example HTTP request body: ``` { "example": { "contents": [ { "role": "user", + "parts": [ { "text": "What is the capital of France?" } ] } ], "references": { + "answer": "Paris" } }, "response": { "parts": [ { "text": "London" } ] }, + "metadata": { "step": 1, "tuning_job_id": 123456789 } } ``` Example HTTP + response body: ``` { "reward": -1.0 } ``` Note: Reward output by Cloud Run + reward function is clipped to be within `[-1, 1]`, i.e., `reward = + max(min(reward, 1.0), -1.0)`. This data type is not supported in Gemini API. + """ cloud_run_uri: Optional[str] = Field( default=None, - description="""URI of the Cloud Run service that will be used to compute the reward. The Vertex AI Secure Fine Tuning Service Agent (`service-PROJECT_NUMBER@gcp-sa-vertex-tune.iam.gserviceaccount.com`, where `PROJECT_NUMBER` is the numeric project number) must be granted the permission (e.g. by granting `roles/run.invoker` in IAM) to invoke the Cloud Run service.""", + description="""URI of the Cloud Run service that will be used to compute the reward. The [Vertex AI Secure Fine Tuning Service Agent](https://docs.cloud.google.com/iam/docs/service-agents#vertex-ai-secure-fine-tuning-service-agent) (`service-@gcp-sa-vertex-tune.iam.gserviceaccount.com`) must be granted the permission (e.g. by granting `roles/run.invoker` in IAM) to invoke the Cloud Run service.""", ) class ReinforcementTuningCloudRunRewardScorerDict(TypedDict, total=False): - """Scores parsed responses by calling a Cloud Run service.""" + """ReinforcementTuningCloudRunRewardScorer allows users to implement a reward function through GCP Cloud Run. + + Comparing with ReinforcementTuningCodeExecutionRewardScorer that runs in a + Sandbox and has no internet access, Cloud Run reward scorer is fully + controlled by users. The Cloud Run service should implement the following HTTP + API: HTTP method: `POST` HTTP request body: ``` { "example": + ReinforcementTuningExample, "response": Content, "metadata": { "step": int + "tuning_job_id": int64 } } ``` * `example` is a ReinforcementTuningExample in + ProtoJSON format, (i.e., the format is the same as as one line in the + training/validation dataset except that the keys must be in camel case). + System instructions (i.e., `example.get("systemInstruction")`) and references + (i.e., `example.get("references")`) are also included in the `example` + provided that they are set in the training/validation dataset. * `response` is + a Content in ProtoJSON format (i.e., keys must be in camel case), which is the + same as the Online Prediction response for Gemini models. HTTP response body: + { "reward": float, "user_requested_aux_info": str // Optional } where the + field "user_requested_aux_info" is any (optional) string provided by users for + assisting debugging. It's in snake case. This field is mostly useful when + calling the GenAiTuningService.ValidateReinforcementTuningReward API, where + the proto field (not Cloud Run HTTP response body) userRequestedAuxInfo will + be populated if the Cloud Run reward function sets this field in the HTTP + response. The following are examples for the HTTP request and response body. + Example HTTP request body: ``` { "example": { "contents": [ { "role": "user", + "parts": [ { "text": "What is the capital of France?" } ] } ], "references": { + "answer": "Paris" } }, "response": { "parts": [ { "text": "London" } ] }, + "metadata": { "step": 1, "tuning_job_id": 123456789 } } ``` Example HTTP + response body: ``` { "reward": -1.0 } ``` Note: Reward output by Cloud Run + reward function is clipped to be within `[-1, 1]`, i.e., `reward = + max(min(reward, 1.0), -1.0)`. This data type is not supported in Gemini API. + """ cloud_run_uri: Optional[str] - """URI of the Cloud Run service that will be used to compute the reward. The Vertex AI Secure Fine Tuning Service Agent (`service-PROJECT_NUMBER@gcp-sa-vertex-tune.iam.gserviceaccount.com`, where `PROJECT_NUMBER` is the numeric project number) must be granted the permission (e.g. by granting `roles/run.invoker` in IAM) to invoke the Cloud Run service.""" + """URI of the Cloud Run service that will be used to compute the reward. The [Vertex AI Secure Fine Tuning Service Agent](https://docs.cloud.google.com/iam/docs/service-agents#vertex-ai-secure-fine-tuning-service-agent) (`service-@gcp-sa-vertex-tune.iam.gserviceaccount.com`) must be granted the permission (e.g. by granting `roles/run.invoker` in IAM) to invoke the Cloud Run service.""" ReinforcementTuningCloudRunRewardScorerOrDict = Union[ @@ -12555,29 +13043,30 @@ class SingleReinforcementTuningRewardConfig(_common.BaseModel): ) reward_name: Optional[str] = Field( default=None, - description="""A unique reward name used to identify each single reinforcement tuning reward.""", + description="""A unique reward name for identifying each single reinforcement tuning reward.""", ) parse_response_config: Optional[ReinforcementTuningParseResponseConfig] = ( Field( - default=None, description="""Defines how to parse sample response.""" + default=None, + description="""Defines how to parse sample response. For example, given a sample response for evaluating the reward, users might want to extract the text only between `` and `` in the sample response, and keeps only the last one in case there are multiple such tags. To achieve such a purpose, they can define a regex `".*(.*?)"` using the ReinforcementTuningParseResponseConfig.ResponseParseType.REGEX_EXTRACT parse type.""", ) ) code_execution_reward_scorer: Optional[ ReinforcementTuningCodeExecutionRewardScorer ] = Field( default=None, - description="""Scores parsed responses for code execution use cases.""", + description="""ReinforcementTuningCodeExecutionRewardScorer is used to score parsed responses for code execution use cases.""", ) string_match_reward_scorer: Optional[ ReinforcementTuningStringMatchRewardScorer ] = Field( default=None, - description="""Scores parsed responses for simple string matching use cases against reference answer without writing python code.""", + description="""ReinforcementTuningStringMatchRewardScorer is used to score parsed responses for simple string matching use cases against reference answers.""", ) cloud_run_reward_scorer: Optional[ReinforcementTuningCloudRunRewardScorer] = ( Field( default=None, - description="""Scores parsed responses by calling a Cloud Run service.""", + description="""ReinforcementTuningCloudRunRewardScorer is used to score parsed responses by calling a Cloud Run service.""", ) ) @@ -12589,23 +13078,23 @@ class SingleReinforcementTuningRewardConfigDict(TypedDict, total=False): """Scores parsed responses for autorater use cases by using a model to compute the reward.""" reward_name: Optional[str] - """A unique reward name used to identify each single reinforcement tuning reward.""" + """A unique reward name for identifying each single reinforcement tuning reward.""" parse_response_config: Optional[ReinforcementTuningParseResponseConfigDict] - """Defines how to parse sample response.""" + """Defines how to parse sample response. For example, given a sample response for evaluating the reward, users might want to extract the text only between `` and `` in the sample response, and keeps only the last one in case there are multiple such tags. To achieve such a purpose, they can define a regex `".*(.*?)"` using the ReinforcementTuningParseResponseConfig.ResponseParseType.REGEX_EXTRACT parse type.""" code_execution_reward_scorer: Optional[ ReinforcementTuningCodeExecutionRewardScorerDict ] - """Scores parsed responses for code execution use cases.""" + """ReinforcementTuningCodeExecutionRewardScorer is used to score parsed responses for code execution use cases.""" string_match_reward_scorer: Optional[ ReinforcementTuningStringMatchRewardScorerDict ] - """Scores parsed responses for simple string matching use cases against reference answer without writing python code.""" + """ReinforcementTuningStringMatchRewardScorer is used to score parsed responses for simple string matching use cases against reference answers.""" cloud_run_reward_scorer: Optional[ReinforcementTuningCloudRunRewardScorerDict] - """Scores parsed responses by calling a Cloud Run service.""" + """ReinforcementTuningCloudRunRewardScorer is used to score parsed responses by calling a Cloud Run service.""" SingleReinforcementTuningRewardConfigOrDict = Union[ @@ -12620,11 +13109,11 @@ class CompositeReinforcementTuningRewardConfigWeightedRewardConfig( """Composite reinforcement tuning reward config weighted reward config.""" reward_config: Optional[SingleReinforcementTuningRewardConfig] = Field( - default=None, description="""""" + default=None, description="""Single reward configuration.""" ) weight: Optional[float] = Field( default=None, - description="""How much this single reward contributes to the total overall reward.""", + description="""How much this single reward contributes to the total overall reward. Total reward is a linear combination of single rewards with their corresponding weights, i.e., ``` total_reward = ( weight_a * reward_a + weight_b * reward_b + ... ) / (weight_a + weight_b + ...) ```""", ) @@ -12634,10 +13123,10 @@ class CompositeReinforcementTuningRewardConfigWeightedRewardConfigDict( """Composite reinforcement tuning reward config weighted reward config.""" reward_config: Optional[SingleReinforcementTuningRewardConfigDict] - """""" + """Single reward configuration.""" weight: Optional[float] - """How much this single reward contributes to the total overall reward.""" + """How much this single reward contributes to the total overall reward. Total reward is a linear combination of single rewards with their corresponding weights, i.e., ``` total_reward = ( weight_a * reward_a + weight_b * reward_b + ... ) / (weight_a + weight_b + ...) ```""" CompositeReinforcementTuningRewardConfigWeightedRewardConfigOrDict = Union[ @@ -12651,7 +13140,10 @@ class CompositeReinforcementTuningRewardConfig(_common.BaseModel): weighted_reward_configs: Optional[ list[CompositeReinforcementTuningRewardConfigWeightedRewardConfig] - ] = Field(default=None, description="""""") + ] = Field( + default=None, + description="""List of reward function configurations with weights.""", + ) class CompositeReinforcementTuningRewardConfigDict(TypedDict, total=False): @@ -12660,7 +13152,7 @@ class CompositeReinforcementTuningRewardConfigDict(TypedDict, total=False): weighted_reward_configs: Optional[ list[CompositeReinforcementTuningRewardConfigWeightedRewardConfigDict] ] - """""" + """List of reward function configurations with weights.""" CompositeReinforcementTuningRewardConfigOrDict = Union[ @@ -12674,38 +13166,43 @@ class ReinforcementTuningHyperParameters(_common.BaseModel): epoch_count: Optional[int] = Field( default=None, - description="""Number of training epochs for the tuning job.""", + description="""Optional. Number of training epoches for the tuning job.""", ) learning_rate_multiplier: Optional[float] = Field( default=None, description="""Learning rate multiplier for Reinforcement Learning.""", ) adapter_size: Optional[AdapterSize] = Field( - default=None, description="""Adapter size for Reinforcement Tuning.""" + default=None, + description="""Optional. Adapter size for Reinforcement Tuning.""", ) samples_per_prompt: Optional[int] = Field( default=None, - description="""Number of different responses to generate per prompt during tuning.""", + description="""Optional. Number of different responses to generate per prompt during tuning.""", ) batch_size: Optional[int] = Field( default=None, - description="""Batch size for the tuning job. How many prompts to process at a train step. If not set, the batch size will be determined automatically.""", + description="""Optional. Batch size for the tuning job. How many prompts to process at a train step. If not set, the batch size will be determined automatically.""", ) evaluate_interval: Optional[int] = Field( default=None, - description="""How often (in steps) to evaluate the tuning job during training. If not set, evaluation will run per epoch.""", + description="""Optional. How often at steps to evaluate the tuning job during training. If not set, evel will be run per epoch. `total_steps = epoch_count * samples_per_prompt / total_prompts_in_dataset`""", ) checkpoint_interval: Optional[int] = Field( default=None, - description="""How often (in steps) to save checkpoints during training. If not set, one checkpoint per epoch will be saved.""", + description="""Optional. How often at steps to save checkpoints during training. If not set, one checkpoint per epoch will be set. ```total_steps = epoch_count * samples_per_prompt / total_prompts_in_dataset```""", ) max_output_tokens: Optional[int] = Field( default=None, - description="""The maximum number of tokens to generate per prompt. If not set, defaults to 32768.""", + description="""Optional. The maximum number of tokens to generate per prompt. Default to 32768.""", ) thinking_level: Optional[ReinforcementTuningThinkingLevel] = Field( default=None, - description="""Indicates the maximum thinking depth. Use with earlier models shall result in error.""", + description="""Indicates the maximum thinking depth during tuning. Starting from Gemini 3.5 models, the old thinking_budget will no longer be supported and will result in a user error if set. Instead, users should use the thinking_level parameter to control the maximum thinking depth.""", + ) + thinking_budget: Optional[int] = Field( + 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).""", ) @@ -12713,31 +13210,34 @@ class ReinforcementTuningHyperParametersDict(TypedDict, total=False): """Hyperparameters for Reinforcement Tuning.""" epoch_count: Optional[int] - """Number of training epochs for the tuning job.""" + """Optional. Number of training epoches for the tuning job.""" learning_rate_multiplier: Optional[float] """Learning rate multiplier for Reinforcement Learning.""" adapter_size: Optional[AdapterSize] - """Adapter size for Reinforcement Tuning.""" + """Optional. Adapter size for Reinforcement Tuning.""" samples_per_prompt: Optional[int] - """Number of different responses to generate per prompt during tuning.""" + """Optional. Number of different responses to generate per prompt during tuning.""" batch_size: Optional[int] - """Batch size for the tuning job. How many prompts to process at a train step. If not set, the batch size will be determined automatically.""" + """Optional. Batch size for the tuning job. How many prompts to process at a train step. If not set, the batch size will be determined automatically.""" evaluate_interval: Optional[int] - """How often (in steps) to evaluate the tuning job during training. If not set, evaluation will run per epoch.""" + """Optional. How often at steps to evaluate the tuning job during training. If not set, evel will be run per epoch. `total_steps = epoch_count * samples_per_prompt / total_prompts_in_dataset`""" checkpoint_interval: Optional[int] - """How often (in steps) to save checkpoints during training. If not set, one checkpoint per epoch will be saved.""" + """Optional. How often at steps to save checkpoints during training. If not set, one checkpoint per epoch will be set. ```total_steps = epoch_count * samples_per_prompt / total_prompts_in_dataset```""" max_output_tokens: Optional[int] - """The maximum number of tokens to generate per prompt. If not set, defaults to 32768.""" + """Optional. The maximum number of tokens to generate per prompt. Default to 32768.""" thinking_level: Optional[ReinforcementTuningThinkingLevel] - """Indicates the maximum thinking depth. Use with earlier models shall result in error.""" + """Indicates the maximum thinking depth during tuning. Starting from Gemini 3.5 models, the old thinking_budget will no longer be supported and will result in a user error if set. Instead, users should use the thinking_level parameter to control the maximum thinking depth.""" + + 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).""" ReinforcementTuningHyperParametersOrDict = Union[ @@ -12750,14 +13250,17 @@ class ReinforcementTuningSpec(_common.BaseModel): composite_reward_config: Optional[ CompositeReinforcementTuningRewardConfig - ] = Field(default=None, description="""""") + ] = Field( + default=None, + description="""Composite 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.""", + description="""Cloud Storage path to the file containing training dataset for tuning. 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 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.""", + description="""Cloud Storage path to the file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.""", ) hyper_parameters: Optional[ReinforcementTuningHyperParameters] = Field( default=None, @@ -12775,13 +13278,13 @@ class ReinforcementTuningSpecDict(TypedDict, total=False): composite_reward_config: Optional[ CompositeReinforcementTuningRewardConfigDict ] - """""" + """Composite 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.""" + """Cloud Storage path to the file containing training dataset for tuning. The dataset must be formatted as a JSONL file.""" 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.""" + """Cloud Storage path to the file containing validation dataset for tuning. The dataset must be formatted as a JSONL file.""" hyper_parameters: Optional[ReinforcementTuningHyperParametersDict] """Additional hyper-parameters to use during tuning.""" @@ -13078,6 +13581,71 @@ class DatasetDistributionDict(TypedDict, total=False): DatasetDistributionOrDict = Union[DatasetDistribution, DatasetDistributionDict] +class ReinforcementTuningExample(_common.BaseModel): + """User-facing format for Gemini Reinforcement Tuning examples on Vertex.""" + + contents: Optional[list[Content]] = Field( + default=None, + description="""Multi-turn contents that represents the Prompt.""", + ) + references: Optional[dict[str, str]] = Field( + default=None, + description="""References for the given prompt. The key is the name of the reference, and the value is the reference itself.""", + ) + system_instruction: Optional[Content] = Field( + default=None, + description="""Corresponds to system_instruction in user-facing GenerateContentRequest.""", + ) + + +class ReinforcementTuningExampleDict(TypedDict, total=False): + """User-facing format for Gemini Reinforcement Tuning examples on Vertex.""" + + contents: Optional[list[ContentDict]] + """Multi-turn contents that represents the Prompt.""" + + references: Optional[dict[str, str]] + """References for the given prompt. The key is the name of the reference, and the value is the reference itself.""" + + system_instruction: Optional[ContentDict] + """Corresponds to system_instruction in user-facing GenerateContentRequest.""" + + +ReinforcementTuningExampleOrDict = Union[ + ReinforcementTuningExample, ReinforcementTuningExampleDict +] + + +class ReinforcementTuningUserDatasetExamples(_common.BaseModel): + """Sample reinforcement tuning user data in the training dataset. + + The contents are truncated for better UI showing. This data type is not + supported in Gemini API. + """ + + user_dataset_examples: Optional[list[ReinforcementTuningExample]] = Field( + default=None, + description="""List of user datasset examples showing to user.""", + ) + + +class ReinforcementTuningUserDatasetExamplesDict(TypedDict, total=False): + """Sample reinforcement tuning user data in the training dataset. + + The contents are truncated for better UI showing. This data type is not + supported in Gemini API. + """ + + user_dataset_examples: Optional[list[ReinforcementTuningExampleDict]] + """List of user datasset examples showing to user.""" + + +ReinforcementTuningUserDatasetExamplesOrDict = Union[ + ReinforcementTuningUserDatasetExamples, + ReinforcementTuningUserDatasetExamplesDict, +] + + class DatasetStats(_common.BaseModel): """Statistics computed over a tuning dataset. @@ -13124,6 +13692,20 @@ class DatasetStats(_common.BaseModel): default=None, description="""Output only. Dataset distributions for the user output tokens.""", ) + contents_per_example_distribution: Optional[DatasetDistribution] = Field( + default=None, + description="""Output only. Dataset distributions for the number of contents per example.""", + ) + reinforcement_tuning_user_dataset_examples: Optional[ + ReinforcementTuningUserDatasetExamples + ] = Field( + default=None, + description="""Output only. Sample user dataset examples in the training dataset uri for Reinforcement Tuning.""", + ) + total_billable_token_count: Optional[int] = Field( + default=None, + description="""Output only. Number of billable tokens in the tuning dataset.""", + ) class DatasetStatsDict(TypedDict, total=False): @@ -13162,6 +13744,17 @@ class DatasetStatsDict(TypedDict, total=False): user_output_token_distribution: Optional[DatasetDistributionDict] """Output only. Dataset distributions for the user output tokens.""" + contents_per_example_distribution: Optional[DatasetDistributionDict] + """Output only. Dataset distributions for the number of contents per example.""" + + reinforcement_tuning_user_dataset_examples: Optional[ + ReinforcementTuningUserDatasetExamplesDict + ] + """Output only. Sample user dataset examples in the training dataset uri for Reinforcement Tuning.""" + + total_billable_token_count: Optional[int] + """Output only. Number of billable tokens in the tuning dataset.""" + DatasetStatsOrDict = Union[DatasetStats, DatasetStatsDict] @@ -13615,6 +14208,10 @@ class TuningDataStats(_common.BaseModel): supervised_tuning_data_stats: Optional[SupervisedTuningDataStats] = Field( default=None, description="""The SFT Tuning data stats.""" ) + reinforcement_tuning_data_stats: Optional[DatasetStats] = Field( + default=None, + description="""Output only. Statistics for reinforcement tuning.""", + ) class TuningDataStatsDict(TypedDict, total=False): @@ -13634,6 +14231,9 @@ class TuningDataStatsDict(TypedDict, total=False): supervised_tuning_data_stats: Optional[SupervisedTuningDataStatsDict] """The SFT Tuning data stats.""" + reinforcement_tuning_data_stats: Optional[DatasetStatsDict] + """Output only. Statistics for reinforcement tuning.""" + TuningDataStatsOrDict = Union[TuningDataStats, TuningDataStatsDict] @@ -14462,7 +15062,7 @@ class TuningJob(_common.BaseModel): default=None, description="""Tuning Spec for Distillation.""" ) reinforcement_tuning_spec: Optional[ReinforcementTuningSpec] = Field( - default=None, description="""""" + default=None, description="""Tuning Spec for Reinforcement Tuning.""" ) tuning_data_stats: Optional[TuningDataStats] = Field( default=None, @@ -14591,7 +15191,7 @@ class TuningJobDict(TypedDict, total=False): """Tuning Spec for Distillation.""" reinforcement_tuning_spec: Optional[ReinforcementTuningSpecDict] - """""" + """Tuning Spec for Reinforcement Tuning.""" tuning_data_stats: Optional[TuningDataStatsDict] """Output only. The tuning data statistics associated with this TuningJob.""" @@ -15200,41 +15800,6 @@ class TuningOperationDict(TypedDict, total=False): TuningOperationOrDict = Union[TuningOperation, TuningOperationDict] -class ReinforcementTuningExample(_common.BaseModel): - """User-facing format for Gemini Reinforcement Tuning examples on Vertex.""" - - contents: Optional[list[Content]] = Field( - default=None, - description="""Multi-turn contents that represents the Prompt.""", - ) - references: Optional[dict[str, str]] = Field( - default=None, - description="""References for the given prompt. The key is the name of the reference, and the value is the reference itself.""", - ) - system_instruction: Optional[Content] = Field( - default=None, - description="""Corresponds to `system_instruction` in user-facing GenerateContentRequest.""", - ) - - -class ReinforcementTuningExampleDict(TypedDict, total=False): - """User-facing format for Gemini Reinforcement Tuning examples on Vertex.""" - - contents: Optional[list[ContentDict]] - """Multi-turn contents that represents the Prompt.""" - - references: Optional[dict[str, str]] - """References for the given prompt. The key is the name of the reference, and the value is the reference itself.""" - - system_instruction: Optional[ContentDict] - """Corresponds to `system_instruction` in user-facing GenerateContentRequest.""" - - -ReinforcementTuningExampleOrDict = Union[ - ReinforcementTuningExample, ReinforcementTuningExampleDict -] - - class ValidateRewardConfig(_common.BaseModel): """Optional parameters for tunings.validate_reward.""" @@ -15331,7 +15896,7 @@ class ReinforcementTuningRewardInfo(_common.BaseModel): ) user_requested_aux_info: Optional[str] = Field( default=None, - description="""Output only. The user-requested auxiliary info for the reward function.""", + description="""Output only. The user-requested auxiliary info for the reward function. This field is set only if the Cloud Run reward function configured by user returns a "user_requested_aux_info". Refer to ReinforcementTuningCloudRunRewardScorer for more details.""", ) @@ -15342,7 +15907,7 @@ class ReinforcementTuningRewardInfoDict(TypedDict, total=False): """Output only. The calculated reward for the reward function.""" user_requested_aux_info: Optional[str] - """Output only. The user-requested auxiliary info for the reward function.""" + """Output only. The user-requested auxiliary info for the reward function. This field is set only if the Cloud Run reward function configured by user returns a "user_requested_aux_info". Refer to ReinforcementTuningCloudRunRewardScorer for more details.""" ReinforcementTuningRewardInfoOrDict = Union[ @@ -20627,38 +21192,6 @@ class RealtimeInputConfigDict(TypedDict, total=False): RealtimeInputConfigOrDict = Union[RealtimeInputConfig, RealtimeInputConfigDict] -class TranslationConfig(_common.BaseModel): - """Config for stream translation.""" - - echo_target_language: Optional[bool] = Field( - default=None, - description="""If true, the model will generate audio when the target language is - spoken, essentially it will parrot the input. If false, we will not produce - audio for the target language.""", - ) - target_language_code: Optional[str] = Field( - default=None, - description="""The target language for translation. Supported values are BCP-47 - language codes (e.g. "en", "es", "fr").""", - ) - - -class TranslationConfigDict(TypedDict, total=False): - """Config for stream translation.""" - - echo_target_language: Optional[bool] - """If true, the model will generate audio when the target language is - spoken, essentially it will parrot the input. If false, we will not produce - audio for the target language.""" - - target_language_code: Optional[str] - """The target language for translation. Supported values are BCP-47 - language codes (e.g. "en", "es", "fr").""" - - -TranslationConfigOrDict = Union[TranslationConfig, TranslationConfigDict] - - class LiveConnectConfig(_common.BaseModel): """Session config for the API connection."""