gamalkh299/gpt-content-reviewer

A Laravel package to review content and images using ChatGPT API

1.0.0 2024-12-23 11:48 UTC

This package is auto-updated.

Last update: 2025-06-16 17:36:26 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package allows you to review the content of a model using ChatGPT Moderation API.

Installation

You can install the package via composer:

composer require gamalkh299/gpt-content-reviewer

You can publish and run the migrations with:

php artisan vendor:publish --tag="gpt-content-reviewer"
php artisan migrate

This is the contents of the published config file:

return [
    'key' => env('CHAT_GPT_API_KEY'),
    'queue' => env('GPT_QUEUE', 'gpt-content-reviewer'),
];

Usage

  • At fisrt, you need to get an API key from ChatGPT.
  • Then, you need to add the API key to your .env file.
CHAT_GPT_API_KEY=your-api-key

Then add the following trait to the model you want to review its content.

use gamalkh\GptContentReviewer\Traits\Reviewable;

Don't forget to implement the getReviewableColumns abstract function to specify the columns you want to review and handleReviewResult abstract function to handle the review result.

public function getReviewableColumns(): array
{
   // return the columns you want to review
    return ['content'];
}

public function handleReviewResult($result)
{
    // handle the review result
}

before you use it you need to run the following command to create the review table.

php artisan queue:work --queue=gpt-content-reviewer

you can use the package to create a review for a model and it will be added to the queue to be reviewed.

$model = Model::find(1);
$gptContentReviewer = new gamalkh\GptContentReviewer();
$gptContentReviewer->createReview($model);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.