pub trait Embedder: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn embed<'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 test_connection<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ConnectionTestResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn generate_with_prompt<'life0, 'async_trait>(
&'life0 self,
_text: String,
_system_prompt: String,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Trait for embedding providers
Implement this trait to add support for additional embedding APIs.
Required Methods§
Sourcefn embed<'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<'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,
Generate embeddings for a batch of texts
Sourcefn dimensions(&self) -> usize
fn dimensions(&self) -> usize
Get the dimensions of the embeddings
Sourcefn test_connection<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ConnectionTestResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn test_connection<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<ConnectionTestResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Test the connection to the embedding service