WordPress\AiClient\Messages\DTO

MessagePart::__construct │ public │ WP 0.1.0

Constructor that accepts various content types and infers the message part type.

Метод класса: MessagePart{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$MessagePart = new MessagePart();
$MessagePart->__construct( $content, ?MessagePartChannelEnum $channel, ?string $thoughtSignature );
$content(разное) (обязательный)
The content of this message part.
?MessagePartChannelEnum $channel
.
По умолчанию: null
?string $thoughtSignature
.
По умолчанию: null

Список изменений

С версии 0.1.0 Введена.

Код MessagePart::__construct() WP 7.1.2

public function __construct($content, ?MessagePartChannelEnum $channel = null, ?string $thoughtSignature = null)
{
    $this->channel = $channel ?? MessagePartChannelEnum::content();
    $this->thoughtSignature = $thoughtSignature;
    if (is_string($content)) {
        $this->type = MessagePartTypeEnum::text();
        $this->text = $content;
    } elseif ($content instanceof File) {
        $this->type = MessagePartTypeEnum::file();
        $this->file = $content;
    } elseif ($content instanceof FunctionCall) {
        $this->type = MessagePartTypeEnum::functionCall();
        $this->functionCall = $content;
    } elseif ($content instanceof FunctionResponse) {
        $this->type = MessagePartTypeEnum::functionResponse();
        $this->functionResponse = $content;
    } else {
        $type = is_object($content) ? get_class($content) : gettype($content);
        throw new InvalidArgumentException(sprintf('Unsupported content type %s. Expected string, File, ' . 'FunctionCall, or FunctionResponse.', $type));
    }
}