🚀 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
+9 -5
View File
@@ -31,7 +31,7 @@ async def query_agent_async(prompt: str, override_provider=None, chat_history=No
# Identifica o modelo padrão baseado no provedor # Identifica o modelo padrão baseado no provedor
if provider == "minimax": if provider == "minimax":
current_model = cfg.get("minimax_model") or "abab7-preview" current_model = cfg.get("minimax_model") or "minimax-2.7"
model_desc = f"**{current_model}** via Hermes (MiniMax API)" model_desc = f"**{current_model}** via Hermes (MiniMax API)"
elif provider == "openrouter": elif provider == "openrouter":
current_model = cfg.get("openrouter_model") or "qwen/qwen-2.5-72b-instruct" current_model = cfg.get("openrouter_model") or "qwen/qwen-2.5-72b-instruct"
@@ -150,12 +150,16 @@ DIRETRIZES:
if t_name in all_tools: if t_name in all_tools:
tool_info = all_tools[t_name] tool_info = all_tools[t_name]
func = tool_info["func"] func = tool_info["func"]
print(f"[AGENT] Executando {t_name} com argumento: {arg[:50]}...") import inspect
sig = inspect.signature(func)
has_params = len(sig.parameters) > 0
print(f"[AGENT] Executando {t_name}{f' com argumento: {arg[:50]}' if arg and has_params else ''}...")
if asyncio.iscoroutinefunction(func): if asyncio.iscoroutinefunction(func):
obs = await func(arg) if arg else await func() obs = await func(arg) if (arg and has_params) else await func()
else: else:
obs = func(arg) if arg else func() obs = func(arg) if (arg and has_params) else func()
if isinstance(obs, dict): if isinstance(obs, dict):
obs = obs.get("output") or obs.get("message") or str(obs) obs = obs.get("output") or obs.get("message") or str(obs)
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env python3
import sys
sys.path.insert(0, "/host_root/usr/local/lib/hermes-agent")
sys.argv = ["/usr/local/bin/hermes", "-z"] + sys.argv[1:]
from hermes_cli.main import main
main()
+20 -5
View File
@@ -5,8 +5,12 @@ import asyncio
import time import time
from typing import Optional, Dict, List from typing import Optional, Dict, List
from collections import deque from collections import deque
from dotenv import load_dotenv
from config import get_config, save_config 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) # Monitor de requisições (Rate Limiting Monitoring)
REQUEST_HISTORY = deque() REQUEST_HISTORY = deque()
ALERT_THRESHOLD = 20 ALERT_THRESHOLD = 20
@@ -91,8 +95,8 @@ LLM_PROVIDERS = {
"minimax": { "minimax": {
"name": "MiniMax (Hermes)", "name": "MiniMax (Hermes)",
"type": "api", "type": "api",
"models": ["abab7-preview", "abab6.5s-chat", "minimax-text-01"], "models": ["minimax-2.7", "abab6.5s-chat", "minimax-text-01"],
"default": "abab7-preview", "default": "minimax-2.7",
"endpoint": "https://api.minimax.io/v1/text/chatcompletion_v2" "endpoint": "https://api.minimax.io/v1/text/chatcompletion_v2"
}, },
"ollama": { "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) res = await client.post(url, json=payload, headers=headers, timeout=120)
if res.status_code == 200: if res.status_code == 200:
data = res.json() data = res.json()
if "choices" in data and len(data["choices"]) > 0: if data.get("choices") and len(data["choices"]) > 0:
return { return {
"content": data["choices"][0]["message"]["content"], "content": data["choices"][0]["message"]["content"],
"usage": data.get("usage", {}), "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: async def _call_minimax_async(model: str, prompt: str, system_prompt: str = None) -> dict:
"""Chama API do MiniMax (V2) via httpx (async).""" """Chama API do MiniMax (V2) via httpx (async)."""
api_key = get_api_key("minimax") 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" url = "https://api.minimax.io/v1/text/chatcompletion_v2"
messages = [] messages = []
@@ -377,13 +387,18 @@ async def _call_minimax_async(model: str, prompt: str, system_prompt: str = None
if res.status_code == 200: if res.status_code == 200:
data = res.json() data = res.json()
# MiniMax V2 structure # MiniMax V2 structure
if "choices" in data and len(data["choices"]) > 0: if data.get("choices") and len(data["choices"]) > 0:
return { return {
"content": data["choices"][0]["message"]["content"], "content": data["choices"][0]["message"]["content"],
"usage": data.get("usage", {}), "usage": data.get("usage", {}),
"model": data.get("base_resp", {}).get("model") or model "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": {}} return {"content": f"Erro MiniMax {res.status_code}: {res.text}", "usage": {}}
except Exception as e: except Exception as e:
return {"content": f"Erro MiniMax: {str(e)}", "usage": {}} return {"content": f"Erro MiniMax: {str(e)}", "usage": {}}
+18
View File
@@ -0,0 +1,18 @@
import os
from dotenv import load_dotenv
import sys
# Add current dir to path to import local modules
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from llm_providers import get_api_key
load_dotenv()
key = get_api_key("minimax")
print(f"MINIMAX_API_KEY found: {bool(key)}")
if key:
print(f"Key starts with: {key[:4]}...")
else:
print("Key is empty!")
print(f"Direct os.getenv('MINIMAX_API_KEY'): {bool(os.getenv('MINIMAX_API_KEY'))}")