v1.0.162: auto-classify backend — classify/grouping services, 7 new columns, /classify-batch, /api/groups, /apply-groups

This commit is contained in:
2026-06-24 08:22:21 +04:00
parent 740f75a791
commit 7a96f5b95b
8 changed files with 372 additions and 6 deletions
+27
View File
@@ -232,3 +232,30 @@ def build_prompt(current_spec: list, doc_text: str) -> tuple:
result = result.replace("{spec_current}", _build_spec_text(current_spec))
return result, prompt_id
def build_classify_prompt(header_text):
"""Build classify prompt. Returns (prompt, prompt_id)."""
from db import prompts as db_prompts
prompt = db_prompts.get_active("classify")
if prompt:
body = prompt["body"].replace("{header_text}", header_text)
return body, prompt.get("id", "")
# Fallback
body = """Ты — классификатор договорных документов. Ниже фрагмент текста документа.
Определи:
1. doc_type: "contract", "supplement", "specification", "other"
2. own_number: номер ЭТОГО документа
3. parent_number: номер родительского договора (для допников/спецификаций)
4. doc_date: дата в формате YYYY-MM-DD
5. counterparty: название контрагента
6. confidence: "ok" или "low"
Верни СТРОГО JSON: {"doc_type":"...","own_number":"...","parent_number":"...","doc_date":"...","counterparty":"...","confidence":"..."}
ДОКУМЕНТ:
---
{header_text}
---""".replace("{header_text}", header_text)
return body, ""