git-topology 0.1.2

Shared clustering and topology primitives for git-cognitive and git-semantic
Documentation
pub mod config;
pub(crate) mod gemma;
pub(crate) mod openai;

use anyhow::Result;

#[allow(dead_code)]
pub(crate) trait EmbeddingProvider: Send + Sync {
    fn generate_embedding(&mut self, text: &str) -> Result<Vec<f32>>;
    fn embedding_dimension(&self) -> usize;
    fn provider_name(&self) -> &str;

    fn init(&mut self) -> Result<()> {
        Ok(())
    }
}

pub(crate) fn create_provider(
    config: &config::EmbeddingConfig,
) -> Result<Box<dyn EmbeddingProvider>> {
    match config.provider {
        config::EmbeddingProviderType::OpenAI => {
            Ok(Box::new(openai::OpenAIProvider::new(config.clone())?))
        }
        config::EmbeddingProviderType::Gemma => Ok(Box::new(gemma::GemmaProvider::new()?)),
    }
}