/
a11igator
/
gigachat-php-sdk
Обзор
Документация
Войти
/
a11igator
/
gigachat-php-sdk
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/Type/Message.php
50 строк
1 KB
Eduard Gaynutdinov
init commit
03 фев 2024, 02:14
03 фев 2024, 02:14
0bf6651
Код
Авторство
О чём код?
<?php declare(strict_types=1); namespace Edvardpotter\GigaChat\Type; class Message implements ArrayConverterInterface { public const ROLE_SYSTEM = 'system'; public const ROLE_USER = 'user'; public const ROLE_ASSISTANT = 'assistant'; public const ROLE_SEARCH_RESULT = 'search_result'; private string $content; private string $role; public function __construct( string $content, string $role = self::ROLE_USER ) { $this->content = $content; $this->role = $role; } public function getContent(): string { return $this->content; } public function getRole(): string { return $this->role; } public function toArray(): array { return [ 'role' => $this->role, 'content' => $this->content, ]; } public static function createFromArray(array $array): self { return new Message( $array['content'], $array['role'] ); } }