WordPress\AiClient\Results\DTO

TokenUsage::toArraypublicWP 0.1.0

{@inheritDoc}

Method of the class: TokenUsage{}

No Hooks.

Returns

TokenUsageArrayShape.

Usage

$TokenUsage = new TokenUsage();
$TokenUsage->toArray(): array;

Changelog

Since 0.1.0 Introduced.

TokenUsage::toArray() code WP 7.0

public function toArray(): array
{
    $data = [self::KEY_PROMPT_TOKENS => $this->promptTokens, self::KEY_COMPLETION_TOKENS => $this->completionTokens, self::KEY_TOTAL_TOKENS => $this->totalTokens];
    if ($this->thoughtTokens !== null) {
        $data[self::KEY_THOUGHT_TOKENS] = $this->thoughtTokens;
    }
    return $data;
}