Skip to content

Commit f22b46b

Browse files
jaycee-licopybara-github
authored andcommitted
chore: Clean up internal configurations
PiperOrigin-RevId: 845882194
1 parent 22500b5 commit f22b46b

File tree

6 files changed

+668
-670
lines changed

6 files changed

+668
-670
lines changed

google/genai/_live_converters.py

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ def _FunctionDeclaration_to_vertex(
106106
parent_object: Optional[dict[str, Any]] = None,
107107
) -> dict[str, Any]:
108108
to_object: dict[str, Any] = {}
109-
if getv(from_object, ['behavior']) is not None:
110-
raise ValueError('behavior parameter is not supported in Vertex AI.')
111-
112109
if getv(from_object, ['description']) is not None:
113110
setv(to_object, ['description'], getv(from_object, ['description']))
114111

@@ -135,6 +132,9 @@ def _FunctionDeclaration_to_vertex(
135132
getv(from_object, ['response_json_schema']),
136133
)
137134

135+
if getv(from_object, ['behavior']) is not None:
136+
raise ValueError('behavior parameter is not supported in Vertex AI.')
137+
138138
return to_object
139139

140140

@@ -1287,23 +1287,9 @@ def _Tool_to_mldev(
12871287
parent_object: Optional[dict[str, Any]] = None,
12881288
) -> dict[str, Any]:
12891289
to_object: dict[str, Any] = {}
1290-
if getv(from_object, ['function_declarations']) is not None:
1291-
setv(
1292-
to_object,
1293-
['functionDeclarations'],
1294-
[item for item in getv(from_object, ['function_declarations'])],
1295-
)
1296-
12971290
if getv(from_object, ['retrieval']) is not None:
12981291
raise ValueError('retrieval parameter is not supported in Gemini API.')
12991292

1300-
if getv(from_object, ['google_search_retrieval']) is not None:
1301-
setv(
1302-
to_object,
1303-
['googleSearchRetrieval'],
1304-
getv(from_object, ['google_search_retrieval']),
1305-
)
1306-
13071293
if getv(from_object, ['computer_use']) is not None:
13081294
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
13091295

@@ -1318,6 +1304,13 @@ def _Tool_to_mldev(
13181304
'enterprise_web_search parameter is not supported in Gemini API.'
13191305
)
13201306

