AI Lawyer Chat

📜 An AI-powered legal document assistant that allows users to upload PDFs and ask legal questions based on the document's content. This tool uses FAISS vector search for information retrieval and Groq's deepseek-r1-distill-llama-70b model for generating AI-powered responses.

Features

  • 📄 Upload and process PDF documents.
  • 🔍 Retrieve relevant information using FAISS vector search.
  • 🤖 AI-powered responses using Groq's deepseek-r1-distill-llama-70b model.
  • 💬 Interactive chat history for seamless user experience.

Directory Structure

            ai-lawyer-chat/
            ├── app.py                # Main Streamlit App
            ├── frontend.py           # Handles UI components
            ├── vector_store.py       # Handles vector embeddings and retrieval
            ├── document_processor.py # Loads & processes PDFs
            ├── model.py              # Handles AI model interactions
            ├── utils.py              # Utility functions
            ├── requirements.txt      # Dependencies
            ├── vectorstore/          # Stores FAISS index
            ├── pdfs/                 # Stores uploaded PDFs
            └── .env                  # Environment variables
        

Installation

Prerequisites

  • Python 3.8 or higher
  • A Groq API key (sign up at Groq)

Steps to Install

  1. Clone the Repository:
    git clone https://github.com/Devmbm2/ai-lawyer-chat.git
    cd ai-lawyer-chat
  2. Set Up a Virtual Environment (Optional but Recommended):
    python -m venv venv
    source venv/bin/activate (On Windows: venv\\Scripts\\activate)
  3. Install Dependencies:
    pip install -r requirements.txt
  4. Create a .env File:
    Create a file named .env in the project root and add the following:
    GROQ_API_KEY=your_groq_api_key
    OLLAMA_MODEL=deepseek-r1:1.5b
    Replace your_groq_api_key with your actual Groq API key.
  5. Ensure Required Directories Exist:
    mkdir vectorstore pdfs

How to Use This Tool

Uploading a PDF Document:

  • Navigate to the "Upload Document" section.
  • Upload a PDF file containing legal content.
  • The system will process the PDF and create a vector store for quick retrieval.

Asking Legal Questions:

  • In the "Ask a Question" section, type your legal query related to the uploaded document.
  • The AI will analyze the document and provide a response based on the content.
  • View the interactive chat history for context and clarity.

Troubleshooting:

  • If you encounter ModuleNotFoundError, ensure all dependencies are installed by running:
    pip install -r requirements.txt.
  • If the app does not open, ensure Streamlit is installed:
    pip install streamlit.
  • If the vector store is not saving, ensure the vectorstore/ directory exists:
    mkdir vectorstore.

Images and Videos from the Project



View the Code