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.
//! Example demonstrating how to delete a context from chat history
//!
//! This example shows:
//! 1. Creating a RAG module with chat history
//! 2. Adding chat messages with a specific context_id
//! 3. Verifying the messages exist
//! 4. Deleting all messages for that context_id
//! 5. Verifying the deletion was successful

use rag_module::RagModule;
use anyhow::Result;

#[tokio::main]
async fn main() -> Result<()> {
    // Initialize tracing for better logging visibility
    tracing_subscriber::fmt()
        .with_env_filter("info")
        .init();

    println!("╔══════════════════════════════════════════════════════════════╗");
    println!("║     Delete Context from Chat History - Example Demo         ║");
    println!("╚══════════════════════════════════════════════════════════════╝\n");

    // Step 1: Create RAG module
    println!("📦 Step 1: Initializing RAG Module");
    println!("─────────────────────────────────────────────────────────────\n");

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

    rag_module.initialize().await?;
    println!("✅ RAG Module initialized successfully\n");

    // Step 2: Define test context and user
    let context_id = "c0a53fe9-0ff0-4911-85bf-3fa01982ce9d";
    let user_id = "148854b8-9091-70e0-ed07-40553c514535";
    let chat_title = Some("Test Conversation");

    println!("📝 Step 2: Creating Chat Messages");
    println!("─────────────────────────────────────────────────────────────");
    println!("   Context ID: {}", context_id);
    println!("   User ID: {}", user_id);
    println!("   Chat Title: {:?}\n", chat_title);

    

    // Step 6: Delete the context
    println!("🗑️  Step 5: Deleting Context");
    println!("─────────────────────────────────────────────────────────────");
    println!("   Deleting context_id: {}\n", context_id);

    let deleted_count = rag_module.delete_context_from_chat_history(context_id, user_id).await?;

    println!("\n✅ Context deletion completed!");
    println!("   Documents deleted: {}\n", deleted_count);

    println!("🎉 Example completed successfully!\n");

    Ok(())
}