An end-to-end Retrieval-Augmented Generation (RAG) system that leverages multiple intelligent agents for enhanced document understanding, retrieval, and response generation with comprehensive source attribution.
-
Multi-Format Document Processing
- PDF, DOCX, HTML support
- Hierarchical document parsing
- Metadata extraction
- Page-level information preservation
-
Intelligent Agent System
- Retriever Agent: Smart document chunk retrieval
- Metadata Agent: Context-aware filtering
- Reflection Agent: Response quality assurance
- Web Search Agent: External knowledge integration
-
Advanced RAG Capabilities
- Hybrid search (semantic + keyword + metadata)
- Composable graph indices
- Source attribution tracking
- Confidence scoring
agentic_rag/
├── app/ # Application code
│ ├── api/ # FastAPI endpoints
│ ├── core/ # Core business logic
│ │ ├── agents/ # Agent implementations
│ │ ├── parsers/ # Document parsers
│ │ └── retrievers/ # Retrieval logic
│ ├── models/ # Data models
│ └── utils/ # Utility functions
├── config/ # Configuration files
├── data/ # Data storage
│ ├── documents/ # Uploaded documents
│ └── vector_store/ # Vector database
├── tests/ # Test suite
└── scripts/ # Utility scripts
- Python 3.9+
- Docker (optional, for containerized deployment)
- LLAMA API key (for LLAMAParse)
-
Clone the repository:
git clone https://github.com/yourusername/agentic-rag.git cd agentic-rag -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: .\venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
cp .env.example .env # Edit .env with your API keys and configuration
-
Start the vector database:
docker-compose up -d qdrant
-
Launch the API server:
uvicorn app.api.main:app --reload
-
Access the API documentation at
http://localhost:8000/docs
from app.core.parsers import DocumentParser
parser = DocumentParser()
document = parser.parse("path/to/document.pdf")from app.core.agents import QueryProcessor
processor = QueryProcessor()
response = processor.process_query(
"What was the product launch date?",
metadata_filters={"date_range": "2023"}
){
"answer": "The product was launched in March 2023.",
"sources": [
{
"type": "document",
"document": "Product_Overview.pdf",
"page": 14,
"chunk_id": "c_004",
"heading": "Product Launch Details",
"confidence": 0.95
}
]
}The system is evaluated on multiple metrics:
- Retrieval accuracy (Precision@K)
- Answer quality (BLEU/ROUGE + human evaluation)
- Reflection agent correction rate
- Response latency
- Source attribution correctness
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- LLAMAIndex team for the excellent RAG framework
- Qdrant team for the vector database
- All contributors and users of this project