From 2a566869aaa9550482127d3b2ee84c15cda47e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Wed, 24 Jun 2026 19:23:34 +0400 Subject: [PATCH] =?UTF-8?q?v1.0.176:=20classify=5Finput=20+=20elements=5Fj?= =?UTF-8?q?son=20=D0=B2=20=D0=BF=D1=80=D0=BE=D0=BC=D0=B5=D0=B6=D1=83=D1=82?= =?UTF-8?q?=D0=BE=D1=87=D0=BD=D1=8B=D1=85=20=D1=80=D0=B5=D0=B7=D1=83=D0=BB?= =?UTF-8?q?=D1=8C=D1=82=D0=B0=D1=82=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/app.js | 15 ++++++++++++++- deploy/convert_server.py | 2 ++ deploy/db/documents.py | 10 +++++----- deploy/services/classify.py | 1 + 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/deploy/app.js b/deploy/app.js index f89c4b7..726bbc3 100644 --- a/deploy/app.js +++ b/deploy/app.js @@ -109,11 +109,24 @@ window.toggleClassifyDetail = async function(i) { if (qData.doc_date) html += 'Дата: ' + escHtml(qData.doc_date) + ''; if (qData.counterparty) html += 'Контрагент: ' + escHtml(qData.counterparty) + ''; html += ''; + if (qData.classify_input) { + html += '
📤 Текст отправленный в LLM'; + html += '
' + escHtml(qData.classify_input) + '
'; + html += '
'; + } if (qData.classify_raw) { - html += '
Сырой ответ LLM'; + html += '
📥 Сырой ответ LLM'; html += '
' + escHtml(qData.classify_raw) + '
'; html += '
'; } + if (qData.elements_json) { + var ej = qData.elements_json; + if (typeof ej === 'object' && ej.Value) ej = ej.Value; + var ejStr = typeof ej === 'string' ? ej : JSON.stringify(ej, null, 2); + html += '
📄 Распарсенные элементы (JSON)'; + html += '
' + escHtml(ejStr.substring(0, 5000)) + (ejStr.length > 5000 ? '\n... (обрезано)' : '') + '
'; + html += '
'; + } } else if (qData.classify_status === 'failed') { html += '✗ Ошибка классификации: ' + escHtml(qData.error_message || '?') + ''; } else { diff --git a/deploy/convert_server.py b/deploy/convert_server.py index a0058d5..568a4a3 100755 --- a/deploy/convert_server.py +++ b/deploy/convert_server.py @@ -11,6 +11,7 @@ from db.connection import DB_CONFIG, execute db_prompts.seed_defaults() # Schema migration: classify_raw column (idempotent) execute("ALTER TABLE documents ADD COLUMN IF NOT EXISTS classify_raw text") +execute("ALTER TABLE documents ADD COLUMN IF NOT EXISTS classify_input text") # ── DB modules ──────────────────────────────────────────────────────────── from db import supplements as db_supplements @@ -155,6 +156,7 @@ class Handler(BaseHTTPRequestHandler): "counterparty": doc.get("counterparty"), "classify_status": doc.get("classify_status"), "classify_raw": doc.get("classify_raw"), + "classify_input": doc.get("classify_input"), }) def _handle_api_document_delete(self, parsed): diff --git a/deploy/db/documents.py b/deploy/db/documents.py index 5ede938..c7d05a3 100644 --- a/deploy/db/documents.py +++ b/deploy/db/documents.py @@ -36,13 +36,13 @@ def delete(doc_id): return execute("DELETE FROM documents WHERE id = %s", (doc_id,)) -def set_classification(doc_id, doc_type, own_number, parent_number, doc_date, counterparty, classify_raw=None): - """Store LLM classification results + raw response.""" +def set_classification(doc_id, doc_type, own_number, parent_number, doc_date, counterparty, classify_raw=None, classify_input=None): + """Store LLM classification results + raw response + input text.""" return execute( """UPDATE documents SET doc_type=%s, own_number=%s, parent_number=%s, - doc_date=%s, counterparty=%s, classify_status='classified', classify_raw=%s + doc_date=%s, counterparty=%s, classify_status='classified', classify_raw=%s, classify_input=%s WHERE id=%s""", - (doc_type, own_number, parent_number, doc_date, counterparty, classify_raw, doc_id), + (doc_type, own_number, parent_number, doc_date, counterparty, classify_raw, classify_input, doc_id), ) @@ -73,7 +73,7 @@ def list_by_batch(batch_id): """All documents in a batch with classification fields.""" return query( """SELECT id, filename, status, doc_type, own_number, parent_number, - doc_date, counterparty, classify_status, error_message, classify_raw + doc_date, counterparty, classify_status, error_message, classify_raw, classify_input FROM documents WHERE batch_id=%s ORDER BY created_at""", (batch_id,), ) diff --git a/deploy/services/classify.py b/deploy/services/classify.py index 936b8fb..aec3f23 100644 --- a/deploy/services/classify.py +++ b/deploy/services/classify.py @@ -82,6 +82,7 @@ def classify_batch(batch_id): result.get("doc_date"), result.get("counterparty"), classify_raw=raw, + classify_input=text, ) return True except Exception as e: