Skip to content

snath-ai/rag-demo

Repository files navigation

Glass Box Ready Sponsor

GlassBox RAG Demo (powered by Lár)

This repository is the "killer demo" for the Lár Engine — an open-source, glass box framework for building auditable, self-correcting AI agents.

This app is a live, interactive RAG agent that doesn't just give you an answer.

It shows you its work.

You can watch the agent plan, retrieve, write, critique itself, and loop until the final answer is strong, grounded, and verifiable.


Glass Box vs Black Box

Other Frameworks (“Black Box”) Lár (“Glass Box”)
Returns a single answer with no trace. Shows a full execution trace with diffs.
Silent failures — no idea why an agent messed up. Every step’s state changes are visible and auditable.
Debugging = guesswork. Debugging = inspecting exact node transitions.
“I don’t know what happened.” “I see exactly what happened.”

This demo intentionally creates a self-correcting loop so you can see Lár in full power.


See a Real Failure: The "Glass Box" Audit Trail

You don't have to guess. Here is a real log from this demo after hitting the Gemini API's free-tier rate limit.

Instead of a generic 500 ERROR, the lar engine caught the failure, logged the exact reason, and ended the graph gracefully.

Execution Summary:

Step Node Outcome Key Changes
0 LLMNode success + ADDED: 'search_query'
1 ToolNode success + ADDED: 'retrieved_context'
2 LLMNode success + ADDED: 'draft_answer'
3 LLMNode error + ADDED: 'error': "APIConnectionError"

This is the lar difference. You know the exact node (LLMNode), the exact step (3), and the exact reason (APIConnectionError) for the failure. You can't debug a "black box," but you can always fix a "glass box."

How to Run This Demo

This project runs with two main scripts:

  1. build_index.py — builds a FAISS vector store
  2. rag_app.py — launches the interactive Streamlit GlassBox RAG app

Prerequisites

  • Python 3.10+
  • Poetry
  • Google Gemini API Key
  • macOS/Linux/WSL/Windows

1 Installation

git clone https://github.com/snath-ai/rag-demo.git
cd rag-demo

poetry install

2 Set Up Environment Variables

Create a .env file:

GOOGLE_API_KEY="YOUR_API_KEY_HERE"

3 Build the Local Vector Index (Run Once)

poetry run python build_index.py

This creates your FAISS index in vector_store/.


4 Run the GlassBox RAG App

poetry run streamlit run rag_app.py

Open in browser:
http://localhost:8501

Ask:

“What is the recommendation for Project Astra-7?”

Watch the agent plan → retrieve → draft → critique → revise → finalize.


How the Agent Works — Execution Blueprint

This demo integrates:

  • Local similarity search (FAISS)
  • Cloud LLM reasoning (Gemini)
  • Critique-driven self-correction
  • Lár’s define-by-run execution
  • Full state diff visibility

High-Level Execution Graph

graph TD
    A[User Question] --> B[Planner LLMNode<br/>'Plan Query']
    B --> C[Retriever ToolNode<br/>'FAISS Search']
    C --> D[Writer LLMNode<br/>'Draft Answer']
    D --> E[Critic LLMNode<br/>'Critique & Score']
    E --> F{RouterNode<br/>'Is It Good Enough?'}

    F -- "no" --> G[Reviser LLMNode<br/>'Improve Answer']
    G --> D

    F -- "yes" --> H[Finalize Node<br/>'Return Answer']
Loading

Loop Summary

  1. Planner interprets question
  2. Retriever gathers relevant context
  3. Writer drafts
  4. Critic evaluates
  5. Router decides:
    • weak → revise loop
    • strong → finalize

Folder Structure

rag-demo/
├── build_index.py
├── rag_app.py
├── document_text.txt
├── vector_store/
├── .env
├── pyproject.toml
└── README.md

Show Your Agents are Auditable

If you build an agent using the Lár Engine, you are building a dependable, verifiable system. Help us spread the philosophy of the "Glass Box" by displaying the badge below in your project's README.

By adopting this badge, you signal to users and collaborators that your agent is built for production reliability and auditability.

Show an Auditable Badge to your project: Glass Box Ready

Badge Markdown:

[![Glass Box Ready](https://img.shields.io/badge/Auditable-Glass%20Box%20Ready-54B848?style=flat&logo=checkmarx&logoColor=white)](https://docs.snath.ai)

⚡ Ready to build with Lár? (Agentic IDEs)

Lár is designed for Agentic IDEs (Cursor, Windsurf, Antigravity) and strict code generation.

We provide a 3-Step Workflow to make your IDE an expert Lár Architect.

1. The Strategy: "Reference, Don't Copy"

Instead of pasting massive prompts, simply reference the master files in the lar/ directory (or download them from the main repo).

2. The Workflow

  1. Context (The Brain): In your IDE chat, reference @lar/IDE_MASTER_PROMPT.md. This loads the strict typing rules and "Code-as-Graph" philosophy.
  2. Integrations (The Hands): Reference @lar/IDE_INTEGRATION_PROMPT.md to generate production-ready API wrappers in seconds.
  3. Scaffold (The Ask): Open @lar/IDE_PROMPT_TEMPLATE.md, fill in your agent's goal, and ask the IDE to "Implement this."

Example Prompt to Cursor/Windsurf: "Using the rules in @lar/IDE_MASTER_PROMPT.md, implement the agent described in @lar/IDE_PROMPT_TEMPLATE.md."


Support the Project

Lár is an open-source agent framework built to be clear, debuggable, and developer-friendly. If this project helps you, consider supporting its development through GitHub Sponsors.

Become a sponsor → Sponsor on GitHub

Your support helps me continue improving the framework and building new tools for the community.

Credits

License

This Project is licensed under the Apache License 2.0

This means:

  • You are free to use Làr in personal, academic, or commercial projects.
  • You may modify and distribute the code.
  • You MUST retain the LICENSE and the NOTICE file.
  • If you distribute a modified version, you must document what you changed.

Apache 2.0 protects the original author (Aadithya Vishnu Sajeev) while encouraging broad adoption and community collaboration.

For developers building on Làr: Please ensure that the LICENSE and NOTICE files remain intact to preserve full legal compatibility with the Apache 2.0 terms.

About

A self-correcting RAG demo built using the Làr Engine

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages