PHPackages                             fomvasss/laravel-ai-tasks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. fomvasss/laravel-ai-tasks

ActiveLibrary[Queues &amp; Workers](/categories/queues)

fomvasss/laravel-ai-tasks
=========================

Orchestrator AI-tasks for Laravel: drivers, routing, queue, ai\_runs, post-processing

0.1.0(6mo ago)14MITPHPPHP ^8.1

Since Nov 1Pushed 6mo agoCompare

[ Source](https://github.com/fomvasss/laravel-ai-tasks)[ Packagist](https://packagist.org/packages/fomvasss/laravel-ai-tasks)[ RSS](/packages/fomvasss-laravel-ai-tasks/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (2)Used By (0)

Laravel Ai Tasks
================

[](#laravel-ai-tasks)

[![License](https://camo.githubusercontent.com/a4386c31b4a766f3e3477645bfcbb1b79fb8bf237a57d1dceed1aeee672bd72b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f666f6d76617373732f6c61726176656c2d61692d7461736b732e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/fomvasss/laravel-ai-tasks)[![Build Status](https://camo.githubusercontent.com/d7e5e40a247584884dc2e542e1c226e89d019fa95a3dbdf4d5712f262ead8829/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f666f6d76617373732f6c61726176656c2d61692d7461736b732e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/fomvasss/laravel-ai-tasks)[![Latest Stable Version](https://camo.githubusercontent.com/c0aedde61de498a09077139a8bfd2bb5cb358c096c1e209f803867e3394f2371/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666f6d76617373732f6c61726176656c2d61692d7461736b732e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/fomvasss/laravel-ai-tasks)[![Total Downloads](https://camo.githubusercontent.com/393fae60afc159660f6666bcc4d4fe99905b79c822275f703381861155c3253e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666f6d76617373732f6c61726176656c2d61692d7461736b732e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/fomvasss/laravel-ai-tasks)[![Quality Score](https://camo.githubusercontent.com/044c7a4390fb495605dab10e233c88167b0edbe6a9e2b23285166cfb9703cd7c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f666f6d76617373732f6c61726176656c2d61692d7461736b732e7376673f7374796c653d666f722d7468652d6261646765)](https://scrutinizer-ci.com/g/fomvasss/laravel-ai-tasks)

Orchestrator AI-tasks for Laravel: drivers, routing, webhooks, queue, ai\_runs, post-processing.

Installation
------------

[](#installation)

Install the package via composer:

```
composer require fomvasss/laravel-ai-tasks
```

Publish and run the migrations with:

```
php artisan vendor:publish --provider="Fomvasss\AiTasks\AiServiceProvider" --tag=config
php artisan vendor:publish --provider="Fomvasss\AiTasks\AiServiceProvider" --tag=migrations
php artisan migrate
```

Example `.env`:

```

OPENAI_API_KEY=...
GEMINI_API_KEY=...

```

### Supervisor/Queue configuration

[](#supervisorqueue-configuration)

Add the following queues to your queue worker command (or use Horizon as below):

```
php artisan queue:work --queue=ai:webhook,ai:high,ai:default,ai:low,ai:post,ai:webhook
```

### Horizon configuration

[](#horizon-configuration)

If you are using Laravel Horizon, you can configure the queues in `config/horizon.php`:

 See details:```
'environments' => [
    '*' => [
        // Prioryty online dialogues/streams (min. latency)
        'supervisor-ai-high' => [
            'connection'   => 'redis',
            'queue'        => ['ai:high'],
            'balance'      => 'auto',     // auto|simple|false
            'minProcesses' => 2,
            'maxProcesses' => 24,
            'tries'        => 1,
            'timeout'      => 40,         // seconds
            'nice'         => 0,
        ],

        // Typical text generations
        'supervisor-ai-default' => [
            'connection'   => 'redis',
            'queue'        => ['ai:default'],
            'balance'      => 'auto',
            'minProcesses' => 2,
            'maxProcesses' => 32,
            'tries'        => 3,
            'timeout'      => 120,
            'nice'         => 5,
        ],

        // Mass/slow tasks (catalogs, images)
        'supervisor-ai-low' => [
            'connection'   => 'redis',
            'queue'        => ['ai:low'],
            'balance'      => 'simple',
            'minProcesses' => 1,
            'maxProcesses' => 24,
            'tries'        => 2,
            'timeout'      => 300,
            'nice'         => 10,
        ],

        // Postprocessing tasks (validation JSON, conversions, saving)
        'supervisor-ai-post' => [
            'connection'   => 'redis',
            'queue'        => ['ai:post'],
            'balance'      => 'simple',
            'minProcesses' => 1,
            'maxProcesses' => 12,
            'tries'        => 2,
            'timeout'      => 300,
            'nice'         => 5,
        ],

        // Webhook from providers (short, reactive)
        'supervisor-ai-webhook' => [
            'connection'   => 'redis',
            'queue'        => ['ai:webhook'],
            'balance'      => 'simple',
            'minProcesses' => 1,
            'maxProcesses' => 8,
            'tries'        => 1,
            'timeout'      => 30,
        ],
    ],
]
```

Usage
-----

[](#usage)

### Make Task

[](#make-task)

Use command to create new task:

```
php artisan ai:make-task SomeInterestingTask --modality=text
```

This will create new task class in `app/Ai/Tasks/SomeInterestingTask.php`.

### Configure Task

[](#configure-task)

 Edit the created task class to configure it:```
