Skip to main content

EmbeddingClient

Trait EmbeddingClient 

Source
pub trait EmbeddingClient: Send + Sync {
    // Required method
    fn get_embeddings<'life0, 'async_trait>(
        &'life0 self,
        values: Vec<String>,
        options: Option<EmbeddingGenerationOptions>,
    ) -> Pin<Box<dyn Future<Output = Result<GeneratedEmbeddings, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided method
    fn model(&self) -> Option<&str> { ... }
}
Expand description

The interface every embedding client implements.

Rust equivalent of upstream’s SupportsGetEmbeddings protocol / BaseEmbeddingClient (_clients.py): generate one embedding per input string, batched in a single request. Vectors are Vec<f32> — see the note on crate::types::Embedding about upstream’s genericity.

Required Methods§

Source

fn get_embeddings<'life0, 'async_trait>( &'life0 self, values: Vec<String>, options: Option<EmbeddingGenerationOptions>, ) -> Pin<Box<dyn Future<Output = Result<GeneratedEmbeddings, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Generate embeddings for the given values (one per value, in order).

Provided Methods§

Source

fn model(&self) -> Option<&str>

The default embedding model id for this client, if any.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T> EmbeddingClient for Arc<T>
where T: EmbeddingClient + ?Sized,

Blanket impl so Arc<dyn EmbeddingClient> and wrappers are usable as clients.

Source§

fn get_embeddings<'life0, 'async_trait>( &'life0 self, values: Vec<String>, options: Option<EmbeddingGenerationOptions>, ) -> Pin<Box<dyn Future<Output = Result<GeneratedEmbeddings, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Source§

fn model(&self) -> Option<&str>

Implementors§