This project is a multi-agent system for reviewing legal documents, designed to extract important legal clauses, analyze risk, and provide a plain English summary. It supports both English and Nepali documents and includes auto-translation functionality.
👉 Click here to view the system diagram in Lucidchart
- 📄 Upload legal documents (PDF, DOCX, or image)
- 🔍 Detects if content is in Nepali and translates to English
- 🤖 Multi-agent system:
- Clause extraction agent
- Risk analysis agent (only if risky terms are found)
- Summarization agent
- 🗣️ Supports English and Nepali documents
- 🌐 Deployed with Gradio (can be shared or hosted on Hugging Face Spaces)
- Gradio – Web interface
- AutoGen – Agent communication
- pymupdf4llm – PDF to markdown parser
- docx – DOCX parser
- Ollama – Vision model for image text extraction
- Custom translation pipeline – Translates Nepali to English
- Langdetect / Regex – Language detection logic
.
├── app.py # Gradio UI for user interaction
├── agent.py # Main multi-agent pipeline logic
├── parse.py # Parses files and handles translation
├── markdown_loader.py # Provides LLM prompts for each agent task
├── model_adapter.py # Model connection helper
├── model_prompt/ # Prompt definitions for each agent
├── translation_model/ # Contains run_translation_pipeline logic
├── requirements.txt # Required packages
└── README.md # This file
flowchart TD
A[User Uploads Document] --> B[parse.py]
B --> C{Is text in Nepali?}
C -- Yes --> D[Translate to English]
C -- No --> E[Use text as-is]
D --> F[ClauseExtractorAgent]
E --> F
F --> G{Risky keywords found?}
G -- Yes --> H[RiskAnalysisAgent]
G -- No --> I[Skip]
H --> J[SummarizerAgent]
I --> J
J --> K[Display English Summary]
The clause extractor attempts to extract:
- Parties involved
- Effective date and term
- Scope or Purpose
- Payment and Compensation
- Confidentiality / NDA
- Termination
- Governing law
- Liability
- Warranties
- Force majeure
- Dispute resolution
- Assignment
- Modification
- Entire agreement
- Severability
- Notices
- Execution / Signatures
- 📦 Install dependencies:
pip install -r requirements.txt▶️ Launch Gradio:
python app.py- 🌐 Visit:
http://localhost:7860
Or use the Gradio public share link if enabled.
- Install CLI and login:
pip install gradio
huggingface-cli login- Deploy:
gradio deployThis will give you a permanent live URL to share your Gradio app with others.
- ✅ English
- ✅ Nepali (auto-translated)
- ❌ Any other language will show: "Sorry, we currently only support English and Nepali."
- Upload a scanned legal document in Nepali
- Automatically translated to English
- Extracted and summarized into a clean plain English summary
- Support for highlighting risky clauses
- FastAPI or Streamlit deployment
This project is for educational and research purposes only. Not intended for legal advice or commercial production use.