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;
use uuid::Uuid;

#[tokio::main]
async fn main() -> Result<()> {
    println!("๐Ÿงช Testing request_id (ri) field functionality\n");

    // Initialize RAG module
    let mut rag = RagModule::new("./test-ri-data").await?;
    rag.initialize().await?;

    let context_id = "test-ri-conversation";
    let user_id = "test-user-ri";
    let chat_title = "Testing RI Field";

    println!("๐Ÿ“ Adding messages with request_id...\n");

    // Conversation Turn 1
    let req_id_1 = Uuid::new_v4().to_string();
    println!("Turn 1 - Request ID: {}", &req_id_1[0..8]);

    rag.add_prompt(
        context_id,
        "How many EC2 instances do we have?",
        user_id,
        Some(chat_title),
        &req_id_1
    ).await?;

    rag.add_response(
        context_id,
        "You have 16 EC2 instances running.",
        user_id,
        Some(chat_title),
        &req_id_1
    ).await?;

    // Conversation Turn 2
    let req_id_2 = Uuid::new_v4().to_string();
    println!("Turn 2 - Request ID: {}", &req_id_2[0..8]);

    rag.add_prompt(
        context_id,
        "Which ones run PostgreSQL?",
        user_id,
        Some(chat_title),
        &req_id_2
    ).await?;

    rag.add_response(
        context_id,
        "13 instances are running PostgreSQL.",
        user_id,
        Some(chat_title),
        &req_id_2
    ).await?;

    println!("\nโœ… Messages added successfully!\n");

    // Retrieve and display
    println!("๐Ÿ”“ Retrieving decrypted chat history...\n");
    let history = rag.get_decrypted_chat_history(user_id).await?;

    println!("{}\n", serde_json::to_string_pretty(&history)?);

    println!("โœ… Done! Check the 'ri' field in each message above.");

    Ok(())
}