From e3b7f283f0ab5bed93ebe4f686dbe859aecc4357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Thu, 18 Jun 2026 09:14:32 +0400 Subject: [PATCH] =?UTF-8?q?v3.2.5:=20=D1=81=D1=80=D0=B0=D0=B2=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B2=D1=8B=D0=B9=20vs?= =?UTF-8?q?=20=D0=BE=D1=81=D1=82=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5,=20?= =?UTF-8?q?=D1=82=D0=B0=D0=B9=D0=BC=D0=B5=D1=80=20LLM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/routes/llm.py | 19 ++++++++++++++----- site/templates/llm.html | 8 ++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/site/routes/llm.py b/site/routes/llm.py index 48d3a3b..ed44645 100644 --- a/site/routes/llm.py +++ b/site/routes/llm.py @@ -88,23 +88,32 @@ def process(cid): extracted[s["supp_id"]] = rows yield f"data: {_json.dumps({'type': 'extract_done', 'name': s['filename'], 'time_s': elapsed, 'count': len(rows), 'unresolved': unresolved})}\n\n" - # ── Шаг 2: Сравнение допников ──────────────────────── + # ── Шаг 2: Сравнение ──────────────────────────────── yield f"data: {_json.dumps({'type': 'diff_start', 'files': len(supp_rows)})}\n\n" - # Группируем: initial + amendments + # Группируем: ищем amendments, если нет — сравниваем первый с остальными initial_rows = None amendments = [] for s in supp_rows: - if s["type"] == "initial": - initial_rows = extracted.get(s["supp_id"], []) - else: + if s["type"] != "initial": amendments.append({ "supp_id": s["supp_id"], "filename": s["filename"], "type": s["type"], "rows": extracted.get(s["supp_id"], []), }) + elif initial_rows is None: + # Первый initial — базовый + initial_rows = extracted.get(s["supp_id"], []) + else: + # Последующие initial — как допники (fallback) + amendments.append({ + "supp_id": s["supp_id"], + "filename": s["filename"], + "type": "initial", + "rows": extracted.get(s["supp_id"], []), + }) all_changes = [] diff --git a/site/templates/llm.html b/site/templates/llm.html index e075a43..6ea1d3e 100644 --- a/site/templates/llm.html +++ b/site/templates/llm.html @@ -448,6 +448,12 @@ diffBody.innerHTML = '⏳ LLM-извлечение строк спецификации...'; var es = new EventSource('/llm/process/' + contractId); + var llmStart = Date.now(); + + var timerInterval = setInterval(function() { + var elapsed = ((Date.now() - llmStart) / 1000).toFixed(1); + diffStatus.textContent = '⏳ ' + elapsed + 'с'; + }, 200); es.onmessage = function(e) { var d = JSON.parse(e.data); @@ -473,6 +479,7 @@ diffBody.innerHTML += '
' + d.name + ': +' + (s.added||0) + ' ~' + (s.changed||0) + ' -' + (s.deleted||0) + '
'; } else if (d.type === 'done') { + clearInterval(timerInterval); es.close(); llmBtn.innerHTML = ' ✓ Готово'; lucide.createIcons(); @@ -505,6 +512,7 @@ }; es.addEventListener('error', function() { + clearInterval(timerInterval); es.close(); llmBtn.innerHTML = ' Сравнить (LLM)'; llmBtn.disabled = false;