lenorix/laravel-ai-jobs

Queue AI to process in background

v0.1.1 2025-05-02 04:27 UTC

This package is auto-updated.

Last update: 2025-05-02 04:27:30 UTC


README

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

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.