Model update: Llama 3.1 8B 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 "tencent/hy3-preview:free"
|
||||
current_model = cfg.get("model") or "meta-llama/llama-3.1-8b-instruct: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 Hunyuan falhar, tenta o Qwen
|
||||
# Lógica de FALLBACK: Se o Llama 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 Hunyuan. Tentando {backup_model}...")
|
||||
print(f"⚠️ [FALLBACK] Falha no Llama. 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 Hunyuan, tenta o Qwen
|
||||
print(f"⚠️ [EMERGENCY FALLBACK] Exceção no Hunyuan ({str(e)}). Tentando {backup_model}...")
|
||||
# Lógica de EMERGÊNCIA: Se houver exceção no Llama, tenta o Qwen
|
||||
print(f"⚠️ [EMERGENCY FALLBACK] Exceção no Llama ({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 Hunyuan e Qwen estão instáveis no OpenRouter no momento. Por favor, tente novamente em instantes."
|
||||
return f"RESUMO: ❌ Desculpe, os modelos Llama 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 (Hunyuan/Qwen):\n`{response[:200]}...`\n\nPor favor, tente reenviar sua mensagem."
|
||||
return f"RESUMO: ⚠️ Instabilidade no OpenRouter (Llama/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 (Hunyuan/Qwen):\n`{response[:200]}...`\n\nPor favor, tente reenviar sua mensagem."
|
||||
return f"RESUMO: ⚠️ Instabilidade no OpenRouter (Llama/Qwen):\n`{response[:200]}...`\n\nPor favor, tente reenviar sua mensagem."
|
||||
|
||||
usage = res_dict.get("usage", {})
|
||||
usage = res_dict.get("usage", {})
|
||||
|
||||
Reference in New Issue
Block a user