feat: enhance GoogleClient to include grounding and URL context metadata#104
Open
rasphlat wants to merge 1 commit intodatapizza-labs:mainfrom
Open
feat: enhance GoogleClient to include grounding and URL context metadata#104rasphlat wants to merge 1 commit intodatapizza-labs:mainfrom
rasphlat wants to merge 1 commit intodatapizza-labs:mainfrom
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
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.
Add
grounding_metadataandurl_context_metadatato Google Client ResponseSummary
This PR exposes
grounding_metadataandurl_context_metadatafrom Google's API response as dynamic attributes onClientResponsewhen usinginvoke()ora_invoke(). These metadata objects are only added when present and non-empty.Motivation
When using Google's grounding tools (Google Search, Google Maps, URL Context), the API returns rich metadata that enables building citation experiences, verifying sources, and understanding how the model grounded its response. Previously, this metadata was discarded.
Supported Tools
🔍 Google Search Grounding
When using
google_search, thegrounding_metadataprovides:web_search_queries: The search queries the model executedgrounding_chunks: Web sources with URIs and titlesgrounding_supports: Maps text segments to source citations (enables inline citations)search_entry_point: HTML/CSS for rendering search suggestionsDocumentation
🗺️ Google Maps Grounding
When using
google_maps, thegrounding_metadatacontains location-based grounding information from Google Maps data, enabling place-aware responses with verifiable sources.Documentation
🔗 URL Context Tool
When using
url_context, theurl_context_metadataprovides:url_metadata: Array of retrieved URLs with their retrieval status (URL_RETRIEVAL_STATUS_SUCCESS, etc.)This helps verify which URLs were successfully fetched and used to ground the response.
Documentation
Usage
Notes
types.GroundingMetadata,types.UrlContextMetadata)hasattr()to check for presence before accessinginvoke()anda_invoke()methods