WordPress\AiClient\Results\DTO
GenerativeAiResult::toFile
Converts the first candidate to a file.
Only files from the content channel are considered. Files within model thought or reasoning are ignored.
Method of the class: GenerativeAiResult{}
No Hooks.
Returns
File. The file.
Usage
$GenerativeAiResult = new GenerativeAiResult(); $GenerativeAiResult->toFile(): File;
Changelog
| Since 0.1.0 | Introduced. |
GenerativeAiResult::toFile() GenerativeAiResult::toFile code WP 7.0
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');
}