pub struct EmbeddingModel { /* private fields */ }Expand description
Text embedding model wrapper with configurable providers and LRU cache
Supports hash-based embeddings (default), local ONNX models, and API services.
Users can configure their preferred embedding method via manx config.
Implementations§
Source§impl EmbeddingModel
impl EmbeddingModel
Sourcepub async fn new() -> Result<Self>
pub async fn new() -> Result<Self>
Create a new embedding model with default hash-based provider
Sourcepub async fn new_auto_select() -> Result<Self>
pub async fn new_auto_select() -> Result<Self>
Create embedding model with smart auto-selection of best available provider
Sourcepub async fn new_with_config(config: EmbeddingConfig) -> Result<Self>
pub async fn new_with_config(config: EmbeddingConfig) -> Result<Self>
Create a new embedding model with custom configuration
Sourcepub async fn embed_text(&self, text: &str) -> Result<Vec<f32>>
pub async fn embed_text(&self, text: &str) -> Result<Vec<f32>>
Generate embeddings for a single text using configured provider with caching
Sourcepub async fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>>
pub async fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>>
Generate embeddings for multiple texts (batch processing) More efficient than calling embed_text repeatedly - uses native batch for ONNX providers
Sourcepub async fn get_dimension(&self) -> Result<usize>
pub async fn get_dimension(&self) -> Result<usize>
Get the dimension of embeddings produced by this model
Sourcepub async fn health_check(&self) -> Result<()>
pub async fn health_check(&self) -> Result<()>
Test if the embedding model is working correctly
Sourcepub fn get_provider_info(&self) -> ProviderInfo
pub fn get_provider_info(&self) -> ProviderInfo
Get information about the current provider
Sourcepub fn get_config(&self) -> &EmbeddingConfig
pub fn get_config(&self) -> &EmbeddingConfig
Get the current configuration
Sourcepub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32
pub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32
Calculate cosine similarity between two embeddings
Sourcepub async fn auto_select_best_provider() -> Result<EmbeddingConfig>
pub async fn auto_select_best_provider() -> Result<EmbeddingConfig>
Automatically select the best available embedding provider from installed models Respects user’s installed models and doesn’t hardcode specific model names
Auto Trait Implementations§
impl !Freeze for EmbeddingModel
impl !RefUnwindSafe for EmbeddingModel
impl Send for EmbeddingModel
impl Sync for EmbeddingModel
impl Unpin for EmbeddingModel
impl !UnwindSafe for EmbeddingModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more