Skip to content

Commit 1efc057

Browse files
holtskinnercopybara-github
authored andcommitted
feat: Add support for Grounding with Google Maps
PiperOrigin-RevId: 755055455
1 parent dfdea36 commit 1efc057

File tree

4 files changed

+846
-0
lines changed

4 files changed

+846
-0
lines changed

google/genai/_live_converters.py

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,136 @@ def _EnterpriseWebSearch_to_vertex(
286286
return to_object
287287

288288

289+
def _ApiKeyConfig_to_mldev(
290+
api_client: BaseApiClient,
291+
from_object: Union[dict[str, Any], object],
292+
parent_object: Optional[dict[str, Any]] = None,
293+
) -> dict[str, Any]:
294+
to_object: dict[str, Any] = {}
295+
if getv(from_object, ['api_key_string']) is not None:
296+
raise ValueError('api_key_string parameter is not supported in Gemini API.')
297+
298+
return to_object
299+
300+
301+
def _ApiKeyConfig_to_vertex(
302+
api_client: BaseApiClient,
303+
from_object: Union[dict[str, Any], object],
304+
parent_object: Optional[dict[str, Any]] = None,
305+
) -> dict[str, Any]:
306+
to_object: dict[str, Any] = {}
307+
if getv(from_object, ['api_key_string']) is not None:
308+
setv(to_object, ['apiKeyString'], getv(from_object, ['api_key_string']))
309+
310+
return to_object
311+
312+
313+
def _AuthConfig_to_mldev(
314+
api_client: BaseApiClient,
315+
from_object: Union[dict[str, Any], object],
316+
parent_object: Optional[dict[str, Any]] = None,
317+
) -> dict[str, Any]:
318+
to_object: dict[str, Any] = {}
319+
if getv(from_object, ['api_key_config']) is not None:
320+
raise ValueError('api_key_config parameter is not supported in Gemini API.')
321+
322+
if getv(from_object, ['auth_type']) is not None:
323+
setv(to_object, ['authType'], getv(from_object, ['auth_type']))
324+
325+
if getv(from_object, ['google_service_account_config']) is not None:
326+
setv(
327+
to_object,
328+
['googleServiceAccountConfig'],
329+
getv(from_object, ['google_service_account_config']),
330+
)
331+
332+
if getv(from_object, ['http_basic_auth_config']) is not None:
333+
setv(
334+
to_object,
335+
['httpBasicAuthConfig'],
336+
getv(from_object, ['http_basic_auth_config']),
337+
)
338+
339+
if getv(from_object, ['oauth_config']) is not None:
340+
setv(to_object, ['oauthConfig'], getv(from_object, ['oauth_config']))
341+
342+
if getv(from_object, ['oidc_config']) is not None:
343+
setv(to_object, ['oidcConfig'], getv(from_object, ['oidc_config']))
344+
345+
return to_object
346+
347+
348+
def _AuthConfig_to_vertex(
349+
api_client: BaseApiClient,
350+
from_object: Union[dict[str, Any], object],
351+
parent_object: Optional[dict[str, Any]] = None,
352+
) -> dict[str, Any]:
353+
to_object: dict[str, Any] = {}
354+
if getv(from_object, ['api_key_config']) is not None:
355+
setv(
356+
to_object,
357+
['apiKeyConfig'],
358+
_ApiKeyConfig_to_vertex(
359+
api_client, getv(from_object, ['api_key_config']), to_object
360+
),
361+
)
362+
363+
if getv(from_object, ['auth_type']) is not None:
364+
setv(to_object, ['authType'], getv(from_object, ['auth_type']))
365+
366+
if getv(from_object, ['google_service_account_config']) is not None:
367+
setv(
368+
to_object,
369+
['googleServiceAccountConfig'],
370+
getv(from_object, ['google_service_account_config']),
371+
)
372+
373+
if getv(from_object, ['http_basic_auth_config']) is not None:
374+
setv(
375+
to_object,
376+
['httpBasicAuthConfig'],
377+
getv(from_object, ['http_basic_auth_config']),
378+
)
379+
380+
if getv(from_object, ['oauth_config']) is not None:
381+
setv(to_object, ['oauthConfig'], getv(from_object, ['oauth_config']))
382+
383+
if getv(from_object, ['oidc_config']) is not None:
384+
setv(to_object, ['oidcConfig'], getv(from_object, ['oidc_config']))
385+
386+
return to_object
387+
388+
389+
def _GoogleMaps_to_mldev(
390+
api_client: BaseApiClient,
391+
from_object: Union[dict[str, Any], object],
392+
parent_object: Optional[dict[str, Any]] = None,
393+
) -> dict[str, Any]:
394+
to_object: dict[str, Any] = {}
395+
if getv(from_object, ['auth_config']) is not None:
396+
raise ValueError('auth_config parameter is not supported in Gemini API.')
397+
398+
return to_object
399+
400+
401+
def _GoogleMaps_to_vertex(
402+
api_client: BaseApiClient,
403+
from_object: Union[dict[str, Any], object],
404+
parent_object: Optional[dict[str, Any]] = None,
405+
) -> dict[str, Any]:
406+
to_object: dict[str, Any] = {}
407+
if getv(from_object, ['auth_config']) is not None:
408+
setv(
409+
to_object,
410+
['authConfig'],
411+
_AuthConfig_to_vertex(
412+
api_client, getv(from_object, ['auth_config']), to_object
413+
),
414+
)
415+
416+
return to_object
417+
418+
289419
def _Tool_to_mldev(
290420
api_client: BaseApiClient,
291421
from_object: Union[dict[str, Any], object],
@@ -320,6 +450,9 @@ def _Tool_to_mldev(
320450
'enterprise_web_search parameter is not supported in Gemini API.'
321451
)
322452

453+
if getv(from_object, ['google_maps']) is not None:
454+
raise ValueError('google_maps parameter is not supported in Gemini API.')
455+
323456
if getv(from_object, ['code_execution']) is not None:
324457
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
325458

@@ -371,6 +504,15 @@ def _Tool_to_vertex(
371504
),
372505
)
373506

507+
if getv(from_object, ['google_maps']) is not None:
508+
setv(
509+
to_object,
510+
['googleMaps'],
511+
_GoogleMaps_to_vertex(
512+
api_client, getv(from_object, ['google_maps']), to_object
513+
),
514+
)
515+
374516
if getv(from_object, ['code_execution']) is not None:
375517
setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
376518

0 commit comments

Comments
 (0)