Skip to content

animshamura/AdvoCat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

AdvoCat

Overview

AdvoCat is an advanced, AI-powered legal assistant built with FastAPI. The application leverages OpenAI's GPT-3 model to provide users with instant legal advice and information. It combines natural language processing (NLP) techniques, powered by spaCy and NLTK, to classify and respond to various legal queries, such as contract laws, general legal terms, and case procedures.

Additionally, the system logs all user queries and responses to a database for analysis and continuous improvement. The app also provides suggested actions and related links to help users better understand their legal concerns.

Features

  • AI-Powered Legal Assistance: Instant responses generated by OpenAI GPT-3.
  • Predefined Legal Chatbot: Custom NLP patterns to handle common legal queries.
  • Query Classification: Categorizes queries and provides suggested actions and related links.
  • Query Logging: Logs user queries and AI-generated responses in a database (SQLite).
  • Search History: A /queries endpoint to retrieve past user queries and responses.
  • FastAPI Backend: High-performance API built using FastAPI.

Technologies Used

  • FastAPI: A modern, fast web framework for building APIs with Python.
  • OpenAI GPT-3: AI model for generating legal advice and answering legal questions.
  • spaCy: Advanced NLP library used for classifying and extracting entities from legal queries.
  • NLTK: Provides a simple chatbot structure for predefined legal patterns.
  • SQLAlchemy: ORM used for query logging and database interactions.
  • SQLite: Lightweight relational database for storing user queries and responses.
  • Uvicorn: ASGI server to run the FastAPI application.

Installation

  1. Clone the repository:
git clone https://github.com/shamuraanim7/AdvoCat.git
cd AdvoCat
  1. Install required dependencies:
pip install -r requirements.txt
  1. Install spaCy and download the English model:
python -m spacy download en_core_web_sm
  1. Set OpenAI API Key: Replace 'your_openai_api_key_here' in the code with your OpenAI API key.

Running the Application

To run the server locally, use the following command:

uvicorn main:app --reload

This will start the FastAPI application at http://localhost:8000.

API Endpoints

1. POST /ask

The main endpoint for asking legal questions.

Request Body:

{
  "query": "What is contract law?"
}

Response:

{
  "response": "Contract law is the body of law that governs legally binding agreements between parties.",
  "suggested_actions": ["Review the contract terms thoroughly."],
  "related_links": ["https://www.law.com/contract-terms/"]
}

2. GET /queries

Fetch all previously logged queries and responses.

Parameters:

  • skip: Number of queries to skip (default is 0).
  • limit: Number of queries to return (default is 10).

Example:

GET /queries?skip=0&limit=10

Response:

[
  {
    "id": 1,
    "query": "What is contract law?",
    "response": "Contract law is the body of law that governs legally binding agreements between parties."
  }
]

Database Setup

The application uses SQLite to store logs of user queries and responses. This helps track previous interactions, analyze trends, and improve the AI's responses.

Contributing

If you'd like to contribute to this project, please fork the repository and submit a pull request with your changes.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature-branch)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to your branch (git push origin feature-branch)
  5. Submit a pull request

License

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

Acknowledgments

  • OpenAI GPT-3 for its powerful language model.
  • spaCy and NLTK for simplifying natural language processing tasks.
  • FastAPI for providing a fast and efficient framework for building APIs.

About

An ML app gives legal solutions and advices based on different laws

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages