pub trait EmbeddingProvider: Send + Sync {
// Required methods
fn info(&self) -> ProviderInfo;
fn is_available(&self) -> impl Future<Output = bool> + Send;
fn generate_embedding(
&self,
text: &str,
) -> impl Future<Output = Result<Vec<f32>>> + Send;
// Provided method
fn generate_embeddings(
&self,
texts: &[&str],
) -> impl Future<Output = Result<Vec<Vec<f32>>>> + Send { ... }
}Expand description
Trait for embedding providers.
Implemented by Ollama and HuggingFace providers. The trait is object-safe to allow runtime provider selection.
Required Methods§
Sourcefn info(&self) -> ProviderInfo
fn info(&self) -> ProviderInfo
Get provider metadata.
Sourcefn is_available(&self) -> impl Future<Output = bool> + Send
fn is_available(&self) -> impl Future<Output = bool> + Send
Check if the provider is available.
For Ollama, this checks if the server is running and the model is available. For HuggingFace, this checks if the API token is valid.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.