Skip to content

Commit a0d5538

Browse files
amirhcopybara-github
authored andcommitted
feat: Introduce tool retrieval config
feat: Add displayName to FileData feat: Add responseModalities and speechconfig to GenerationConfig PiperOrigin-RevId: 747683395
1 parent 0af470b commit a0d5538

File tree

4 files changed

+278
-240
lines changed

4 files changed

+278
-240
lines changed

google/genai/caches.py

+36-44
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ def _Part_to_mldev(
3939
if getv(from_object, ['video_metadata']) is not None:
4040
raise ValueError('video_metadata parameter is not supported in Gemini API.')
4141

42-
if getv(from_object, ['thought']) is not None:
43-
setv(to_object, ['thought'], getv(from_object, ['thought']))
44-
4542
if getv(from_object, ['code_execution_result']) is not None:
4643
setv(
4744
to_object,
@@ -71,6 +68,9 @@ def _Part_to_mldev(
7168
if getv(from_object, ['text']) is not None:
7269
setv(to_object, ['text'], getv(from_object, ['text']))
7370

71+
if getv(from_object, ['thought']) is not None:
72+
setv(to_object, ['thought'], getv(from_object, ['thought']))
73+
7474
return to_object
7575

7676

@@ -196,16 +196,6 @@ def _FunctionDeclaration_to_mldev(
196196
return to_object
197197

198198

199-
def _GoogleSearch_to_mldev(
200-
api_client: BaseApiClient,
201-
from_object: Union[dict, object],
202-
parent_object: Optional[dict] = None,
203-
) -> dict:
204-
to_object: dict[str, Any] = {}
205-
206-
return to_object
207-
208-
209199
def _DynamicRetrievalConfig_to_mldev(
210200
api_client: BaseApiClient,
211201
from_object: Union[dict, object],
@@ -264,15 +254,6 @@ def _Tool_to_mldev(
264254
if getv(from_object, ['retrieval']) is not None:
265255
raise ValueError('retrieval parameter is not supported in Gemini API.')
266256

267-
if getv(from_object, ['google_search']) is not None:
268-
setv(
269-
to_object,
270-
['googleSearch'],
271-
_GoogleSearch_to_mldev(
272-
api_client, getv(from_object, ['google_search']), to_object
273-
),
274-
)
275-
276257
if getv(from_object, ['google_search_retrieval']) is not None:
277258
setv(
278259
to_object,
@@ -287,6 +268,16 @@ def _Tool_to_mldev(
287268
if getv(from_object, ['code_execution']) is not None:
288269
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
289270

271+
if getv(from_object, ['enterprise_web_search']) is not None:
272+
setv(
273+
to_object,
274+
['enterpriseWebSearch'],
275+
getv(from_object, ['enterprise_web_search']),
276+
)
277+
278+
if getv(from_object, ['google_search']) is not None:
279+
setv(to_object, ['googleSearch'], getv(from_object, ['google_search']))
280+
290281
return to_object
291282

292283

@@ -326,6 +317,11 @@ def _ToolConfig_to_mldev(
326317
),
327318
)
328319

320+
if getv(from_object, ['retrieval_config']) is not None:
321+
setv(
322+
to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
323+
)
324+
329325
return to_object
330326

331327

@@ -543,9 +539,6 @@ def _Part_to_vertex(
543539
if getv(from_object, ['video_metadata']) is not None:
544540
setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
545541

546-
if getv(from_object, ['thought']) is not None:
547-
setv(to_object, ['thought'], getv(from_object, ['thought']))
548-
549542
if getv(from_object, ['code_execution_result']) is not None:
550543
setv(
551544
to_object,
@@ -575,6 +568,9 @@ def _Part_to_vertex(
575568
if getv(from_object, ['text']) is not None:
576569
setv(to_object, ['text'], getv(from_object, ['text']))
577570

571+
if getv(from_object, ['thought']) is not None:
572+
setv(to_object, ['thought'], getv(from_object, ['thought']))
573+
578574
return to_object
579575

580576

@@ -706,16 +702,6 @@ def _FunctionDeclaration_to_vertex(
706702
return to_object
707703

708704

709-
def _GoogleSearch_to_vertex(
710-
api_client: BaseApiClient,
711-
from_object: Union[dict, object],
712-
parent_object: Optional[dict] = None,
713-
) -> dict:
714-
to_object: dict[str, Any] = {}
715-
716-
return to_object
717-
718-
719705
def _DynamicRetrievalConfig_to_vertex(
720706
api_client: BaseApiClient,
721707
from_object: Union[dict, object],
@@ -774,15 +760,6 @@ def _Tool_to_vertex(
774760
if getv(from_object, ['retrieval']) is not None:
775761
setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
776762

777-
if getv(from_object, ['google_search']) is not None:
778-
setv(
779-
to_object,
780-
['googleSearch'],
781-
_GoogleSearch_to_vertex(
782-
api_client, getv(from_object, ['google_search']), to_object
783-
),
784-
)
785-
786763
if getv(from_object, ['google_search_retrieval']) is not None:
787764
setv(
788765
to_object,
@@ -797,6 +774,16 @@ def _Tool_to_vertex(
797774
if getv(from_object, ['code_execution']) is not None:
798775
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
799776

777+
if getv(from_object, ['enterprise_web_search']) is not None:
778+
setv(
779+
to_object,
780+
['enterpriseWebSearch'],
781+
getv(from_object, ['enterprise_web_search']),
782+
)
783+
784+
if getv(from_object, ['google_search']) is not None:
785+
setv(to_object, ['googleSearch'], getv(from_object, ['google_search']))
786+
800787
return to_object
801788

802789

@@ -836,6 +823,11 @@ def _ToolConfig_to_vertex(
836823
),
837824
)
838825

826+
if getv(from_object, ['retrieval_config']) is not None:
827+
setv(
828+
to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
829+
)
830+
839831
return to_object
840832

841833

0 commit comments

Comments
 (0)