A sophisticated Retrieval-Augmented Generation (RAG) chatbot that uses multiple AI agents to answer questions from uploaded PDF documents.
The system implements a multi-agent workflow with:
- Relevance Checker: Determines if the question can be answered from the documents
- Research Agent: Generates answers based on retrieved context
- Verification Agent: Validates the accuracy of generated answers
- Hybrid Retriever: Combines vector similarity and BM25 search for optimal document retrieval
- 📄 PDF document ingestion and indexing
- 🔍 Hybrid retrieval (Vector + BM25)
- 🤖 Multi-agent workflow with LangGraph
- ✅ Answer verification and quality control
- 💬 Interactive chat interface with Streamlit
- 🔄 Iterative answer refinement
pip install -r requirements.txtCreate a .env file in the project root:
cp .env.example .envEdit .env and add your Groq API key:
GROQ_API_KEY=your_actual_api_key_here
Get your API key from: https://console.groq.com/keys
streamlit run app.py- Upload PDFs: Click "Browse files" and select one or more PDF documents
- Wait for Indexing: The system will process and index your documents
- Ask Questions: Type your question in the chat input
- Get Answers: The multi-agent system will:
- Check if the question is relevant to your documents
- Retrieve relevant context
- Generate an answer
- Verify the answer's accuracy
- Refine if needed (up to 2 iterations)
- View Verification: Click on the "🔍 Verification Report" expander below each answer to see:
- Whether the answer is supported by the documents
- Any unsupported claims
- Any contradictions found
- Relevance assessment
- Additional details
.
├── agents/
│ ├── __init__.py
│ ├── relevance_checker.py # Checks question relevance
│ ├── research_agent.py # Generates answers
│ ├── verification_agent.py # Validates answers
│ └── workflow.py # LangGraph workflow orchestration
├── data/
│ ├── uploads/ # Uploaded PDF files
│ └── llamaindex/ # Vector store index
├── app.py # Streamlit UI
├── config.py # Configuration settings
├── ingest.py # PDF processing and indexing
├── retriever.py # Hybrid retrieval implementation
├── requirements.txt # Python dependencies
├── runtime.txt # Python version specification
└── .env.example # Environment variables template
- Fixed TypeError in app.py: Removed the extra
chat_historyargument fromworkflow.full_pipeline()call - Added API key validation: All agents now check for GROQ_API_KEY and raise informative errors if missing
- Improved error handling: Added try-catch blocks throughout the pipeline
- Added iteration limits: Prevents infinite loops in the verification-research cycle (max 2 iterations)
- Enhanced retriever error handling: Gracefully handles missing or corrupted indices
- Fixed verification report parsing: More robust parsing of LLM responses
- Added empty document checks: Handles cases where no documents are retrieved
- Improved logging: Better error messages and debugging information
- Added
.env.examplefor easy setup - Enhanced error messages for better user experience
- Added safeguards against missing/empty documents
- Improved state management in the workflow
- Better metadata handling in document conversion
- streamlit: Web interface
- llama-index: Document indexing and retrieval
- langchain: Agent framework and document processing
- langgraph: Workflow orchestration
- langchain-groq: Groq LLM integration
- sentence-transformers: Text embeddings
- pypdf: PDF processing
- Make sure you created a
.envfile with your API key - Verify the key is correctly formatted (no quotes or extra spaces)
- Upload at least one PDF document through the UI
- Wait for the indexing process to complete
- The system tried to refine the answer twice but couldn't verify it
- This usually means the documents don't contain enough information
- Try rephrasing your question or uploading more relevant documents
This project is for educational and demonstration purposes.