pub trait EmbeddingModel: Send + Sync {
// Required methods
fn embed(
&self,
texts: &[&str],
) -> impl Future<Output = Result<Vec<Vec<f32>>>> + Send;
fn dimensions(&self) -> usize;
}Expand description
Trait for models that produce vector embeddings from text.
Implement this for your embedding provider, then use it with vector stores and RAG pipelines.
Required Methods§
Sourcefn embed(
&self,
texts: &[&str],
) -> impl Future<Output = Result<Vec<Vec<f32>>>> + Send
fn embed( &self, texts: &[&str], ) -> impl Future<Output = Result<Vec<Vec<f32>>>> + Send
Computes embeddings for one or more texts. Returns one vector per input.
Sourcefn dimensions(&self) -> usize
fn dimensions(&self) -> usize
Returns the dimensionality of the embedding vectors this model produces.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".