Skip to content

Latest commit

 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Legal Chatbot

Chatbot Home Page Interface

Overview

This project is a legal chatbot that provides legal advice and helps users with various legal queries. The chatbot uses a combination of advanced technologies such as Retrieval-Augmented Generation (RAG), semantic search, vector databases, and large language models (LLMs) to provide precise and relevant answers. It utilizes Milvus as a vector database for indexing legal documents, and Ollama (Llama 3.2 1B parameters) as the underlying large language model to interpret user queries.

The frontend is developed using React and Vite, while the backend is built using Flask.

Features

  1. IPC Section Query Assistance: The chatbot can interpret and respond to user queries related to sections of the Indian Penal Code (IPC). It retrieves the most relevant IPC sections based on the user's query, with their brief descriptions.
  2. Legal Document Generation: The chatbot can help in drafting various legal documents, such as contracts, agreements, and notices, by guiding the user through the necessary inputs.
  3. Precedents Search: The chatbot can assist users in finding relevant case law precedents. It retreives key cases along with their citations and summaries, helping users understand judicial interpretations and their implications under Indian law.

Tech Stack

  • Frontend: React, Vite
  • Backend: Flask
  • Semantic Search: Retrieval-Augmented Generation (RAG) with Milvus vector database
  • LLM: Ollama (Llama 3.2 with 1B parameters)

How It Works

Watch Video

  1. Query Processing: The user enters a query through the frontend interface. The query is processed and sent to the backend Flask server.
  2. Semantic Search: The query is run against a vectorized database of legal documents stored in Milvus, using semantic search. This search retrieves relevant legal content, such as IPC sections, case precedents, or other legal information.
  3. LLM Response Generation: The retrieved information is passed to Ollama's LLM, which then generates a precise and coherent response to the user’s query.
  4. Frontend Display: The response is returned to the frontend, where it is displayed to the user in an easy-to-read format.

Requirements

  • Python 3.8 or higher
  • Node.js (for React and Vite)
  • Milvus (for vector storage)
  • Ollama LLM
  • Flask

Setup

  1. Clone the repository:

    git clone https://github.com/reethuthota/Legal_Chatbot.git
    cd Legal_Chatbot
  2. Create and activate a virtual environment:

    python3 -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
  3. Install backend dependencies:

    pip install -r requirements.txt
  4. If the previous one doesnt work and if you face anyy dependancy issues

    pip install -r requirements1.txt

Milvus Setup

```

Run the create_collections.py file 2 times, once with "./IPC.pdf" as the path and once more with "./documentforms.pdf" as the path

  1. Run the script to make collections on the vector database.
    create_collections.py
  2. Then run precedance_collections.py file with "./case_files" as the path

By doing steps 1 and 2 you insert the vector embeddings into milvus which should already be running in docker

Backend Setup (Flask)

  1. Start the Flask backend:

    cd backend
    python app.py

    The backend server will be running on http://localhost:8080.

Frontend Setup (React + Vite)

  1. Install frontend dependencies:

    cd frontend
    npm install
  2. Run the frontend development server:

    npm run dev

    The frontend will be available at http://localhost:5173.

Usage

  • IPC Section Queries: To inquire about a specific section of the Indian Penal Code, simply type the section number or describe your query. For example: “What is Section 302 of the IPC?” The chatbot will retrieve the relevant sections and provide concise descriptions.

  • Legal Document Creation: To create a legal document (e.g., an affidavit, agreement, or contract), you must provide a detailed prompt that includes all the necessary information. For example, if you want to generate a rental agreement, your prompt should include the following details:

    • Names of the parties (e.g., Landlord and Tenant)
    • Property address
    • Terms of the agreement (e.g., rent amount, security deposit)
    • Duration of the lease (e.g., 1 year)
    • Any special clauses or terms (e.g., restrictions on subletting, maintenance responsibilities)
  • Precedent Search: You can request the chatbot to search for relevant case law precedents by providing case details or describing the legal issue you're researching. The chatbot will search through past case law and return relevant cases along with citations and summaries.

Contributing

If you'd like to contribute to the development of the Legal Chatbot, feel free to fork the repository and submit a pull request with your changes. Please ensure that your code follows the project's coding standards and is well-documented.

License

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

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages