fix(genkit_google_genai)!: wire seed and fileSearch into the request - #393
Draft
cabljac wants to merge 6 commits into
Draft
fix(genkit_google_genai)!: wire seed and fileSearch into the request#393cabljac wants to merge 6 commits into
cabljac wants to merge 6 commits into
Conversation
…egory and threshold
…stead of sending UNSPECIFIED Unset category fell back to HARM_CATEGORY_UNSPECIFIED on the wire, which the API rejects with 400 INVALID_ARGUMENT. Filter those entries out and pass threshold through as-is, omitting it when unset so the server default applies. Fixes #365
…ission on the wire
seed was accepted by GeminiOptions and GeminiTtsOptions but never mapped into GenerationConfig; fileSearch was accepted but never added to tools. Map seed in toGeminiSettings and toGeminiTtsSettings, add a FileSearch tool member to the generated client (hand-authored via schemaOverrides, since the discovery doc has no Tool schema) and pass the config through at both toGeminiTools call sites. Align the FileSearch config schema with the JS plugin: fileSearchStoreNames is now required, metadataFilter and topK added. Fixes #363 BREAKING CHANGE: the exported FileSearch() constructor now requires fileSearchStoreNames, and its getter is non-nullable (previously both were optional/nullable).
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces support for the fileSearch tool and the seed generation configuration option across the genkit_google_genai package, including updates to plugins, generated client code, schema definitions, and corresponding unit tests. The feedback suggests an improvement in common_plugin.dart to directly instantiate gcl.FileSearch using its constructor rather than serializing and deserializing via JSON, which enhances type safety and avoids unnecessary runtime overhead.
…ON round trip The generated FileSearch extension type has a named-argument constructor whose map literal uses null-aware entries, so unset optional fields are omitted rather than sent as explicit nulls. Constructing it directly type checks each field and builds a fresh map, where FileSearch.fromJson wrapped the caller's own options map and forwarded any explicit null in it to the wire.
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.
Fixes #363. Stacked on #392 (targets
fix/googlegenai-safety-settings-unset).seedandfileSearchwere accepted byGeminiOptions/GeminiTtsOptionsbut silently dropped when building the request. This wires both:seedis mapped intoGenerationConfigin both settings builders, andfileSearchbecomes a tool entry - the generated client's hand-authoredTooltype gains afileSearchmember viaschemaOverrides(the discovery doc has no Tool schema), with the config passed through verbatim, matching the JS plugin. Wire-level tests cover both the standard and TTS paths and pin omission when unset.The
FileSearchconfig schema is aligned with the JS plugin, which is a breaking change to the exportedFileSearchAPI:fileSearchStoreNamesis now required and non-nullable;metadataFilterandtopKare added.Caveat: fileSearch is a Google AI-only feature reachable from the shared
GeminiOptionsschema; Vertex callers setting it will get the API's error. Flagging the schema layering question for maintainers.