ВРЕМЕННЫЙ ОТКАТ к v1.0.91 — для проверки деплоя. Вернуть через revert.
This commit is contained in:
@@ -7,13 +7,13 @@ class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
|
||||
"""Многопоточный HTTP-сервер."""
|
||||
daemon_threads = True
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
import subprocess, tempfile, os, sys, json, time, re
|
||||
import subprocess, tempfile, os, sys, json, time
|
||||
|
||||
import httpx
|
||||
from llm_prompt import build_prompt
|
||||
|
||||
LLM_URL = "https://api.aillm.ru/v1/chat/completions"
|
||||
LLM_KEY = os.environ.get("LLM_KEY", "")
|
||||
LLM_KEY = "sk-ucI5YvOticoOQ9Kuj5K9mQ"
|
||||
LLM_MODEL = "gpt-oss-120b"
|
||||
LUCEE_URL = "https://contractor.luceek8s.dev.nubes.ru"
|
||||
|
||||
@@ -91,10 +91,6 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if not cid:
|
||||
self.send_error(400, "contract_id required")
|
||||
return
|
||||
# Validate UUID to prevent SQL injection
|
||||
if not re.fullmatch(r'[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}', cid, re.I):
|
||||
self.send_error(400, "invalid contract_id format")
|
||||
return
|
||||
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/event-stream; charset=utf-8")
|
||||
@@ -107,12 +103,6 @@ class Handler(BaseHTTPRequestHandler):
|
||||
t0 = time.time()
|
||||
|
||||
try:
|
||||
# 0. Сброс предыдущих результатов сравнения
|
||||
r = httpx.get(f"{LUCEE_URL}/reset_contract.cfm?contract_id={cid}", timeout=10)
|
||||
if r.status_code != 200:
|
||||
self._sse({"type": "error", "message": f"reset failed: HTTP {r.status_code}"})
|
||||
return
|
||||
|
||||
# 1. Список supplements
|
||||
supps = self._lucee_query(
|
||||
f"SELECT s.id, s.type, d.filename FROM supplements s "
|
||||
@@ -150,15 +140,9 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if not docs:
|
||||
continue
|
||||
ej = docs[0]["elements_json"]
|
||||
# Lucee JSONB может вернуть: строку, dict-обёртку {Value,Type}, или уже список
|
||||
if isinstance(ej, dict) and "Value" in ej:
|
||||
ej = ej["Value"]
|
||||
if isinstance(ej, str):
|
||||
elements = json.loads(ej)
|
||||
elif isinstance(ej, list):
|
||||
elements = ej
|
||||
else:
|
||||
elements = []
|
||||
elements = json.loads(ej)
|
||||
# Lucee serializeJSON → UPPERCASE keys, normalize to lowercase
|
||||
elements = [{k.lower(): v for k, v in el.items()} for el in elements]
|
||||
lines = []
|
||||
|
||||
Reference in New Issue
Block a user