Model hierarchy update: Tencent Hunyuan 3 primary, Qwen fallback

This commit is contained in:
2026-04-30 17:38:45 +00:00
parent 67db23f9c5
commit 0878f9fbc0
2 changed files with 9 additions and 9 deletions

View File

@@ -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()]) 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 # 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. 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. Seu modelo base atual é o **{current_model}** via OpenRouter.
@@ -87,30 +87,30 @@ DIRETRIZES:
try: try:
res_dict = await call_llm(provider, current_model, system_prompt + current_history) 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": 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" 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) res_dict = await call_llm("openrouter", backup_model, system_prompt + current_history)
except Exception as e: except Exception as e:
# Lógica de EMERGÊNCIA: Se houver exceção no Ling, tenta o Qwen # Lógica de EMERGÊNCIA: Se houver exceção no Hunyuan, tenta o Qwen
print(f"⚠️ [EMERGENCY FALLBACK] Exceção no Ling ({str(e)}). Tentando {backup_model}...") print(f"⚠️ [EMERGENCY FALLBACK] Exceção no Hunyuan ({str(e)}). Tentando {backup_model}...")
try: try:
backup_model = "qwen/qwen-2.5-72b-instruct" backup_model = "qwen/qwen-2.5-72b-instruct"
res_dict = await call_llm("openrouter", backup_model, system_prompt + current_history) res_dict = await call_llm("openrouter", backup_model, system_prompt + current_history)
except: 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.") response = res_dict.get("content", "Erro: Resposta vazia.")
# Limpeza de segurança: Se a resposta for um erro técnico persistente # Limpeza de segurança: Se a resposta for um erro técnico persistente
if response.startswith("Erro OpenRouter"): 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 # Limpeza de segurança: Se a resposta for um erro técnico persistente
if response.startswith("Erro OpenRouter"): 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", {})
usage = res_dict.get("usage", {}) usage = res_dict.get("usage", {})

View File

@@ -45,7 +45,7 @@ def run_bash_command(command: str) -> str:
except Exception as e: except Exception as e:
return f"ERRO fatal ao rodar bash: {str(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.""" """Retorna um texto detalhado da saúde do servidor para a IA."""
cpu = psutil.cpu_percent(interval=0.1) cpu = psutil.cpu_percent(interval=0.1)
vm = psutil.virtual_memory() vm = psutil.virtual_memory()