Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions google/genai/_live_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,12 @@ def _GoogleMaps_to_mldev(
if getv(from_object, ['enable_widget']) is not None:
setv(to_object, ['enableWidget'], getv(from_object, ['enable_widget']))

if getv(from_object, ['grounding_types']) is not None:
raise ValueError(
'grounding_types parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

return to_object


Expand Down
6 changes: 6 additions & 0 deletions google/genai/_tokens_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ def _GoogleMaps_to_mldev(
if getv(from_object, ['enable_widget']) is not None:
setv(to_object, ['enableWidget'], getv(from_object, ['enable_widget']))

if getv(from_object, ['grounding_types']) is not None:
raise ValueError(
'grounding_types parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

return to_object


Expand Down
6 changes: 6 additions & 0 deletions google/genai/batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,12 @@ def _GoogleMaps_to_mldev(
if getv(from_object, ['enable_widget']) is not None:
setv(to_object, ['enableWidget'], getv(from_object, ['enable_widget']))

if getv(from_object, ['grounding_types']) is not None:
raise ValueError(
'grounding_types parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

return to_object


Expand Down
6 changes: 6 additions & 0 deletions google/genai/caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,12 @@ def _GoogleMaps_to_mldev(
if getv(from_object, ['enable_widget']) is not None:
setv(to_object, ['enableWidget'], getv(from_object, ['enable_widget']))

if getv(from_object, ['grounding_types']) is not None:
raise ValueError(
'grounding_types parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

return to_object


Expand Down
6 changes: 6 additions & 0 deletions google/genai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3076,6 +3076,12 @@ def _GoogleMaps_to_mldev(
if getv(from_object, ['enable_widget']) is not None:
setv(to_object, ['enableWidget'], getv(from_object, ['enable_widget']))

if getv(from_object, ['grounding_types']) is not None:
raise ValueError(
'grounding_types parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

return to_object


Expand Down
26 changes: 26 additions & 0 deletions google/genai/tests/models/test_generate_content_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,32 @@ def divide_floats(a: float, b: float) -> float:
config={'tools': [{'google_maps': {'enable_widget': True}}]},
),
),
pytest_helper.TestTableItem(
name='test_google_maps_places_routing',
parameters=types._GenerateContentParameters(
model='gemini-3.5-flash',
contents=t.t_contents(
'How long does it take to drive from SFO to LAX?'
),
config={
'tools': [{'google_maps': {'grounding_types': {'places': {}}}}]
},
),
exception_if_mldev='only supported in',
),
pytest_helper.TestTableItem(
name='test_google_maps_routing',
parameters=types._GenerateContentParameters(
model='gemini-3.5-flash',
contents=t.t_contents(
'Give me directions from SFO to LAX.'
),
config={
'tools': [{'google_maps': {'grounding_types': {'routing': {}}}}]
},
),
exception_if_mldev='only supported in',
),
pytest_helper.TestTableItem(
name='test_include_server_side_tool_invocations',
parameters=types._GenerateContentParameters(
Expand Down
85 changes: 85 additions & 0 deletions google/genai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3753,6 +3753,84 @@ class AuthConfigDict(TypedDict, total=False):
AuthConfigOrDict = Union[AuthConfig, AuthConfigDict]


class GoogleMapsPlaces(_common.BaseModel):
"""Grounding with Google Maps Places data (e.g.

QueryPlaces). This is the default Google Maps grounding type when no other
type is specified. This data type is not supported in Gemini API.
"""

pass


class GoogleMapsPlacesDict(TypedDict, total=False):
"""Grounding with Google Maps Places data (e.g.

QueryPlaces). This is the default Google Maps grounding type when no other
type is specified. This data type is not supported in Gemini API.
"""

pass


GoogleMapsPlacesOrDict = Union[GoogleMapsPlaces, GoogleMapsPlacesDict]


class GoogleMapsRouting(_common.BaseModel):
"""Grounding with Google Maps Routing APIs (ComputeRoutes and SearchAlongRoute).

This data type is not supported in Gemini API.
"""

pass


class GoogleMapsRoutingDict(TypedDict, total=False):
"""Grounding with Google Maps Routing APIs (ComputeRoutes and SearchAlongRoute).

This data type is not supported in Gemini API.
"""

pass


GoogleMapsRoutingOrDict = Union[GoogleMapsRouting, GoogleMapsRoutingDict]


class GoogleMapsGroundingTypes(_common.BaseModel):
"""Defines the types of Google Maps grounding that can be enabled and their configurations.

This data type is not supported in Gemini API.
"""

places: Optional[GoogleMapsPlaces] = Field(
default=None,
description="""Optional. Enables grounding with Google Maps Places. This is the default grounding type when no `GroundingTypes` are specified.""",
)
routing: Optional[GoogleMapsRouting] = Field(
default=None,
description="""Optional. Enables grounding with Google Maps Routing APIs (ComputeRoutes and SearchAlongRoute).""",
)


class GoogleMapsGroundingTypesDict(TypedDict, total=False):
"""Defines the types of Google Maps grounding that can be enabled and their configurations.

This data type is not supported in Gemini API.
"""

places: Optional[GoogleMapsPlacesDict]
"""Optional. Enables grounding with Google Maps Places. This is the default grounding type when no `GroundingTypes` are specified."""

routing: Optional[GoogleMapsRoutingDict]
"""Optional. Enables grounding with Google Maps Routing APIs (ComputeRoutes and SearchAlongRoute)."""


GoogleMapsGroundingTypesOrDict = Union[
GoogleMapsGroundingTypes, GoogleMapsGroundingTypesDict
]


class GoogleMaps(_common.BaseModel):
"""Tool to retrieve knowledge from Google Maps."""

Expand All @@ -3764,6 +3842,10 @@ class GoogleMaps(_common.BaseModel):
default=None,
description="""Deprecated. The Google Maps contextual widget behavior in Grounding with Google Maps is being deprecated; this field is planned for removal and no longer has any effect once removed. Optional. Whether to return a widget context token in the GroundingMetadata of the response.""",
)
grounding_types: Optional[GoogleMapsGroundingTypes] = Field(
default=None,
description="""Optional. Specifies the types of Google Maps grounding to enable. This field is not supported in Gemini API.""",
)


class GoogleMapsDict(TypedDict, total=False):
Expand All @@ -3775,6 +3857,9 @@ class GoogleMapsDict(TypedDict, total=False):
enable_widget: Optional[bool]
"""Deprecated. The Google Maps contextual widget behavior in Grounding with Google Maps is being deprecated; this field is planned for removal and no longer has any effect once removed. Optional. Whether to return a widget context token in the GroundingMetadata of the response."""

grounding_types: Optional[GoogleMapsGroundingTypesDict]
"""Optional. Specifies the types of Google Maps grounding to enable. This field is not supported in Gemini API."""


GoogleMapsOrDict = Union[GoogleMaps, GoogleMapsDict]

Expand Down
Loading