GenerativeAiOperation
- Since
- 0.1.0
- Source
wp-includes/php-ai-client/src/Operations/DTO/GenerativeAiOperation.php:24
Represents a long-running generative AI operation.
Description
This DTO tracks the progress of generative AI tasks that may not complete immediately, providing access to the result once available.
Compatibility
- WordPress
- since 0.1.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in 2 of the 5 tracked releases, added in 0.1.0.
Properties · 3
$idstringprivate$stateWordPress\AiClient\Operations\Enums\OperationStateEnumprivate$resultWordPress\AiClient\Results\DTO\GenerativeAiResult|nullprivate
Methods · 8
- __construct()Constructor.
- __clone()Creates a deep clone of this operation.
- getId(){@inheritDoc}
- getState(){@inheritDoc}
- getResult()Gets the operation result.
- getJsonSchema(){@inheritDoc}
- toArray(){@inheritDoc}
- fromArray(){@inheritDoc}
Source code
class GenerativeAiOperation extends AbstractDataTransferObject implements OperationInterface{ public const KEY_ID = 'id'; public const KEY_STATE = 'state'; public const KEY_RESULT = 'result'; /** * @var string Unique identifier for this operation. */ private string $id; /** * @var OperationStateEnum The current state of the operation. */ private OperationStateEnum $state; /** * @var GenerativeAiResult|null The result once the operation completes. */ private ?GenerativeAiResult $result; /** * Constructor. * * @since 0.1.0 * * @param string $id Unique identifier for this operation. * @param OperationStateEnum $state The current state of the operation. * @param GenerativeAiResult|null $result The result once the operation completes. */ public function __construct(string $id, OperationStateEnum $state, ?GenerativeAiResult $result = null) { $this->id = $id; $this->state = $state; $this->result = $result; } /** * Creates a deep clone of this operation. * * Clones the result object if present to ensure the cloned * operation is independent of the original. * The state enum is immutable and can be safely shared. * * @since 0.4.2 */ public function __clone() { // Clone the result if present (GenerativeAiResult has __clone) if ($this->result !== null) { $this->result = clone $this->result; } // Note: $state is an immutable enum and can be safely shared } /** * {@inheritDoc} * * @since 0.1.0 */ public function getId(): string { return $this->id; } /** * {@inheritDoc} * * @since 0.1.0 */ public function getState(): OperationStateEnum { return $this->state; } /** * Gets the operation result. * * @since 0.1.0 * * @return GenerativeAiResult|null The result or null if not yet complete. */ public function getResult(): ?GenerativeAiResult { return $this->result; } /** * {@inheritDoc}Changelog
Introduced in 0.1.0. Unchanged from 7.0.4 through 7.1.0.
Signature, return type and hooks compared across 2 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/php-ai-client/src/Operations/DTO/GenerativeAiOperation.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.