WordPress\AiClient\Results\DTO
GenerativeAiResult::toText
Converts the first candidate to text.
Only text from the content channel is considered. Text within model thought or reasoning is ignored.
Метод класса: GenerativeAiResult{}
Хуков нет.
Возвращает
string. The text content.
Использование
$GenerativeAiResult = new GenerativeAiResult(); $GenerativeAiResult->toText(): string;
Список изменений
| С версии 0.1.0 | Введена. |
Код GenerativeAiResult::toText() GenerativeAiResult::toText WP 7.1.5
public function toText(): string
{
$message = $this->candidates[0]->getMessage();
foreach ($message->getParts() as $part) {
$channel = $part->getChannel();
$text = $part->getText();
if ($channel->isContent() && $text !== null) {
return $text;
}
}
throw new RuntimeException('No text content found in first candidate');
}