pub trait Embedder: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn version(&self) -> &str;
fn dim(&self) -> usize;
fn dtype(&self) -> EmbeddingDtype;
fn embed_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Embedding>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided method
fn embed<'life0, 'life1, 'async_trait>(
&'life0 self,
text: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Embedding>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Pluggable embedder. Production impls live in solo-storage (or a future
solo-embed crate); this trait is the contract.
Required Methods§
Sourcefn name(&self) -> &str
fn name(&self) -> &str
Embedder identity. The migration tool solo reembed keys on
(name, version) to decide whether stored embeddings need to be
regenerated.
Sourcefn version(&self) -> &str
fn version(&self) -> &str
Embedder version. Bump on any change that produces different vectors for the same input.
Sourcefn dim(&self) -> usize
fn dim(&self) -> usize
Output dimension. Must be invariant across calls for a given Embedder instance.
Sourcefn dtype(&self) -> EmbeddingDtype
fn dtype(&self) -> EmbeddingDtype
Output dtype. Determines how raw bytes in Embedding::data are
interpreted.
Sourcefn embed_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Embedding>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn embed_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
texts: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Embedding>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Embed a batch of texts. Output is in input order with the same length as the input. Implementations should batch internally for throughput; callers may pass any number of texts (including 1).
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".