pub mod local;
use anyhow::Result;
pub const EMBEDDING_DIM: usize = 384;
#[allow(dead_code)]
pub trait EmbeddingProvider: Send + Sync {
fn embed(&self, text: &str) -> Result<Vec<f32>>;
fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>> {
texts.iter().map(|t| self.embed(t)).collect()
}
fn dimensions(&self) -> usize {
EMBEDDING_DIM
}
}
pub fn create_provider(
config: &crate::config::EmbeddingConfig,
) -> Result<Box<dyn EmbeddingProvider>> {
match config.provider.as_str() {
"local" => {
let provider = local::LocalEmbeddingProvider::new(config)?;
Ok(Box::new(provider))
}
other => anyhow::bail!("unknown embedding provider: {other}. Supported: local"),
}
}