Skip to main content

manx_cli/rag/providers/
mod.rs

1use anyhow::Result;
2
3pub mod custom;
4pub mod hash;
5pub mod huggingface;
6pub mod ollama;
7pub mod onnx;
8pub mod openai;
9
10/// Trait for embedding providers
11#[async_trait::async_trait]
12pub trait EmbeddingProvider: std::any::Any {
13    /// Generate embeddings for a single text
14    async fn embed_text(&self, text: &str) -> Result<Vec<f32>>;
15
16    /// Get the dimension of embeddings produced by this provider
17    async fn get_dimension(&self) -> Result<usize>;
18
19    /// Test if the provider is available and working
20    async fn health_check(&self) -> Result<()>;
21
22    /// Get provider-specific information
23    fn get_info(&self) -> ProviderInfo;
24
25    /// Downcast support for accessing provider-specific methods
26    fn as_any(&self) -> &dyn std::any::Any;
27}
28
29/// Information about an embedding provider
30#[derive(Debug, Clone)]
31pub struct ProviderInfo {
32    pub name: String,
33    pub provider_type: String,
34    pub model_name: Option<String>,
35    pub description: String,
36    pub max_input_length: Option<usize>,
37}