pub trait Embedder: Send + Sync {
// Required methods
fn dimension(&self) -> usize;
fn embed(&self, text: &str) -> Result<Vec<f32>>;
fn model_name(&self) -> &str;
// Provided method
fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>> { ... }
}Expand description
Trait for generating embeddings from text
Implementations can use:
- Local models (e.g., sentence-transformers, embeddinggemma)
- Remote APIs (e.g., OpenAI, Cohere)
- Mock implementations for testing
Required Methods§
Sourcefn model_name(&self) -> &str
fn model_name(&self) -> &str
Get the model name/identifier