Skip to content

Commit 01487a6

Browse files
ruvnetclaude
andcommitted
feat(embeddings): Add pluggable embedding provider system for AgenticDB
Implements a proper embedding abstraction layer to replace the hash-based placeholder: ## New Features ### EmbeddingProvider Trait - Pluggable interface for any embedding system - Methods: embed(), dimensions(), name() - Thread-safe (Send + Sync) ### Built-in Providers - **HashEmbedding**: Original placeholder (default, backward compatible) - **ApiEmbedding**: Production-ready API providers (OpenAI, Cohere, Voyage AI) - **CandleEmbedding**: Stub for candle-transformers (feature: real-embeddings) ### AgenticDB Updates - New constructor: `AgenticDB::with_embedding_provider(options, provider)` - Backward compatible: `AgenticDB::new(options)` still works with HashEmbedding - Dimension validation ensures provider matches database configuration ### Files Added - src/embeddings.rs: Core embedding provider system - tests/embeddings_test.rs: Comprehensive test suite - docs/EMBEDDINGS.md: Complete usage documentation - examples/embeddings_example.rs: Working example ### Usage ```rust // Production (OpenAI) let provider = Arc::new(ApiEmbedding::openai(&key, "text-embedding-3-small")); let db = AgenticDB::with_embedding_provider(options, provider)?; ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent cce57de commit 01487a6

File tree

9 files changed

+1307
-82
lines changed

9 files changed

+1307
-82
lines changed

Cargo.lock

Lines changed: 73 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ruvector-core/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ once_cell = { workspace = true }
4343
chrono = { workspace = true }
4444
uuid = { workspace = true, features = ["v4"] }
4545

46+
# HTTP client for API embeddings
47+
reqwest = { version = "0.11", default-features = false, features = ["blocking", "json", "rustls-tls"] }
48+
4649
[dev-dependencies]
4750
criterion = { workspace = true }
4851
proptest = { workspace = true }
@@ -81,6 +84,7 @@ storage = ["redb", "memmap2"] # File-based storage (not available in WASM)
8184
hnsw = ["hnsw_rs"] # HNSW indexing (not available in WASM due to mmap dependency)
8285
memory-only = [] # Pure in-memory storage for WASM
8386
uuid-support = [] # Deprecated: uuid is now always included
87+
real-embeddings = [] # Feature flag for embedding provider API (use ApiEmbedding for production)
8488

8589
[lib]
8690
crate-type = ["rlib"]

0 commit comments

Comments
 (0)