A production-style Retrieval Augmented Generation (RAG) chatbot built using LangGraph, LangChain, Cerebras (Qwen), FAISS, and Streamlit.
This chatbot can:
- 💬 Chat normally with memory
- 📄 Answer questions from uploaded PDFs (RAG)
- 🔧 Use tools like Web Search, Calculator, and Stock Price Fetching
- 🧵 Maintain multiple chat threads
- 💾 Persist conversations using SQLite
- Graph-based agent workflow
- Tool calling with conditional routing
- Stateful conversations with persistence
- Upload PDFs per chat thread
- Chunking + embeddings using HuggingFace
- FAISS vector search for fast retrieval
- Thread-wise document indexing
- 🔍 Web Search (DuckDuckGo)
- 🧮 Calculator (add, sub, mul, div)
- 📈 Stock price lookup (Alpha Vantage API)
- 📄 RAG tool for PDF-based Q&A
- Streaming responses (token-by-token)
- Multi-threaded conversations
- Resume old chats
- Thread-specific memory & documents
- SQLite-based checkpointing
- Conversations survive app restarts
- Thread history is stored automatically
| Layer | Technology |
|---|---|
| LLM | Cerebras Qwen-3-32B |
| Agent Framework | LangGraph |
| LLM Interface | LangChain |
| Embeddings | HuggingFace (MiniLM) |
| Vector DB | FAISS |
| UI | Streamlit |
| Persistence | SQLite |
| Tools | DuckDuckGo, Alpha Vantage |
rag-ai-agent/
│
├── rag_agent_backend.py # LangGraph agent, tools, RAG logic
├── rag_agent_frontend # Streamlit frontend
├── chatbot.db # SQLite database (auto-created)
├── .env # API keys & environment variables
├── requirements.txt # Python dependencies
└── README.md # Project documentation
User Message
↓
LangGraph Chat Node
↓
(If needed)
Tool Selection
├── Web Search
├── Calculator
├── Stock Price
└── RAG Tool (PDF)
↓
Tool Result
↓
LLM Response
↓
Persist State (SQLite)
-
User uploads a PDF
-
PDF is:
- Loaded using PyPDFLoader
- Split into chunks
- Embedded using HuggingFace embeddings
-
Chunks are stored in FAISS
-
Each chat thread has its own retriever
When a question is asked:
- Relevant chunks are retrieved
- Context is injected into the LLM
- Answer is generated
-
Each chat has a unique thread ID
-
Threads store:
- Conversation history
- Indexed PDFs
Users can:
- Start a new chat
- Resume old chats
- Use different PDFs in different threads
- Operations: add, sub, mul, div
- Powered by DuckDuckGo
- Uses Alpha Vantage API
- Retrieves relevant content from uploaded PDFs
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activatepip install -r requirements.txtCreate a .env file:
CEREBRAS_API_KEY=your_api_key_herestreamlit run app.py- Chat with your college notes PDFs
- Ask questions from research papers
- Financial queries using stock price tool
- Mixed conversations using tools + RAG
- Long-term chatbot memory
- 🔐 Authentication
- 📊 LangSmith observability
- 🧠 Hybrid RAG (BM25 + Vector)
- 🗂️ Multi-document comparison
- 🧪 Evaluation & feedback loop
- 🌐 Deployment (Docker / Cloud)
- LangChain & LangGraph team
- Cerebras Systems
- HuggingFace
- Streamlit community
⭐ If you like this project
Give it a ⭐ on GitHub and feel free to fork & extend it!