feat: support native Gemini text embeddings - #4350
Merged
Merged
Conversation
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🔴 CRITICAL
| if !ok || dims <= 0 || dims > math.MaxInt32 { | ||
| return nil, fmt.Errorf("provider_opts.%s must be a positive integer, got %v", outputDimensionalityOpt, c.ModelConfig.ProviderOpts[outputDimensionalityOpt]) | ||
| } | ||
| config.OutputDimensionality = new(int32(dims)) |
Contributor
There was a problem hiding this comment.
[high] new(int32(dims)) is a Go compilation error — new requires a type, not a value expression
The embedConfig() function passes a type-conversion expression to new, which Go's type system rejects at compile time. new(T) requires T to be a type literal; int32(dims) is a value expression, not a type. The Go compiler confirms this: int32(dims) is not a type. This prevents the entire gemini package from building, so any attempt to use output_dimensionality in provider_opts will result in a build failure.
Suggested change
| config.OutputDimensionality = new(int32(dims)) | |
| v := int32(dims) | |
| config.OutputDimensionality = &v |
| Confidence | Score |
|---|---|
| 🟢 strong | 100/100 |
dgageot
marked this pull request as ready for review
September 17, 2026 17:06
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
Implements CreateEmbedding/CreateBatchEmbedding via batchEmbedContents (Vertex single-input path), output_dimensionality provider_opt, and ordering/cardinality/dimension validation. Adds docs, schema update, and examples/rag/gemini_embeddings.yaml. Assisted-By: docker-agent Signed-off-by: David Gageot <david.gageot@docker.com>
dgageot
force-pushed
the
feat/gemini-text-embeddings
branch
from
September 18, 2026 08:29
c543b6f to
d3ae193
Compare
aheritier
approved these changes
Sep 18, 2026
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.
Google's genai SDK exposes a dedicated embeddings API that is meaningfully different from the generic chat path, and wiring it up properly enables RAG use-cases on Gemini without routing through a chat model or falling back to zero-vectors. This PR adds that native embedding support to the Gemini provider.
The implementation lives in
pkg/model/provider/gemini/embed.goand handles both the direct (batchEmbedContents) and gateway (predict/Embedding2) transport paths. Single and batch embedding share the same entry point; responses are reordered to match input order so callers never see shuffled results. Input validation rejects empty slices, cardinality mismatches, and unexpected dimension counts early, and the existing retry/error plumbing from the rest of the Gemini provider is reused unchanged.output_dimensionalityis exposed as an optional config field in the schema and thelatestconfig package. A worked RAG example (examples/rag/gemini_embeddings.yaml) and updated provider and RAG docs show how to wire it together.Embeddings are only invoked when the configured backend supplies them; nothing changes for chat, multimodal, default model selection, or task-type prefixes. Switching embedding model or dimensions requires a full reindex — this is called out in the docs. No live paid API calls are made in tests; coverage is via targeted unit and race tests against the Gemini and RAG packages.