LegalOSS179.5ktracked
AI Platforms & Workbenches · Retrieval & RAG · Legal AI & NLP

lawglanceMaintained

lawglance/lawglance

Free RAG based AI legal assistant

⚖️ LawGlance: AI-Powered Legal Assistant

GitHub stars GitHub Forks License: Apache 2.0 Python 3.9+ Colab Loom LangChain LangGraph Crew AI

Bridging the Gap Between People and Legal Access 🌍

🌐 Website: LawGlance

LawGlance is a free, open-source, people-centric initiative 💡 designed to make legal guidance accessible to everyone. Using AI-powered Retriever-Augmented Generation (RAG), LawGlance delivers quick, accurate legal support tailored to your needs, whether you're seeking information as a layperson or a professional.

🛡️ Mission: “Justice should be accessible to everyone. LawGlance ensures that no one is left behind when it comes to legal knowledge.”

This project is developed with support from mentors and experts at Data Science Academy and Curvelogics. 💼


📚 Legal Coverage

LawGlance currently supports the following laws, with plans to expand internationally:

  • 🏛️ The Indian Constitution
  • 📜 The Bharatiya Nyaya Sanhita, 2023
  • 🚨 The Bharatiya Nagarik Suraksha Sanhita, 2023
  • 🧾 The Bharatiya Sakshya Adhiniyam, 2023
  • 📦 The Consumer Protection Act, 2019
  • 🧭 The Motor Vehicles Act, 1988
  • 💻 Information Technology Act, 2000
  • 👧 The Protection of Children from Sexual Offences Act (POCSO), 2012
  • The Sexual Harassment of Women at Workplace (Prevention, Prohibition and Redressal) Act, 2013

Originally launched as Niyam SahaAI, LawGlance aims to cover legal systems from different countries in the near future.


🎥 Video Tutorial

Curious how LawGlance works? Watch this detailed tutorial!

Niyam SahaAI Tutorial


💻 Developer Quick Start Guide


Ready to get started? Follow these simple steps to set up LawGlance on your machine:

  1. Clone the Repository 🌀

    git clone https://github.com/lawglance/lawglance.git
  2. Install uv 📂

    First, let’s install uv and set up our Python project and environment

    MacOS/Linux:

    curl -LsSf https://astral.sh/uv/install.sh | sh

    Windows:

    powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

    Make sure to restart your terminal afterwards to ensure that the uv command gets picked up.

  3. Install Dependencies 📦

    uv sync
  4. Set Your OpenAI API Key 🔑

    Open .env and add your OpenAI API key:

    OPENAI_API_KEY=your-api-key-here
  5. Run the Application 🚀

    uv run streamlit run app.py
  6. Access the App 🌐
    Open your browser and visit:

    http://127.0.0.1:8501

🤖 Agentic Backend

LawGlance is now powered by an agentic retrieval pipeline built with LangGraph, living in the backend/ folder. Instead of a single fixed RAG chain, the agent decides for itself when to call the retrieve_docs tool, loops until it has enough context, and only then produces a cited final answer.

  • backend/graph.py / backend/nodes.py — the LangGraph agent loop (llm_calltool_nodefinal_answer)
  • backend/tools.py — the vector-store retrieval tool the agent can call
  • backend/retrieval.pyagent_invoke(), the entry point the Streamlit app (app.py) now calls
  • backend/main.py — an optional FastAPI HTTP API in front of the same agent

The original single-chain implementation (lawglance_main.py, chains.py) is still in the repo for reference and is not deleted, but it's no longer what app.py runs against.

Run the FastAPI backend standalone (useful for integrating LawGlance into another app):

uv run uvicorn backend.main:app --reload

Then query it directly:

curl "http://127.0.0.1:8000/query?query=What+is+Article+21%3F"

🗄️ Enable Redis Caching (Recommended for Production Use)

LawGlance uses Redis to cache chat history and LLM responses for faster, scalable performance.

How to Install and Activate Redis

  1. Install Redis Server

    Ubuntu/Linux:

     sudo apt-get update
     sudo apt-get install redis-server

    MacOS (with Homebrew):

    brew install redis

    Windows (Recommended: Use WSL - Windows Subsystem for Linux):

    1. Install WSL and set up a Linux distribution (e.g., Ubuntu).
    2. Inside the WSL terminal, run:
      sudo apt-get update
      sudo apt-get install redis-server
    3. Start the Redis server:
      redis-server
  2. Start Redis Server

    redis-server
  3. Verify Redis is Running

    redis-cli ping

    You should see: PONG

  4. No Additional Python Setup Needed

  • The LawGlance backend automatically connects to Redis at redis://localhost:6379/0.
  • If you want to use a different host or port, update the redis_url parameter in your code. Redis caching is optional for local development but highly recommended for production deployments to ensure fast and reliable chat experiences.

🔧 Tools & Technologies

💡 Technology 🔍 Description
LangChain Framework for building language model applications
LangGraph Powers the agentic retrieval loop in backend/
ChromaDB Vector database for RAG implementation
FastAPI HTTP API for the agentic backend (backend/main.py)
Streamlit Chat UI (app.py)
Redis Chat history and response caching
OpenAI API Powering natural language understanding

🌟 Future Roadmap

Exciting developments are planned for LawGlance! Here’s what’s coming next:

Agentic Framework — Delivered! The single-agent, tool-calling retrieval pipeline described above (LangGraph, backend/) now powers the live app. Extending it into a full multi-agent team of specialists is still on the roadmap.

  1. 🌎 Law Without Borders: Expanding Our Global Reach 🇨🇦 + More!

    • LawGlance is going global! We're significantly expanding our legal knowledge base to include jurisdictions like Canada and beyond. Soon, you'll have access to a truly worldwide legal resource at your fingertips.
  2. 🗣️ Your Voice is the Key: Introducing Voice Interaction 🎙️

    • Navigate and access legal information effortlessly with our new voice command feature. Simply speak your queries and let LawGlance do the rest – making legal research more intuitive and accessible.
  3. 🌍 Bridging Language Barriers: Multi-Lingual Legal Assistance 🌐

    • We're committed to serving a global audience. LawGlance will soon offer legal assistance in multiple languages, breaking down communication barriers and making our platform truly inclusive.
  4. 🎯 Precision & Personalization: Advanced Search & Tailored Assistance 🔍

    • Say goodbye to endless scrolling! Our enhanced search engine will pinpoint the exact legal information you need with lightning speed. Plus, enjoy personalized suggestions and assistance crafted just for you.
  5. ✍️ Draft with Confidence: Introducing Legal Document Generation 📄

    • Need a contract or agreement? Our upcoming legal document generation feature will empower you to create essential legal documents using customizable templates and intuitive user input.
  6. 🗓️ Stay Organized, Stay Ahead: Introducing Case Management 📁

    • Effortlessly manage your legal matters with our new case management feature. Track crucial deadlines, appointments, and important events all in one centralized location, keeping you in control.

🤝 Contribute

We are always looking for contributors! Whether you want to help with development, report issues, or request features, we welcome you to fork the repo and submit a pull request. Every contribution helps to make LawGlance better for everyone! 🚀


LawGlance is more than just an AI tool—it's a movement to democratize access to legal knowledge for everyone. Together, let’s make justice truly accessible! ✨