namespace yii_app\records;
use yii\db\ActiveQuery;
-use yii_app\records\Products1c;
/**
* Предсказание авторазметки товара из 1С.
* @property string $method
* @property int $status
* @property int|null $approved_by
+ * @property string|null $llm_verdict
+ * @property string|null $llm_verified_at
+ * @property string|null $llm_comment
* @property string $created_at
* @property string|null $updated_at
*/
public const METHOD_RULE = 'rule';
public const METHOD_SIMILARITY = 'similarity';
+ public const METHOD_LLM = 'llm';
+
+ public const LLM_VERDICT_APPROVED = 'approved';
+ public const LLM_VERDICT_REJECTED = 'rejected';
public static function tableName(): string
{
return [
[['product_id', 'confidence', 'method', 'status'], 'required'],
[['product_id', 'category', 'subcategory', 'species', 'sort', 'type', 'color', 'method'], 'string', 'max' => 255],
+ [['llm_verdict', 'llm_comment'], 'string', 'max' => 500],
[['size', 'status', 'approved_by'], 'integer'],
[['confidence'], 'number', 'min' => 0, 'max' => 1],
- [['method'], 'in', 'range' => [self::METHOD_RULE, self::METHOD_SIMILARITY]],
+ [['method'], 'in', 'range' => [self::METHOD_RULE, self::METHOD_SIMILARITY, self::METHOD_LLM]],
[['status'], 'in', 'range' => [self::STATUS_PENDING, self::STATUS_APPROVED, self::STATUS_REJECTED]],
- [['created_at', 'updated_at'], 'safe'],
- [['category', 'subcategory', 'species', 'sort', 'type', 'color', 'approved_by', 'updated_at', 'size'], 'default', 'value' => null],
+ [['llm_verdict'], 'in', 'range' => [self::LLM_VERDICT_APPROVED, self::LLM_VERDICT_REJECTED], 'skipOnEmpty' => true],
+ [['created_at', 'updated_at', 'llm_verified_at'], 'safe'],
+ [['category', 'subcategory', 'species', 'sort', 'type', 'color', 'approved_by', 'updated_at', 'size',
+ 'llm_verdict', 'llm_verified_at', 'llm_comment'], 'default', 'value' => null],
];
}
return $this->status === self::STATUS_REJECTED;
}
+ public function isLlmVerified(): bool
+ {
+ return $this->llm_verdict !== null;
+ }
+
public function getProduct(): ActiveQuery
{
return $this->hasOne(Products1c::class, ['id' => 'product_id']);