Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
304 changes: 150 additions & 154 deletions google/genai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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,
Expand All @@ -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."""
Expand Down Expand Up @@ -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
<a href="https://en.wikipedia.org/wiki/World_Geodetic_System#1984_version">
WGS84 standard</a>. 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
<a href="https://en.wikipedia.org/wiki/World_Geodetic_System#1984_version">
WGS84 standard</a>. 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."""

Expand Down Expand Up @@ -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]


Expand Down
Loading