2323from ._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+
2660def _Blob_to_mldev (
2761 from_object : Union [dict [str , Any ], object ],
2862 parent_object : Optional [dict [str , Any ]] = None ,
@@ -61,6 +95,27 @@ def _Content_to_mldev(
6195 return to_object
6296
6397
98+ def _Content_to_vertex (
99+ from_object : Union [dict [str , Any ], object ],
100+ parent_object : Optional [dict [str , Any ]] = None ,
101+ ) -> dict [str , Any ]:
102+ to_object : dict [str , Any ] = {}
103+ if getv (from_object , ['parts' ]) is not None :
104+ setv (
105+ to_object ,
106+ ['parts' ],
107+ [
108+ _Part_to_vertex (item , to_object )
109+ for item in getv (from_object , ['parts' ])
110+ ],
111+ )
112+
113+ if getv (from_object , ['role' ]) is not None :
114+ setv (to_object , ['role' ], getv (from_object , ['role' ]))
115+
116+ return to_object
117+
118+
64119def _FileData_to_mldev (
65120 from_object : Union [dict [str , Any ], object ],
66121 parent_object : Optional [dict [str , Any ]] = None ,
@@ -226,13 +281,7 @@ def _GenerationConfig_to_vertex(
226281 setv (to_object , ['seed' ], getv (from_object , ['seed' ]))
227282
228283 if getv (from_object , ['speech_config' ]) is not None :
229- setv (
230- to_object ,
231- ['speechConfig' ],
232- _SpeechConfig_to_vertex (
233- getv (from_object , ['speech_config' ]), to_object
234- ),
235- )
284+ setv (to_object , ['speechConfig' ], getv (from_object , ['speech_config' ]))
236285
237286 if getv (from_object , ['stop_sequences' ]) is not None :
238287 setv (to_object , ['stopSequences' ], getv (from_object , ['stop_sequences' ]))
@@ -263,7 +312,11 @@ def _GoogleMaps_to_mldev(
263312) -> dict [str , Any ]:
264313 to_object : dict [str , Any ] = {}
265314 if getv (from_object , ['auth_config' ]) is not None :
266- raise ValueError ('auth_config parameter is not supported in Gemini API.' )
315+ setv (
316+ to_object ,
317+ ['authConfig' ],
318+ _AuthConfig_to_mldev (getv (from_object , ['auth_config' ]), to_object ),
319+ )
267320
268321 if getv (from_object , ['enable_widget' ]) is not None :
269322 setv (to_object , ['enableWidget' ], getv (from_object , ['enable_widget' ]))
@@ -276,14 +329,14 @@ def _GoogleSearch_to_mldev(
276329 parent_object : Optional [dict [str , Any ]] = None ,
277330) -> dict [str , Any ]:
278331 to_object : dict [str , Any ] = {}
279- if getv (from_object , ['exclude_domains ' ]) is not None :
332+ if getv (from_object , ['blocking_confidence ' ]) is not None :
280333 raise ValueError (
281- 'exclude_domains parameter is not supported in Gemini API.'
334+ 'blocking_confidence parameter is not supported in Gemini API.'
282335 )
283336
284- if getv (from_object , ['blocking_confidence ' ]) is not None :
337+ if getv (from_object , ['exclude_domains ' ]) is not None :
285338 raise ValueError (
286- 'blocking_confidence parameter is not supported in Gemini API.'
339+ 'exclude_domains parameter is not supported in Gemini API.'
287340 )
288341
289342 if getv (from_object , ['time_range_filter' ]) is not None :
@@ -315,6 +368,27 @@ def _LiveClientContent_to_mldev(
315368 return to_object
316369
317370
371+ def _LiveClientContent_to_vertex (
372+ from_object : Union [dict [str , Any ], object ],
373+ parent_object : Optional [dict [str , Any ]] = None ,
374+ ) -> dict [str , Any ]:
375+ to_object : dict [str , Any ] = {}
376+ if getv (from_object , ['turns' ]) is not None :
377+ setv (
378+ to_object ,
379+ ['turns' ],
380+ [
381+ _Content_to_vertex (item , to_object )
382+ for item in getv (from_object , ['turns' ])
383+ ],
384+ )
385+
386+ if getv (from_object , ['turn_complete' ]) is not None :
387+ setv (to_object , ['turnComplete' ], getv (from_object , ['turn_complete' ]))
388+
389+ return to_object
390+
391+
318392def _LiveClientMessage_to_mldev (
319393 api_client : BaseApiClient ,
320394 from_object : Union [dict [str , Any ], object ],
@@ -370,7 +444,13 @@ def _LiveClientMessage_to_vertex(
370444 )
371445
372446 if getv (from_object , ['client_content' ]) is not None :
373- setv (to_object , ['clientContent' ], getv (from_object , ['client_content' ]))
447+ setv (
448+ to_object ,
449+ ['clientContent' ],
450+ _LiveClientContent_to_vertex (
451+ getv (from_object , ['client_content' ]), to_object
452+ ),
453+ )
374454
375455 if getv (from_object , ['realtime_input' ]) is not None :
376456 setv (
@@ -564,7 +644,9 @@ def _LiveClientSetup_to_vertex(
564644 setv (
565645 to_object ,
566646 ['systemInstruction' ],
567- t .t_content (getv (from_object , ['system_instruction' ])),
647+ _Content_to_vertex (
648+ t .t_content (getv (from_object , ['system_instruction' ])), to_object
649+ ),
568650 )
569651
570652 if getv (from_object , ['tools' ]) is not None :
@@ -842,10 +924,7 @@ def _LiveConnectConfig_to_vertex(
842924 setv (
843925 parent_object ,
844926 ['setup' , 'generationConfig' , 'speechConfig' ],
845- _SpeechConfig_to_vertex (
846- t .t_live_speech_config (getv (from_object , ['speech_config' ])),
847- to_object ,
848- ),
927+ t .t_live_speech_config (getv (from_object , ['speech_config' ])),
849928 )
850929
851930 if getv (from_object , ['thinking_config' ]) is not None :
@@ -866,7 +945,9 @@ def _LiveConnectConfig_to_vertex(
866945 setv (
867946 parent_object ,
868947 ['setup' , 'systemInstruction' ],
869- t .t_content (getv (from_object , ['system_instruction' ])),
948+ _Content_to_vertex (
949+ t .t_content (getv (from_object , ['system_instruction' ])), to_object
950+ ),
870951 )
871952
872953 if getv (from_object , ['tools' ]) is not None :
@@ -1274,38 +1355,80 @@ def _Part_to_mldev(
12741355 if getv (from_object , ['video_metadata' ]) is not None :
12751356 setv (to_object , ['videoMetadata' ], getv (from_object , ['video_metadata' ]))
12761357
1358+ if getv (from_object , ['part_metadata' ]) is not None :
1359+ setv (to_object , ['partMetadata' ], getv (from_object , ['part_metadata' ]))
1360+
12771361 return to_object
12781362
12791363
1280- def _SessionResumptionConfig_to_mldev (
1364+ def _Part_to_vertex (
12811365 from_object : Union [dict [str , Any ], object ],
12821366 parent_object : Optional [dict [str , Any ]] = None ,
12831367) -> dict [str , Any ]:
12841368 to_object : dict [str , Any ] = {}
1285- if getv (from_object , ['handle' ]) is not None :
1286- setv (to_object , ['handle' ], getv (from_object , ['handle' ]))
1369+ if getv (from_object , ['media_resolution' ]) is not None :
1370+ setv (
1371+ to_object , ['mediaResolution' ], getv (from_object , ['media_resolution' ])
1372+ )
12871373
1288- if getv (from_object , ['transparent' ]) is not None :
1289- raise ValueError ('transparent parameter is not supported in Gemini API.' )
1374+ if getv (from_object , ['code_execution_result' ]) is not None :
1375+ setv (
1376+ to_object ,
1377+ ['codeExecutionResult' ],
1378+ getv (from_object , ['code_execution_result' ]),
1379+ )
1380+
1381+ if getv (from_object , ['executable_code' ]) is not None :
1382+ setv (to_object , ['executableCode' ], getv (from_object , ['executable_code' ]))
1383+
1384+ if getv (from_object , ['file_data' ]) is not None :
1385+ setv (to_object , ['fileData' ], getv (from_object , ['file_data' ]))
1386+
1387+ if getv (from_object , ['function_call' ]) is not None :
1388+ setv (to_object , ['functionCall' ], getv (from_object , ['function_call' ]))
1389+
1390+ if getv (from_object , ['function_response' ]) is not None :
1391+ setv (
1392+ to_object ,
1393+ ['functionResponse' ],
1394+ getv (from_object , ['function_response' ]),
1395+ )
1396+
1397+ if getv (from_object , ['inline_data' ]) is not None :
1398+ setv (to_object , ['inlineData' ], getv (from_object , ['inline_data' ]))
1399+
1400+ if getv (from_object , ['text' ]) is not None :
1401+ setv (to_object , ['text' ], getv (from_object , ['text' ]))
1402+
1403+ if getv (from_object , ['thought' ]) is not None :
1404+ setv (to_object , ['thought' ], getv (from_object , ['thought' ]))
1405+
1406+ if getv (from_object , ['thought_signature' ]) is not None :
1407+ setv (
1408+ to_object ,
1409+ ['thoughtSignature' ],
1410+ getv (from_object , ['thought_signature' ]),
1411+ )
1412+
1413+ if getv (from_object , ['video_metadata' ]) is not None :
1414+ setv (to_object , ['videoMetadata' ], getv (from_object , ['video_metadata' ]))
1415+
1416+ if getv (from_object , ['part_metadata' ]) is not None :
1417+ raise ValueError ('part_metadata parameter is not supported in Vertex AI.' )
12901418
12911419 return to_object
12921420
12931421
1294- def _SpeechConfig_to_vertex (
1422+ def _SessionResumptionConfig_to_mldev (
12951423 from_object : Union [dict [str , Any ], object ],
12961424 parent_object : Optional [dict [str , Any ]] = None ,
12971425) -> dict [str , Any ]:
12981426 to_object : dict [str , Any ] = {}
1299- if getv (from_object , ['voice_config' ]) is not None :
1300- setv (to_object , ['voiceConfig' ], getv (from_object , ['voice_config' ]))
1301-
1302- if getv (from_object , ['language_code' ]) is not None :
1303- setv (to_object , ['languageCode' ], getv (from_object , ['language_code' ]))
1427+ if getv (from_object , ['handle' ]) is not None :
1428+ setv (to_object , ['handle' ], getv (from_object , ['handle' ]))
13041429
1305- if getv (from_object , ['multi_speaker_voice_config' ]) is not None :
1306- raise ValueError (
1307- 'multi_speaker_voice_config parameter is not supported in Vertex AI.'
1308- )
1430+ if getv (from_object , ['transparent' ]) is not None :
1431+ raise ValueError ('transparent parameter is not supported in Gemini API.' )
13091432
13101433 return to_object
13111434
@@ -1338,6 +1461,13 @@ def _Tool_to_mldev(
13381461 if getv (from_object , ['file_search' ]) is not None :
13391462 setv (to_object , ['fileSearch' ], getv (from_object , ['file_search' ]))
13401463
1464+ if getv (from_object , ['google_maps' ]) is not None :
1465+ setv (
1466+ to_object ,
1467+ ['googleMaps' ],
1468+ _GoogleMaps_to_mldev (getv (from_object , ['google_maps' ]), to_object ),
1469+ )
1470+
13411471 if getv (from_object , ['code_execution' ]) is not None :
13421472 setv (to_object , ['codeExecution' ], getv (from_object , ['code_execution' ]))
13431473
@@ -1346,13 +1476,6 @@ def _Tool_to_mldev(
13461476 'enterprise_web_search parameter is not supported in Gemini API.'
13471477 )
13481478
1349- if getv (from_object , ['google_maps' ]) is not None :
1350- setv (
1351- to_object ,
1352- ['googleMaps' ],
1353- _GoogleMaps_to_mldev (getv (from_object , ['google_maps' ]), to_object ),
1354- )
1355-
13561479 if getv (from_object , ['google_search' ]) is not None :
13571480 setv (
13581481 to_object ,
@@ -1397,6 +1520,9 @@ def _Tool_to_vertex(
13971520 if getv (from_object , ['file_search' ]) is not None :
13981521 raise ValueError ('file_search parameter is not supported in Vertex AI.' )
13991522
1523+ if getv (from_object , ['google_maps' ]) is not None :
1524+ setv (to_object , ['googleMaps' ], getv (from_object , ['google_maps' ]))
1525+
14001526 if getv (from_object , ['code_execution' ]) is not None :
14011527 setv (to_object , ['codeExecution' ], getv (from_object , ['code_execution' ]))
14021528
@@ -1407,9 +1533,6 @@ def _Tool_to_vertex(
14071533 getv (from_object , ['enterprise_web_search' ]),
14081534 )
14091535
1410- if getv (from_object , ['google_maps' ]) is not None :
1411- setv (to_object , ['googleMaps' ], getv (from_object , ['google_maps' ]))
1412-
14131536 if getv (from_object , ['google_search' ]) is not None :
14141537 setv (to_object , ['googleSearch' ], getv (from_object , ['google_search' ]))
14151538
0 commit comments