/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
backend/forms/data/task/BaseTaskForm.php
218 строк
5 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace backend\forms\data\task; use common\forms\base\ObjectIdForm; use common\helpers\ArrayHelper; use common\helpers\NumHelper; use common\memoQ\meta\serverproject\TMEngineType; use common\models\Glossary; use common\models\ModelAI; use common\models\Task; use common\models\tm\Tm; use Yii; /** * Форма редактирования сервиса * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2024 */ abstract class BaseTaskForm extends ObjectIdForm { /** * Пользователь * @var string */ public $user_id = null; /** * Глоссарий * @var string */ public $glossary_id = null; /** * Уровень глоссария * @var string */ public $passing_score = 60; /** * Глоссарий * @var string */ public $tm_id = null; /** * Уровень глоссария * @var string */ public $passing_score_tm = 70; /** * Название * @var string */ public $title = null; /** * Модель * @var null */ public $model_id = null; /** * ТопП * @var array */ public $top_p = null; /** * промт * @var null */ public $promt = null; /** * Температура * @var null */ public $temperature = null; /** * Исследовательская таска * @var null */ public $is_research = null; /** * Режим отладки * @var null */ public $is_debug = null; /** * Тип task * @var null */ protected $type_id = null; /** * @inheritdoc */ public function rules() { return ArrayHelper::merge(parent::rules(), [ [['title'], 'required'], [['title'], 'string'], ['passing_score', 'default', 'value' => 60], [ [ 'user_id', 'is_research', 'is_debug', 'glossary_id', 'passing_score', 'tm_id', 'passing_score_tm' ], 'integer' ], ]); } /** * @inheritdoc */ public function attributeLabels() { return ArrayHelper::merge(parent::attributeLabels(), [ 'title' => Yii::t('app', 'Title'), 'user_id' => Yii::t('app', 'User'), 'glossary_id' => Yii::t('app', 'Glossary'), 'passing_score' => Yii::t('app', 'Passing score Glossary'), 'passing_score_tm' => Yii::t('app', 'Passing score TM'), 'tm_id' => Yii::t('app', 'TM'), 'is_research' => Yii::t('app', 'Research Task'), 'is_debug' => Yii::t('app', 'Debug Mode'), ]); } /** * @inheritdoc */ public function attributeHints() { return ArrayHelper::merge(parent::attributeHints(), [ 'promt' => Yii::t('app', 'use {source_lang}, {target_lang} and {subject_area} as parameters'), 'is_research' => Yii::t('app', 'Will not be automatically added to new users'), 'is_debug' => Yii::t('app', 'Debugging information will be saved for each request'), ]); } /** * @inheritdoc */ public function loadModel($condition) { parent::loadModel($condition); $this->user_id = ArrayHelper::getValue($condition, 'parent_id'); $obj = Task::findOne([ 'id' => $this->oid, ]); if ($obj) { $this->initState($obj); } } /** * @inheritdoc */ public function getPublicFields() { return ArrayHelper::merge(parent::getPublicFields(), [ 'title', 'user_id', 'passing_score', 'passing_score_tm', 'is_debug', 'glossary_id' => function () { return $this->prepareSelectField(Glossary::find(), 'glossary_id', 'title'); }, 'tm_id' => function () { return $this->prepareSelectField(Tm::find(), 'tm_id', 'title'); }, ]); } /** * @inheritdoc */ protected function doSave() { $t = Task::findOrNew([ 'id' => $this->oid, ]); $t->setAttributes([ 'title' => $this->title, 'type_id' => $this->type_id, 'is_debug' => $this->is_debug, ]); if (!$t->save()) { $this->addErrors($t->errors); return false; } $this->model = $t; return true; } }