A sophisticated, stateful Agentic RAG (Retrieval-Augmented Generation) system designed for intelligent document interaction. This agent doesn't just retrieve; it reasons about the necessity of retrieval and maintains a coherent conversation state across multiple turns.
- 🧠 Agentic Reasoning: Powered by LangGraph, the system employs a cyclic graph-based workflow where the LLM autonomously decides whether to query the knowledge base or respond directly.
- 🔄 Stateful Persistence: Implements
MemorySaverto preserve chat history, ensuring contextually aware responses within a single user session. - ⚡ High-Performance Retrieval: Utilizes ChromaDB for local vector storage and OpenAI's
text-embedding-3-smallfor precision-grade semantic search. - 📄 Seamless Ingestion: Automated PDF processing, chunking, and indexing for immediate "chat-with-your-data" capabilities.
- Orchestration: LangGraph (StateGraph, Nodes, Edges)
- Framework: LangChain
- Vector Database: ChromaDB
- LLM: OpenAI GPT models (Optimized for GPT-4o / GPT-5)
- Embeddings: OpenAI
text-embedding-3-small
.
├── chroma_db/ # Local Vector Store persistence
├── your_document.pdf # Target knowledge source
├── RAG_Agent.py # Core Agentic logic & Graph definition
├── .env # Environment configuration
└── requirements.txt # Project dependencies
git clone https://github.com/savinoo/RAG_Agent.git
cd RAG_Agent
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtCreate a .env file:
OPENAI_API_KEY=your_key_herePlace your PDF in the root directory and run:
python RAG_Agent.py- Ingestion: The script checks for an existing ChromaDB instance. If absent, it parses the PDF into semantic chunks and generates embeddings.
- Decision Loop: When a query is received, the agent enters a LangGraph node.
- Tool Call: If the agent determines retrieval is needed, it calls the ChromaDB tool.
- Final Response: The agent synthesizes the retrieved context and conversation history into a final answer.
Developed by Lucas Lorenzo Savino