A sophisticated Retrieval-Augmented Generation (RAG) chatbot built with LangGraph, Groq, Pinecone, and Streamlit. Combines document-based knowledge retrieval with real-time web search capabilities for comprehensive answers.
- π Document Upload & Indexing - Upload PDF documents and automatically index them in Pinecone vector database
- π Semantic Search - Retrieve relevant document chunks using semantic embeddings
- π Web Search Integration - Real-time web search via Tavily API for current information
- π€ Intelligent Routing - LLM-powered agent that decides between RAG, web search, or direct answer
- π¬ Interactive Chat - Beautiful Streamlit UI with conversation history and session management
- π Execution Tracing - View detailed traces of how the agent processed your query
- π Production Ready - Docker support, health checks, and error handling
- β‘ Fast Processing - Groq API integration for rapid LLM responses
βββββββββββββββββββββββ
β Streamlit UI β (Frontend)
β - Chat Interface β
β - File Upload β
β - Trace Viewer β
ββββββββββββ¬βββββββββββ
β HTTP/REST
βΌ
βββββββββββββββββββββββ
β FastAPI Backend β (Backend)
β - Chat Endpoint β
β - Upload Endpoint β
β - Health Check β
ββββββββββββ¬βββββββββββ
β
ββββββββ΄βββββββ¬βββββββββββ¬ββββββββββ
βΌ βΌ βΌ βΌ
ββββββββββ ββββββββββββ βββββββ ββββββββββββ
βLangGraphβ βPinecone β βGroq β β Tavily β
β Agent β β Vector DBβ β LLM β βWeb Searchβ
ββββββββββ ββββββββββββ βββββββ ββββββββββββ
- Python 3.12+
- Docker & Docker Compose (for containerized deployment)
- API Keys:
- π Groq API Key - Get from console.groq.com
- π Pinecone API Key - Get from pinecone.io
- π Tavily API Key - Get from tavily.com
# Clone the repository
git clone <repository-url>
cd RAG_Chatbot
# Create .env file with your API keys
cat > .env << EOF
GROQ_API_KEY=your_groq_api_key
PINECONE_API_KEY=your_pinecone_api_key
TAVILY_API_KEY=your_tavily_api_key
PINECONE_ENVIRONMENT=us-east-1
PINECONE_INDEX_NAME=rag-index
EOF
# Start all services
docker-compose up -d
# Access the services
# Frontend: http://localhost:8501
# Backend: http://localhost:8000
# API Docs: http://localhost:8000/docscd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Create .env file
cat > .env << EOF
GROQ_API_KEY=your_groq_api_key
PINECONE_API_KEY=your_pinecone_api_key
TAVILY_API_KEY=your_tavily_api_key
EOF
# Run the backend
uvicorn main:app --reloadcd frontend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run Streamlit
streamlit run streamlit_app.py-
Chat Tab π¬
- Ask questions about your uploaded documents
- Toggle web search on/off in the sidebar
- View conversation history with timestamps
- Messages are stored in session state
-
Upload Documents Tab π€
- Upload PDF files (one at a time)
- View upload status and chunk count
- Track all uploaded documents
-
Trace Tab π
- View detailed execution traces
- Understand agent decision-making
- See routing decisions and data flow
POST /chat/
Request:
{
"session_id": "session_123",
"query": "What is the capital of France?",
"enable_web_search": true
}
Response:
{
"response": "Paris is the capital of France...",
"trace_events": [
{
"step": 1,
"node_name": "router",
"description": "Router decided: 'rag'",
"event_type": "router_decision"
},
...
]
}POST /upload-document/
Form Data:
- file: (PDF file)
Response:
{
"message": "PDF successfully uploaded and indexed.",
"filename": "document.pdf",
"processed_chunks": 15
}GET /health
Response:
{
"status": "ok"
}# Groq Configuration
GROQ_API_KEY=gsk_xxxxx
# Pinecone Configuration
PINECONE_API_KEY=pcsk_xxxxx
PINECONE_ENVIRONMENT=us-east-1
PINECONE_INDEX_NAME=rag-index
# Tavily Configuration
TAVILY_API_KEY=tvly-xxxxx
# Embedding Model
EMBED_MODEL=sentence-transformers/all-MiniLM-L6-v2
# Data Directory
DOC_SOURCE_DIR=data- Vector Database: Pinecone serverless
- Embedding Model: sentence-transformers/all-MiniLM-L6-v2 (384 dimensions)
- LLM Model: llama-3.1-70b-versatile (via Groq)
- Chunk Size: 1000 characters with 200 character overlap
- Primary Color: #10a37f (green)
- Port: 8501
- Theme: Dark with custom modern styling
RAG_Chatbot/
βββ backend/
β βββ agent.py # LangGraph RAG agent
β βββ config.py # Configuration & API keys
β βββ main.py # FastAPI application
β βββ vectorstore.py # Pinecone integration
β βββ requirements.txt
β
βββ frontend/
β βββ streamlit_app.py # Streamlit UI
β βββ requirements.txt
β βββ .streamlit/
β βββ config.toml # Streamlit configuration
β
βββ Dockerfile.backend # Backend container
βββ Dockerfile.frontend # Frontend container
βββ docker-compose.yml # Multi-container orchestration
βββ .gitignore # Git ignore rules
βββ README.md # This file
βββ requirements.txt # All dependencies
- User Input β Frontend sends query to backend
- Router Node β LLM decides: RAG, Web Search, or Direct Answer
- RAG Node (if selected) β Retrieves relevant document chunks
- Judge Node β Evaluates if chunks are sufficient
- Web Node (if needed) β Performs web search via Tavily
- Answer Node β Generates final response using context
- Response β Returns answer with execution trace
- PDF file uploaded to backend
- Text extracted using PyPDF
- Text split into chunks (1000 chars, 200 char overlap)
- Chunks converted to embeddings (384-dim vectors)
- Embeddings stored in Pinecone vector database
- Ready for semantic search queries
docker-compose builddocker-compose up -ddocker-compose logs -f backend
docker-compose logs -f frontenddocker-compose downdocker-compose down -v # Remove volumes- Ensure backend is running on
http://localhost:8000 - Check
API URLin frontend sidebar - Verify firewall isn't blocking port 8000
- Verify all keys in
.envfile - Check keys are valid and not expired
- Ensure keys have proper permissions
- Ensure file is a valid PDF
- Check file size isn't too large
- Verify
python-multipartis installed - Try uploading smaller PDFs first
- Clear browser cache
- Restart Streamlit app
- Check system resources
- Try
streamlit run streamlit_app.py --logger.level=debug
# Check service health
docker-compose ps
# View detailed logs
docker-compose logs --tail=100
# Rebuild with no cache
docker-compose build --no-cache
# Reset everything
docker-compose down -v
docker-compose up -d --build- Response Time: ~2-5 seconds (RAG only), ~5-10 seconds (with web search)
- Chunk Retrieval: <100ms (Pinecone)
- Embedding Generation: ~200ms (HuggingFace)
- LLM Inference: ~1-3 seconds (Groq)
- Max Concurrent Users: Limited by Pinecone/Groq API quotas
- Store API keys in environment variables (never in code)
- Use
.envfile with.gitignore - For production:
- Use secrets management (AWS Secrets Manager, HashiCorp Vault)
- Enable HTTPS/TLS
- Set up authentication/authorization
- Rate limiting on API endpoints
- Run in isolated network
langgraph- Agentic frameworklangchain- LLM orchestrationfastapi- Web frameworkuvicorn- ASGI serverlangchain-groq- Groq LLM integrationlangchain-pinecone- Pinecone vector storelangchain-tavily- Web search toollangchain-huggingface- Embeddings
streamlit- Web UI frameworkrequests- HTTP client
Contributions welcome! Please:
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License - see LICENSE file for details.
For issues, questions, or suggestions:
- Open an issue on GitHub
- Check existing documentation
- Review execution traces for debugging
- LangChain - LLM framework
- LangGraph - Agentic orchestration
- Groq - Fast LLM inference
- Pinecone - Vector database
- Tavily - Web search API
- Streamlit - Frontend framework
- FastAPI - Backend framework
- Multi-language support
- Advanced query expansion
- Custom prompt templates
- Document metadata filtering
- User authentication
- Analytics dashboard
- Response caching
- Batch document processing
- Export conversation as PDF
- Integration with more LLM providers
Made with β€οΈ for intelligent document Q&A