Model hierarchy update: Tencent Hunyuan 3 primary, Qwen fallback
This commit is contained in:
16
ai_agent.py
16
ai_agent.py
@@ -32,7 +32,7 @@ async def query_agent_async(prompt: str, override_provider=None, chat_history=No
|
||||
tools_desc = "\n".join([f"- {k}: {v.get('description') or v.get('desc')}" for k, v in ALL_TOOLS.items()])
|
||||
|
||||
# Identifica o modelo para o prompt do sistema
|
||||
current_model = cfg.get("model") or "inclusionai/ling-2.6-flash:free"
|
||||
current_model = cfg.get("model") or "tencent/hy3-preview:free"
|
||||
|
||||
system_prompt = f"""Você é o Antigravity, um assistente de IA de alto desempenho operando na VPS do Marcos.
|
||||
Seu modelo base atual é o **{current_model}** via OpenRouter.
|
||||
@@ -87,30 +87,30 @@ DIRETRIZES:
|
||||
try:
|
||||
res_dict = await call_llm(provider, current_model, system_prompt + current_history)
|
||||
|
||||
# Lógica de FALLBACK: Se o Ling falhar, tenta o Qwen
|
||||
# Lógica de FALLBACK: Se o Hunyuan falhar, tenta o Qwen
|
||||
if (res_dict.get("content", "").startswith("Erro OpenRouter") or "error" in res_dict.get("content", "").lower()) and provider == "openrouter":
|
||||
backup_model = "qwen/qwen-2.5-72b-instruct"
|
||||
print(f"⚠️ [FALLBACK] Falha no Ling. Tentando {backup_model}...")
|
||||
print(f"⚠️ [FALLBACK] Falha no Hunyuan. Tentando {backup_model}...")
|
||||
res_dict = await call_llm("openrouter", backup_model, system_prompt + current_history)
|
||||
|
||||
except Exception as e:
|
||||
# Lógica de EMERGÊNCIA: Se houver exceção no Ling, tenta o Qwen
|
||||
print(f"⚠️ [EMERGENCY FALLBACK] Exceção no Ling ({str(e)}). Tentando {backup_model}...")
|
||||
# Lógica de EMERGÊNCIA: Se houver exceção no Hunyuan, tenta o Qwen
|
||||
print(f"⚠️ [EMERGENCY FALLBACK] Exceção no Hunyuan ({str(e)}). Tentando {backup_model}...")
|
||||
try:
|
||||
backup_model = "qwen/qwen-2.5-72b-instruct"
|
||||
res_dict = await call_llm("openrouter", backup_model, system_prompt + current_history)
|
||||
except:
|
||||
return f"RESUMO: ❌ Desculpe, os modelos Ling e Qwen estão instáveis no OpenRouter no momento. Por favor, tente novamente em instantes."
|
||||
return f"RESUMO: ❌ Desculpe, os modelos Hunyuan e Qwen estão instáveis no OpenRouter no momento. Por favor, tente novamente em instantes."
|
||||
|
||||
response = res_dict.get("content", "Erro: Resposta vazia.")
|
||||
|
||||
# Limpeza de segurança: Se a resposta for um erro técnico persistente
|
||||
if response.startswith("Erro OpenRouter"):
|
||||
return f"RESUMO: ⚠️ Instabilidade no OpenRouter (Ling/Qwen):\n`{response[:200]}...`\n\nPor favor, tente reenviar sua mensagem."
|
||||
return f"RESUMO: ⚠️ Instabilidade no OpenRouter (Hunyuan/Qwen):\n`{response[:200]}...`\n\nPor favor, tente reenviar sua mensagem."
|
||||
|
||||
# Limpeza de segurança: Se a resposta for um erro técnico persistente
|
||||
if response.startswith("Erro OpenRouter"):
|
||||
return f"RESUMO: ⚠️ Instabilidade no OpenRouter (Ling/Qwen):\n`{response[:200]}...`\n\nPor favor, tente reenviar sua mensagem."
|
||||
return f"RESUMO: ⚠️ Instabilidade no OpenRouter (Hunyuan/Qwen):\n`{response[:200]}...`\n\nPor favor, tente reenviar sua mensagem."
|
||||
|
||||
usage = res_dict.get("usage", {})
|
||||
usage = res_dict.get("usage", {})
|
||||
|
||||
2
tools.py
2
tools.py
@@ -45,7 +45,7 @@ def run_bash_command(command: str) -> str:
|
||||
except Exception as e:
|
||||
return f"ERRO fatal ao rodar bash: {str(e)}"
|
||||
|
||||
def get_system_health() -> str:
|
||||
def get_system_health(*args) -> str:
|
||||
"""Retorna um texto detalhado da saúde do servidor para a IA."""
|
||||
cpu = psutil.cpu_percent(interval=0.1)
|
||||
vm = psutil.virtual_memory()
|
||||
|
||||
Reference in New Issue
Block a user