pub trait EmbeddingProvider: Send + Sync {
// Required methods
fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, EmbeddingError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn embed_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, EmbeddingError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn dimensions(&self) -> usize;
fn name(&self) -> &'static str;
fn is_simulation(&self) -> bool;
}Expand description
Trait for embedding providers.
TigerStyle: Unified interface for simulation and production.
All providers implement this trait, allowing higher-level components to work with any provider without knowing the concrete type.
§Example
use umi_memory::embedding::{EmbeddingProvider, SimEmbeddingProvider};
async fn generate_embedding<P: EmbeddingProvider>(provider: &P, text: &str) -> Vec<f32> {
provider.embed(text).await.unwrap()
}Required Methods§
Sourcefn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, EmbeddingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, EmbeddingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn embed_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, EmbeddingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn embed_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, EmbeddingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sourcefn dimensions(&self) -> usize
fn dimensions(&self) -> usize
Get the embedding dimensions (e.g., 1536 for text-embedding-3-small).
Sourcefn is_simulation(&self) -> bool
fn is_simulation(&self) -> bool
Check if this is a simulation provider.
Returns true for SimEmbeddingProvider, false for real providers.