WordPress\AiClient\Builders
MessageBuilder::__construct
Constructor.
Метод класса: MessageBuilder{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$MessageBuilder = new MessageBuilder(); $MessageBuilder->__construct( $input, ?MessageRoleEnum $role );
- $input(Input)
- Optional initial content.
По умолчанию:null - ?MessageRoleEnum $role
- .
По умолчанию:null
Список изменений
| С версии 0.2.0 | Введена. |
Код MessageBuilder::__construct() MessageBuilder:: construct WP 7.1.2
public function __construct($input = null, ?MessageRoleEnum $role = null)
{
$this->role = $role;
if ($input === null) {
return;
}
// Handle different input types
if ($input instanceof MessagePart) {
$this->parts[] = $input;
} elseif (is_string($input)) {
$this->withText($input);
} elseif ($input instanceof File) {
$this->withFile($input);
} elseif ($input instanceof FunctionCall) {
$this->withFunctionCall($input);
} elseif ($input instanceof FunctionResponse) {
$this->withFunctionResponse($input);
} elseif (is_array($input) && MessagePart::isArrayShape($input)) {
$this->parts[] = MessagePart::fromArray($input);
} else {
throw new InvalidArgumentException('Input must be a string, MessagePart, MessagePartArrayShape, File, FunctionCall, or FunctionResponse.');
}
}