2323from ._common import set_value_by_path as setv
2424
2525
26+ def _ThinkingLevel_to_vertex_enum_validate (enum_value : Any ) -> None :
27+ if enum_value in set (['MINIMAL' , 'MEDIUM' ]):
28+ raise ValueError (f'{ enum_value } enum value is not supported in Vertex AI.' )
29+
30+
31+ def _AuthConfig_to_mldev (
32+ from_object : Union [dict [str , Any ], object ],
33+ parent_object : Optional [dict [str , Any ]] = None ,
34+ ) -> dict [str , Any ]:
35+ to_object : dict [str , Any ] = {}
36+ if getv (from_object , ['api_key' ]) is not None :
37+ setv (to_object , ['apiKey' ], getv (from_object , ['api_key' ]))
38+
39+ if getv (from_object , ['api_key_config' ]) is not None :
40+ raise ValueError ('api_key_config parameter is not supported in Gemini API.' )
41+
42+ if getv (from_object , ['auth_type' ]) is not None :
43+ raise ValueError ('auth_type parameter is not supported in Gemini API.' )
44+
45+ if getv (from_object , ['google_service_account_config' ]) is not None :
46+ raise ValueError (
47+ 'google_service_account_config parameter is not supported in Gemini'
48+ ' API.'
49+ )
50+
51+ if getv (from_object , ['http_basic_auth_config' ]) is not None :
52+ raise ValueError (
53+ 'http_basic_auth_config parameter is not supported in Gemini API.'
54+ )
55+
56+ if getv (from_object , ['oauth_config' ]) is not None :
57+ raise ValueError ('oauth_config parameter is not supported in Gemini API.' )
58+
59+ if getv (from_object , ['oidc_config' ]) is not None :
60+ raise ValueError ('oidc_config parameter is not supported in Gemini API.' )
61+
62+ return to_object
63+
64+
2665def _Blob_to_mldev (
2766 from_object : Union [dict [str , Any ], object ],
2867 parent_object : Optional [dict [str , Any ]] = None ,
@@ -61,6 +100,27 @@ def _Content_to_mldev(
61100 return to_object
62101
63102
103+ def _Content_to_vertex (
104+ from_object : Union [dict [str , Any ], object ],
105+ parent_object : Optional [dict [str , Any ]] = None ,
106+ ) -> dict [str , Any ]:
107+ to_object : dict [str , Any ] = {}
108+ if getv (from_object , ['parts' ]) is not None :
109+ setv (
110+ to_object ,
111+ ['parts' ],
112+ [
113+ _Part_to_vertex (item , to_object )
114+ for item in getv (from_object , ['parts' ])
115+ ],
116+ )
117+
118+ if getv (from_object , ['role' ]) is not None :
119+ setv (to_object , ['role' ], getv (from_object , ['role' ]))
120+
121+ return to_object
122+
123+
64124def _FileData_to_mldev (
65125 from_object : Union [dict [str , Any ], object ],
66126 parent_object : Optional [dict [str , Any ]] = None ,
@@ -235,7 +295,13 @@ def _GenerationConfig_to_vertex(
235295 setv (to_object , ['temperature' ], getv (from_object , ['temperature' ]))
236296
237297 if getv (from_object , ['thinking_config' ]) is not None :
238- setv (to_object , ['thinkingConfig' ], getv (from_object , ['thinking_config' ]))
298+ setv (
299+ to_object ,
300+ ['thinkingConfig' ],
301+ _ThinkingConfig_to_vertex (
302+ getv (from_object , ['thinking_config' ]), to_object
303+ ),
304+ )
239305
240306 if getv (from_object , ['top_k' ]) is not None :
241307 setv (to_object , ['topK' ], getv (from_object , ['top_k' ]))
@@ -257,7 +323,11 @@ def _GoogleMaps_to_mldev(
257323) -> dict [str , Any ]:
258324 to_object : dict [str , Any ] = {}
259325 if getv (from_object , ['auth_config' ]) is not None :
260- raise ValueError ('auth_config parameter is not supported in Gemini API.' )
326+ setv (
327+ to_object ,
328+ ['authConfig' ],
329+ _AuthConfig_to_mldev (getv (from_object , ['auth_config' ]), to_object ),
330+ )
261331
262332 if getv (from_object , ['enable_widget' ]) is not None :
263333 setv (to_object , ['enableWidget' ], getv (from_object , ['enable_widget' ]))
@@ -270,14 +340,14 @@ def _GoogleSearch_to_mldev(
270340 parent_object : Optional [dict [str , Any ]] = None ,
271341) -> dict [str , Any ]:
272342 to_object : dict [str , Any ] = {}
273- if getv (from_object , ['exclude_domains ' ]) is not None :
343+ if getv (from_object , ['blocking_confidence ' ]) is not None :
274344 raise ValueError (
275- 'exclude_domains parameter is not supported in Gemini API.'
345+ 'blocking_confidence parameter is not supported in Gemini API.'
276346 )
277347
278- if getv (from_object , ['blocking_confidence ' ]) is not None :
348+ if getv (from_object , ['exclude_domains ' ]) is not None :
279349 raise ValueError (
280- 'blocking_confidence parameter is not supported in Gemini API.'
350+ 'exclude_domains parameter is not supported in Gemini API.'
281351 )
282352
283353 if getv (from_object , ['time_range_filter' ]) is not None :
@@ -309,6 +379,27 @@ def _LiveClientContent_to_mldev(
309379 return to_object
310380
311381
382+ def _LiveClientContent_to_vertex (
383+ from_object : Union [dict [str , Any ], object ],
384+ parent_object : Optional [dict [str , Any ]] = None ,
385+ ) -> dict [str , Any ]:
386+ to_object : dict [str , Any ] = {}
387+ if getv (from_object , ['turns' ]) is not None :
388+ setv (
389+ to_object ,
390+ ['turns' ],
391+ [
392+ _Content_to_vertex (item , to_object )
393+ for item in getv (from_object , ['turns' ])
394+ ],
395+ )
396+
397+ if getv (from_object , ['turn_complete' ]) is not None :
398+ setv (to_object , ['turnComplete' ], getv (from_object , ['turn_complete' ]))
399+
400+ return to_object
401+
402+
312403def _LiveClientMessage_to_mldev (
313404 api_client : BaseApiClient ,
314405 from_object : Union [dict [str , Any ], object ],
@@ -364,7 +455,13 @@ def _LiveClientMessage_to_vertex(
364455 )
365456
366457 if getv (from_object , ['client_content' ]) is not None :
367- setv (to_object , ['clientContent' ], getv (from_object , ['client_content' ]))
458+ setv (
459+ to_object ,
460+ ['clientContent' ],
461+ _LiveClientContent_to_vertex (
462+ getv (from_object , ['client_content' ]), to_object
463+ ),
464+ )
368465
369466 if getv (from_object , ['realtime_input' ]) is not None :
370467 setv (
@@ -558,7 +655,9 @@ def _LiveClientSetup_to_vertex(
558655 setv (
559656 to_object ,
560657 ['systemInstruction' ],
561- t .t_content (getv (from_object , ['system_instruction' ])),
658+ _Content_to_vertex (
659+ t .t_content (getv (from_object , ['system_instruction' ])), to_object
660+ ),
562661 )
563662
564663 if getv (from_object , ['tools' ]) is not None :
@@ -843,7 +942,9 @@ def _LiveConnectConfig_to_vertex(
843942 setv (
844943 parent_object ,
845944 ['setup' , 'generationConfig' , 'thinkingConfig' ],
846- getv (from_object , ['thinking_config' ]),
945+ _ThinkingConfig_to_vertex (
946+ getv (from_object , ['thinking_config' ]), to_object
947+ ),
847948 )
848949
849950 if getv (from_object , ['enable_affective_dialog' ]) is not None :
@@ -857,7 +958,9 @@ def _LiveConnectConfig_to_vertex(
857958 setv (
858959 parent_object ,
859960 ['setup' , 'systemInstruction' ],
860- t .t_content (getv (from_object , ['system_instruction' ])),
961+ _Content_to_vertex (
962+ t .t_content (getv (from_object , ['system_instruction' ])), to_object
963+ ),
861964 )
862965
863966 if getv (from_object , ['tools' ]) is not None :
@@ -1265,6 +1368,67 @@ def _Part_to_mldev(
12651368 if getv (from_object , ['video_metadata' ]) is not None :
12661369 setv (to_object , ['videoMetadata' ], getv (from_object , ['video_metadata' ]))
12671370
1371+ if getv (from_object , ['part_metadata' ]) is not None :
1372+ setv (to_object , ['partMetadata' ], getv (from_object , ['part_metadata' ]))
1373+
1374+ return to_object
1375+
1376+
1377+ def _Part_to_vertex (
1378+ from_object : Union [dict [str , Any ], object ],
1379+ parent_object : Optional [dict [str , Any ]] = None ,
1380+ ) -> dict [str , Any ]:
1381+ to_object : dict [str , Any ] = {}
1382+ if getv (from_object , ['media_resolution' ]) is not None :
1383+ setv (
1384+ to_object , ['mediaResolution' ], getv (from_object , ['media_resolution' ])
1385+ )
1386+
1387+ if getv (from_object , ['code_execution_result' ]) is not None :
1388+ setv (
1389+ to_object ,
1390+ ['codeExecutionResult' ],
1391+ getv (from_object , ['code_execution_result' ]),
1392+ )
1393+
1394+ if getv (from_object , ['executable_code' ]) is not None :
1395+ setv (to_object , ['executableCode' ], getv (from_object , ['executable_code' ]))
1396+
1397+ if getv (from_object , ['file_data' ]) is not None :
1398+ setv (to_object , ['fileData' ], getv (from_object , ['file_data' ]))
1399+
1400+ if getv (from_object , ['function_call' ]) is not None :
1401+ setv (to_object , ['functionCall' ], getv (from_object , ['function_call' ]))
1402+
1403+ if getv (from_object , ['function_response' ]) is not None :
1404+ setv (
1405+ to_object ,
1406+ ['functionResponse' ],
1407+ getv (from_object , ['function_response' ]),
1408+ )
1409+
1410+ if getv (from_object , ['inline_data' ]) is not None :
1411+ setv (to_object , ['inlineData' ], getv (from_object , ['inline_data' ]))
1412+
1413+ if getv (from_object , ['text' ]) is not None :
1414+ setv (to_object , ['text' ], getv (from_object , ['text' ]))
1415+
1416+ if getv (from_object , ['thought' ]) is not None :
1417+ setv (to_object , ['thought' ], getv (from_object , ['thought' ]))
1418+
1419+ if getv (from_object , ['thought_signature' ]) is not None :
1420+ setv (
1421+ to_object ,
1422+ ['thoughtSignature' ],
1423+ getv (from_object , ['thought_signature' ]),
1424+ )
1425+
1426+ if getv (from_object , ['video_metadata' ]) is not None :
1427+ setv (to_object , ['videoMetadata' ], getv (from_object , ['video_metadata' ]))
1428+
1429+ if getv (from_object , ['part_metadata' ]) is not None :
1430+ raise ValueError ('part_metadata parameter is not supported in Vertex AI.' )
1431+
12681432 return to_object
12691433
12701434
@@ -1282,6 +1446,28 @@ def _SessionResumptionConfig_to_mldev(
12821446 return to_object
12831447
12841448
1449+ def _ThinkingConfig_to_vertex (
1450+ from_object : Union [dict [str , Any ], object ],
1451+ parent_object : Optional [dict [str , Any ]] = None ,
1452+ ) -> dict [str , Any ]:
1453+ to_object : dict [str , Any ] = {}
1454+ if getv (from_object , ['include_thoughts' ]) is not None :
1455+ setv (
1456+ to_object , ['includeThoughts' ], getv (from_object , ['include_thoughts' ])
1457+ )
1458+
1459+ if getv (from_object , ['thinking_budget' ]) is not None :
1460+ setv (to_object , ['thinkingBudget' ], getv (from_object , ['thinking_budget' ]))
1461+
1462+ if getv (from_object , ['thinking_level' ]) is not None :
1463+ _ThinkingLevel_to_vertex_enum_validate (
1464+ getv (from_object , ['thinking_level' ])
1465+ )
1466+ setv (to_object , ['thinkingLevel' ], getv (from_object , ['thinking_level' ]))
1467+
1468+ return to_object
1469+
1470+
12851471def _Tool_to_mldev (
12861472 from_object : Union [dict [str , Any ], object ],
12871473 parent_object : Optional [dict [str , Any ]] = None ,
@@ -1296,6 +1482,13 @@ def _Tool_to_mldev(
12961482 if getv (from_object , ['file_search' ]) is not None :
12971483 setv (to_object , ['fileSearch' ], getv (from_object , ['file_search' ]))
12981484
1485+ if getv (from_object , ['google_maps' ]) is not None :
1486+ setv (
1487+ to_object ,
1488+ ['googleMaps' ],
1489+ _GoogleMaps_to_mldev (getv (from_object , ['google_maps' ]), to_object ),
1490+ )
1491+
12991492 if getv (from_object , ['code_execution' ]) is not None :
13001493 setv (to_object , ['codeExecution' ], getv (from_object , ['code_execution' ]))
13011494
@@ -1311,13 +1504,6 @@ def _Tool_to_mldev(
13111504 [item for item in getv (from_object , ['function_declarations' ])],
13121505 )
13131506
1314- if getv (from_object , ['google_maps' ]) is not None :
1315- setv (
1316- to_object ,
1317- ['googleMaps' ],
1318- _GoogleMaps_to_mldev (getv (from_object , ['google_maps' ]), to_object ),
1319- )
1320-
13211507 if getv (from_object , ['google_search' ]) is not None :
13221508 setv (
13231509 to_object ,
@@ -1332,9 +1518,21 @@ def _Tool_to_mldev(
13321518 getv (from_object , ['google_search_retrieval' ]),
13331519 )
13341520
1521+ if getv (from_object , ['parallel_ai_search' ]) is not None :
1522+ raise ValueError (
1523+ 'parallel_ai_search parameter is not supported in Gemini API.'
1524+ )
1525+
13351526 if getv (from_object , ['url_context' ]) is not None :
13361527 setv (to_object , ['urlContext' ], getv (from_object , ['url_context' ]))
13371528
1529+ if getv (from_object , ['mcp_servers' ]) is not None :
1530+ setv (
1531+ to_object ,
1532+ ['mcpServers' ],
1533+ [item for item in getv (from_object , ['mcp_servers' ])],
1534+ )
1535+
13381536 return to_object
13391537
13401538
@@ -1352,6 +1550,9 @@ def _Tool_to_vertex(
13521550 if getv (from_object , ['file_search' ]) is not None :
13531551 raise ValueError ('file_search parameter is not supported in Vertex AI.' )
13541552
1553+ if getv (from_object , ['google_maps' ]) is not None :
1554+ setv (to_object , ['googleMaps' ], getv (from_object , ['google_maps' ]))
1555+
13551556 if getv (from_object , ['code_execution' ]) is not None :
13561557 setv (to_object , ['codeExecution' ], getv (from_object , ['code_execution' ]))
13571558
@@ -1372,9 +1573,6 @@ def _Tool_to_vertex(
13721573 ],
13731574 )
13741575
1375- if getv (from_object , ['google_maps' ]) is not None :
1376- setv (to_object , ['googleMaps' ], getv (from_object , ['google_maps' ]))
1377-
13781576 if getv (from_object , ['google_search' ]) is not None :
13791577 setv (to_object , ['googleSearch' ], getv (from_object , ['google_search' ]))
13801578
@@ -1385,9 +1583,19 @@ def _Tool_to_vertex(
13851583 getv (from_object , ['google_search_retrieval' ]),
13861584 )
13871585
1586+ if getv (from_object , ['parallel_ai_search' ]) is not None :
1587+ setv (
1588+ to_object ,
1589+ ['parallelAiSearch' ],
1590+ getv (from_object , ['parallel_ai_search' ]),
1591+ )
1592+
13881593 if getv (from_object , ['url_context' ]) is not None :
13891594 setv (to_object , ['urlContext' ], getv (from_object , ['url_context' ]))
13901595
1596+ if getv (from_object , ['mcp_servers' ]) is not None :
1597+ raise ValueError ('mcp_servers parameter is not supported in Vertex AI.' )
1598+
13911599 return to_object
13921600
13931601
0 commit comments