Skip to main content

Embedder

Trait Embedder 

Source
pub trait Embedder {
    // Required methods
    fn dimension(&self) -> usize;
    fn embed(&self, text: &str) -> Result<Vec<f32>, EmbedError>;
}
Expand description

Turns text into a fixed-dimension embedding vector.

Required Methods§

Source

fn dimension(&self) -> usize

Embedding dimension produced by Embedder::embed.

Source

fn embed(&self, text: &str) -> Result<Vec<f32>, EmbedError>

Embed text into a vector of length Embedder::dimension.

§Errors

Returns EmbedError if the backend cannot produce an embedding.

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: Embedder + ?Sized> Embedder for Box<T>

Forward Embedder through a box, enabling a non-generic MemoryService<DynEmbedder> for the MCP server and bindings.

Source§

fn dimension(&self) -> usize

Source§

fn embed(&self, text: &str) -> Result<Vec<f32>, EmbedError>

Implementors§

Source§

impl Embedder for HashEmbedder

Source§

impl Embedder for OllamaEmbedder

Available on crate feature ollama only.
Source§

impl Embedder for OpenAiEmbedder

Available on crate feature ollama only.