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";
let docs = rag_module.get_encrypted_chat_documents(user_id).await?;
println!("\n📄 Total encrypted chat documents: {}", docs.len());
use std::collections::HashMap;
let mut context_counts: HashMap<String, usize> = HashMap::new();
for doc in &docs {
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(())
}