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 ,
@@ -257,7 +312,11 @@ def _GoogleMaps_to_mldev(
257312) -> dict [str , Any ]:
258313 to_object : dict [str , Any ] = {}
259314 if getv (from_object , ['auth_config' ]) is not None :
260- 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+ )
261320
262321 if getv (from_object , ['enable_widget' ]) is not None :
263322 setv (to_object , ['enableWidget' ], getv (from_object , ['enable_widget' ]))
@@ -270,14 +329,14 @@ def _GoogleSearch_to_mldev(
270329 parent_object : Optional [dict [str , Any ]] = None ,
271330) -> dict [str , Any ]:
272331 to_object : dict [str , Any ] = {}
273- if getv (from_object , ['exclude_domains ' ]) is not None :
332+ if getv (from_object , ['blocking_confidence ' ]) is not None :
274333 raise ValueError (
275- 'exclude_domains parameter is not supported in Gemini API.'
334+ 'blocking_confidence parameter is not supported in Gemini API.'
276335 )
277336
278- if getv (from_object , ['blocking_confidence ' ]) is not None :
337+ if getv (from_object , ['exclude_domains ' ]) is not None :
279338 raise ValueError (
280- 'blocking_confidence parameter is not supported in Gemini API.'
339+ 'exclude_domains parameter is not supported in Gemini API.'
281340 )
282341
283342 if getv (from_object , ['time_range_filter' ]) is not None :
@@ -309,6 +368,27 @@ def _LiveClientContent_to_mldev(
309368 return to_object
310369
311370
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+
312392def _LiveClientMessage_to_mldev (
313393 api_client : BaseApiClient ,
314394 from_object : Union [dict [str , Any ], object ],
@@ -364,7 +444,13 @@ def _LiveClientMessage_to_vertex(
364444 )
365445
366446 if getv (from_object , ['client_content' ]) is not None :
367- 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+ )
368454
369455 if getv (from_object , ['realtime_input' ]) is not None :
370456 setv (
@@ -558,7 +644,9 @@ def _LiveClientSetup_to_vertex(
558644 setv (
559645 to_object ,
560646 ['systemInstruction' ],
561- t .t_content (getv (from_object , ['system_instruction' ])),
647+ _Content_to_vertex (
648+ t .t_content (getv (from_object , ['system_instruction' ])), to_object
649+ ),
562650 )
563651
564652 if getv (from_object , ['tools' ]) is not None :
@@ -857,7 +945,9 @@ def _LiveConnectConfig_to_vertex(
857945 setv (
858946 parent_object ,
859947 ['setup' , 'systemInstruction' ],
860- t .t_content (getv (from_object , ['system_instruction' ])),
948+ _Content_to_vertex (
949+ t .t_content (getv (from_object , ['system_instruction' ])), to_object
950+ ),
861951 )
862952
863953 if getv (from_object , ['tools' ]) is not None :
@@ -1265,6 +1355,67 @@ def _Part_to_mldev(
12651355 if getv (from_object , ['video_metadata' ]) is not None :
12661356 setv (to_object , ['videoMetadata' ], getv (from_object , ['video_metadata' ]))
12671357
1358+ if getv (from_object , ['part_metadata' ]) is not None :
1359+ setv (to_object , ['partMetadata' ], getv (from_object , ['part_metadata' ]))
1360+
1361+ return to_object
1362+
1363+
1364+ def _Part_to_vertex (
1365+ from_object : Union [dict [str , Any ], object ],
1366+ parent_object : Optional [dict [str , Any ]] = None ,
1367+ ) -> dict [str , Any ]:
1368+ to_object : dict [str , Any ] = {}
1369+ if getv (from_object , ['media_resolution' ]) is not None :
1370+ setv (
1371+ to_object , ['mediaResolution' ], getv (from_object , ['media_resolution' ])
1372+ )
1373+
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.' )
1418+
12681419 return to_object
12691420
12701421
@@ -1310,6 +1461,13 @@ def _Tool_to_mldev(
13101461 if getv (from_object , ['file_search' ]) is not None :
13111462 setv (to_object , ['fileSearch' ], getv (from_object , ['file_search' ]))
13121463
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+
13131471 if getv (from_object , ['code_execution' ]) is not None :
13141472 setv (to_object , ['codeExecution' ], getv (from_object , ['code_execution' ]))
13151473
@@ -1318,13 +1476,6 @@ def _Tool_to_mldev(
13181476 'enterprise_web_search parameter is not supported in Gemini API.'
13191477 )
13201478
1321- if getv (from_object , ['google_maps' ]) is not None :
1322- setv (
1323- to_object ,
1324- ['googleMaps' ],
1325- _GoogleMaps_to_mldev (getv (from_object , ['google_maps' ]), to_object ),
1326- )
1327-
13281479 if getv (from_object , ['google_search' ]) is not None :
13291480 setv (
13301481 to_object ,
@@ -1369,6 +1520,9 @@ def _Tool_to_vertex(
13691520 if getv (from_object , ['file_search' ]) is not None :
13701521 raise ValueError ('file_search parameter is not supported in Vertex AI.' )
13711522
1523+ if getv (from_object , ['google_maps' ]) is not None :
1524+ setv (to_object , ['googleMaps' ], getv (from_object , ['google_maps' ]))
1525+
13721526 if getv (from_object , ['code_execution' ]) is not None :
13731527 setv (to_object , ['codeExecution' ], getv (from_object , ['code_execution' ]))
13741528
@@ -1379,9 +1533,6 @@ def _Tool_to_vertex(
13791533 getv (from_object , ['enterprise_web_search' ]),
13801534 )
13811535
1382- if getv (from_object , ['google_maps' ]) is not None :
1383- setv (to_object , ['googleMaps' ], getv (from_object , ['google_maps' ]))
1384-
13851536 if getv (from_object , ['google_search' ]) is not None :
13861537 setv (to_object , ['googleSearch' ], getv (from_object , ['google_search' ]))
13871538
0 commit comments