feat(gemini): Phase 5 -- embeddings (embedContent)#1664
Merged
Conversation
52917fc to
76f2919
Compare
Add embedContent support to GeminiProvider:
- GeminiConfig gains optional `embedding_model` field
- `supports_embeddings()` returns true when embedding_model is set
- `embed()` calls POST /v1beta/models/{model}:embedContent?key=...
with taskType=RETRIEVAL_QUERY
- Error handling reuses parse_gemini_error() -- 429 RESOURCE_EXHAUSTED
maps to LlmError::RateLimited
- Empty string rejected in with_embedding_model()
- Configured embedding model included in list_models()
- Bootstrap wires embedding_model at primary provider creation sites
- 14 unit + HTTP tests via spawn_mock_server, 1 ignored integration test
Part of epic #1592.
- Use x-goog-api-key header instead of ?key= query param (SEC-EMBED-01) - Replace direct .send() with send_with_retry() and pre-serialized body (PERF-EMBED-01) - Remove undeclared #[cfg(feature = "integration")] gate from integration test (IMPL-1) - Fix gemini_embed_api_error_429 test to supply MAX_RETRIES+1 mock responses
76f2919 to
a492d46
Compare
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.
Closes #1597
Part of #1592
Summary
embedding_model: Option<String>toGeminiConfig(configurable via[llm.gemini] embedding_model = "text-embedding-004")embed()inGeminiProvidercallingPOST /v1beta/models/{model}:embedContentwithtaskType: RETRIEVAL_QUERYsupports_embeddings()returnstruewhenembedding_modelis configuredx-goog-api-keyheader (consistent with other endpoints)parse_gemini_error()— 429 RESOURCE_EXHAUSTED maps toLlmError::RateLimitedsend_with_retry()— consistent with all other send_* methodsTest plan
cargo +nightly fmt --checkpassescargo clippy --workspace --features full -- -D warningspasses (0 warnings)cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins— 5250 passed