WordPress\AiClient\Messages\DTO
Message::validateParts
Validates that the message parts are appropriate for the message role.
Method of the class: Message{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->validateParts(): void;
Changelog
| Since 0.1.0 | Introduced. |
Message::validateParts() Message::validateParts code WP 7.0
private function validateParts(): void
{
foreach ($this->parts as $part) {
$type = $part->getType();
if ($this->role->isUser() && $type->isFunctionCall()) {
throw new InvalidArgumentException('User messages cannot contain function calls.');
}
if ($this->role->isModel() && $type->isFunctionResponse()) {
throw new InvalidArgumentException('Model messages cannot contain function responses.');
}
}
}