Skip to content

feat(firebaseai): add Google Maps Grounding support#18144

Open
ryanwilson wants to merge 5 commits intomainfrom
rw-maps-grounding
Open

feat(firebaseai): add Google Maps Grounding support#18144
ryanwilson wants to merge 5 commits intomainfrom
rw-maps-grounding

Conversation

@ryanwilson
Copy link
Member

@ryanwilson ryanwilson commented Mar 25, 2026

Introduces support for Google Maps Grounding to the firebase_ai SDK, establishing feature parity with other platforms.

API Changes:

  • Added Tool.googleMaps() factory and GoogleMaps class.
  • Introduced RetrievalConfig and LatLng for dynamic location-based tool configurations.
  • Expanded ToolConfig to include an optional retrievalConfig property.
  • Added GoogleMapsGroundingChunk to represent parsed Maps location properties (uri, title, placeId).
  • Updated GroundingChunk to expose the new maps property alongside web.
  • Exported all new grounding models publicly via firebase_ai.dart.

Example App:

  • Added a dedicated "Grounding" page (grounding_page.dart) to the main navigation menu.
  • Implemented dynamic UI toggles for both Search and Maps Grounding.
  • Implemented dynamic parsing and Markdown rendering of returned grounding chunks.

Testing:

  • Added comprehensive JSON roundtrip serialization tests for all new Tool configurations.
  • Added parsing tests mapping Developer API JSON payloads to GoogleMapsGroundingChunk.
  • Manually tested newly added web app section with Vertex and Developer APIs

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See [Contributor Guide]).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the [Flutter Style Guide].
  • I signed the [CLA].
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

Introduces support for Google Maps Grounding to the firebase_ai SDK,
establishing feature parity with other platforms.

API Changes:
- Added `Tool.googleMaps()` factory and `GoogleMaps` class.
- Introduced `RetrievalConfig` and `LatLng` for dynamic location-based tool configurations.
- Expanded `ToolConfig` to include an optional `retrievalConfig` property.
- Added `GoogleMapsGroundingChunk` to represent parsed Maps location properties (`uri`, `title`, `placeId`).
- Updated `GroundingChunk` to expose the new `maps` property alongside `web`.
- Exported all new grounding models publicly via `firebase_ai.dart`.

Example App:
- Added a dedicated "Grounding" page (`grounding_page.dart`) to the main navigation menu.
- Implemented dynamic UI toggles for both Search and Maps Grounding.
- Implemented dynamic parsing and Markdown rendering of returned grounding chunks.

Testing:
- Added comprehensive JSON roundtrip serialization tests for all new Tool configurations.
- Added parsing tests mapping Developer API JSON payloads to `GoogleMapsGroundingChunk`.
- Manually tested newly added web app section with Vertex and Developer APIs
@gemini-code-assist
Copy link
Contributor

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@ryanwilson
Copy link
Member Author

Sample app snippets showing functionality (and the Search grounding part of the sample)

Search Vertex Maps - Developer Maps - Vertex with coordinates Search Developer

@ryanwilson
Copy link
Member Author

The Android test appears to be a flake

@ryanwilson
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces Google Maps grounding capabilities to the firebase_ai library and demonstrates its usage in the example application. Key changes include new API classes for Google Maps grounding chunks, tools, and configuration (like LatLng and RetrievalConfig), along with updated serialization/deserialization logic and comprehensive unit tests. The example app now features a dedicated "Grounding" page, enabling users to toggle Search and Maps grounding, input latitude/longitude, and interact with the model to visualize grounding sources in the response. Review comments suggest adding a mounted check in _sendPrompt to prevent potential errors, improving the display of nullable Google Maps grounding source properties for better user experience, and refactoring the model initialization logic to reduce code duplication.

ryanwilson and others added 2 commits March 25, 2026 22:03
…age.dart

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@ryanwilson ryanwilson requested a review from cynthiajoan March 26, 2026 10:45
@ryanwilson ryanwilson marked this pull request as ready for review March 26, 2026 10:45
GoogleMapsGroundingChunk({this.uri, this.title, this.placeId});

/// The URI of the place.
final String? uri;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does dart have a URL type and would that be more idiomatic?

Copy link
Member Author

@ryanwilson ryanwilson Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe so - this is copying Google Search Grounding's same uri parameter

/// The URI of the retrieved web page.
  final String? uri;

CitationMetadata,
Citation,
GoogleMapsGroundingChunk,
GroundingChunk,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why adding GroundingChunk here? Was it missed before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe so but I'll defer to @cynthiajoan on if that should be here or not

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open question on if WebGroundingChunk also needs to be exposed (separately maybe?)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since they are on the receiving side, developer usually don't have the necessity to construct them. But it also would not hurt if they need to take it as an entity and pass it around on the user side. I would say let's add all three in this change.

@cynthiajoan cynthiajoan changed the title feat(ai): add Google Maps Grounding support feat(firebaseai): add Google Maps Grounding support Mar 27, 2026
expect(model, isA<GenerativeModel>());
});

// ... other tests (e.g., with different parameters)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol let's remove this line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants