Use this library to generate avatars for your users by letting them insert a short description about themselves.
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.
$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"
}
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
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.