Skip to main content

ImageEmbeddingModel

Trait ImageEmbeddingModel 

Source
pub trait ImageEmbeddingModel:
    Clone
    + WasmCompatSend
    + WasmCompatSync {
    const MAX_DOCUMENTS: usize;

    // Required methods
    fn ndims(&self) -> usize;
    fn embed_images(
        &self,
        images: impl IntoIterator<Item = Vec<u8>> + WasmCompatSend,
    ) -> impl Future<Output = Result<Vec<Embedding>, EmbeddingError>> + Send;

    // Provided method
    fn embed_image<'a>(
        &'a self,
        bytes: &'a [u8],
    ) -> impl Future<Output = Result<Embedding, EmbeddingError>> + WasmCompatSend { ... }
}
Expand description

Trait for embedding models that can generate embeddings for images.

Required Associated Constants§

Source

const MAX_DOCUMENTS: usize

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

Required Methods§

Source

fn ndims(&self) -> usize

The number of dimensions in the embedding vector.

Source

fn embed_images( &self, images: impl IntoIterator<Item = Vec<u8>> + WasmCompatSend, ) -> impl Future<Output = Result<Vec<Embedding>, EmbeddingError>> + Send

Embed multiple images in a single request from bytes.

Implementations should preserve input order in the returned embeddings.

Provided Methods§

Source

fn embed_image<'a>( &'a self, bytes: &'a [u8], ) -> impl Future<Output = Result<Embedding, EmbeddingError>> + WasmCompatSend

Embed a single image from bytes.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§