lenorix / laravel-ai-jobs
Queue AI to process in background
Fund package maintenance!
lenorix
Requires
- php: ^8.3||^8.4
- illuminate/contracts: ^10.0||^11.0||^12.0
- lenorix/laravel-job-status: ^0.4
- maltekuhr/laravel-gpt: ^0.1
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9||^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3||^2.0
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
README
Queue AI to process in background.
Support us
Support this work in GitHub or get in contact.
Installation
You can install the package via composer:
composer require lenorix/laravel-ai-jobs
Usage
After create your maltekuhr/laravel-gpt
class extending GPTChat
create a job and extend
Lenorix\LaravelAiJobs\GptChatJob
class.
class MyGptJob extends GptChatJob { protected function getGptChatInstance(): GPTChat { return MyChatGPTChat::make(); // This helps the job to get an instance of your GPTChat. } }
And now queue it instead of use send
method, and save the tracker ID:
$trackerId = MyGptJob::dispatch($myGptChat) ->getJob() ->tracker() ->id;
When the tracker isSuccessful
method returns true, get ready an instance of
your GPTChat
and use GptChatFuture
to update that with the result.
GptChatFuture::find($trackerId) ->getResultIn($myGptChat);
Now you can use that as usually, using latestMessage
method.
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.