Skip to content

Meenakshimkumar/SatHackNight-LangChain

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

LangChain notion

Law Sphere

Powered by AI, driven by Justice

Law Sphere is an AI-driven web application providing intelligent legal assistance and document generation services. Utilizing advanced language models via the Groq API and leveraging the LangChain framework for prompt management, it ensures accessible, efficient, and reliable support through a secure and user-friendly interface built with Streamlit. Key features include user authentication, AI-powered legal advice, document generation, and query-response history tracking. The application leverages a modern, customizable theme and maintains security with SHA-256 password hashing. Designed for easy setup and deployment, Law Sphere aims to democratize legal support and streamline legal document creation for individuals and professionals alike.

Team members

  1. Meenakshi M Kumar
  2. Meenakshi Pramod
  3. Aleena Bino

Link to product walkthrough

Law_Sphere_1 Law_Sphere_2 Law_Sphere_3 Law_Sphere_4 Law_Sphere_5 Law_Sphere_6

How it Works ?

1. Setup and Configuration:

  • Streamlit Page Configuration: The page is configured with a custom theme including background, text, and primary colors.
  • Groq API Key: The application retrieves the Groq API key from the environment variable GROQ_API_KEY.

2. Database Initialization:

  • SQLite Connection: The application connects to an SQLite database (user_profiles.db).
  • Tables Creation: If not already present, it creates two tables: users for user authentication data and user_profiles for storing user queries and AI-generated responses.

3. Session State Initialization:

  • Session Variables: It initializes session state variables to keep track of the user's login status, user ID, and username.

4. User Authentication:

  • Signup: Users can create a new account by providing a username, email, and password. The password is hashed using SHA-256 before being stored.
  • Login: Existing users can log in using their email and password. Upon successful login, session state variables are updated with the user's information.

5. AI Model Initialization:

  • Chat Models: Two AI models are initialized using the Groq API:
  • chat for legal advice with the llama3-70b-8192 model.
  • llm for document generation with the llama3-8b-8192 model.

6. Prompt Templates:

  • Legal Advice Prompt: A prompt template for legal advice is defined.
  • Document Generation Prompt: A prompt template for document generation is defined.

7. User Interface:

  • Main Interface: Once logged in, users are welcomed and presented with a text area to input their queries or document content.
  • Option Selection: Users can select either "Get Legal Advice" or "Generate Document" from a dropdown menu.

8. Processing User Input:

  • Legal Advice: Upon clicking "Give Advice," the user input is processed through the legal advice model. The generated response is displayed and saved in the database.
  • Document Generation: Upon clicking "Generate Document," the user input is processed through the document generation model. The generated document content is displayed and saved in the database.

9. Display User History:

  • Query and Response History: The application retrieves and displays the user's previous queries and responses from the database.

10. Closing the Database Connection:

  • Connection Closure: The database connection is closed at the end of the script to ensure proper resource management.
Law.Sphere.-.Google.Chrome.2024-06-23.07-32-52.mp4

Libraries used

  1. Streamlit
  2. ChatPromptTemplate
  3. ChatGroq
  4. os

How to configure

  1. Install Python.

  2. Clone this repository.

  3. Create the virtual environment.

     python -m venv env
    
  4. Activate the virtual environment.

     env/Scripts/activate.bat
    
  5. Install streamlit using pip.

     pip install streamlit
    
  6. Install langchain and groq using pip.

     pip install langchain-groq
    
  7. Install requests using pip

    pip install requests
    
  8. Set an environment variable for the Groq API Key

    In Command Prompt(cmd)

    set GROQ_API_KEY=your_api_key_here
    

    In Powershell

    $env:GROQ_API_KEY = "your_api_key_here"
    
  9. Verifying whether the environment variable is set

    In Command Prompt(cmd)

    echo %GROQ_API_KEY%
    

    In Powershell

    echo $env:GROQ_API_KEY
    

    If set it will show your original API key.

  10. If required, you can upgrade pip(optional)

    python -m pip install --upgrade pip
    

How to Run

 streamlit run legalAI.py

About

A legal assistant and document generator using Langchain, Groq API and Streamlit.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%