fix: LLM иногда возвращает пустой текст — raise при пустом content, ретрай в generate_response_with_retry, фронтенд показывает ошибку вместо молчания
This commit is contained in:
1 parent
d757d2f8c7
commit
8ca070ed70
3 files changed
+9
-4
No files matched your search
@@ -90,7 +90,10 @@ def generate_response(llm_config, vacancy, resume_text, style_hint=""):
|
||||
raise RuntimeError(f"LLM ошибка {resp.status_code}: {resp.text[:300]}")
|
||||
|
||||
data = resp.json()
|
||||
return data["choices"][0]["message"]["content"].strip()
|
||||
content = (data["choices"][0]["message"].get("content") or "").strip()
|
||||
if not content:
|
||||
raise RuntimeError("LLM вернул пустой текст — попробуйте ещё раз")
|
||||
return content
|
||||
|
||||
|
||||
def generate_response_with_retry(llm_config, vacancy, resume_text, style_hint="", attempts=2):
|
||||
|
||||
Reference in new issue
Block a user