Skip to content
Open
Show file tree
Hide file tree
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
45 changes: 1 addition & 44 deletions google/genai/_live_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,46 +167,6 @@ def _FunctionCall_to_mldev(
return to_object


def _FunctionDeclaration_to_vertex(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}
if getv(from_object, ['description']) is not None:
setv(to_object, ['description'], getv(from_object, ['description']))

if getv(from_object, ['name']) is not None:
setv(to_object, ['name'], getv(from_object, ['name']))

if getv(from_object, ['parameters']) is not None:
setv(to_object, ['parameters'], getv(from_object, ['parameters']))

if getv(from_object, ['parameters_json_schema']) is not None:
setv(
to_object,
['parametersJsonSchema'],
getv(from_object, ['parameters_json_schema']),
)

if getv(from_object, ['response']) is not None:
setv(to_object, ['response'], getv(from_object, ['response']))

if getv(from_object, ['response_json_schema']) is not None:
setv(
to_object,
['responseJsonSchema'],
getv(from_object, ['response_json_schema']),
)

if getv(from_object, ['behavior']) is not None:
raise ValueError(
'behavior parameter is not supported in Gemini Enterprise Agent'
' Platform.'
)

return to_object


def _GenerationConfig_to_vertex(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
Expand Down Expand Up @@ -1854,10 +1814,7 @@ def _Tool_to_vertex(
setv(
to_object,
['functionDeclarations'],
[
_FunctionDeclaration_to_vertex(item, to_object)
for item in getv(from_object, ['function_declarations'])
],
[item for item in getv(from_object, ['function_declarations'])],
)

if getv(from_object, ['google_search_retrieval']) is not None:
Expand Down
45 changes: 1 addition & 44 deletions google/genai/caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,46 +407,6 @@ def _FunctionCallingConfig_to_mldev(
return to_object


def _FunctionDeclaration_to_vertex(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}
if getv(from_object, ['description']) is not None:
setv(to_object, ['description'], getv(from_object, ['description']))

if getv(from_object, ['name']) is not None:
setv(to_object, ['name'], getv(from_object, ['name']))

if getv(from_object, ['parameters']) is not None:
setv(to_object, ['parameters'], getv(from_object, ['parameters']))

if getv(from_object, ['parameters_json_schema']) is not None:
setv(
to_object,
['parametersJsonSchema'],
getv(from_object, ['parameters_json_schema']),
)

if getv(from_object, ['response']) is not None:
setv(to_object, ['response'], getv(from_object, ['response']))

if getv(from_object, ['response_json_schema']) is not None:
setv(
to_object,
['responseJsonSchema'],
getv(from_object, ['response_json_schema']),
)

if getv(from_object, ['behavior']) is not None:
raise ValueError(
'behavior parameter is not supported in Gemini Enterprise Agent'
' Platform.'
)

return to_object


def _GetCachedContentParameters_to_mldev(
api_client: BaseApiClient,
from_object: Union[dict[str, Any], object],
Expand Down Expand Up @@ -944,10 +904,7 @@ def _Tool_to_vertex(
setv(
to_object,
['functionDeclarations'],
[
_FunctionDeclaration_to_vertex(item, to_object)
for item in getv(from_object, ['function_declarations'])
],
[item for item in getv(from_object, ['function_declarations'])],
)

if getv(from_object, ['google_search_retrieval']) is not None:
Expand Down
46 changes: 1 addition & 45 deletions google/genai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,47 +1135,6 @@ def _FunctionCallingConfig_to_mldev(
return to_object


def _FunctionDeclaration_to_vertex(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
root_object: Optional[Union[dict[str, Any], object]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}
if getv(from_object, ['description']) is not None:
setv(to_object, ['description'], getv(from_object, ['description']))

if getv(from_object, ['name']) is not None:
setv(to_object, ['name'], getv(from_object, ['name']))

if getv(from_object, ['parameters']) is not None:
setv(to_object, ['parameters'], getv(from_object, ['parameters']))

if getv(from_object, ['parameters_json_schema']) is not None:
setv(
to_object,
['parametersJsonSchema'],
getv(from_object, ['parameters_json_schema']),
)

if getv(from_object, ['response']) is not None:
setv(to_object, ['response'], getv(from_object, ['response']))

if getv(from_object, ['response_json_schema']) is not None:
setv(
to_object,
['responseJsonSchema'],
getv(from_object, ['response_json_schema']),
)

if getv(from_object, ['behavior']) is not None:
raise ValueError(
'behavior parameter is not supported in Gemini Enterprise Agent'
' Platform.'
)

return to_object


def _GenerateContentConfig_to_mldev(
api_client: BaseApiClient,
from_object: Union[dict[str, Any], object],
Expand Down Expand Up @@ -4252,10 +4211,7 @@ def _Tool_to_vertex(
setv(
to_object,
['functionDeclarations'],
[
_FunctionDeclaration_to_vertex(item, to_object, root_object)
for item in getv(from_object, ['function_declarations'])
],
[item for item in getv(from_object, ['function_declarations'])],
)

if getv(from_object, ['google_search_retrieval']) is not None:
Expand Down
9 changes: 3 additions & 6 deletions google/genai/tests/live/test_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,12 +1193,9 @@ async def test_bidi_setup_to_api_with_tools_function_behavior(vertexai):
}
config = types.LiveConnectConfig(**config_dict)

with pytest_helper.exception_if_vertex(api_client, ValueError):
result = await get_connect_message(
mock_api_client(vertexai=vertexai), model='test_model', config=config
)
if vertexai:
return
result = await get_connect_message(
mock_api_client(vertexai=vertexai), model='test_model', config=config
)

assert (
result['setup']['tools'][0]['functionDeclarations'][0]['behavior']
Expand Down
11 changes: 6 additions & 5 deletions google/genai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,13 @@ class PhishBlockThreshold(_common.CaseInSensitiveEnum):
class Behavior(_common.CaseInSensitiveEnum):
"""Specifies the function Behavior.

Currently only supported by the BidiGenerateContent method. This enum is not
supported in Vertex AI.
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.
"""

UNSPECIFIED = 'UNSPECIFIED'
"""This value is unused."""
"""This value is unspecified."""
BLOCKING = 'BLOCKING'
"""If set, the system will wait to receive the function response before continuing the conversation."""
NON_BLOCKING = 'NON_BLOCKING'
Expand Down Expand Up @@ -4392,7 +4393,7 @@ class FunctionDeclaration(_common.BaseModel):
)
behavior: Optional[Behavior] = Field(
default=None,
description="""Optional. Specifies the function Behavior. Currently only supported by the BidiGenerateContent method. This field is not supported in Vertex AI.""",
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.""",
)

@classmethod
Expand Down Expand Up @@ -4615,7 +4616,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 supported by the BidiGenerateContent method. This field is not supported in Vertex AI."""
"""Optional. Specifies the function Behavior. Currently only non-blocking functions are supported. If not specified, the system keeps the current function call behavior. This field is currently only supported by the BidiGenerateContent method."""


FunctionDeclarationOrDict = Union[FunctionDeclaration, FunctionDeclarationDict]
Expand Down
Loading