🚀 Auto-deploy: BotVPS atualizado em 14/05/2026 10:11:13

This commit is contained in:
2026-05-14 10:11:13 +00:00
parent 6503770898
commit aa04276c9a
4 changed files with 53 additions and 10 deletions
+20 -5
View File
@@ -5,8 +5,12 @@ import asyncio
import time
from typing import Optional, Dict, List
from collections import deque
from dotenv import load_dotenv
from config import get_config, save_config
# Carrega variáveis do .env caso não tenham sido carregadas
load_dotenv()
# Monitor de requisições (Rate Limiting Monitoring)
REQUEST_HISTORY = deque()
ALERT_THRESHOLD = 20
@@ -91,8 +95,8 @@ LLM_PROVIDERS = {
"minimax": {
"name": "MiniMax (Hermes)",
"type": "api",
"models": ["abab7-preview", "abab6.5s-chat", "minimax-text-01"],
"default": "abab7-preview",
"models": ["minimax-2.7", "abab6.5s-chat", "minimax-text-01"],
"default": "minimax-2.7",
"endpoint": "https://api.minimax.io/v1/text/chatcompletion_v2"
},
"ollama": {
@@ -293,7 +297,7 @@ async def _call_openrouter_async(model: str, prompt: str, system_prompt: str = N
res = await client.post(url, json=payload, headers=headers, timeout=120)
if res.status_code == 200:
data = res.json()
if "choices" in data and len(data["choices"]) > 0:
if data.get("choices") and len(data["choices"]) > 0:
return {
"content": data["choices"][0]["message"]["content"],
"usage": data.get("usage", {}),
@@ -352,6 +356,12 @@ async def _call_gemini_async(model: str, prompt: str, system_prompt: str = None)
async def _call_minimax_async(model: str, prompt: str, system_prompt: str = None) -> dict:
"""Chama API do MiniMax (V2) via httpx (async)."""
api_key = get_api_key("minimax")
if api_key:
api_key = api_key.strip()
if not api_key:
return {"content": "Erro: API Key do MiniMax não encontrada ou vazia no .env.", "usage": {}}
url = "https://api.minimax.io/v1/text/chatcompletion_v2"
messages = []
@@ -377,13 +387,18 @@ async def _call_minimax_async(model: str, prompt: str, system_prompt: str = None
if res.status_code == 200:
data = res.json()
# MiniMax V2 structure
if "choices" in data and len(data["choices"]) > 0:
if data.get("choices") and len(data["choices"]) > 0:
return {
"content": data["choices"][0]["message"]["content"],
"usage": data.get("usage", {}),
"model": data.get("base_resp", {}).get("model") or model
}
return {"content": f"Erro MiniMax (Resposta inesperada): {json.dumps(data)}", "usage": {}}
base_resp = data.get("base_resp", {})
status_code = base_resp.get("status_code")
status_msg = base_resp.get("status_msg", "Unknown")
if status_code == 2013:
return {"content": f"Modelo indefinido/no MiniMax: {model}. API disse: {status_msg}", "usage": {}}
return {"content": f"Erro MiniMax: [{status_code}] {status_msg} | Raw: {json.dumps(data)}", "usage": {}}
return {"content": f"Erro MiniMax {res.status_code}: {res.text}", "usage": {}}
except Exception as e:
return {"content": f"Erro MiniMax: {str(e)}", "usage": {}}