EmbeddingProviderTrait

Trait EmbeddingProviderTrait 

Source
pub trait EmbeddingProviderTrait: Send + Sync {
    // Required methods
    fn generate_embedding<'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 generate_embeddings<'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 embedding_dimensions(&self) -> usize;
    fn max_tokens(&self) -> usize;
    fn name(&self) -> &'static str;
    fn is_available<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Embedding provider trait

Required Methods§

Source

fn generate_embedding<'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 text

Source

fn generate_embeddings<'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 multiple texts

Source

fn embedding_dimensions(&self) -> usize

Get embedding dimensions

Source

fn max_tokens(&self) -> usize

Get maximum tokens for embedding

Source

fn name(&self) -> &'static str

Get provider name

Source

fn is_available<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if provider is available

Implementors§