Skip to content

Repository files navigation

🤖 LangGraph RAG Agent & Streamlit Demo

A stateful AI Agent combining Retrieval-Augmented Generation (RAG) and Tool Execution (Calculations & Knowledge Retrieval) built with LangGraph, LangChain, Groq, FAISS, and Streamlit.


✨ Features

  • 🧠 Stateful Agent (LangGraph): Built using StateGraph with custom nodes for LLM reasoning, dynamic tool selection, and state management.
  • 📚 Local Document Search (RAG): FAISS vector database indexed with Google Generative AI Embeddings (models/gemini-embedding-001) for semantic search over AI/ML concepts.
  • 🧮 Math & Utility Tools: Custom agent tools for arithmetic calculations (add, multiply, divide).
  • 🖥️ Streamlit Web Interface:
    • Real-time interactive chat display.
    • Live Tool Trace Sidebar showing exact tool calls, arguments, and execution outputs per turn.
  • ⚡ Powered by Groq: Ultra-fast LLM inference via ChatGroq.

🏗️ Architecture & Agent Flow

graph TD
    User([User Prompt]) --> START((Start))
    START --> LLM[LLM Call Node]
    LLM --> Decision{Requires Tool?}
    Decision -- Yes --> ToolNode[Tool Execution Node]
    ToolNode --> LLM
    Decision -- No / Final Answer --> END((End))
    END --> StreamlitUI[Streamlit Chat & Tool Trace]
Loading

📁 Project Structure

RAG+LangGraph_Project/
├── app.py              # Streamlit UI application with live tool tracking
├── agent.py            # LangGraph agent definition & custom tools
├── ingest.py           # Script to chunk documents & build FAISS vector index
├── assets/             # Streamlit UI screenshots & demo media
├── sample_docs/        # Knowledge base text files (e.g. ai_context.txt)
│   └── ai_context.txt
├── faiss_index/        # Generated local FAISS vector store
├── pyproject.toml      # Project dependencies & configuration
├── .env.example        # Environment variable template
└── README.md           # Project documentation

🖼️ Application Screenshots & Demo

Here is the interactive Streamlit web interface in action, showcasing sample question chips, live tool tracing, document search (RAG), and mathematical tool executions:

1. Interactive Dashboard & Quick Sample Prompts

Interactive Dashboard

2. RAG Semantic Document Search (search_docs)

RAG Semantic Search

3. Custom Math Tool & Live Tool Trace (divide)

Math Tool Execution

4. Direct Conversational Response (No Tools Required)

Direct Response

5. FAISS Vector Retrieval & Markdown Rendering

FAISS Knowledge Search


🚀 Quick Start

1. Prerequisites

  • Python >= 3.11
  • uv (recommended) or standard pip

2. Clone Repository

git clone https://github.com/Jaydeep0832/RAG-LangGraph.git
cd RAG-LangGraph

3. Setup Virtual Environment & Install Dependencies

Using uv:

uv sync

Or using standard pip:

python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r pyproject.toml

4. Configure Environment Variables

Copy .env.example to .env and fill in your API keys:

cp .env.example .env

Add your keys inside .env:

GOOGLE_API_KEY="your_google_ai_studio_key"
GROQ_API_KEY="your_groq_api_key"

📖 Usage

Step 1: Ingest Documents into FAISS

Build the local vector index from documents in sample_docs/:

uv run python ingest.py

Step 2: Run Streamlit Web Application

Launch the interactive agent interface:

uv run streamlit run app.py

Open your browser at http://localhost:8501.


🛠️ Tech Stack

  • Framework: LangGraph, LangChain Core
  • LLM: Groq (ChatGroq)
  • Embeddings: Google Generative AI Embeddings (gemini-embedding-001)
  • Vector Store: FAISS (Facebook AI Similarity Search)
  • UI: Streamlit
  • Package Manager: UV

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

About

A stateful RAG agent framework leveraging LangGraph and Groq for high-speed inference and decision-making. Implements FAISS vector indexing with Google AI embeddings for deep semantic search, combined with integrated mathematical tools. Features an interactive Streamlit web UI showcasing live step-by-step agent traces and tool outputs.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages