feat(firebaseai): add Google Maps Grounding support#18144
feat(firebaseai): add Google Maps Grounding support#18144ryanwilson wants to merge 5 commits intomainfrom
Conversation
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
Using Gemini Code AssistThe 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
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 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. |
|
The Android test appears to be a flake |
|
/gemini review |
There was a problem hiding this comment.
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.
packages/firebase_ai/firebase_ai/example/lib/pages/grounding_page.dart
Outdated
Show resolved
Hide resolved
packages/firebase_ai/firebase_ai/example/lib/pages/grounding_page.dart
Outdated
Show resolved
Hide resolved
…age.dart Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
| GoogleMapsGroundingChunk({this.uri, this.title, this.placeId}); | ||
|
|
||
| /// The URI of the place. | ||
| final String? uri; |
There was a problem hiding this comment.
Does dart have a URL type and would that be more idiomatic?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Why adding GroundingChunk here? Was it missed before?
There was a problem hiding this comment.
I believe so but I'll defer to @cynthiajoan on if that should be here or not
There was a problem hiding this comment.
Open question on if WebGroundingChunk also needs to be exposed (separately maybe?)
There was a problem hiding this comment.
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.
| expect(model, isA<GenerativeModel>()); | ||
| }); | ||
|
|
||
| // ... other tests (e.g., with different parameters) |
There was a problem hiding this comment.
lol let's remove this line.




Introduces support for Google Maps Grounding to the firebase_ai SDK, establishing feature parity with other platforms.
API Changes:
Tool.googleMaps()factory andGoogleMapsclass.RetrievalConfigandLatLngfor dynamic location-based tool configurations.ToolConfigto include an optionalretrievalConfigproperty.GoogleMapsGroundingChunkto represent parsed Maps location properties (uri,title,placeId).GroundingChunkto expose the newmapsproperty alongsideweb.firebase_ai.dart.Example App:
grounding_page.dart) to the main navigation menu.Testing:
GoogleMapsGroundingChunk.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.yamland changelogs is not required.///).melos run analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?