feat: add support for Google Search grounding as a tool type for Gemini models #1641
+173
−2
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.
Description
Adds support for Google Search grounding 1 as a tool type for Gemini models, complementing the existing enterprise web search support added in #1526. Enterprise search and Google Search are two different tools in Vertex. See 2 for more details.
The implementation translates the google_search tool type to Gemini's GoogleSearch with support for all configuration options:
Response grounding metadata is already handled by the existing GroundingMetadata field from #1526.
Related Issues/PRs (if applicable)
Related PR: #1526
Special notes for reviewers (if applicable)
The config structs are prefixed with GCP (e.g., GCPGoogleSearchConfig, GCPTimeRangeFilter) to follow the existing pattern for vendor-specific extensions (GCPVertexAIVendorFields, GCPVertexAIGenerationConfig).
I'm not completely sure this is the right design pattern for tool options going forward. These fields are necessary to expose the full functionality of the underlying API, but adding vendor-specific config structs to the OpenAI schema does muddy the interface a bit. The alternative would be something more generic (e.g., map[string]any), but that loses type safety. Open to feedback on whether this approach makes sense or if we want to establish a different pattern for future tool configurations.