Skip to main content

EmbeddingBackend

Trait EmbeddingBackend 

Source
pub trait EmbeddingBackend: Send + Sync {
    // Required methods
    fn embed(
        &self,
        input: &str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + '_>>;
    fn dimensions(&self) -> usize;
    fn model_name(&self) -> &str;
}
Expand description

Trait for embedding providers.

Implementations call an external embedding API and return the result as a little-endian f32 byte blob ready for libsql F32_BLOB columns.

The built-in providers are super::OpenAIEmbedding, super::GeminiEmbedding, super::MistralEmbedding, and super::VoyageEmbedding. Custom providers implement this trait directly.

Required Methods§

Source

fn embed( &self, input: &str, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + '_>>

Embed a single text string.

Returns a little-endian f32 byte blob of length dimensions() * 4.

Source

fn dimensions(&self) -> usize

Number of dimensions this provider/model produces.

Source

fn model_name(&self) -> &str

Model identifier string (e.g. "text-embedding-3-small").

Implementors§