Skip to content

algo-aryan/LegalAI-Pro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LegalAI Pro

AI-Powered Legal Solutions for Modern Law Practices

LegalAI Pro is a comprehensive AI-powered legal technology platform that empowers legal professionals with cutting-edge AI technology for contract analysis, legal assistance, and case prediction. Our advanced algorithms and machine learning models are specifically designed for the legal domain to enhance efficiency and accuracy in legal practice.

πŸš€ Features

1. Smart Contract Analyzer

  • AI-Powered Analysis: Upload PDF contracts for comprehensive AI-powered analysis using InLegalBERT
  • Risk Assessment: Automated risk scoring and identification with detailed risk level categorization
  • Key Terms Extraction: Extract important contract terms, dates, parties, and durations
  • Contract Type Detection: Automatically classify contract types (NDAs, Lease Agreements, Employment, etc.)
  • Interactive Chat: Contract-specific AI chat support using Google Gemini for detailed Q&A

2. Virtual Legal Assistant

  • 24/7 Legal Support: Get instant answers to legal questions across multiple domains
  • Conversation Memory: Maintains conversation history and context for better assistance
  • Professional Guidance: Clear, point-wise responses with recommendations to consult qualified attorneys
  • Multi-Domain Expertise: Covers various areas of law and legal procedures

3. Case Outcome Prediction

  • AI-Driven Analysis: Predict case outcomes using historical data and legal precedents
  • Confidence Scoring: Provides confidence percentages and detailed analysis
  • Strategic Recommendations: Offers strategic decision support and recommendations
  • Timeline Estimation: Estimates case duration and potential settlement ranges

πŸ› οΈ Technology Stack

Backend

  • Framework: Flask (Python)
  • AI/ML:
    • PyTorch for deep learning
    • Transformers (InLegalBERT) for legal text analysis
    • Google Generative AI (Gemini) for conversational AI
    • LangChain for RAG implementation
  • Document Processing:
    • PyMuPDF for PDF parsing
    • pdfplumber for text extraction
  • Vector Database: FAISS for document embeddings
  • API: RESTful API with CORS support

Frontend

  • HTML5: Modern semantic markup
  • CSS3: Responsive design with animations
  • JavaScript: Interactive UI components
  • File Upload: Drag & drop interface for contracts

AI Models

  • InLegalBERT: Specialized BERT model for legal text understanding
  • Google Gemini: For conversational AI and general legal assistance
  • Custom Risk Scoring: Proprietary algorithm for contract risk assessment

πŸ“ Project Structure

LegalAI-Pro/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app.py                    # Main Flask application
β”‚   β”œβ”€β”€ legal_bert_service.py     # Contract analysis service with InLegalBERT
β”‚   β”œβ”€β”€ contract_bot.py           # Gemini-powered contract chatbot
β”‚   β”œβ”€β”€ general_legal_bot.py      # General legal assistant
β”‚   β”œβ”€β”€ globals.py                # Global variables store
β”‚   └── uploads/                  # Contract upload directory
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ index.html               # Homepage
β”‚   β”œβ”€β”€ contract-analyzer.html   # Contract analysis interface
β”‚   β”œβ”€β”€ virtual-assistant.html   # Legal assistant chat
β”‚   β”œβ”€β”€ case-prediction.html     # Case prediction interface
β”‚   β”œβ”€β”€ about.html              # About page
β”‚   └── contact.html            # Contact information
└── README.md

πŸš€ Installation & Setup

Prerequisites

  • Python 3.8+
  • pip package manager
  • Google API Key for Gemini

1. Clone the Repository

git clone https://github.com/algo-aryan/legalAI-pro.git
cd legalAI-pro

2. Install Dependencies

pip install -r requirements.txt

3. Environment Setup

Create a .env file in the backend directory:

GOOGLE_API_KEY=your_google_api_key_here
LEGAL_MODEL=law-ai/InLegalBERT
BATCH_SIZE=16

4. Run the Application

cd backend
python app.py

The application will be available at:

πŸ“‹ Required Dependencies

flask
flask-cors
torch
transformers
numpy
pdfplumber
PyMuPDF
langchain
langchain-google-genai
faiss-cpu
google-generativeai
tqdm
werkzeug
uuid

πŸ”§ API Endpoints

General Endpoints

  • GET /api/health - Health check
  • POST /api/cleanup - Session cleanup

Contract Analysis

  • POST /api/contract/upload - Upload and analyze contract
  • POST /api/contract/chat - Chat about uploaded contract
  • POST /api/contract/analyze - Re-analyze contract

Legal Assistant

  • POST /api/chat/general - General legal questions

Case Prediction

  • POST /api/case/predict - Predict case outcomes

🎯 Key Features in Detail

Contract Analysis Pipeline

  1. PDF Processing: Extract text from uploaded PDF contracts
  2. BERT Embeddings: Generate embeddings using InLegalBERT
  3. Contract Classification: Identify contract type using semantic similarity
  4. Entity Extraction: Extract parties, dates, durations using regex patterns
  5. Risk Assessment: Calculate risk scores based on keyword analysis
  6. Key Terms Identification: Find important clauses and terms
  7. Interactive Chat: Enable Q&A about the contract using Gemini

Risk Scoring Algorithm

  • Uses weighted keyword matching for risk factors
  • Considers: indemnity, liability, penalty, termination, warranty, disputes
  • Provides normalized risk scores (0-100) with LOW/MEDIUM/HIGH categories

Security Features

  • File upload validation (PDF only, size limits)
  • Session-based contract storage
  • Automatic cleanup capabilities
  • CORS protection

🎨 User Interface

  • Responsive Design: Works on desktop and mobile devices
  • Modern UI: Clean, professional interface
  • Drag & Drop: Easy file upload experience
  • Real-time Chat: Interactive chat interfaces
  • Progress Indicators: Visual feedback during processing
  • Downloadable Results: Analysis results and recommendations

πŸ‘₯ Team

Made by:

  • Aryan Bansal - Backend Development & AI Integration
  • Anushka Gupta - Frontend Development & UI/UX Design
  • Aryan Gupta - AI Model Implementation & Testing

πŸ”’ Privacy & Security

  • Enterprise-grade security measures
  • Local file processing
  • Session-based data management
  • No permanent storage of sensitive documents
  • Compliance with legal industry standards

πŸš€ Future Enhancements

  • Integration with more legal databases
  • Advanced ML models for case prediction
  • Multi-language support
  • Real-time collaboration features
  • Integration with legal practice management systems
  • Mobile application development

βš–οΈ Legal Disclaimer

LegalAI Pro is a technology tool designed to assist legal professionals. It does not provide legal advice and should not replace professional legal consultation. Always consult with qualified attorneys for specific legal matters.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Transform your legal practice with AI-powered intelligence. Experience the future of legal technology with LegalAI Pro.

About

A comprehensive AI-powered legal technology platform empowering professionals with contract analysis, legal assistance, and case prediction.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors