Skip to main content

Embedder

Trait Embedder 

Source
pub trait Embedder: Send + Sync {
    // Required methods
    fn dims(&self) -> usize;
    fn embed<'life0, 'life1, 'async_trait>(
        &'life0 self,
        texts: &'life1 [String],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, ContextError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
}
Expand description

Turns texts into fixed-length vectors for a VectorStore. Object safe, so the model can be chosen at runtime as Arc<dyn Embedder>. embed returns one vector of dims() floats per input text, in order.

Required Methods§

Source

fn dims(&self) -> usize

Source

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

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Embedder for HttpEmbedder

Source§

fn dims(&self) -> usize

Source§

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

Source§

impl Embedder for LocalEmbedder

Source§

fn dims(&self) -> usize

Source§

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

Implementors§