fix: убрать хардкод API-ключа (chat.cfm), verify=True (llm.py), отвязать llm_prompt от Lucee
This commit is contained in:
+6
-16
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user