🚀 Auto-deploy: BotVPS atualizado em 28/04/2026 23:27:49
This commit is contained in:
@@ -222,7 +222,16 @@ 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"]
|
||||
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)}"
|
||||
|
||||
Reference in New Issue
Block a user