WordPress\AiClient\Results\DTO
GenerativeAiResult::toTexts
Converts all candidates to text.
Method of the class: GenerativeAiResult{}
No Hooks.
Returns
list
Usage
$GenerativeAiResult = new GenerativeAiResult(); $GenerativeAiResult->toTexts(): array;
Changelog
| Since 0.1.0 | Introduced. |
GenerativeAiResult::toTexts() GenerativeAiResult::toTexts code WP 7.0
public function toTexts(): array
{
$texts = [];
foreach ($this->candidates as $candidate) {
$message = $candidate->getMessage();
foreach ($message->getParts() as $part) {
$channel = $part->getChannel();
$text = $part->getText();
if ($channel->isContent() && $text !== null) {
$texts[] = $text;
break;
}
}
}
return $texts;
}