wppaste
WordPress

AfterGenerateResultEvent

Since
0.4.0
Source
wp-includes/php-ai-client/src/Events/AfterGenerateResultEvent.php:18
Event dispatched after a prompt has been sent to the AI model and a response received.

Description

This event allows listeners to inspect the result of the model call for logging, analytics, or other post-processing purposes. The result object is immutable.

Compatibility

WordPress
since 0.4.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.4.0.

Properties · 4

$messagesWordPress\AiClient\Events\list<Message>private
$modelWordPress\AiClient\Providers\Models\Contracts\ModelInterfaceprivate
$capabilityWordPress\AiClient\Providers\Models\Enums\CapabilityEnum|nullprivate
$resultWordPress\AiClient\Results\DTO\GenerativeAiResultprivate

Methods · 6

Source code

class AfterGenerateResultEvent{    /**     * @var list<Message> The messages that were sent to the model.     */    private array $messages;    /**     * @var ModelInterface The model that processed the prompt.     */    private ModelInterface $model;    /**     * @var CapabilityEnum|null The capability that was used for generation.     */    private ?CapabilityEnum $capability;    /**     * @var GenerativeAiResult The result from the model.     */    private GenerativeAiResult $result;    /**     * Constructor.     *     * @since 0.4.0     *     * @param list<Message> $messages The messages that were sent to the model.     * @param ModelInterface $model The model that processed the prompt.     * @param CapabilityEnum|null $capability The capability that was used for generation.     * @param GenerativeAiResult $result The result from the model.     */    public function __construct(array $messages, ModelInterface $model, ?CapabilityEnum $capability, GenerativeAiResult $result)    {        $this->messages = $messages;        $this->model = $model;        $this->capability = $capability;        $this->result = $result;    }    /**     * Gets the messages that were sent to the model.     *     * @since 0.4.0     *     * @return list<Message> The messages.     */    public function getMessages(): array    {        return $this->messages;    }    /**     * Gets the model that processed the prompt.     *     * @since 0.4.0     *     * @return ModelInterface The model.     */    public function getModel(): ModelInterface    {        return $this->model;    }    /**     * Gets the capability that was used for generation.     *     * @since 0.4.0     *     * @return CapabilityEnum|null The capability, or null if not specified.     */    public function getCapability(): ?CapabilityEnum    {        return $this->capability;    }    /**     * Gets the result from the model.     *     * @since 0.4.0     *     * @return GenerativeAiResult The result.     */    public function getResult(): GenerativeAiResult    {        return $this->result;    }    /**

Changelog

Introduced in 0.4.0. Unchanged from 7.0.4 through 7.1.0.

  1. 7.0.4
  2. 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/Events/AfterGenerateResultEvent.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.