WordPress\AiClient\Providers\OpenAiCompatibleImplementation

AbstractOpenAiCompatibleTextGenerationModel::getMessageRoleStringprotectedWP 0.1.0

Returns the OpenAI API specific role string for the given message role.

Method of the class: AbstractOpenAiCompatibleTextGenerationModel{}

No Hooks.

Returns

String. The role for the API request.

Usage

// protected - for code of main (parent) or child class
$result = $this->getMessageRoleString( $role ): string;
$role(MessageRoleEnum) (required)
The message role.

Changelog

Since 0.1.0 Introduced.

AbstractOpenAiCompatibleTextGenerationModel::getMessageRoleString() code WP 7.0

protected function getMessageRoleString(MessageRoleEnum $role): string
{
    if ($role === MessageRoleEnum::model()) {
        return 'assistant';
    }
    return 'user';
}