Skip to main content

TextEmbedder

Trait TextEmbedder 

Source
pub trait TextEmbedder: Send + Sync {
    // Required method
    fn embed(&self, text: &str) -> Result<Embedding, EmbedderError>;
}
Expand description

Turns free-form text into an Embedding suitable for projection through the sphereQL pipeline.

Implement on a newtype that owns the embedder’s state (HTTP client, tokenizer, model weights). The trait is Send + Sync so a single embedder can be shared across async request handlers via Arc<dyn TextEmbedder>.

Required Methods§

Source

fn embed(&self, text: &str) -> Result<Embedding, EmbedderError>

Embed a text query.

Returns an Embedding whose dimensionality must match whatever pipeline the result will be fed into. Implementations should surface upstream failures as EmbedderError::Embedding rather than panicking.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T: TextEmbedder + ?Sized> TextEmbedder for Arc<T>

Source§

impl<T: TextEmbedder + ?Sized> TextEmbedder for Box<T>

Implementors§