feat: метрики качества — арифметика (sum==price*qty) + частота JSON-фиксов

This commit is contained in:
2026-06-27 13:18:10 +04:00
parent 909468b5b7
commit 31e5ef7ac5
3 changed files with 97 additions and 8 deletions
+5
View File
@@ -1,6 +1,7 @@
"""Process service — SSE pipeline: reset → supplements → LLM → apply."""
import json, time, threading
from db import supplements, spec_current, spec_events
from .metrics import check_arithmetic
def run_pipeline(contract_id, order_ids, sse_send, build_prompt_fn):
@@ -108,6 +109,10 @@ def run_pipeline(contract_id, order_ids, sse_send, build_prompt_fn):
summary = spec_events.apply_ops(
contract_id, sid, s.get("document_id", ""), ops, prompt_id, llm_result
)
# Arithmetic quality check (free signal, no golden dataset needed)
arith_mismatches = check_arithmetic(ops)
if arith_mismatches:
summary["arithmetic_mismatches"] = len(arith_mismatches)
sse_send({"type": "applied", "supplement_id": sid, "summary": summary, "ops": ops})
total_time = round(time.time() - t0, 1)