EmbeddingService

Trait EmbeddingService 

Source
pub trait EmbeddingService: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn dimension(&self) -> usize;
    fn embed<'life0, 'life1, 'async_trait>(
        &'life0 self,
        texts: &'life1 [String],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<EmbeddingVector>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn embed_single<'life0, 'life1, 'async_trait>(
        &'life0 self,
        text: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<EmbeddingVector>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Trait for embedding providers

Required Methods§

Source

fn name(&self) -> &str

Get the provider name

Source

fn dimension(&self) -> usize

Get embedding dimension

Source

fn embed<'life0, 'life1, 'async_trait>( &'life0 self, texts: &'life1 [String], ) -> Pin<Box<dyn Future<Output = Result<Vec<EmbeddingVector>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Generate embeddings for a batch of texts

Provided Methods§

Source

fn embed_single<'life0, 'life1, 'async_trait>( &'life0 self, text: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<EmbeddingVector>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Generate a single embedding

Implementors§