Skip to main content

EmbeddingProvider

Trait EmbeddingProvider 

Source
pub trait EmbeddingProvider: Send + Sync {
    // Required methods
    fn provider_id(&self) -> &str;
    fn model_id(&self) -> &str;
    fn dimension(&self) -> u32;
    fn embed(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, EmbeddingError>;
}
Expand description

One registered embedding backend (local model runner, remote HTTP adapter, test double, …). Implementations live outside core storage; core only holds the trait object in a process-local registry.

Required Methods§

Source

fn provider_id(&self) -> &str

Stable registry key (matches EmbeddingSource::GeneratedColumn / local model ids).

Source

fn model_id(&self) -> &str

Model identity stamped onto ANN generations when this provider runs.

Source

fn dimension(&self) -> u32

Fixed output dimension; must match the column’s TypeId::Embedding { dim }.

Source

fn embed(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, EmbeddingError>

Encode one or more texts into dense vectors of Self::dimension.

Implementations must not invent weak hashed stand-ins for real semantic models. Prefer returning EmbeddingError::ProviderFailed over producing misleading vectors.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§