1307+
if getv(from_object, ['function_declarations']) is not None:
1308+
setv(
1309+
to_object,
1310+
['functionDeclarations'],
1311+
[item for item in getv(from_object, ['function_declarations'])],
1312+
)
1313+
13211314
if getv(from_object, ['google_maps']) is not None:
13221315
setv(
13231316
to_object,
@@ -1332,6 +1325,13 @@ def _Tool_to_mldev(
13321325
_GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
13331326
)
13341327

1328+
if getv(from_object, ['google_search_retrieval']) is not None:
1329+
setv(
1330+
to_object,
1331+
['googleSearchRetrieval'],
1332+
getv(from_object, ['google_search_retrieval']),
1333+
)
1334+
13351335
if getv(from_object, ['url_context']) is not None:
13361336
setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
13371337

@@ -1343,26 +1343,9 @@ def _Tool_to_vertex(
13431343
parent_object: Optional[dict[str, Any]] = None,
13441344
) -> dict[str, Any]:
13451345
to_object: dict[str, Any] = {}
1346-
if getv(from_object, ['function_declarations']) is not None:
1347-
setv(
1348-
to_object,
1349-
['functionDeclarations'],
1350-
[
1351-
_FunctionDeclaration_to_vertex(item, to_object)
1352-
for item in getv(from_object, ['function_declarations'])
1353-
],
1354-
)
1355-
13561346
if getv(from_object, ['retrieval']) is not None:
13571347
setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
13581348

1359-
if getv(from_object, ['google_search_retrieval']) is not None:
1360-
setv(
1361-
to_object,
1362-
['googleSearchRetrieval'],
1363-
getv(from_object, ['google_search_retrieval']),
1364-
)
1365-
13661349
if getv(from_object, ['computer_use']) is not None:
13671350
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
13681351

@@ -1379,12 +1362,29 @@ def _Tool_to_vertex(
13791362
getv(from_object, ['enterprise_web_search']),
13801363
)
13811364

1365+
if getv(from_object, ['function_declarations']) is not None:
1366+
setv(
1367+
to_object,
1368+
['functionDeclarations'],
1369+
[
1370+
_FunctionDeclaration_to_vertex(item, to_object)
1371+
for item in getv(from_object, ['function_declarations'])
1372+
],
1373+
)
1374+
13821375
if getv(from_object, ['google_maps']) is not None:
13831376
setv(to_object, ['googleMaps'], getv(from_object, ['google_maps']))
13841377

13851378
if getv(from_object, ['google_search']) is not None:
13861379
setv(to_object, ['googleSearch'], getv(from_object, ['google_search']))
13871380

1381+
if getv(from_object, ['google_search_retrieval']) is not None:
1382+
setv(
1383+
to_object,
1384+
['googleSearchRetrieval'],
1385+
getv(from_object, ['google_search_retrieval']),
1386+
)
1387+
13881388
if getv(from_object, ['url_context']) is not None:
13891389
setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
13901390

google/genai/_tokens_converters.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -474,23 +474,9 @@ def _Tool_to_mldev(
474474
parent_object: Optional[dict[str, Any]] = None,
475475
) -> dict[str, Any]:
476476
to_object: dict[str, Any] = {}
477-
if getv(from_object, ['function_declarations']) is not None:
478-
setv(
479-
to_object,
480-
['functionDeclarations'],
481-
[item for item in getv(from_object, ['function_declarations'])],
482-
)
483-
484477
if getv(from_object, ['retrieval']) is not None:
485478
raise ValueError('retrieval parameter is not supported in Gemini API.')
486479

487-
if getv(from_object, ['google_search_retrieval']) is not None:
488-
setv(
489-
to_object,
490-
['googleSearchRetrieval'],
491-
getv(from_object, ['google_search_retrieval']),
492-
)
493-
494480
if getv(from_object, ['computer_use']) is not None:
495481
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
496482

@@ -505,6 +491,13 @@ def _Tool_to_mldev(
505491
'enterprise_web_search parameter is not supported in Gemini API.'
506492
)
507493

494+
if getv(from_object, ['function_declarations']) is not None:
495+
setv(
496+
to_object,
497+
['functionDeclarations'],
498+
[item for item in getv(from_object, ['function_declarations'])],
499+
)
500+
508501
if getv(from_object, ['google_maps']) is not None:
509502
setv(
510503
to_object,
@@ -519,6 +512,13 @@ def _Tool_to_mldev(
519512
_GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
520513
)
521514

515+
if getv(from_object, ['google_search_retrieval']) is not None:
516+
setv(
517+
to_object,
518+
['googleSearchRetrieval'],
519+
getv(from_object, ['google_search_retrieval']),
520+
)
521+
522522
if getv(from_object, ['url_context']) is not None:
523523
setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
524524

google/genai/batches.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -824,16 +824,16 @@ def _FunctionCallingConfig_to_mldev(
824824
parent_object: Optional[dict[str, Any]] = None,
825825
) -> dict[str, Any]:
826826
to_object: dict[str, Any] = {}
827-
if getv(from_object, ['mode']) is not None:
828-
setv(to_object, ['mode'], getv(from_object, ['mode']))
829-
830827
if getv(from_object, ['allowed_function_names']) is not None:
831828
setv(
832829
to_object,
833830
['allowedFunctionNames'],
834831
getv(from_object, ['allowed_function_names']),
835832
)
836833

834+
if getv(from_object, ['mode']) is not None:
835+
setv(to_object, ['mode'], getv(from_object, ['mode']))
836+
837837
if getv(from_object, ['stream_function_call_arguments']) is not None:
838838
raise ValueError(
839839
'stream_function_call_arguments parameter is not supported in Gemini'
@@ -1420,6 +1420,11 @@ def _ToolConfig_to_mldev(
14201420
parent_object: Optional[dict[str, Any]] = None,
14211421
) -> dict[str, Any]:
14221422
to_object: dict[str, Any] = {}
1423+
if getv(from_object, ['retrieval_config']) is not None:
1424+
setv(
1425+
to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
1426+
)
1427+
14231428
if getv(from_object, ['function_calling_config']) is not None:
14241429
setv(
14251430
to_object,
@@ -1429,11 +1434,6 @@ def _ToolConfig_to_mldev(
14291434
),
14301435
)
14311436

1432-
if getv(from_object, ['retrieval_config']) is not None:
1433-
setv(
1434-
to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
1435-
)
1436-
14371437
return to_object
14381438

14391439

@@ -1442,23 +1442,9 @@ def _Tool_to_mldev(
14421442
parent_object: Optional[dict[str, Any]] = None,
14431443
) -> dict[str, Any]:
14441444
to_object: dict[str, Any] = {}
1445-
if getv(from_object, ['function_declarations']) is not None:
1446-
setv(
1447-
to_object,
1448-
['functionDeclarations'],
1449-
[item for item in getv(from_object, ['function_declarations'])],
1450-
)
1451-
14521445
if getv(from_object, ['retrieval']) is not None:
14531446
raise ValueError('retrieval parameter is not supported in Gemini API.')
14541447

1455-
if getv(from_object, ['google_search_retrieval']) is not None:
1456-
setv(
1457-
to_object,
1458-
['googleSearchRetrieval'],
1459-
getv(from_object, ['google_search_retrieval']),
1460-
)
1461-
14621448
if getv(from_object, ['computer_use']) is not None:
14631449
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
14641450

@@ -1473,6 +1459,13 @@ def _Tool_to_mldev(
14731459
'enterprise_web_search parameter is not supported in Gemini API.'
14741460
)
14751461

1462+
if getv(from_object, ['function_declarations']) is not None:
1463+
setv(
1464+
to_object,
1465+
['functionDeclarations'],
1466+
[item for item in getv(from_object, ['function_declarations'])],
1467+
)
1468+
14761469
if getv(from_object, ['google_maps']) is not None:
14771470
setv(
14781471
to_object,
@@ -1487,6 +1480,13 @@ def _Tool_to_mldev(
14871480
_GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
14881481
)
14891482

1483+
if getv(from_object, ['google_search_retrieval']) is not None:
1484+
setv(
1485+
to_object,
1486+
['googleSearchRetrieval'],
1487+
getv(from_object, ['google_search_retrieval']),
1488+
)
1489+
14901490
if getv(from_object, ['url_context']) is not None:
14911491
setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
14921492

0 commit comments

Comments
 (0)