Skip to main content

EmbeddingService

Trait EmbeddingService 

Source
pub trait EmbeddingService: Send + Sync {
    // Required methods
    fn generate_embedding<'life0, 'life1, 'async_trait>(
        &'life0 self,
        text: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn generate_batch_embeddings<'life0, 'life1, 'async_trait>(
        &'life0 self,
        texts: Vec<&'life1 str>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, ContextError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn embedding_dimension(&self) -> usize;
    fn max_text_length(&self) -> usize;
}
Expand description

Embedding service trait for generating vector embeddings

Required Methods§

Source

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

Generate embedding for text content

Source

fn generate_batch_embeddings<'life0, 'life1, 'async_trait>( &'life0 self, texts: Vec<&'life1 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, ContextError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Generate embeddings for multiple texts in batch

Source

fn embedding_dimension(&self) -> usize

Get the dimension of embeddings produced by this service

Source

fn max_text_length(&self) -> usize

Get the maximum text length supported

Implementors§