Skip to content

Commit 6e53ecc

Browse files
holtskinnercopybara-github
authored andcommitted
feat: Add Tool.enterprise_web_search field
PiperOrigin-RevId: 747461219
1 parent c10b127 commit 6e53ecc

File tree

4 files changed

+126
-0
lines changed

4 files changed

+126
-0
lines changed

google/genai/_live_converters.py

+34
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,26 @@ def _GoogleSearchRetrieval_to_vertex(
252252
return to_object
253253

254254

255+
def _EnterpriseWebSearch_to_mldev(
256+
api_client: BaseApiClient,
257+
from_object: Union[dict[str, Any], object],
258+
parent_object: Optional[dict[str, Any]] = None,
259+
) -> dict[str, Any]:
260+
to_object: dict[str, Any] = {}
261+
262+
return to_object
263+
264+
265+
def _EnterpriseWebSearch_to_vertex(
266+
api_client: BaseApiClient,
267+
from_object: Union[dict[str, Any], object],
268+
parent_object: Optional[dict[str, Any]] = None,
269+
) -> dict[str, Any]:
270+
to_object: dict[str, Any] = {}
271+
272+
return to_object
273+
274+
255275
def _Tool_to_mldev(
256276
api_client: BaseApiClient,
257277
from_object: Union[dict[str, Any], object],
@@ -281,6 +301,11 @@ def _Tool_to_mldev(
281301
),
282302
)
283303

304+
if getv(from_object, ['enterprise_web_search']) is not None:
305+
raise ValueError(
306+
'enterprise_web_search parameter is not supported in Gemini API.'
307+
)
308+
284309
if getv(from_object, ['code_execution']) is not None:
285310
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
286311

@@ -323,6 +348,15 @@ def _Tool_to_vertex(
323348
),
324349
)
325350

351+
if getv(from_object, ['enterprise_web_search']) is not None:
352+
setv(
353+
to_object,
354+
['enterpriseWebSearch'],
355+
_EnterpriseWebSearch_to_vertex(
356+
api_client, getv(from_object, ['enterprise_web_search']), to_object
357+
),
358+
)
359+
326360
if getv(from_object, ['code_execution']) is not None:
327361
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
328362

google/genai/caches.py

