Inverting model hierarchy: Ling primary, Qwen fallback and fixing VPSFileCleaner UI
This commit is contained in:
26
ai_agent.py
26
ai_agent.py
@@ -87,20 +87,32 @@ DIRETRIZES:
|
||||
try:
|
||||
res_dict = await call_llm(provider, current_model, system_prompt + current_history)
|
||||
|
||||
# Lógica de FALLBACK: Se o Ling falhar (especialmente por ser free/busy), tenta o Qwen 2.5-72B
|
||||
# Lógica de FALLBACK: Se o Ling 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 CHAT] Falha no Ling. Tentando {backup_model}...")
|
||||
print(f"⚠️ [FALLBACK] Falha no Ling. Tentando {backup_model}...")
|
||||
res_dict = await call_llm("openrouter", backup_model, system_prompt + current_history)
|
||||
|
||||
except Exception as e:
|
||||
if provider == "openrouter":
|
||||
# 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}...")
|
||||
try:
|
||||
backup_model = "qwen/qwen-2.5-72b-instruct"
|
||||
print(f"⚠️ [FALLBACK CHAT] Exceção no Ling ({str(e)}). Tentando {backup_model}...")
|
||||
res_dict = await call_llm("openrouter", backup_model, system_prompt + current_history)
|
||||
else:
|
||||
return f"Erro Crítico no Agente: {str(e)}"
|
||||
except:
|
||||
return f"RESUMO: ❌ Desculpe, os modelos Ling e Qwen estão instáveis no OpenRouter no momento. Por favor, tente novamente em instantes."
|
||||
|
||||
response = res_dict["content"]
|
||||
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."
|
||||
|
||||
# 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."
|
||||
|
||||
usage = res_dict.get("usage", {})
|
||||
usage = res_dict.get("usage", {})
|
||||
total_in += usage.get("prompt_tokens", 0)
|
||||
total_out += usage.get("completion_tokens", 0)
|
||||
|
||||
Reference in New Issue
Block a user