sfolador / ai-avatar-suggest
Create avatar for your users with openai
Requires
- php: ^8.1
- illuminate/contracts: ^9.0|10.*
- openai-php/client: ^0.3.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-11-09 06:10:09 UTC
README
Use this library to generate avatars for your users by letting them insert a short description about themselves.
Installation
You can install the package via composer:
composer require sfolador/ai-avatar-suggest
You can publish the config file with:
php artisan vendor:publish --tag="ai-avatar-suggest-config"
This is the contents of the published config file:
return [ 'openai_key' => env('OPENAI_KEY'), 'default_size' => '256x256', 'default_route' => 'ai-avatar-suggest', 'use_cache' => true, 'throttle' => [ 'enabled' => false, 'max_attempts' => 60, 'prefix' => 'ai-avatar-suggest', ], ];
Remember to set your OpenAI key in your .env file.
If the use_cache
option is set to true
, the package will use the default cache driver to prevent
unnecessary calls to the OpenAI API. You can change the cache driver in your config/cache.php
file.
Usage
$aiAvatarSuggest = new Sfolador\AiAvatarSuggest(); echo $aiAvatarSuggest->suggest('A developer with a red beard and a cool hat'); //or if you want to use the facade echo AiAvatarSuggest::suggest('A developer with a red beard and a cool hat');
You can also invoke the generation by calling the route ai-avatar-suggest
with a prompt
parameter.
The response will be a JSON with the suggested email, such as:
{ "suggestion": "https://www.example.com/link/to/avatar" }
Cache clear
If you use a Cache driver that supports tags, you can clear the cache by invoking the command:
php artisan ai-avatar-suggest:clear-cache
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.