-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Firebase AI] Add URLContext tool
#15221
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Generated by 🚫 Danger |
98bb902 to
f089a87
Compare
|
/gemini summarize |
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Andrew Heard <andrewheard@google.com>
b47609f to
a6e0ce8
Compare
|
Going to merge here and rely on a future PR to update the Changelog with a documentation link. |
paulb777
approved these changes
Sep 23, 2025
peterfriese
pushed a commit
that referenced
this pull request
Oct 7, 2025
Co-authored-by: Paul Beusterien <paulbeusterien@google.com> Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added support for the
URLContexttool which allows developers to provide additional context to the models in the form of URLs.TODO: A subsequent PR(or CL) should update the changelog with a link to the docs.
Summary of Changes
This pull request integrates the
URLContexttool into the Firebase AI SDK, enabling Gemini models to utilize external web content from provided URLs to enrich their responses. This feature enhances the model's ability to understand and generate content based on real-world information, making it more versatile for various applications. The changes involve adding new data models for URL context, updating response structures to include this metadata, and ensuring robust error handling and logging for URL retrieval processes.Highlights
URLContexttool, allowing developers to provide public web URLs as additional context to Gemini models for more informed responses.URLContext,URLContextMetadata, andURLMetadatastructs to handle URL-based context information within the API.GenerateContentResponseandCandidatestructs now includeurlContextMetadataand new token count properties (toolUsePromptTokenCount,toolUsePromptTokensDetails) for better usage tracking.AILog.MessageCode(urlMetadataUnrecognizedURLRetrievalStatus) has been added for improved logging related to URL retrieval status.URLContexttool across different scenarios, including successful retrievals, mixed validity, and streaming responses.Changelog
urlMetadataUnrecognizedURLRetrievalStatustoAILog.MessageCode.toolUsePromptTokenCountandtoolUsePromptTokensDetailstoUsageMetadata.urlContextMetadatatoCandidateand its initializer.Decodableconformance forUsageMetadataandCandidateto handle new fields.urlContextproperty toToolstruct.Tool.urlContext()to create aURLContexttool.URLContextstruct.URLContextMetadatastruct and itsDecodableconformance.URLMetadatastruct,URLRetrievalStatusenum, and itsDecodableconformance.generateContent_withURLContext_succeedsto verify the functionality.generateContent_success_urlContext,generateContent_success_urlContext_mixedValidity, andtestGenerateContentStream_success_urlContext.generateContent_success_urlContext,generateContent_success_urlContext_mixedValidity,testGenerateContent_success_urlContext_retrievedURLPresentOnErrorStatus, andtestGenerateContentStream_success_urlContext.requestHandlerguard statement for clarity.CandidatewithurlContextMetadata.Activity
/gemini summarizecommand.