/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/models/Assistant.php
126 строк
3 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\models; use common\helpers\UuidHelper; use common\interfaces\TitleInterface; use common\traits\TitleRecordTrait; use common\validators\UidValidator; use Yii; use yii\db\ActiveQuery; use yii\helpers\ArrayHelper; /** * Таблица - ассистенты GPT * * @property int $project_id Проект * @property string $name Заголовок * @property string $key ключ * @property int $model_id модель * @property float $temperature температура * @property float $top_p топ-п * @property string $instructions Instructions * * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2024 */ class Assistant extends \common\models\base\BaseModel implements TitleInterface { use TitleRecordTrait; /** * {@inheritdoc} */ public static function tableName() { return 'assistant'; } /** * @inheritdoc */ public static function getTitleFields() { return ['name']; } /** * {@inheritdoc} */ public function rules() { return ArrayHelper::merge(parent::rules(), [ ['guid', 'default', 'value' => UuidHelper::uuid()], [['temperature', 'top_p'], 'default', 'value' => 0], [['name', 'key'], 'trim'], [['name', 'guid', 'key', 'model_id', 'project_id'], 'required'], [['name', 'key'], 'string', 'max' => 255], ['instructions', 'string'], [['model_id', 'project_id'], 'integer'], [['temperature', 'top_p'], 'number'], ['guid', UidValidator::class], [['guid', 'key', 'name'], 'unique'] ]); } /** * {@inheritdoc} */ public function attributeLabels() { return ArrayHelper::merge(parent::attributeLabels(), [ 'name' => Yii::t('app', 'Name'), 'project_id' => Yii::t('app', 'Project'), 'guid' => Yii::t('app', 'Guid'), 'key' => Yii::t('app', 'Key'), 'model_id' => Yii::t('app', 'Model'), 'temperature' => Yii::t('app', 'Temperature'), 'top_p' => Yii::t('app', 'TopP'), 'instructions' => Yii::t('app', 'Instructions'), ]); } /** * @return ActiveQuery */ public function getModel() { return $this->hasOne(ModelAI::class, ['id' => 'model_id']); } /** * @return ActiveQuery */ public function getProject() { return $this->hasOne(Project::class, ['id' => 'project_id']); } /** * {@inheritdoc} */ public function fields() { return [ 'guid', 'name', 'key', 'model' => function () { return $this->model->title; }, 'temperature', 'top_p', ]; } /** * @inheritdoc */ public function getParentModel() { return [ 'project_id' => 'project' ]; } }