From 115e71b2a147f070bcdba5726d05b9cfcf32ed79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Wed, 24 Jun 2026 09:35:42 +0400 Subject: [PATCH] =?UTF-8?q?v1.0.167:=20fix=20grouping=20dead=20code=20(cla?= =?UTF-8?q?ssified=E2=86=92docs)=20+=20max=5Ftokens=20500=E2=86=921000?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/app.js | 7 +++++++ deploy/convert_server.py | 15 +++++++++++++++ deploy/services/classify.py | 2 +- deploy/services/grouping.py | 6 +++--- index.cfm | 2 +- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/deploy/app.js b/deploy/app.js index c79a12a..2e9d7f4 100644 --- a/deploy/app.js +++ b/deploy/app.js @@ -12,6 +12,13 @@ var fileTable = document.getElementById('fileTable'); var fileQueue = []; var contractId = null; var batchId = crypto.randomUUID(); // классификация: привязка всех файлов сессии + +// Автоочистка старых записей без batch_id при загрузке страницы +(async function cleanup() { + try { + await fetch(VM_API + '/api/cleanup?batch=' + batchId, { method: 'POST' }); + } catch(e) { /* ignore */ } +})(); // Утилиты (formatSize, formatDate, moveUp, moveDown, escHtml, fmtDate) — // вынесены в app_utils.js для облегчения анализа и отладки. diff --git a/deploy/convert_server.py b/deploy/convert_server.py index f9067d4..d0db68a 100755 --- a/deploy/convert_server.py +++ b/deploy/convert_server.py @@ -66,6 +66,8 @@ class Handler(BaseHTTPRequestHandler): self._handle_classify_batch() elif self.path == "/api/apply-groups": self._handle_apply_groups() + elif self.path == "/api/cleanup": + self._handle_cleanup() else: self.send_error(404) @@ -178,6 +180,19 @@ class Handler(BaseHTTPRequestHandler): result = apply_groups(batch_id, groups) self._json(result) + # ── POST /api/cleanup ──────────────────────────────────────────────── + + def _handle_cleanup(self): + """Полная очистка всех данных (кроме prompts). Вызывается при загрузке страницы.""" + from db.connection import execute + execute("DELETE FROM spec_current") + execute("DELETE FROM spec_events") + execute("DELETE FROM supplements") + execute("DELETE FROM upload_chunks") + execute("DELETE FROM documents") + execute("DELETE FROM contracts") + self._json({"ok": True, "message": "all data cleaned"}) + # ── /app.js (static) ─────────────────────────────────────────────────── def _handle_app_js(self): diff --git a/deploy/services/classify.py b/deploy/services/classify.py index 71a05b6..2d0d38c 100644 --- a/deploy/services/classify.py +++ b/deploy/services/classify.py @@ -38,7 +38,7 @@ def _call_llm_classify(header_text): payload = { "model": LLM_MODEL, "messages": [{"role": "user", "content": prompt}], - "max_tokens": 500, # классификация укладывается в ~100 токенов ответа + "max_tokens": 1000, # достаточно для JSON с длинными названиями "temperature": 0.1, # минимальная температура для детерминированности } with httpx.Client(http2=True, timeout=60, verify=False) as client: diff --git a/deploy/services/grouping.py b/deploy/services/grouping.py index 2f0f2b1..c226455 100644 --- a/deploy/services/grouping.py +++ b/deploy/services/grouping.py @@ -79,9 +79,9 @@ def group_documents(batch_id): groups.append(group) - # Unmatched documents → "unresolved" group + # Unmatched documents → "unresolved" group (including failed/pending) unmatched = [s for s in supplements_list if s.get("doc_type") != "contract"] - unmatched += [d for d in classified if d.get("classify_status") != "classified"] + unmatched += [d for d in docs if d.get("classify_status") != "classified"] if unmatched or len(contracts_list) == 0: # Put unmatched into a separate group @@ -92,7 +92,7 @@ def group_documents(batch_id): "documents": unmatched, }) - return {"ok": True, "groups": groups, "total_docs": len(classified)} + return {"ok": True, "groups": groups, "total_docs": len(docs)} def apply_groups(batch_id, groups_data): diff --git a/index.cfm b/index.cfm index bb7e629..845f786 100644 --- a/index.cfm +++ b/index.cfm @@ -75,7 +75,7 @@
Nubes - Сверка договоров — LLM AI-driven Event Sourcing v1.0.166 — Lucee + Сверка договоров — LLM AI-driven Event Sourcing v1.0.167 — Lucee