comment-ai-moderation
v1.0.1
Published
Comment moderator with AI
Readme
comment-ai-moderation
Description
comment-ai-moderation is a library that allows you to moderate comments/texts using OpenAI LLM in its gpt-3.5-turbo version.
Based on the comment/text received by the "moderate" function, the model will analyze its content and context and then return relevant information that allows the user to know whether the comment should be banned or not along with the corresponding reason.
Installation
To install the library, you can use npm:
npm install comment-ai-moderationUsage
First, you need to import the moderate function from the library:
import { moderate } from 'comment-ai-moderation';Next, you need to have a valid OpenAI api key (keep in mind that this is a paid service).
In your environment variables file you must define the api key as follows:
OPENAI_API_KEY= your_openai_keyFinally, to moderate a comment all you have to do is use the function as follows
moderate("Your example comment")Example Response
moderate("This event rules!")
{
sentiment: 'positive',
aggressiveness: '1',
ban: false,
reason: '',
language: 'English'
} moderate("You are a bastard!")
{
sentiment: 'negative',
aggressiveness: '5',
ban: true,
reason: 'offensive',
language: 'English'
}Contributions
Contributions to comment-ai-moderation are welcome. Please ensure you follow code and testing conventions before making a pull request.
License
This project is licensed under the terms of the MIT license. See the LICENSE file for details.
