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.
To install the Profanity API, follow these steps:
-
Clone the repository:
git clone https://github.com/Lostovayne/Profanity-Api.git
-
Navigate to the project directory:
cd Profanity-Api
-
Install the dependencies using Bun:
bun install
-
Create the vector database in Upstash.
-
Seed the database with initial data:
bun run seed.ts
To use the Profanity API, you need to set up the server and make requests to the endpoints.
You can run the server using:
bun index.ts
or using Wrangler:
bun wrangler dev index.ts
Endpoint | Method | Description |
---|---|---|
/ |
POST | Check for profanity in text |
/ |
POST | Filter profanity from text |
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.
curl -X POST http://localhost:3000/ -d '{"text": "Some text with profanity"}'
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"
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch:
git checkout -b feature/YourFeature
- Commit your changes:
git commit -m "Add some feature"
- Push to the branch:
git push origin feature/YourFeature
- Open a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.