Skip to main content

Embedder

Trait Embedder 

Source
pub trait Embedder: Send + Sync {
    // Required methods
    fn embed<'a>(&'a self, text: &'a str) -> EmbedFuture<'a>;
    fn embed_batch<'a>(&'a self, texts: Vec<String>) -> EmbedBatchFuture<'a>;
    fn model_name(&self) -> &str;
    fn dimensions(&self) -> usize;
}
Expand description

Trait for embedding text into vectors.

Implement this to swap embedding providers.

Required Methods§

Source

fn embed<'a>(&'a self, text: &'a str) -> EmbedFuture<'a>

Embed a single text. Returns a vector of f32.

Source

fn embed_batch<'a>(&'a self, texts: Vec<String>) -> EmbedBatchFuture<'a>

Embed multiple texts in a batch.

Takes owned strings to avoid lifetime issues across async boundaries.

Source

fn model_name(&self) -> &str

The model name this embedder uses.

Source

fn dimensions(&self) -> usize

Expected embedding dimensions.

Implementors§