Skip to main content

EmbeddingProvider

Trait EmbeddingProvider 

Source
pub trait EmbeddingProvider: Send + Sync {
    // Required methods
    fn content_dim(&self) -> usize;
    fn trigger_dim(&self) -> usize;
    fn embed_content(&self, text: &str) -> Result<Vec<f32>>;
    fn embed_trigger(&self, text: &str) -> Result<Vec<f32>>;

    // Provided methods
    fn model_name(&self) -> &'static str { ... }
    fn embed_both(&self, text: &str) -> Result<(Vec<f32>, Vec<f32>)> { ... }
}
Expand description

Embedding provider trait — swap for real models at construction time.

Required Methods§

Source

fn content_dim(&self) -> usize

Source

fn trigger_dim(&self) -> usize

Source

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

Source

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

Provided Methods§

Source

fn model_name(&self) -> &'static str

Source

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

Embed text for both the content and trigger spaces. Default issues two separate calls. Providers backed by a single shared model (e.g. a remote embedding endpoint) should override this to make one request and avoid the duplicate round trip on the recall hot path.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§