An advanced Agentic RAG (Retrieval-Augmented Generation) system for constitutional and legal document reasoning using ReAct orchestration, dual-vector retrieval pipelines, ChromaDB, and Groq Llama-3.
The system supports:
- Semantic Retrieval
- Parent-Child Context Retrieval
- Dynamic PDF Upload Analysis
- Temporary In-Memory Vector Databases
- ReAct-based Agentic Reasoning
- Evaluation Metrics for RAG Performance
Implements iterative:
- Thought
- Action
- Observation
- Final Answer
reasoning loops for autonomous legal analysis.
Two specialized retrieval pipelines:
Retrieves highly precise sentence-level legal fragments.
Retrieves broader contextual constitutional/legal sections for structural reasoning.
Users can upload PDFs and query documents in real-time using:
- Ephemeral ChromaDB
- Temporary in-memory vector stores
- Runtime indexing
without polluting the permanent database.
Tracks:
- Accuracy
- Faithfulness
- Relevance
- Failure Cases
for RAG quality analysis.
- Python
- Streamlit
- Groq API
- Gemini API
- Llama-3
- ChromaDB
- Sentence Transformers
- LangChain
- PyPDF
- ReAct Agents
User Query
↓
Agent Orchestrator (ReAct Loop)
↓
Tool Selection
┌───────────────┬────────────────┐
│ │ │
Semantic Vault Parent-Child Vault
│ │
Precise Search Contextual Search
└───────────────┴────────────────┘
↓
Observation Injection
↓
Final Legal Synthesis
project/
│
├── app.py
├── agent_orchestrator.py
├── rag_engine.py
├── rag_engine_v2.py
├── upload_pipeline.py
├── evaluation.ipynb
├── chroma_storage/
├── chroma_storage_v2/
├── requirements.txt
└── README.md
git clone https://github.com/pranay0026/LegalRag.git cd LegalRag
python -m venv venvvenv\\Scripts\\activatesource venv/bin/activatepip install -r requirements.txtCreate a .env file:
GROQ_API_KEY=your_key_here
GROQ_API_KEY3=your_key_herestreamlit run app.pyCurrent benchmark results:
| Metric | Score |
|---|---|
| Accuracy | 4.00 / 5 |
| Faithfulness | 3.95 / 5 |
| Relevance | 4.00 / 5 |
- Powers of CMs under Article 162
- Fundamental Rights under Article 21
- Governor discretionary powers
- Emergency provisions in Constitution
- Summarize this agreement
- Identify legal risks
- Extract obligations from contract
- Explain termination clauses
- Hybrid Search (BM25 + Vector Search)
- Reranking Pipelines
- Streaming Responses
- Conversational Memory
- FastAPI Backend
- Multi-document Retrieval
Pranay Koppineedi
This project is intended for educational and research purposes.