+34
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@ def _GoogleSearchRetrieval_to_mldev(
145145
return to_object
146146

147147

148+
def _EnterpriseWebSearch_to_mldev(
149+
api_client: BaseApiClient,
150+
from_object: Union[dict[str, Any], object],
151+
parent_object: Optional[dict[str, Any]] = None,
152+
) -> dict[str, Any]:
153+
to_object: dict[str, Any] = {}
154+
155+
return to_object
156+
157+
148158
def _Tool_to_mldev(
149159
api_client: BaseApiClient,
150160
from_object: Union[dict[str, Any], object],
@@ -174,6 +184,11 @@ def _Tool_to_mldev(
174184
),
175185
)
176186

187+
if getv(from_object, ['enterprise_web_search']) is not None:
188+
raise ValueError(
189+
'enterprise_web_search parameter is not supported in Gemini API.'
190+
)
191+
177192
if getv(from_object, ['code_execution']) is not None:
178193
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
179194

@@ -546,6 +561,16 @@ def _GoogleSearchRetrieval_to_vertex(
546561
return to_object
547562

548563

564+
def _EnterpriseWebSearch_to_vertex(
565+
api_client: BaseApiClient,
566+
from_object: Union[dict[str, Any], object],
567+
parent_object: Optional[dict[str, Any]] = None,
568+
) -> dict[str, Any]:
569+
to_object: dict[str, Any] = {}
570+
571+
return to_object
572+
573+
549574
def _Tool_to_vertex(
550575
api_client: BaseApiClient,
551576
from_object: Union[dict[str, Any], object],
@@ -575,6 +600,15 @@ def _Tool_to_vertex(
575600
),
576601
)
577602

603+
if getv(from_object, ['enterprise_web_search']) is not None:
604+
setv(
605+
to_object,
606+
['enterpriseWebSearch'],
607+
_EnterpriseWebSearch_to_vertex(
608+
api_client, getv(from_object, ['enterprise_web_search']), to_object
609+
),
610+
)
611+
578612
if getv(from_object, ['code_execution']) is not None:
579613
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
580614

google/genai/models.py

+34
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ def _GoogleSearchRetrieval_to_mldev(
178178
return to_object
179179

180180

181+
def _EnterpriseWebSearch_to_mldev(
182+
api_client: BaseApiClient,
183+
from_object: Union[dict[str, Any], object],
184+
parent_object: Optional[dict[str, Any]] = None,
185+
) -> dict[str, Any]:
186+
to_object: dict[str, Any] = {}
187+
188+
return to_object
189+
190+
181191
def _Tool_to_mldev(
182192
api_client: BaseApiClient,
183193
from_object: Union[dict[str, Any], object],
@@ -207,6 +217,11 @@ def _Tool_to_mldev(
207217
),
208218
)
209219

220+
if getv(from_object, ['enterprise_web_search']) is not None:
221+
raise ValueError(
222+
'enterprise_web_search parameter is not supported in Gemini API.'
223+
)
224+
210225
if getv(from_object, ['code_execution']) is not None:
211226
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
212227

@@ -1189,6 +1204,16 @@ def _GoogleSearchRetrieval_to_vertex(
11891204
return to_object
11901205

11911206

1207+
def _EnterpriseWebSearch_to_vertex(
1208+
api_client: BaseApiClient,
1209+
from_object: Union[dict[str, Any], object],
1210+
parent_object: Optional[dict[str, Any]] = None,
1211+
) -> dict[str, Any]:
1212+
to_object: dict[str, Any] = {}
1213+
1214+
return to_object
1215+
1216+
11921217
def _Tool_to_vertex(
11931218
api_client: BaseApiClient,
11941219
from_object: Union[dict[str, Any], object],
@@ -1218,6 +1243,15 @@ def _Tool_to_vertex(
12181243
),
12191244
)
12201245

1246+
if getv(from_object, ['enterprise_web_search']) is not None:
1247+
setv(
1248+
to_object,
1249+
['enterpriseWebSearch'],
1250+
_EnterpriseWebSearch_to_vertex(
1251+
api_client, getv(from_object, ['enterprise_web_search']), to_object
1252+
),
1253+
)
1254+
12211255
if getv(from_object, ['code_execution']) is not None:
12221256
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
12231257

google/genai/types.py

+24
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,21 @@ class GoogleSearchRetrievalDict(TypedDict, total=False):
998998
]
999999

10001000

1001+
class EnterpriseWebSearch(_common.BaseModel):
1002+
"""Tool to search public web data, powered by Vertex AI Search and Sec4 compliance."""
1003+
1004+
pass
1005+
1006+
1007+
class EnterpriseWebSearchDict(TypedDict, total=False):
1008+
"""Tool to search public web data, powered by Vertex AI Search and Sec4 compliance."""
1009+
1010+
pass
1011+
1012+
1013+
EnterpriseWebSearchOrDict = Union[EnterpriseWebSearch, EnterpriseWebSearchDict]
1014+
1015+
10011016
class VertexAISearch(_common.BaseModel):
10021017
"""Retrieve from Vertex AI Search datastore or engine for grounding.
10031018
@@ -2120,6 +2135,11 @@ class Tool(_common.BaseModel):
21202135
default=None,
21212136
description="""Optional. GoogleSearchRetrieval tool type. Specialized retrieval tool that is powered by Google search.""",
21222137
)
2138+
enterprise_web_search: Optional[EnterpriseWebSearch] = Field(
2139+
default=None,
2140+
description="""Optional. Enterprise web search tool type. Specialized retrieval
2141+
tool that is powered by Vertex AI Search and Sec4 compliance.""",
2142+
)
21232143
code_execution: Optional[ToolCodeExecution] = Field(
21242144
default=None,
21252145
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.""",
@@ -2143,6 +2163,10 @@ class ToolDict(TypedDict, total=False):
21432163
google_search_retrieval: Optional[GoogleSearchRetrievalDict]
21442164
"""Optional. GoogleSearchRetrieval tool type. Specialized retrieval tool that is powered by Google search."""
21452165

2166+
enterprise_web_search: Optional[EnterpriseWebSearchDict]
2167+
"""Optional. Enterprise web search tool type. Specialized retrieval
2168+
tool that is powered by Vertex AI Search and Sec4 compliance."""
2169+
21462170
code_execution: Optional[ToolCodeExecutionDict]
21472171
"""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."""
21482172

0 commit comments

Comments
 (0)