akhil-katta1/Legal_AI
3.2
If you are the rightful owner of Legal_AI and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Legal AI System is designed to assist attorneys in generating demand letters and analyzing cases efficiently.
Tools
5
Resources
0
Prompts
0
Legal AI System
Overview
This project is a Legal AI Assistant designed to help attorneys streamline demand letter generation and case analysis. It integrates:
- A PostgreSQL case management system (MCP server)
- A Retrieval-Augmented Generation (RAG) pipeline for document search and citation
- LLM-powered demand letter generation with inline citations
- A frontend UI for attorney interaction
Features
- Retrieve structured case details via MCP endpoints
- Ingest, chunk, and embed legal documents into ChromaDB
- Perform semantic search with page-level citations
- Extract dates, financial amounts, and named entities
- Generate demand letters with citations and validation
- Save outputs as .txt and .docx files
System Architecture
flowchart TD
A[Attorney Request] --> B["UI: Streamlit / FastAPI"]
B --> C["MCP Server: FastAPI + PostgreSQL"]
C --> D["Database: Cases, Parties, Events"]
C --> E["Case Documents: PDFs"]
E --> F["RAG Pipeline: Embeddings + ChromaDB"]
F --> G["LLM Layer: GPT-4 / LegalBERT"]
G --> H["Demand Letter Generator"]
H --> I["Output: Word / TXT / UI Preview"]
Setup Instructions
1. Clone Repository
git clone https://github.com/your-username/legal-ai-system.git
cd legal-ai-system
2. Create Virtual Environment
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
3. Install Requirements
pip install -r requirements.txt
4. Configure Environment
Create a .env file:
OPENAI_API_KEY=your-openai-key
DB_NAME=legal_case_management
DB_USER=postgres
DB_PASSWORD=yourpassword
DB_HOST=127.0.0.1
DB_PORT=5432
5. Setup Database
Run schema script in PostgreSQL (see provided SQL file). Verify with:
\c legal_case_management;
SELECT * FROM cases;
6. Run MCP Server
uvicorn mcp.server:app --reload
7. Ingest Documents
python rag/legal_ai_system.py
8. Generate Demand Letter
python generator/demand_letter.py --request "Generate a demand letter for Case #2024-PI-001 focusing on medical expenses and lost wages"
Output:
sample_output/demand_letter_2024-PI-001.txtsample_output/demand_letter_2024-PI-001.docx
9. Run Frontend UI
streamlit run app/ui.py
MCP Endpoints
get_case_details(case_id)→ Case info + partiesget_case_documents(case_id, category=None)→ Document metadataget_case_timeline(case_id, event_type=None)→ Chronological eventsget_financial_summary(case_id)→ Damages summarysearch_similar_cases(case_type, keywords)→ Case precedentsget_party_details(case_id, party_type)→ Specific party info
Deliverables
- ✅ Codebase with structured repo
- ✅ Working MCP server with DB integration
- ✅ RAG pipeline with citations
- ✅ Demand letter generator with QA validation
- ✅ Sample outputs in
/sample_output/ - ✅ README documentation
Example Attorney Requests
- "Generate a demand letter for Case #2024-PI-001 focusing on medical expenses and lost wages."
- "Generate a demand letter for Case #2024-PI-001. Include all medical expenses, lost wages, and pain and suffering damages. Reference Dr. Jones and cite the police report."