EmbeddingModel

Trait EmbeddingModel 

Source
pub trait EmbeddingModel: WasmCompatSend + WasmCompatSync {
    type Client;

    const MAX_DOCUMENTS: usize;

    // Required methods
    fn make(
        client: &Self::Client,
        model: impl Into<String>,
        dims: Option<usize>,
    ) -> Self;
    fn ndims(&self) -> usize;
    fn embed_texts(
        &self,
        texts: impl IntoIterator<Item = String> + WasmCompatSend,
    ) -> impl Future<Output = Result<Vec<Embedding>, EmbeddingError>> + WasmCompatSend;

    // Provided method
    fn embed_text(
        &self,
        text: &str,
    ) -> impl Future<Output = Result<Embedding, EmbeddingError>> + WasmCompatSend { ... }
}
Expand description

Trait for embedding models that can generate embeddings for documents.

Required Associated Constants§

Source

const MAX_DOCUMENTS: usize

The maximum number of documents that can be embedded in a single request.

Required Associated Types§

Required Methods§

Source

fn make( client: &Self::Client, model: impl Into<String>, dims: Option<usize>, ) -> Self

Source

fn ndims(&self) -> usize

The number of dimensions in the embedding vector.

Source

fn embed_texts( &self, texts: impl IntoIterator<Item = String> + WasmCompatSend, ) -> impl Future<Output = Result<Vec<Embedding>, EmbeddingError>> + WasmCompatSend

Embed multiple text documents in a single request

Provided Methods§

Source

fn embed_text( &self, text: &str, ) -> impl Future<Output = Result<Embedding, EmbeddingError>> + WasmCompatSend

Embed a single text document.

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§

Source§

impl<T> EmbeddingModel for rig::providers::azure::EmbeddingModel<T>

Source§

impl<T> EmbeddingModel for rig::providers::cohere::embeddings::EmbeddingModel<T>

Source§

impl<T> EmbeddingModel for rig::providers::gemini::embedding::EmbeddingModel<T>
where T: Clone + HttpClientExt,

Source§

impl<T> EmbeddingModel for rig::providers::mistral::embedding::EmbeddingModel<T>
where T: HttpClientExt + Clone,

Source§

impl<T> EmbeddingModel for rig::providers::ollama::EmbeddingModel<T>
where T: HttpClientExt + Clone + 'static,

Source§

impl<T> EmbeddingModel for rig::providers::openai::embedding::EmbeddingModel<T>
where T: HttpClientExt + Clone + Debug + Default + Send + 'static,

Source§

impl<T> EmbeddingModel for rig::providers::together::embedding::EmbeddingModel<T>
where T: HttpClientExt + Default + Clone + Send + 'static,

Source§

impl<T> EmbeddingModel for rig::providers::voyageai::EmbeddingModel<T>
where T: HttpClientExt + Clone + Debug + Default + 'static,