fix: LLM timeout 60→120с + graceful fallback без 500 ошибки
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@ class Diagnoser:
|
||||
"temperature": 0.3, # пониже — меньше фантазий
|
||||
"max_tokens": 4096,
|
||||
},
|
||||
timeout=60,
|
||||
timeout=120, # api.aillm.ru бывает медленным
|
||||
)
|
||||
resp.raise_for_status()
|
||||
data = resp.json()
|
||||
|
||||
@@ -86,7 +86,11 @@ def register(app):
|
||||
model=cfg["llm"].get("model", "gpt-oss-120b"),
|
||||
base_url=cfg["llm"].get("base_url", "https://api.aillm.ru/v1"),
|
||||
)
|
||||
answer = diagnoser.diagnose(SYSTEM_PROMPT, _build_diagnosis_prompt(parsed))
|
||||
try:
|
||||
answer = diagnoser.diagnose(SYSTEM_PROMPT, _build_diagnosis_prompt(parsed))
|
||||
except Exception as e:
|
||||
logger.warning(f"LLM failed: {e}")
|
||||
answer = format_no_llm(parsed) + f"\n\n(LLM недоступен: {e})"
|
||||
|
||||
return jsonify({
|
||||
"diagnosis": answer,
|
||||
|
||||
Reference in New Issue
Block a user