Embedder

Trait Embedder 

Source
pub trait Embedder: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn embed<'life0, 'async_trait>(
        &'life0 self,
        texts: Vec<String>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn dimensions(&self) -> usize;
    fn test_connection<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<ConnectionTestResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn generate_with_prompt<'life0, 'async_trait>(
        &'life0 self,
        _text: String,
        _system_prompt: String,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Trait for embedding providers

Implement this trait to add support for additional embedding APIs.

Required Methods§

Source

fn name(&self) -> &str

Get the name of this embedder

Source

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

Generate embeddings for a batch of texts

Source

fn dimensions(&self) -> usize

Get the dimensions of the embeddings

Source

fn test_connection<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<ConnectionTestResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Test the connection to the embedding service

Provided Methods§

Source

fn generate_with_prompt<'life0, 'async_trait>( &'life0 self, _text: String, _system_prompt: String, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Optional: Generate text with prompt (for LLM features)

Implementors§