Skip to content

API built using Typescript and Honojs, connected to a vector database using an embedding of Upstash to compare similar words and phrases and determine if they are insults etc.

Notifications You must be signed in to change notification settings

Lostovayne/Profanity-Api

Repository files navigation

Profanity API

Build Status License Version Technology

Description

The Profanity API was created to provide an endpoint that can quickly and efficiently respond to words or phrases that are considered offensive or inappropriate. Its primary goal is to filter out content that could harm a healthy community, thereby cleaning up chats and fostering a more positive environment. By using this API, developers can help prevent toxic behavior and promote a healthier community.

This API utilizes a vector database for words and similarities, along with Langchain to handle contextual understanding. It offers an easy-to-use interface for integrating profanity detection into applications.

Table of Contents

Installation

To install the Profanity API, follow these steps:

  1. Clone the repository:

    git clone https://github.com/Lostovayne/Profanity-Api.git
  2. Navigate to the project directory:

    cd Profanity-Api
  3. Install the dependencies using Bun:

    bun install
  4. Create the vector database in Upstash.

  5. Seed the database with initial data:

    bun run seed.ts

Usage

To use the Profanity API, you need to set up the server and make requests to the endpoints.

Starting the Server

You can run the server using:

bun index.ts

or using Wrangler:

bun wrangler dev index.ts

API Endpoints

Endpoint Method Description
/ POST Check for profanity in text
/ POST Filter profanity from text

Request Parameters

For both endpoints, the request body should be a JSON object containing the following parameter:

  • text (string): The text to check or filter for profanity.

Example Request

Check for Profanity

curl -X POST http://localhost:3000/ -d '{"text": "Some text with profanity"}'

Response Format

The API will return a JSON response. Here’s an example response for the /check endpoint:

{
  "isProfanity": true,
  "score": 0.95,
  "flaggedFor": "profanity word"
}

## Environment Variables
You need to set the following environment variables in your `.env` file:

- `VECTOR_URL`: The URL for your Upstash vector database.
- `VECTOR_TOKEN`: The token for authenticating with your Upstash vector database.

Example `.env` file:
```plaintext
VECTOR_URL="https://your-upstash-vector-url"
VECTOR_TOKEN="your-upstash-token"

Contributing

Contributions are welcome! Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch:
    git checkout -b feature/YourFeature
  3. Commit your changes:
    git commit -m "Add some feature"
  4. Push to the branch:
    git push origin feature/YourFeature
  5. Open a pull request.

License

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

About

API built using Typescript and Honojs, connected to a vector database using an embedding of Upstash to compare similar words and phrases and determine if they are insults etc.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published