pub trait EmbeddingProvider: Send + Sync {
// Required methods
fn embed_documents<'life0, 'async_trait>(
&'life0 self,
texts: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn dimensions(&self) -> usize;
fn model_name(&self) -> &str;
fn provider_name(&self) -> &str;
// Provided methods
fn embed_query<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<f32>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn max_batch_size(&self) -> usize { ... }
fn embed_documents_batched<'life0, 'async_trait>(
&'life0 self,
texts: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Trait for embedding generation providers
Implementors generate vector embeddings from text, supporting both single queries and batch document processing.
Required Methods§
Sourcefn embed_documents<'life0, 'async_trait>(
&'life0 self,
texts: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn embed_documents<'life0, 'async_trait>(
&'life0 self,
texts: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn dimensions(&self) -> usize
fn dimensions(&self) -> usize
Get the embedding dimension size
Sourcefn model_name(&self) -> &str
fn model_name(&self) -> &str
Get the model name/identifier
Sourcefn provider_name(&self) -> &str
fn provider_name(&self) -> &str
Get the provider name (e.g., “fastembed”, “openai”, “ollama”)
Provided Methods§
Sourcefn embed_query<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<f32>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn embed_query<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<f32>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Generate embedding for a single query
Some providers optimize query embeddings differently than document embeddings. By default, this calls embed_documents with a single item.
§Arguments
text- The query text to embed
Sourcefn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check if the provider is available (API key set, server running, etc.)
Sourcefn max_batch_size(&self) -> usize
fn max_batch_size(&self) -> usize
Get the maximum batch size for embed_documents