Skip to content
Merged
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
34 changes: 34 additions & 0 deletions google/genai/_live_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,26 @@ def _GoogleSearchRetrieval_to_vertex(
return to_object


def _EnterpriseWebSearch_to_mldev(
api_client: BaseApiClient,
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}

return to_object


def _EnterpriseWebSearch_to_vertex(
api_client: BaseApiClient,
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}

return to_object


def _Tool_to_mldev(
api_client: BaseApiClient,
from_object: Union[dict[str, Any], object],
Expand Down Expand Up @@ -281,6 +301,11 @@ def _Tool_to_mldev(
),
)

if getv(from_object, ['enterprise_web_search']) is not None:
raise ValueError(
'enterprise_web_search parameter is not supported in Gemini API.'
)

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

Expand Down Expand Up @@ -323,6 +348,15 @@ def _Tool_to_vertex(
),
)

if getv(from_object, ['enterprise_web_search']) is not None:
setv(
to_object,
['enterpriseWebSearch'],
_EnterpriseWebSearch_to_vertex(
api_client, getv(from_object, ['enterprise_web_search']), to_object
),
)

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

Expand Down
34 changes: 34 additions & 0 deletions google/genai/caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ def _GoogleSearchRetrieval_to_mldev(
return to_object


def _EnterpriseWebSearch_to_mldev(
api_client: BaseApiClient,
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}

return to_object


def _Tool_to_mldev(
api_client: BaseApiClient,
from_object: Union[dict[str, Any], object],
Expand Down Expand Up @@ -174,6 +184,11 @@ def _Tool_to_mldev(
),
)

if getv(from_object, ['enterprise_web_search']) is not None:
raise ValueError(
'enterprise_web_search parameter is not supported in Gemini API.'
)

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

Expand Down Expand Up @@ -546,6 +561,16 @@ def _GoogleSearchRetrieval_to_vertex(
return to_object


def _EnterpriseWebSearch_to_vertex(
api_client: BaseApiClient,
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}

return to_object


def _Tool_to_vertex(
api_client: BaseApiClient,
from_object: Union[dict[str, Any], object],
Expand Down Expand Up @@ -575,6 +600,15 @@ def _Tool_to_vertex(
),
)

if getv(from_object, ['enterprise_web_search']) is not None:
setv(
to_object,
['enterpriseWebSearch'],
_EnterpriseWebSearch_to_vertex(
api_client, getv(from_object, ['enterprise_web_search']), to_object
),
)

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

Expand Down
34 changes: 34 additions & 0 deletions google/genai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ def _GoogleSearchRetrieval_to_mldev(
return to_object


def _EnterpriseWebSearch_to_mldev(
api_client: BaseApiClient,
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}

return to_object


def _Tool_to_mldev(
api_client: BaseApiClient,
from_object: Union[dict[str, Any], object],
Expand Down Expand Up @@ -207,6 +217,11 @@ def _Tool_to_mldev(
),
)

if getv(from_object, ['enterprise_web_search']) is not None:
raise ValueError(
'enterprise_web_search parameter is not supported in Gemini API.'
)

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

Expand Down Expand Up @@ -1189,6 +1204,16 @@ def _GoogleSearchRetrieval_to_vertex(
return to_object


def _EnterpriseWebSearch_to_vertex(
api_client: BaseApiClient,
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}

return to_object


def _Tool_to_vertex(
api_client: BaseApiClient,
from_object: Union[dict[str, Any], object],
Expand Down Expand Up @@ -1218,6 +1243,15 @@ def _Tool_to_vertex(
),
)

if getv(from_object, ['enterprise_web_search']) is not None:
setv(
to_object,
['enterpriseWebSearch'],
_EnterpriseWebSearch_to_vertex(
api_client, getv(from_object, ['enterprise_web_search']), to_object
),
)

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

Expand Down
24 changes: 24 additions & 0 deletions google/genai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,21 @@ class GoogleSearchRetrievalDict(TypedDict, total=False):
]


class EnterpriseWebSearch(_common.BaseModel):
"""Tool to search public web data, powered by Vertex AI Search and Sec4 compliance."""

pass


class EnterpriseWebSearchDict(TypedDict, total=False):
"""Tool to search public web data, powered by Vertex AI Search and Sec4 compliance."""

pass


EnterpriseWebSearchOrDict = Union[EnterpriseWebSearch, EnterpriseWebSearchDict]


class VertexAISearch(_common.BaseModel):
"""Retrieve from Vertex AI Search datastore or engine for grounding.

Expand Down Expand Up @@ -2120,6 +2135,11 @@ class Tool(_common.BaseModel):
default=None,
description="""Optional. GoogleSearchRetrieval tool type. Specialized retrieval tool that is powered by Google search.""",
)
enterprise_web_search: Optional[EnterpriseWebSearch] = Field(
default=None,
description="""Optional. Enterprise web search tool type. Specialized retrieval
tool that is powered by Vertex AI Search and Sec4 compliance.""",
)
code_execution: Optional[ToolCodeExecution] = Field(
default=None,
description="""Optional. CodeExecution tool type. Enables the model to execute code as part of generation. This field is only used by the Gemini Developer API services.""",
Expand All @@ -2143,6 +2163,10 @@ class ToolDict(TypedDict, total=False):
google_search_retrieval: Optional[GoogleSearchRetrievalDict]
"""Optional. GoogleSearchRetrieval tool type. Specialized retrieval tool that is powered by Google search."""

enterprise_web_search: Optional[EnterpriseWebSearchDict]
"""Optional. Enterprise web search tool type. Specialized retrieval
tool that is powered by Vertex AI Search and Sec4 compliance."""

code_execution: Optional[ToolCodeExecutionDict]
"""Optional. CodeExecution tool type. Enables the model to execute code as part of generation. This field is only used by the Gemini Developer API services."""

Expand Down