fix: убрать хардкод API-ключа (chat.cfm), verify=True (llm.py), отвязать llm_prompt от Lucee

This commit is contained in:
2026-06-27 13:06:21 +04:00
parent 465be4ca04
commit a474b4324b
3 changed files with 14 additions and 26 deletions
+6 -16
View File
@@ -1,10 +1,8 @@
"""llm_prompt.py — Формирование промпта для LLM-анализа ДС.
Читает активный промпт из БД (через Lucee API). При ошибке — fallback на хардкод."""
Читает активный промпт из БД напрямую (db.prompts). При ошибке — fallback на хардкод."""
import os
import httpx
LUCEE_URL = os.environ.get("LUCEE_URL", "https://contractor.luceek8s.dev.nubes.ru")
from db import prompts as db_prompts
# ── Fallback-промпты (если БД недоступна) ──────────────────────
@@ -178,19 +176,11 @@ EDGE-CASES:
def _fetch_prompt(role: str) -> dict | None:
"""Получить активный промпт из БД. Возвращает {id, body} или None."""
"""Получить активный промпт из БД напрямую (а не через Lucee HTTP)."""
try:
with httpx.Client(http2=True, timeout=10) as client:
resp = client.get(
f"{LUCEE_URL}/prompt.cfm",
params={"action": "get_active", "role": role},
)
resp.raise_for_status()
data = resp.json()
# Lucee serializeJSON → UPPERCASE keys, normalize to lowercase
data = {k.lower(): v for k, v in data.items()}
if data.get("ok") and data.get("body"):
return {"id": data.get("id", ""), "body": data["body"]}
row = db_prompts.get_active(role)
if row and row.get("body"):
return {"id": row.get("id", ""), "body": row["body"]}
except Exception:
pass
return None
+1 -1
View File
@@ -16,7 +16,7 @@ def call_llm(current_spec, doc_text, build_prompt_fn):
"max_tokens": 8000,
"temperature": 0.1,
}
with httpx.Client(http2=True, timeout=120, verify=False) as client:
with httpx.Client(http2=True, timeout=120, verify=True) as client:
resp = client.post(
LLM_URL,
json=payload,