From ce21889c8047d86c33faa98f8f17e4b741a87688 Mon Sep 17 00:00:00 2001 From: fomichev Date: Thu, 30 Apr 2026 18:24:16 +0300 Subject: [PATCH] =?utf8?q?feat(ERP-292):=20=D0=BA=D0=BE=D0=BD=D1=81=D0=BE?= =?utf8?q?=D0=BB=D1=8C=D0=BD=D0=B0=D1=8F=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD?= =?utf8?q?=D0=B4=D0=B0=20verify-llm,=20=D1=82=D1=80=D0=B8=D0=B3=D0=B3?= =?utf8?q?=D0=B5=D1=80=20=D0=B2=20run-new?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/commands/AutoMarkController.php | 48 +++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/erp24/commands/AutoMarkController.php b/erp24/commands/AutoMarkController.php index b48c6613..72a1b101 100644 --- a/erp24/commands/AutoMarkController.php +++ b/erp24/commands/AutoMarkController.php @@ -12,22 +12,32 @@ use yii_app\services\AutoMarkService; * Авторазметка товаров из 1С (ERP-292). * * Использование: - * php yii auto-mark/run-new — разметить все товары без номенклатуры + * php yii auto-mark/run-new — разметить новые товары; если нет новых — запустить LLM-верификацию * php yii auto-mark/run-product GUID — разметить конкретный товар - * php yii auto-mark/apply PRED_ID — применить одобренное предсказание + * php yii auto-mark/apply PRED_ID — применить одобренное предсказание + * php yii auto-mark/verify-llm — запустить LLM-верификацию принудительно */ class AutoMarkController extends Controller { - public string $defaultAction = 'run-new'; + public $defaultAction = 'run-new'; public function actionRunNew(): int { + $service = new AutoMarkService(); + $this->stdout("Запуск авторазметки новых товаров...\n"); + $newCount = $service->batchPredict(); + $this->stdout("Создано предсказаний: {$newCount}\n"); - $service = new AutoMarkService(); - $count = $service->batchPredict(); + if ($newCount === 0) { + $pendingCount = $service->getPendingUnverifiedCount(); + if ($pendingCount > 0) { + $this->stdout("Новых товаров нет. Запуск LLM-верификации ({$pendingCount} ожидают)...\n"); + return $this->runLlmVerify($service); + } + $this->stdout("Нет новых товаров и нет ожидающих верификации.\n"); + } - $this->stdout("Создано предсказаний: {$count}\n"); return ExitCode::OK; } @@ -58,4 +68,30 @@ class AutoMarkController extends Controller $this->stdout("Предсказание ID={$predictionId} применено.\n"); return ExitCode::OK; } + + public function actionVerifyLlm(): int + { + $service = new AutoMarkService(); + $pendingCount = $service->getPendingUnverifiedCount(); + + if ($pendingCount === 0) { + $this->stdout("Нет предсказаний для LLM-верификации.\n"); + return ExitCode::OK; + } + + $this->stdout("Запуск LLM-верификации ({$pendingCount} предсказаний)...\n"); + return $this->runLlmVerify($service); + } + + private function runLlmVerify(AutoMarkService $service): int + { + try { + $verified = $service->llmBatchVerify(); + $this->stdout("LLM верифицировано: {$verified}\n"); + return ExitCode::OK; + } catch (\RuntimeException $e) { + $this->stderr("Ошибка LLM-верификации: {$e->getMessage()}\n"); + return ExitCode::UNSPECIFIED_ERROR; + } + } } -- 2.39.5