Skip to main content

EmbeddingProvider

Trait EmbeddingProvider 

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

    // Provided method
    fn embed_one<'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 { ... }
}
Expand description

Port for text-to-vector embedding capability.

Required Methods§

Source

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

Embeds a batch of texts, returning vectors in input order.

Source

fn dimension(&self) -> usize

Expected vector dimension of this provider.

Source

fn model_name(&self) -> &str

Model name served by this provider.

Provided Methods§

Source

fn embed_one<'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,

Embeds a single text.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§