ai-legal-assistant

Law Ecosystem is an AI-powered multilingual legal assistant designed to make legal aid accessible and understandable for everyone. It offers instant legal advice in various languages, analyzes and summarizes complex legal documents, helps build arguments with AI suggestions, and facilitates seamless tele-appointments with lawyers.

https://github.com/leksialevin7700/ai-legal-assistant

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (5.6%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

Law Ecosystem is an AI-powered multilingual legal assistant designed to make legal aid accessible and understandable for everyone. It offers instant legal advice in various languages, analyzes and summarizes complex legal documents, helps build arguments with AI suggestions, and facilitates seamless tele-appointments with lawyers.

Basic Info
  • Host: GitHub
  • Owner: leksialevin7700
  • Language: HTML
  • Default Branch: main
  • Homepage:
  • Size: 193 KB
Statistics
  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created 9 months ago · Last pushed 7 months ago
Metadata Files
Readme Citation

README.md

AI-Powered Legal Assistant

This makes legal help accessible, multilingual, and available 24/7 using AI. It’s designed for individuals facing language barriers, high legal fees, and complex procedures.

🚀 Features

  • 💬 Multilingual AI chatbot for instant legal advice
  • 📄 Auto-generates contracts, notices (BART)
  • 📚 Legal research with context (Legal-BERT + LangChain)
  • 🧠 Argument builder with AI suggestions
  • 🔍 Citation Analyzer for validating and linking legal references
  • 📅 Book lawyers via Google Meet
  • 🔐 Encrypted, privacy-compliant storage

🛠 Tech Stack

  • Frontend: HTML, CSS
  • Backend: Python (Flask)
  • AI Models: Legal-BERT, BART
  • DB: MongoDB
  • Scheduler: Google Calendar API

💡 Why It Matters

  • Supports regional languages
  • Operates 24/7
  • Freemium model: basic help free, pay for more
  • Scales across regions and legal systems

Demo video: https://www.youtube.com/watch?v=gntHSsjw428

See the updated one in [https://github.com/leksialevin7700/all-india-developers-hackathon]

Owner

  • Name: Leksia Nagarajan
  • Login: leksialevin7700
  • Kind: user

Citation (citation_analyzer/app.py)

from flask import Flask, render_template, request
from markupsafe import Markup
import requests
import os
from dotenv import load_dotenv
import markdown as mk

load_dotenv()

app = Flask(__name__, template_folder='frontend')

GEMINI_API_KEY = os.getenv('GEMINI_API_KEY')

def format_response_as_bullet_points(text):
    """Convert text into properly formatted markdown bullet points"""
    # Split text into lines and clean them
    lines = [line.strip() for line in text.split('\n') if line.strip()]
    formatted_lines = []
    
    for line in lines:
        # If it's a citation or numbered item, make it a bullet point
        if line.startswith('*') and not line.startswith('* '):
            line = '* ' + line[1:].strip()
        elif line.startswith('•'):
            line = '* ' + line[1:].strip()
        elif not (line.startswith('* ') or line.startswith('- ')):
            # If it doesn't start with bullet point formatting already
            line = '* ' + line
        
        formatted_lines.append(line)
    
    return '\n'.join(formatted_lines)

def get_key_points(case_description):
    api_url = "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent"
    headers = {"Content-Type": "application/json"}
    payload = {
        "contents": [
            {
                "parts": [
                    {
                        "text": f"Extract important key points to handle this legal case. Format each point as a bullet point with an asterisk (*):\n{case_description}"
                    }
                ]
            }
        ]
    }
    params = {"key": GEMINI_API_KEY}
    response = requests.post(api_url, headers=headers, json=payload, params=params)
    result = response.json()
    
    try:
        key_points_text = result['candidates'][0]['content']['parts'][0]['text']
        key_points_text = format_response_as_bullet_points(key_points_text)
    except (KeyError, IndexError):
        key_points_text = "* Error: Unable to extract key points."
    
    return key_points_text

def get_court_questions(case_description):
    api_url = "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent"
    headers = {"Content-Type": "application/json"}
    payload = {
        "contents": [
            {
                "parts": [
                    {
                        "text": f"Suggest what questions a lawyer should ask in court based on this case. Format each question as a bullet point with an asterisk (*):\n{case_description}"
                    }
                ]
            }
        ]
    }
    params = {"key": GEMINI_API_KEY}
    response = requests.post(api_url, headers=headers, json=payload, params=params)
    result = response.json()
    
    try:
        questions_text = result['candidates'][0]['content']['parts'][0]['text']
        questions_text = format_response_as_bullet_points(questions_text)
    except (KeyError, IndexError):
        questions_text = "* Error: Unable to generate court questions."
    
    return questions_text

@app.route('/', methods=['GET'])
def index():
    return render_template('index.html')

@app.route('/process_case', methods=['POST'])
def process_case():
    case_description = request.form['case_description']
    key_points = get_key_points(case_description)
    court_questions = get_court_questions(case_description)
    
    # Convert markdown to HTML and mark as safe for rendering
    key_points_html = Markup(mk.markdown(key_points))
    court_questions_html = Markup(mk.markdown(court_questions))
    
    return render_template('index.html',
                          case_description=case_description,
                          key_points=key_points_html,
                          court_questions=court_questions_html)

if __name__ == '__main__':
    app.run(debug=True,port = 5045)

GitHub Events

Total
  • Watch event: 5
  • Member event: 1
  • Push event: 9
Last Year
  • Watch event: 5
  • Member event: 1
  • Push event: 9

Dependencies

homePage/requirements.txt pypi
  • Flask ==1.1.2
  • Flask-RESTful ==0.3.8
requirements.txt pypi
  • huggingface_hub *
  • torch *
  • transformers *