-
Notifications
You must be signed in to change notification settings - Fork 46
[FirebaseAI] Add support for Grounding with Google Search #1285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @dlarocque, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a significant new capability to the Firebase AI SDK: support for grounding AI model responses with Google Search. This allows the model to leverage up-to-date information from the web to enhance its generations. The changes involve both configuring the model to use Google Search as a tool and providing rich, structured grounding metadata within the model's responses. Comprehensive tests have been added to validate this new functionality and the parsing of its associated data structures.
Highlights
- New Feature: Google Search Grounding: I've added support for grounding AI model responses with Google Search. This includes a new
GoogleSearch
tool that can be included in the generation configuration to enable this functionality. - Grounding Metadata in Responses: The
Candidate
response object now includesGroundingMetadata
. This new structure provides detailed information about how the model's response is grounded, includingWebSearchQueries
,GroundingChunks
(retrieved content),GroundingSupports
(links between response segments and chunks), andSearchEntryPoint
(an HTML/CSS snippet for a Google Search entry point). - Enhanced Tool Configuration: The
Tool
class has been updated to flexibly support both traditional function declarations and the newGoogleSearch
grounding tool, allowing for diverse model configurations. - Comprehensive Testing: I've added extensive tests for the new grounding feature. This includes an integration test (
TestSearchGrounding
) and several unit tests (InternalTestVertexAIGrounding
,InternalTestGoogleAIGrounding
, etc.) to validate the parsing and behavior of grounding metadata from various mock responses. - Code Clarity Improvement & Mock Data Update: For improved clarity, I've renamed the
Functions
property toFunctionDeclarations
within theTool
struct. Additionally, the commit hash for the external mock response data repository has been updated to ensure the latest grounding mock responses are used for testing, and a minor fix was applied to a citations test due to a mock response change.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
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 is currently in preview and 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 to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this 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 support for Grounding with Google Search. I've suggested using JsonParseOptions.ThrowEverything
for stricter JSON parsing and using Any()
to improve the correctness of assertions in a new test case.
Description
Adds support for Grounding with Google Search. This includes adding a new
GoogleSearch
tool to include in the generation config, and theGroundingMetadata
which is populated for grounded results.Stray changes:
Functions
inTool
toFunctionsDeclarations
- I think it's more clear.API proposal: go/fal-grounding-api (internal)
Testing
Added new tests in the sample app, including an integration test and unit tests against the mock responses.
Type of Change