fix: передача реальной ошибки LLM в ответ (вместо null)
Some checks are pending
CI / lint-backend (push) Waiting to run
CI / lint-frontend (push) Waiting to run
CI / build-backend (push) Blocked by required conditions
CI / build-frontend (push) Blocked by required conditions

This commit is contained in:
ed0ss 2026-06-25 12:15:45 +03:00
parent 348b744960
commit 14025ae30d

View file

@ -56,10 +56,11 @@ async def generate_answer(query: str, context: str) -> str | None:
}, },
) )
if response.status_code != 200: if response.status_code != 200:
logger.error("LLM API error [%s]: %s", response.status_code, await response.aread()) body = await response.aread()
return None logger.error("LLM API error [%s]: %s", response.status_code, body)
return f"LLM API error [{response.status_code}]: {body.decode(errors='replace')}"
data = response.json() data = response.json()
if "choices" not in data or not data["choices"]: if "choices" not in data or not data["choices"]:
logger.error("LLM response missing choices: %s", data.get("error", data)) logger.error("LLM response missing choices: %s", data.get("error", data))
return None return f"LLM response error: {data.get('error', data)}"
return data["choices"][0]["message"]["content"] return data["choices"][0]["message"]["content"]