pub trait Embedder:
Send
+ Sync
+ Debug {
// Required methods
fn model(&self) -> &str;
fn embed_documents<'a>(
&'a self,
texts: &'a [String],
) -> BoxFuture<'a, Result<Vec<Vec<f32>>, RagError>>;
// Provided methods
fn dimensions(&self) -> Option<usize> { ... }
fn embed_query<'a>(
&'a self,
text: &'a str,
) -> BoxFuture<'a, Result<Vec<f32>, RagError>> { ... }
}Expand description
Turns text into embedding vectors.
Required Methods§
Provided Methods§
Sourcefn dimensions(&self) -> Option<usize>
fn dimensions(&self) -> Option<usize>
Vector dimensionality, when known up front.
Sourcefn embed_query<'a>(
&'a self,
text: &'a str,
) -> BoxFuture<'a, Result<Vec<f32>, RagError>>
fn embed_query<'a>( &'a self, text: &'a str, ) -> BoxFuture<'a, Result<Vec<f32>, RagError>>
Embed a search query. Defaults to Embedder::embed_documents on one text;
override for models that need a query-specific prefix or endpoint.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".