WordPress\AiClient\Builders
MessageBuilder::get
Builds and returns the Message object.
Method of the class: MessageBuilder{}
No Hooks.
Returns
Message. The built message.
Usage
$MessageBuilder = new MessageBuilder(); $MessageBuilder->get(): Message;
Changelog
| Since 0.2.0 | Introduced. |
MessageBuilder::get() MessageBuilder::get code WP 7.0
public function get(): Message
{
if (empty($this->parts)) {
throw new InvalidArgumentException('Cannot build an empty message. Add content using withText() or similar methods.');
}
if ($this->role === null) {
throw new InvalidArgumentException('Cannot build a message with no role. Set a role using usingRole() or similar methods.');
}
// At this point, we've validated that $this->role is not null
/** @var MessageRoleEnum $role */
$role = $this->role;
return new Message($role, $this->parts);
}