rag-module 0.6.7

Enterprise RAG module with chat context storage, vector search, session management, and model downloading. Rust implementation with Node.js compatibility.
use anyhow::Result;
use rag_module::RagModule;

#[tokio::main]
async fn main() -> Result<()> {
    println!("🔍 Checking document counts");

    let mut rag_module = RagModule::new("/Users/aparnapitchikala/Library/Application Support/Escher").await?;
    rag_module.initialize().await?;

    let user_id = "148854b8-9091-70e0-ed07-40553c514535";

    // Get all encrypted documents (this is internal but we can access via get_decrypted)
    let docs = rag_module.get_encrypted_chat_documents(user_id).await?;
    println!("\n📄 Total encrypted chat documents: {}", docs.len());

    // Group by context_id to see distribution
    use std::collections::HashMap;
    let mut context_counts: HashMap<String, usize> = HashMap::new();

    for doc in &docs {
        // Decrypt to get context_id
        let decrypted_content = rag_module.encryption_service.decrypt_content(&doc.content).await?;
        if let Ok(json) = serde_json::from_str::<serde_json::Value>(&decrypted_content) {
            if let Some(context_id) = json.get("i").and_then(|v| v.as_str()) {
                *context_counts.entry(context_id.to_string()).or_insert(0) += 1;
            }
        }
    }

    println!("\n📊 Documents per context:");
    for (context_id, count) in context_counts.iter() {
        println!("  {}: {} documents", context_id, count);
    }

    Ok(())
}