Industry-grade Retrieval-Augmented Generation system with intelligent query routing, guardrails, and multi-source information retrieval.
- Multi-document Upload: PDF, DOCX, TXT support
- Intelligent Routing: Automatically routes queries to:
- RAG (uploaded documents)
- LLM knowledge
- Internet search (Serper API)
- Guardrails:
- Input validation (malicious query detection)
- Relevance scoring
- Hallucination detection
- Source Attribution: Clear citations for all responses
- Streamlit UI: User-friendly interface
- Evaluation Framework: Comprehensive logging and metrics
- Python 3.9+
- Groq API key (Get it here)
- Serper API key (Get it here)
# Navigate to project directory
cd C:\Users\ashfa\OneDrive\Desktop\My-Learning\Test
# Create virtual environment
python -m venv venv
# Activate virtual environment (Windows)
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtCreate a .env file in the project root:
GROQ_API_KEY=your_groq_api_key_here
SERPER_API_KEY=your_serper_api_key_hereYou can copy .env.example and fill in your API keys:
copy .env.example .envstreamlit run main.pyThe application will open in your browser at http://localhost:8501.
- Upload Documents: Click "Browse files" to upload PDF, DOCX, or TXT files
- Process Documents: Click "Process Documents" to index them
- Ask Questions: Type your question in the chat input
- View Sources: Expand the "Sources" section to see where information came from
Query → Input Validation → Query Analysis → Router
├─→ RAG Tool → Relevance Check → Response Synthesis
├─→ LLM Tool → Response
└─→ Search Tool → Response
↓
Hallucination Check → Final Response
Edit .env or config.py to customize:
- Chunk size and overlap
- Top-K retrieval
- Similarity thresholds
- Relevance/hallucination thresholds
- LLM model selection
View metrics by clicking "View Metrics" in the sidebar:
- Response times
- Source distribution
- Relevance scores
- Error rates
Logs are stored in ./logs/.
Test/
├── data/ # Data persistence
│ ├── uploaded_docs/ # Original documents
│ └── chroma_db/ # Vector database
├── logs/ # Application logs
├── src/ # Source code
│ ├── agents/ # Agentic workflow (LangGraph)
│ ├── document_processing/ # Document loaders and chunking
│ ├── evaluation/ # Logging and metrics
│ ├── guardrails/ # Safety and quality checks
│ ├── llm/ # Groq client
│ ├── search/ # Serper client
│ ├── ui/ # Streamlit components
│ └── vector_store/ # ChromaDB management
├── tests/ # Unit tests
├── config.py # Configuration management
├── main.py # Application entry point
└── requirements.txt # Dependencies
Issue: "No module named 'src'"
- Solution: Ensure you're running from the project root directory
Issue: "API key not found"
- Solution: Check
.envfile exists and contains valid API keys
Issue: "ChromaDB error"
- Solution: Delete
./data/chroma_db/and restart
MIT