Skip to content

Commit 15666c0

Browse files
jscudcopybara-github
authored andcommitted
feat: Update data types from discovery doc.
PiperOrigin-RevId: 876562156
1 parent abb388e commit 15666c0

File tree

7 files changed

+1870
-664
lines changed

7 files changed

+1870
-664
lines changed

google/genai/_live_converters.py

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,40 @@
2323
from ._common import set_value_by_path as setv
2424

2525

26+
def _AuthConfig_to_mldev(
27+
from_object: Union[dict[str, Any], object],
28+
parent_object: Optional[dict[str, Any]] = None,
29+
) -> dict[str, Any]:
30+
to_object: dict[str, Any] = {}
31+
if getv(from_object, ['api_key']) is not None:
32+
setv(to_object, ['apiKey'], getv(from_object, ['api_key']))
33+
34+
if getv(from_object, ['api_key_config']) is not None:
35+
raise ValueError('api_key_config parameter is not supported in Gemini API.')
36+
37+
if getv(from_object, ['auth_type']) is not None:
38+
raise ValueError('auth_type parameter is not supported in Gemini API.')
39+
40+
if getv(from_object, ['google_service_account_config']) is not None:
41+
raise ValueError(
42+
'google_service_account_config parameter is not supported in Gemini'
43+
' API.'
44+
)
45+
46+
if getv(from_object, ['http_basic_auth_config']) is not None:
47+
raise ValueError(
48+
'http_basic_auth_config parameter is not supported in Gemini API.'
49+
)
50+
51+
if getv(from_object, ['oauth_config']) is not None:
52+
raise ValueError('oauth_config parameter is not supported in Gemini API.')
53+
54+
if getv(from_object, ['oidc_config']) is not None:
55+
raise ValueError('oidc_config parameter is not supported in Gemini API.')
56+
57+
return to_object
58+
59+
2660
def _Blob_to_mldev(
2761
from_object: Union[dict[str, Any], object],
2862
parent_object: Optional[dict[str, Any]] = None,
@@ -257,7 +291,11 @@ def _GoogleMaps_to_mldev(
257291
) -> dict[str, Any]:
258292
to_object: dict[str, Any] = {}
259293
if getv(from_object, ['auth_config']) is not None:
260-
raise ValueError('auth_config parameter is not supported in Gemini API.')
294+
setv(
295+
to_object,
296+
['authConfig'],
297+
_AuthConfig_to_mldev(getv(from_object, ['auth_config']), to_object),
298+
)
261299

262300
if getv(from_object, ['enable_widget']) is not None:
263301
setv(to_object, ['enableWidget'], getv(from_object, ['enable_widget']))
@@ -273,14 +311,14 @@ def _GoogleSearch_to_mldev(
273311
if getv(from_object, ['search_types']) is not None:
274312
setv(to_object, ['searchTypes'], getv(from_object, ['search_types']))
275313

276-
if getv(from_object, ['exclude_domains']) is not None:
314+
if getv(from_object, ['blocking_confidence']) is not None:
277315
raise ValueError(
278-
'exclude_domains parameter is not supported in Gemini API.'
316+
'blocking_confidence parameter is not supported in Gemini API.'
279317
)
280318

281-
if getv(from_object, ['blocking_confidence']) is not None:
319+
if getv(from_object, ['exclude_domains']) is not None:
282320
raise ValueError(
283-
'blocking_confidence parameter is not supported in Gemini API.'
321+
'exclude_domains parameter is not supported in Gemini API.'
284322
)
285323

286324
if getv(from_object, ['time_range_filter']) is not None:
@@ -1368,6 +1406,13 @@ def _Tool_to_mldev(
13681406
_GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
13691407
)
13701408

1409+
if getv(from_object, ['google_maps']) is not None:
1410+
setv(
1411+
to_object,
1412+
['googleMaps'],
1413+
_GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
1414+
)
1415+
13711416
if getv(from_object, ['code_execution']) is not None:
13721417
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
13731418

@@ -1383,20 +1428,18 @@ def _Tool_to_mldev(
13831428
[item for item in getv(from_object, ['function_declarations'])],
13841429
)
13851430

1386-
if getv(from_object, ['google_maps']) is not None:
1387-
setv(
1388-
to_object,
1389-
['googleMaps'],
1390-
_GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
1391-
)
1392-
13931431
if getv(from_object, ['google_search_retrieval']) is not None:
13941432
setv(
13951433
to_object,
13961434
['googleSearchRetrieval'],
13971435
getv(from_object, ['google_search_retrieval']),
13981436
)
13991437

1438+
if getv(from_object, ['parallel_ai_search']) is not None:
1439+
raise ValueError(
1440+
'parallel_ai_search parameter is not supported in Gemini API.'
1441+
)
1442+
14001443
if getv(from_object, ['url_context']) is not None:
14011444
setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
14021445

@@ -1427,6 +1470,9 @@ def _Tool_to_vertex(
14271470
if getv(from_object, ['google_search']) is not None:
14281471
setv(to_object, ['googleSearch'], getv(from_object, ['google_search']))
14291472

1473+
if getv(from_object, ['google_maps']) is not None:
1474+
setv(to_object, ['googleMaps'], getv(from_object, ['google_maps']))
1475+
14301476
if getv(from_object, ['code_execution']) is not None:
14311477
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
14321478

@@ -1447,16 +1493,20 @@ def _Tool_to_vertex(
14471493
],
14481494
)
14491495

1450-
if getv(from_object, ['google_maps']) is not None:
1451-
setv(to_object, ['googleMaps'], getv(from_object, ['google_maps']))
1452-
14531496
if getv(from_object, ['google_search_retrieval']) is not None:
14541497
setv(
14551498
to_object,
14561499
['googleSearchRetrieval'],
14571500
getv(from_object, ['google_search_retrieval']),
14581501
)
14591502

1503+
if getv(from_object, ['parallel_ai_search']) is not None:
1504+
setv(
1505+
to_object,
1506+
['parallelAiSearch'],
1507+
getv(from_object, ['parallel_ai_search']),
1508+
)
1509+
14601510
if getv(from_object, ['url_context']) is not None:
14611511
setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
14621512

google/genai/_tokens_converters.py

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,40 @@
2323
from ._common import set_value_by_path as setv
2424

2525

26+
def _AuthConfig_to_mldev(
27+
from_object: Union[dict[str, Any], object],
28+
parent_object: Optional[dict[str, Any]] = None,
29+
) -> dict[str, Any]:
30+
to_object: dict[str, Any] = {}
31+
if getv(from_object, ['api_key']) is not None:
32+
setv(to_object, ['apiKey'], getv(from_object, ['api_key']))
33+
34+
if getv(from_object, ['api_key_config']) is not None:
35+
raise ValueError('api_key_config parameter is not supported in Gemini API.')
36+
37+
if getv(from_object, ['auth_type']) is not None:
38+
raise ValueError('auth_type parameter is not supported in Gemini API.')
39+
40+
if getv(from_object, ['google_service_account_config']) is not None:
41+
raise ValueError(
42+
'google_service_account_config parameter is not supported in Gemini'
43+
' API.'
44+
)
45+
46+
if getv(from_object, ['http_basic_auth_config']) is not None:
47+
raise ValueError(
48+
'http_basic_auth_config parameter is not supported in Gemini API.'
49+
)
50+
51+
if getv(from_object, ['oauth_config']) is not None:
52+
raise ValueError('oauth_config parameter is not supported in Gemini API.')
53+
54+
if getv(from_object, ['oidc_config']) is not None:
55+
raise ValueError('oidc_config parameter is not supported in Gemini API.')
56+
57+
return to_object
58+
59+
2660
def _Blob_to_mldev(
2761
from_object: Union[dict[str, Any], object],
2862
parent_object: Optional[dict[str, Any]] = None,
@@ -177,7 +211,11 @@ def _GoogleMaps_to_mldev(
177211
) -> dict[str, Any]:
178212
to_object: dict[str, Any] = {}
179213
if getv(from_object, ['auth_config']) is not None:
180-
raise ValueError('auth_config parameter is not supported in Gemini API.')
214+
setv(
215+
to_object,
216+
['authConfig'],
217+
_AuthConfig_to_mldev(getv(from_object, ['auth_config']), to_object),
218+
)
181219

182220
if getv(from_object, ['enable_widget']) is not None:
183221
setv(to_object, ['enableWidget'], getv(from_object, ['enable_widget']))
@@ -193,14 +231,14 @@ def _GoogleSearch_to_mldev(
193231
if getv(from_object, ['search_types']) is not None:
194232
setv(to_object, ['searchTypes'], getv(from_object, ['search_types']))
195233

196-
if getv(from_object, ['exclude_domains']) is not None:
234+
if getv(from_object, ['blocking_confidence']) is not None:
197235
raise ValueError(
198-
'exclude_domains parameter is not supported in Gemini API.'
236+
'blocking_confidence parameter is not supported in Gemini API.'
199237
)
200238

201-
if getv(from_object, ['blocking_confidence']) is not None:
239+
if getv(from_object, ['exclude_domains']) is not None:
202240
raise ValueError(
203-
'blocking_confidence parameter is not supported in Gemini API.'
241+
'exclude_domains parameter is not supported in Gemini API.'
204242
)
205243

206244
if getv(from_object, ['time_range_filter']) is not None:
@@ -493,6 +531,13 @@ def _Tool_to_mldev(
493531
_GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
494532
)
495533

534+
if getv(from_object, ['google_maps']) is not None:
535+
setv(
536+
to_object,
537+
['googleMaps'],
538+
_GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
539+
)
540+
496541
if getv(from_object, ['code_execution']) is not None:
497542
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
498543

@@ -508,20 +553,18 @@ def _Tool_to_mldev(
508553
[item for item in getv(from_object, ['function_declarations'])],
509554
)
510555

511-
if getv(from_object, ['google_maps']) is not None:
512-
setv(
513-
to_object,
514-
['googleMaps'],
515-
_GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
516-
)
517-
518556
if getv(from_object, ['google_search_retrieval']) is not None:
519557
setv(
520558
to_object,
521559
['googleSearchRetrieval'],
522560
getv(from_object, ['google_search_retrieval']),
523561
)
524562

563+
if getv(from_object, ['parallel_ai_search']) is not None:
564+
raise ValueError(
565+
'parallel_ai_search parameter is not supported in Gemini API.'
566+
)
567+
525568
if getv(from_object, ['url_context']) is not None:
526569
setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
527570

google/genai/batches.py

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,40 @@
3535
logger = logging.getLogger('google_genai.batches')
3636

3737

38+
def _AuthConfig_to_mldev(
39+
from_object: Union[dict[str, Any], object],
40+
parent_object: Optional[dict[str, Any]] = None,
41+
) -> dict[str, Any]:
42+
to_object: dict[str, Any] = {}
43+
if getv(from_object, ['api_key']) is not None:
44+
setv(to_object, ['apiKey'], getv(from_object, ['api_key']))
45+
46+
if getv(from_object, ['api_key_config']) is not None:
47+
raise ValueError('api_key_config parameter is not supported in Gemini API.')
48+
49+
if getv(from_object, ['auth_type']) is not None:
50+
raise ValueError('auth_type parameter is not supported in Gemini API.')
51+
52+
if getv(from_object, ['google_service_account_config']) is not None:
53+
raise ValueError(
54+
'google_service_account_config parameter is not supported in Gemini'
55+
' API.'
56+
)
57+
58+
if getv(from_object, ['http_basic_auth_config']) is not None:
59+
raise ValueError(
60+
'http_basic_auth_config parameter is not supported in Gemini API.'
61+
)
62+
63+
if getv(from_object, ['oauth_config']) is not None:
64+
raise ValueError('oauth_config parameter is not supported in Gemini API.')
65+
66+
if getv(from_object, ['oidc_config']) is not None:
67+
raise ValueError('oidc_config parameter is not supported in Gemini API.')
68+
69+
return to_object
70+
71+
3872
def _BatchJobDestination_from_mldev(
3973
from_object: Union[dict[str, Any], object],
4074
parent_object: Optional[dict[str, Any]] = None,
@@ -1094,7 +1128,11 @@ def _GoogleMaps_to_mldev(
10941128
) -> dict[str, Any]:
10951129
to_object: dict[str, Any] = {}
10961130
if getv(from_object, ['auth_config']) is not None:
1097-
raise ValueError('auth_config parameter is not supported in Gemini API.')
1131+
setv(
1132+
to_object,
1133+
['authConfig'],
1134+
_AuthConfig_to_mldev(getv(from_object, ['auth_config']), to_object),
1135+
)
10981136

10991137
if getv(from_object, ['enable_widget']) is not None:
11001138
setv(to_object, ['enableWidget'], getv(from_object, ['enable_widget']))
@@ -1110,14 +1148,14 @@ def _GoogleSearch_to_mldev(
11101148
if getv(from_object, ['search_types']) is not None:
11111149
setv(to_object, ['searchTypes'], getv(from_object, ['search_types']))
11121150

1113-
if getv(from_object, ['exclude_domains']) is not None:
1151+
if getv(from_object, ['blocking_confidence']) is not None:
11141152
raise ValueError(
1115-
'exclude_domains parameter is not supported in Gemini API.'
1153+
'blocking_confidence parameter is not supported in Gemini API.'
11161154
)
11171155

1118-
if getv(from_object, ['blocking_confidence']) is not None:
1156+
if getv(from_object, ['exclude_domains']) is not None:
11191157
raise ValueError(
1120-
'blocking_confidence parameter is not supported in Gemini API.'
1158+
'exclude_domains parameter is not supported in Gemini API.'
11211159
)
11221160

11231161
if getv(from_object, ['time_range_filter']) is not None:
@@ -1159,6 +1197,11 @@ def _ImageConfig_to_mldev(
11591197
'output_compression_quality parameter is not supported in Gemini API.'
11601198
)
11611199

1200+
if getv(from_object, ['image_output_options']) is not None:
1201+
raise ValueError(
1202+
'image_output_options parameter is not supported in Gemini API.'
1203+
)
1204+
11621205
return to_object
11631206

11641207

@@ -1474,6 +1517,13 @@ def _Tool_to_mldev(
14741517
_GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
14751518
)
14761519

1520+
if getv(from_object, ['google_maps']) is not None:
1521+
setv(
1522+
to_object,
1523+
['googleMaps'],
1524+
_GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
1525+
)
1526+
14771527
if getv(from_object, ['code_execution']) is not None:
14781528
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
14791529

@@ -1489,20 +1539,18 @@ def _Tool_to_mldev(
14891539
[item for item in getv(from_object, ['function_declarations'])],
14901540
)
14911541

1492-
if getv(from_object, ['google_maps']) is not None:
1493-
setv(
1494-
to_object,
1495-
['googleMaps'],
1496-
_GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
1497-
)
1498-
14991542
if getv(from_object, ['google_search_retrieval']) is not None:
15001543
setv(
15011544
to_object,
15021545
['googleSearchRetrieval'],
15031546
getv(from_object, ['google_search_retrieval']),
15041547
)
15051548

1549+
if getv(from_object, ['parallel_ai_search']) is not None:
1550+
raise ValueError(
1551+
'parallel_ai_search parameter is not supported in Gemini API.'
1552+
)
1553+
15061554
if getv(from_object, ['url_context']) is not None:
15071555
setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
15081556

0 commit comments

Comments
 (0)