Skip to content

feat(gemini): Phase 5 -- embeddings (embedContent)#1664

Merged
bug-ops merged 2 commits intomainfrom
feat-gemini-phase-5-embeddings
Mar 13, 2026
Merged

feat(gemini): Phase 5 -- embeddings (embedContent)#1664
bug-ops merged 2 commits intomainfrom
feat-gemini-phase-5-embeddings

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 13, 2026

Closes #1597
Part of #1592

Summary

  • Add embedding_model: Option<String> to GeminiConfig (configurable via [llm.gemini] embedding_model = "text-embedding-004")
  • Implement embed() in GeminiProvider calling POST /v1beta/models/{model}:embedContent with taskType: RETRIEVAL_QUERY
  • supports_embeddings() returns true when embedding_model is configured
  • API key sent via x-goog-api-key header (consistent with other endpoints)
  • Error handling via existing parse_gemini_error() — 429 RESOURCE_EXHAUSTED maps to LlmError::RateLimited
  • Retry logic via send_with_retry() — consistent with all other send_* methods
  • 17 unit tests with wiremock covering: happy path, EmbedUnsupported, 4xx, 429 rate limit, 500 error, malformed response, builder guards, list_models inclusion

Test plan

  • cargo +nightly fmt --check passes
  • cargo clippy --workspace --features full -- -D warnings passes (0 warnings)
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins — 5250 passed

@github-actions github-actions Bot added documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes enhancement New feature or request core zeph-core crate size/L Large PR (201-500 lines) labels Mar 13, 2026
@bug-ops bug-ops force-pushed the feat-gemini-phase-5-embeddings branch from 52917fc to 76f2919 Compare March 13, 2026 18:08
@bug-ops bug-ops enabled auto-merge (squash) March 13, 2026 18:08
bug-ops added 2 commits March 13, 2026 19:21
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
@bug-ops bug-ops force-pushed the feat-gemini-phase-5-embeddings branch from 76f2919 to a492d46 Compare March 13, 2026 18:21
@bug-ops bug-ops merged commit f0ab9f4 into main Mar 13, 2026
15 checks passed
@bug-ops bug-ops deleted the feat-gemini-phase-5-embeddings branch March 13, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/L Large PR (201-500 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(gemini): Phase 5 -- embeddings (embedContent)

1 participant