-
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
Open
andrewheard
wants to merge
13
commits into
main
Choose a base branch
from
ah/firebaseai-urlcontext
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+428
−5
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 <[email protected]>
b47609f
to
a6e0ce8
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
URLContext
tool which allows developers to provide additional context to the models in the form of URLs.Summary of Changes
This pull request integrates the
URLContext
tool 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
URLContext
tool, allowing developers to provide public web URLs as additional context to Gemini models for more informed responses.URLContext
,URLContextMetadata
, andURLMetadata
structs to handle URL-based context information within the API.GenerateContentResponse
andCandidate
structs now includeurlContextMetadata
and new token count properties (toolUsePromptTokenCount
,toolUsePromptTokensDetails
) for better usage tracking.AILog.MessageCode
(urlMetadataUnrecognizedURLRetrievalStatus
) has been added for improved logging related to URL retrieval status.URLContext
tool across different scenarios, including successful retrievals, mixed validity, and streaming responses.Changelog
urlMetadataUnrecognizedURLRetrievalStatus
toAILog.MessageCode
.toolUsePromptTokenCount
andtoolUsePromptTokensDetails
toUsageMetadata
.urlContextMetadata
toCandidate
and its initializer.Decodable
conformance forUsageMetadata
andCandidate
to handle new fields.urlContext
property toTool
struct.Tool.urlContext()
to create aURLContext
tool.URLContext
struct.URLContextMetadata
struct and itsDecodable
conformance.URLMetadata
struct,URLRetrievalStatus
enum, and itsDecodable
conformance.generateContent_withURLContext_succeeds
to 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
.requestHandler
guard statement for clarity.Candidate
withurlContextMetadata
.Activity
/gemini summarize
command.