CoreFiles by mySites.guru
AfterGenerateEmbeddingEvent.php108 lines, 2,810 bytes, from wordpress-7.2-beta1.zip
Raw History Compare with 7.1-beta4
md5
b65c6de4545714360515b6534fb848cb
sha1
bd0f80c15e7e1ab41433199338c3c7d27a525fd2
sha256
8f52c01f9b1f3cab6063c24666022cca09d4a68b7a7ecbac6bd61603b7290b1b
<?php

declare (strict_types=1);
namespace WordPress\AiClient\Events;

use WordPress\AiClient\Messages\DTO\MessagePart;
use WordPress\AiClient\Providers\Models\Contracts\ModelInterface;
use WordPress\AiClient\Providers\Models\Enums\CapabilityEnum;
use WordPress\AiClient\Results\DTO\EmbeddingResult;
/**
 * Event dispatched after embeddings have been generated.
 *
 * @since 1.4.0
 */
class AfterGenerateEmbeddingEvent
{
    /**
     * @var list<MessagePart> The inputs that were sent to the model.
     */
    private array $inputs;
    /**
     * @var ModelInterface The model that generated embeddings.
     */
    private ModelInterface $model;
    /**
     * @var CapabilityEnum The capability that was used for generation.
     */
    private CapabilityEnum $capability;
    /**
     * @var EmbeddingResult The result from the model.
     */
    private EmbeddingResult $result;
    /**
     * Constructor.
     *
     * @since 1.4.0
     *
     * @param list<MessagePart> $inputs The inputs that were sent to the model.
     * @param ModelInterface    $model The model that generated embeddings.
     * @param CapabilityEnum    $capability The capability that was used for generation.
     * @param EmbeddingResult   $result The result from the model.
     */
    public function __construct(array $inputs, ModelInterface $model, CapabilityEnum $capability, EmbeddingResult $result)
    {
        $this->inputs = $inputs;
        $this->model = $model;
        $this->capability = $capability;
        $this->result = $result;
    }
    /**
     * Gets the inputs that were sent to the model.
     *
     * @since 1.4.0
     *
     * @return list<MessagePart> The inputs.
     */
    public function getInputs(): array
    {
        return $this->inputs;
    }
    /**
     * Gets the model that generated embeddings.
     *
     * @since 1.4.0
     *
     * @return ModelInterface The model.
     */
    public function getModel(): ModelInterface
    {
        return $this->model;
    }
    /**
     * Gets the capability that was used for generation.
     *
     * @since 1.4.0
     *
     * @return CapabilityEnum The capability.
     */
    public function getCapability(): CapabilityEnum
    {
        return $this->capability;
    }
    /**
     * Gets the result from the model.
     *
     * @since 1.4.0
     *
     * @return EmbeddingResult The result.
     */
    public function getResult(): EmbeddingResult
    {
        return $this->result;
    }
    /**
     * Performs a deep clone of the event.
     *
     * @since 1.4.0
     */
    public function __clone()
    {
        $clonedInputs = [];
        foreach ($this->inputs as $input) {
            $clonedInputs[] = clone $input;
        }
        $this->inputs = $clonedInputs;
        $this->result = clone $this->result;
    }
}

The same content is in 5 releases, WordPress 7.2-beta1 to 7.2-beta5. See them all, or every version of this file.