Embedder

Trait Embedder 

Source
pub trait Embedder: Send + Sync {
    // Required methods
    fn model_name(&self) -> &str;
    fn dimension(&self) -> usize;
    fn max_tokens(&self) -> usize;
    fn modalities(&self) -> &[Modality];
    fn embed_text<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        texts: &'life1 [&'life2 str],
        config: &'life3 EmbeddingConfig,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<EmbeddingOutput>, EmbedError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;

    // Provided methods
    fn embed_image<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _image_data: &'life1 [u8],
        _config: &'life2 EmbeddingConfig,
    ) -> Pin<Box<dyn Future<Output = Result<EmbeddingOutput, EmbedError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn embed_query<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        query: &'life1 str,
        config: &'life2 EmbeddingConfig,
    ) -> Pin<Box<dyn Future<Output = Result<EmbeddingOutput, EmbedError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

Trait for generating embeddings.

Required Methods§

Source

fn model_name(&self) -> &str

Model name/identifier.

Source

fn dimension(&self) -> usize

Embedding dimension.

Source

fn max_tokens(&self) -> usize

Maximum tokens per input.

Source

fn modalities(&self) -> &[Modality]

Supported modalities.

Source

fn embed_text<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, texts: &'life1 [&'life2 str], config: &'life3 EmbeddingConfig, ) -> Pin<Box<dyn Future<Output = Result<Vec<EmbeddingOutput>, EmbedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Embed text content.

Provided Methods§

Source

fn embed_image<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _image_data: &'life1 [u8], _config: &'life2 EmbeddingConfig, ) -> Pin<Box<dyn Future<Output = Result<EmbeddingOutput, EmbedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Embed image content.

Source

fn embed_query<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, query: &'life1 str, config: &'life2 EmbeddingConfig, ) -> Pin<Box<dyn Future<Output = Result<EmbeddingOutput, EmbedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Embed a query (may use different instruction).

Implementors§