From cd66b68e3dbffdf4bc5dc99d7949a775797d1c54 Mon Sep 17 00:00:00 2001 From: Jaycee Li Date: Fri, 22 May 2026 13:17:43 -0700 Subject: [PATCH] chore: Internal cleanup PiperOrigin-RevId: 919827744 --- google/genai/types.py | 304 +++++++++++++++++++++--------------------- 1 file changed, 150 insertions(+), 154 deletions(-) diff --git a/google/genai/types.py b/google/genai/types.py index 3d5a7fc45..9f846a74b 100644 --- a/google/genai/types.py +++ b/google/genai/types.py @@ -303,21 +303,6 @@ class DynamicRetrievalConfigMode(_common.CaseInSensitiveEnum): """Run retrieval only when system decides it is necessary.""" -class FunctionCallingConfigMode(_common.CaseInSensitiveEnum): - """Function calling mode.""" - - MODE_UNSPECIFIED = 'MODE_UNSPECIFIED' - """Unspecified function calling mode. This value should not be used.""" - AUTO = 'AUTO' - """Default model behavior, model decides to predict either function calls or natural language response.""" - ANY = 'ANY' - """Model is constrained to always predicting function calls only. If "allowed_function_names" are set, the predicted function calls will be limited to any one of "allowed_function_names", else the predicted function calls will be any one of the provided "function_declarations".""" - NONE = 'NONE' - """Model will not predict any function calls. Model behavior is same as when not passing any function declarations.""" - VALIDATED = 'VALIDATED' - """Model is constrained to predict either function calls or natural language response. If "allowed_function_names" are set, the predicted function calls will be limited to any one of "allowed_function_names", else the predicted function calls will be any one of the provided "function_declarations".""" - - class ThinkingLevel(_common.CaseInSensitiveEnum): """The number of thoughts tokens that the model should generate.""" @@ -427,6 +412,21 @@ class HarmBlockThreshold(_common.CaseInSensitiveEnum): """Turn off the safety filter entirely.""" +class FunctionCallingConfigMode(_common.CaseInSensitiveEnum): + """Function calling mode.""" + + MODE_UNSPECIFIED = 'MODE_UNSPECIFIED' + """Unspecified function calling mode. This value should not be used.""" + AUTO = 'AUTO' + """Default model behavior, model decides to predict either function calls or natural language response.""" + ANY = 'ANY' + """Model is constrained to always predicting function calls only. If "allowed_function_names" are set, the predicted function calls will be limited to any one of "allowed_function_names", else the predicted function calls will be any one of the provided "function_declarations".""" + NONE = 'NONE' + """Model will not predict any function calls. Model behavior is same as when not passing any function declarations.""" + VALIDATED = 'VALIDATED' + """Model is constrained to predict either function calls or natural language response. If "allowed_function_names" are set, the predicted function calls will be limited to any one of "allowed_function_names", else the predicted function calls will be any one of the provided "function_declarations".""" + + class FinishReason(_common.CaseInSensitiveEnum): """Output only. The reason why the model stopped generating tokens. @@ -1593,12 +1593,11 @@ class PartialArgDict(TypedDict, total=False): class FunctionCall(_common.BaseModel): - """A function call.""" + """A predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name and a structured JSON object containing the parameters and their values.""" id: Optional[str] = Field( default=None, - description="""The unique id of the function call. If populated, the client to execute the - `function_call` and return the response with the matching `id`.""", + description="""Optional. The unique id of the function call. If populated, the client to execute the `function_call` and return the response with the matching `id`.""", ) args: Optional[dict[str, Any]] = Field( default=None, @@ -1619,11 +1618,10 @@ class FunctionCall(_common.BaseModel): class FunctionCallDict(TypedDict, total=False): - """A function call.""" + """A predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name and a structured JSON object containing the parameters and their values.""" id: Optional[str] - """The unique id of the function call. If populated, the client to execute the - `function_call` and return the response with the matching `id`.""" + """Optional. The unique id of the function call. If populated, the client to execute the `function_call` and return the response with the matching `id`.""" args: Optional[dict[str, Any]] """Optional. The function parameters and values in JSON object format. See FunctionDeclaration.parameters for parameter details.""" @@ -4966,139 +4964,6 @@ class ToolDict(TypedDict, total=False): SchemaUnionDict = Union[SchemaUnion, SchemaDict] -class LatLng(_common.BaseModel): - """An object that represents a latitude/longitude pair. - - This is expressed as a pair of doubles to represent degrees latitude and - degrees longitude. Unless specified otherwise, this object must conform to the - - WGS84 standard. Values must be within normalized ranges. - """ - - latitude: Optional[float] = Field( - default=None, - description="""The latitude in degrees. It must be in the range [-90.0, +90.0].""", - ) - longitude: Optional[float] = Field( - default=None, - description="""The longitude in degrees. It must be in the range [-180.0, +180.0]""", - ) - - -class LatLngDict(TypedDict, total=False): - """An object that represents a latitude/longitude pair. - - This is expressed as a pair of doubles to represent degrees latitude and - degrees longitude. Unless specified otherwise, this object must conform to the - - WGS84 standard. Values must be within normalized ranges. - """ - - latitude: Optional[float] - """The latitude in degrees. It must be in the range [-90.0, +90.0].""" - - longitude: Optional[float] - """The longitude in degrees. It must be in the range [-180.0, +180.0]""" - - -LatLngOrDict = Union[LatLng, LatLngDict] - - -class RetrievalConfig(_common.BaseModel): - """Retrieval config.""" - - lat_lng: Optional[LatLng] = Field( - default=None, description="""Optional. The location of the user.""" - ) - language_code: Optional[str] = Field( - default=None, description="""The language code of the user.""" - ) - - -class RetrievalConfigDict(TypedDict, total=False): - """Retrieval config.""" - - lat_lng: Optional[LatLngDict] - """Optional. The location of the user.""" - - language_code: Optional[str] - """The language code of the user.""" - - -RetrievalConfigOrDict = Union[RetrievalConfig, RetrievalConfigDict] - - -class FunctionCallingConfig(_common.BaseModel): - """Function calling config.""" - - allowed_function_names: Optional[list[str]] = Field( - default=None, - description="""Optional. Function names to call. Only set when the Mode is ANY. Function names should match FunctionDeclaration.name. With mode set to ANY, model will predict a function call from the set of function names provided.""", - ) - mode: Optional[FunctionCallingConfigMode] = Field( - default=None, description="""Optional. Function calling mode.""" - ) - stream_function_call_arguments: Optional[bool] = Field( - default=None, - description="""Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the `FunctionCall.partial_args` field. This field is not supported in Gemini API.""", - ) - - -class FunctionCallingConfigDict(TypedDict, total=False): - """Function calling config.""" - - allowed_function_names: Optional[list[str]] - """Optional. Function names to call. Only set when the Mode is ANY. Function names should match FunctionDeclaration.name. With mode set to ANY, model will predict a function call from the set of function names provided.""" - - mode: Optional[FunctionCallingConfigMode] - """Optional. Function calling mode.""" - - stream_function_call_arguments: Optional[bool] - """Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the `FunctionCall.partial_args` field. This field is not supported in Gemini API.""" - - -FunctionCallingConfigOrDict = Union[ - FunctionCallingConfig, FunctionCallingConfigDict -] - - -class ToolConfig(_common.BaseModel): - """Tool config. - - This config is shared for all tools provided in the request. - """ - - retrieval_config: Optional[RetrievalConfig] = Field( - default=None, description="""Optional. Retrieval config.""" - ) - function_calling_config: Optional[FunctionCallingConfig] = Field( - default=None, description="""Optional. Function calling config.""" - ) - include_server_side_tool_invocations: Optional[bool] = Field( - default=None, - description="""If true, the API response will include the server-side tool calls and responses within the `Content` message. This allows clients to observe the server's tool invocations.""", - ) - - -class ToolConfigDict(TypedDict, total=False): - """Tool config. - - This config is shared for all tools provided in the request. - """ - - retrieval_config: Optional[RetrievalConfigDict] - """Optional. Retrieval config.""" - - function_calling_config: Optional[FunctionCallingConfigDict] - """Optional. Function calling config.""" - - include_server_side_tool_invocations: Optional[bool] - """If true, the API response will include the server-side tool calls and responses within the `Content` message. This allows clients to observe the server's tool invocations.""" - - -ToolConfigOrDict = Union[ToolConfig, ToolConfigDict] - - class VoiceConsentSignature(_common.BaseModel): """The signature of the voice consent check.""" @@ -5811,6 +5676,137 @@ class SafetySettingDict(TypedDict, total=False): SafetySettingOrDict = Union[SafetySetting, SafetySettingDict] +class LatLng(_common.BaseModel): + """An object that represents a latitude/longitude pair. + + This is expressed as a pair of doubles to represent degrees latitude and + degrees longitude. Unless specified otherwise, this object must conform to the + WGS84 standard. Values must be within normalized ranges. + """ + + latitude: Optional[float] = Field( + default=None, + description="""The latitude in degrees. It must be in the range [-90.0, +90.0].""", + ) + longitude: Optional[float] = Field( + default=None, + description="""The longitude in degrees. It must be in the range [-180.0, +180.0].""", + ) + + +class LatLngDict(TypedDict, total=False): + """An object that represents a latitude/longitude pair. + + This is expressed as a pair of doubles to represent degrees latitude and + degrees longitude. Unless specified otherwise, this object must conform to the + WGS84 standard. Values must be within normalized ranges. + """ + + latitude: Optional[float] + """The latitude in degrees. It must be in the range [-90.0, +90.0].""" + + longitude: Optional[float] + """The longitude in degrees. It must be in the range [-180.0, +180.0].""" + + +LatLngOrDict = Union[LatLng, LatLngDict] + + +class RetrievalConfig(_common.BaseModel): + """Retrieval config.""" + + lat_lng: Optional[LatLng] = Field( + default=None, description="""The location of the user.""" + ) + language_code: Optional[str] = Field( + default=None, description="""The language code of the user.""" + ) + + +class RetrievalConfigDict(TypedDict, total=False): + """Retrieval config.""" + + lat_lng: Optional[LatLngDict] + """The location of the user.""" + + language_code: Optional[str] + """The language code of the user.""" + + +RetrievalConfigOrDict = Union[RetrievalConfig, RetrievalConfigDict] + + +class FunctionCallingConfig(_common.BaseModel): + """Function calling config.""" + + allowed_function_names: Optional[list[str]] = Field( + default=None, + description="""Optional. Function names to call. Only set when the Mode is ANY. Function names should match FunctionDeclaration.name. With mode set to ANY, model will predict a function call from the set of function names provided.""", + ) + mode: Optional[FunctionCallingConfigMode] = Field( + default=None, description="""Optional. Function calling mode.""" + ) + stream_function_call_arguments: Optional[bool] = Field( + default=None, + description="""Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the `FunctionCall.partial_args` field. This field is not supported in Gemini API.""", + ) + + +class FunctionCallingConfigDict(TypedDict, total=False): + """Function calling config.""" + + allowed_function_names: Optional[list[str]] + """Optional. Function names to call. Only set when the Mode is ANY. Function names should match FunctionDeclaration.name. With mode set to ANY, model will predict a function call from the set of function names provided.""" + + mode: Optional[FunctionCallingConfigMode] + """Optional. Function calling mode.""" + + stream_function_call_arguments: Optional[bool] + """Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the `FunctionCall.partial_args` field. This field is not supported in Gemini API.""" + + +FunctionCallingConfigOrDict = Union[ + FunctionCallingConfig, FunctionCallingConfigDict +] + + +class ToolConfig(_common.BaseModel): + """Tool config. + + This config is shared for all tools provided in the request. + """ + + retrieval_config: Optional[RetrievalConfig] = Field( + default=None, description="""Optional. Retrieval config.""" + ) + function_calling_config: Optional[FunctionCallingConfig] = Field( + default=None, description="""Optional. Function calling config.""" + ) + include_server_side_tool_invocations: Optional[bool] = Field( + default=None, + description="""Optional. If true, the API response will include the server-side tool calls and responses within the `Content` message. This allows clients to observe the server's tool interactions. This field is not supported in Vertex AI.""", + ) + + +class ToolConfigDict(TypedDict, total=False): + """Tool config. + + This config is shared for all tools provided in the request. + """ + + retrieval_config: Optional[RetrievalConfigDict] + """Optional. Retrieval config.""" + + function_calling_config: Optional[FunctionCallingConfigDict] + """Optional. Function calling config.""" + + include_server_side_tool_invocations: Optional[bool] + """Optional. If true, the API response will include the server-side tool calls and responses within the `Content` message. This allows clients to observe the server's tool interactions. This field is not supported in Vertex AI.""" + + +ToolConfigOrDict = Union[ToolConfig, ToolConfigDict] + + SpeechConfigUnion = Union[str, SpeechConfig]