v1.0.167: fix grouping dead code (classified→docs) + max_tokens 500→1000

This commit is contained in:
2026-06-24 09:35:42 +04:00
parent 49c472b46d
commit 115e71b2a1
5 changed files with 27 additions and 5 deletions
+7
View File
@@ -12,6 +12,13 @@ var fileTable = document.getElementById('fileTable');
var fileQueue = []; var fileQueue = [];
var contractId = null; var contractId = null;
var batchId = crypto.randomUUID(); // классификация: привязка всех файлов сессии 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) — // Утилиты (formatSize, formatDate, moveUp, moveDown, escHtml, fmtDate) —
// вынесены в app_utils.js для облегчения анализа и отладки. // вынесены в app_utils.js для облегчения анализа и отладки.
+15
View File
@@ -66,6 +66,8 @@ class Handler(BaseHTTPRequestHandler):
self._handle_classify_batch() self._handle_classify_batch()
elif self.path == "/api/apply-groups": elif self.path == "/api/apply-groups":
self._handle_apply_groups() self._handle_apply_groups()
elif self.path == "/api/cleanup":
self._handle_cleanup()
else: else:
self.send_error(404) self.send_error(404)
@@ -178,6 +180,19 @@ class Handler(BaseHTTPRequestHandler):
result = apply_groups(batch_id, groups) result = apply_groups(batch_id, groups)
self._json(result) 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) ─────────────────────────────────────────────────── # ── /app.js (static) ───────────────────────────────────────────────────
def _handle_app_js(self): def _handle_app_js(self):
+1 -1
View File
@@ -38,7 +38,7 @@ def _call_llm_classify(header_text):
payload = { payload = {
"model": LLM_MODEL, "model": LLM_MODEL,
"messages": [{"role": "user", "content": prompt}], "messages": [{"role": "user", "content": prompt}],
"max_tokens": 500, # классификация укладывается в ~100 токенов ответа "max_tokens": 1000, # достаточно для JSON с длинными названиями
"temperature": 0.1, # минимальная температура для детерминированности "temperature": 0.1, # минимальная температура для детерминированности
} }
with httpx.Client(http2=True, timeout=60, verify=False) as client: with httpx.Client(http2=True, timeout=60, verify=False) as client:
+3 -3
View File
@@ -79,9 +79,9 @@ def group_documents(batch_id):
groups.append(group) 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 = [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: if unmatched or len(contracts_list) == 0:
# Put unmatched into a separate group # Put unmatched into a separate group
@@ -92,7 +92,7 @@ def group_documents(batch_id):
"documents": unmatched, "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): def apply_groups(batch_id, groups_data):
+1 -1
View File
@@ -75,7 +75,7 @@
<body> <body>
<div class="topbar"> <div class="topbar">
<img src="/nubes-logo.svg" alt="Nubes"> <img src="/nubes-logo.svg" alt="Nubes">
<span class="title">Сверка договоров — LLM AI-driven Event Sourcing <span style="font-weight:400;color:var(--muted);font-size:12px;">v1.0.166 — Lucee</span></span> <span class="title">Сверка договоров — LLM AI-driven Event Sourcing <span style="font-weight:400;color:var(--muted);font-size:12px;">v1.0.167 — Lucee</span></span>
</div> </div>
<div class="content"> <div class="content">