EmbeddingProvider

Trait EmbeddingProvider 

Source
pub trait EmbeddingProvider: Send + Sync {
    type Config: ProviderConfig;
    type Error: ProviderError;

    // Required method
    fn embed<'life0, 'life1, 'async_trait>(
        &'life0 self,
        texts: &'life1 [String],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Embedding>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Trait for providers that support text embeddings.

This is a separate capability from chat/completion as not all providers support embeddings, and embedding-only providers don’t need chat capabilities.

Required Associated Types§

Source

type Config: ProviderConfig

Provider-specific configuration type

Source

type Error: ProviderError

Provider-specific error type

Required Methods§

Source

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

Generate embeddings for the given texts.

§Arguments
  • texts - The texts to generate embeddings for
§Returns

A result containing the embeddings or an error

Implementors§