From aeacb372a8070e46a241db4e99197ab05df7fc8d Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Tue, 28 Apr 2026 23:27:49 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Auto-deploy:=20BotVPS=20atualiza?= =?UTF-8?q?do=20em=2028/04/2026=2023:27:49?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- llm_providers.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/llm_providers.py b/llm_providers.py index c1397d7..00a2d12 100644 --- a/llm_providers.py +++ b/llm_providers.py @@ -222,8 +222,17 @@ async def _call_openrouter_async(model: str, prompt: str, system_prompt: str = N async with httpx.AsyncClient() as client: res = await client.post(url, json=payload, headers=headers, timeout=120) if res.status_code == 200: - return res.json()["choices"][0]["message"]["content"] - return f"Erro OpenRouter: {res.status_code} - {res.text}" + data = res.json() + if "choices" in data and len(data["choices"]) > 0: + return data["choices"][0]["message"]["content"] + return f"Erro OpenRouter (Resposta sem 'choices'): {json.dumps(data)}" + + # Se não for 200, tenta extrair erro detalhado + try: + error_data = res.json() + return f"Erro OpenRouter {res.status_code}: {json.dumps(error_data)}" + except: + return f"Erro OpenRouter: {res.status_code} - {res.text}" except Exception as e: return f"Erro OpenRouter: {str(e)}"