Skip to main content

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".

Implementors§

Source§

impl<T> EmbeddingModel for rig_extra::providers::gemini::EmbeddingModel<T>
where T: Clone + HttpClientExt + 'static,

Source§

impl<T> EmbeddingModel for rig_extra::providers::mistral::EmbeddingModel<T>
where T: HttpClientExt + Clone + 'static,

Source§

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

Source§

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

Source§

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

Source§

impl<T> EmbeddingModel for rig_extra::providers::openrouter::EmbeddingModel<T>
where T: HttpClientExt + Clone + Debug + Default + WasmCompatSend + 'static,

Source§

impl<T> EmbeddingModel for rig_extra::providers::cohere::EmbeddingModel<T>

Source§

impl<T> EmbeddingModel for rig_extra::providers::azure::EmbeddingModel<T>
where T: HttpClientExt + Default + Clone + 'static,

Source§

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