Generation task 

A GenerationTask represents one AI-generation request. Tasks are stored in the database table tx_ai3_domain_model_generation_task and managed through the Extbase GenerationTaskRepository.

Task lifecycle 

Every task moves through a set of states defined by \Wegewerk\Ai3Core\Enums\Status:

Value Meaning
Pending Task created, waiting to be processed.
Processing Reserved for future use (processing flag).
Done AI generation completed; result is populated.
Failed Generation failed; error_message is populated.
Canceled Task was canceled before processing.

Field reference 

status

status
Type
string (enum)
Default
Pending

Current lifecycle state. One of Pending, Processing, Done, Failed, Canceled.

prompt

prompt
Type
string
Default
(empty)

The text prompt sent to the AI endpoint.

image

image
Type
string
Default
(empty)

Optional path to an image passed to the capability endpoint.

capability

capability
Type
string
Default
(empty)

Key of the registered capability (e.g. my_ext_summary). See Capability API.

record_table

record_table
Type
string
Default
(empty)

Name of the TYPO3 database table that owns the record being processed (e.g. tt_content).

record_field

record_field
Type
string
Default
(empty)

Name of the field within record_table that will receive the generated text.

record_uid

record_uid
Type
int

UID of the owning record.

generate_language

generate_language
Type
string
Default
(empty)

ISO language code passed to the capability endpoint.

result

result
Type
string
Default
(empty)

The text returned by the capability endpoint after a successful generation.

result_meta

result_meta
Type
string
Default
(empty)

Optional JSON metadata returned alongside the result.

error_message

error_message
Type
string
Default
(empty)

Human-readable error description when status is Failed.

reviewed

reviewed
Type
bool
Default
false

Set to true by an editor after reviewing the generated result.

generated_timestamp

generated_timestamp
Type
int (Unix timestamp)
Default
0

Unix timestamp set when generation completes successfully.

GenerationTaskService 

\Wegewerk\Ai3Core\Service\GenerationTaskService is the primary API for working with the task queue. Inject it via constructor:

Adding a generation task
use Wegewerk\Ai3Core\Domain\Model\Dto\AddGenerationTask;
use Wegewerk\Ai3Core\Service\GenerationTaskService;

$dto = new AddGenerationTask(
    status: 'Pending',
    prompt: 'Write a short product description.',
    image: '',
    capability: 'my_ext_summary',
    record_table: 'tt_content',
    record_field: 'bodytext',
    record_uid: 42,
    generateLanguage: 'en',
    parameters: '',
    result: '',
    result_meta: '',
    error_message: '',
);

$task = $this->generationTaskService->addTask($dto);
Copied!

Useful query methods:

Method Description
getTask(int $uid) Latest task for record_uid.
isTaskRunning(int $uid) true if status is Pending or Processing.
hasGenerationDone(int $uid) true if the latest task is Done.
getLatestResult(int $uid) Result string of the most recent Done task.
isReviewed(int $uid) true if the latest task has been reviewed.
setReviewed(GenerationTask $task) Marks the task as reviewed and persists.