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§
Sourcefn embed(
&self,
input: &str,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + '_>>
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.
Sourcefn dimensions(&self) -> usize
fn dimensions(&self) -> usize
Number of dimensions this provider/model produces.
Sourcefn model_name(&self) -> &str
fn model_name(&self) -> &str
Model identifier string (e.g. "text-embedding-3-small").