WordPress\AiClient\Results\DTO

GenerativeAiResult::toFile │ public │ WP 0.1.0

Converts the first candidate to a file.

Only files from the content channel are considered. Files within model thought or reasoning are ignored.

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

Хуков нет.

Возвращает

File. The file.

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

$GenerativeAiResult = new GenerativeAiResult();
$GenerativeAiResult->toFile(): File;

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

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

Код GenerativeAiResult::toFile() WP 7.1.3

public function toFile(): File
{
    $message = $this->candidates[0]->getMessage();
    foreach ($message->getParts() as $part) {
        $channel = $part->getChannel();
        $file = $part->getFile();
        if ($channel->isContent() && $file !== null) {
            return $file;
        }
    }
    throw new RuntimeException('No file content found in first candidate');
}