Trait EmbedderExt

Source
pub trait EmbedderExt: Embedder {
    // Provided methods
    fn into_any_embedder(self) -> DynEmbedder
       where Self: Sized,
             Self::Error: Error { ... }
    fn embed(
        &self,
        input: impl ToString,
    ) -> impl Future<Output = Result<Embedding, Self::Error>> + Send { ... }
    fn embed_query(
        &self,
        input: impl ToString,
    ) -> impl Future<Output = Result<Embedding, Self::Error>> + Send { ... }
    fn embed_batch(
        &self,
        inputs: impl IntoIterator<Item = impl ToString>,
    ) -> impl Future<Output = Result<Vec<Embedding>, Self::Error>> + Send { ... }
    fn embed_batch_for(
        &self,
        inputs: impl IntoIterator<Item = EmbeddingInput>,
    ) -> impl Future<Output = Result<Vec<Embedding>, Self::Error>> + Send { ... }
}
Expand description

An extension trait for Embedder with helper methods for iterators, and types that can be converted into a string.

This trait is automatically implemented for any item that implements Embedder.

Provided Methods§

Source

fn into_any_embedder(self) -> DynEmbedder
where Self: Sized, Self::Error: Error,

Convert this embedder into an embedder trait object.

Source

fn embed( &self, input: impl ToString, ) -> impl Future<Output = Result<Embedding, Self::Error>> + Send

Embed some text into a vector space

Source

fn embed_query( &self, input: impl ToString, ) -> impl Future<Output = Result<Embedding, Self::Error>> + Send

Embed a query into a vector space

Source

fn embed_batch( &self, inputs: impl IntoIterator<Item = impl ToString>, ) -> impl Future<Output = Result<Vec<Embedding>, Self::Error>> + Send

Embed a batch of text into a vector space. Returns a list of embeddings in the same order as the inputs.

Source

fn embed_batch_for( &self, inputs: impl IntoIterator<Item = EmbeddingInput>, ) -> impl Future<Output = Result<Vec<Embedding>, Self::Error>> + Send

Embed a batch of EmbeddingInput into a vector space. Returns a list of embeddings in the same order as the inputs.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§