Message::validateParts(): void

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only by core. It is listed here for completeness.

Validates that the message parts are appropriate for the message role.

Return

void

Source

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.');
        }
    }
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.