🚀 Auto-deploy: BotVPS atualizado em 29/04/2026 10:32:29
This commit is contained in:
24
ai_agent.py
24
ai_agent.py
@@ -31,8 +31,13 @@ async def query_agent_async(prompt: str, override_provider=None, chat_history=No
|
|||||||
ALL_TOOLS = {**TOOLS_LEGACY, **TOOLS_NEW}
|
ALL_TOOLS = {**TOOLS_LEGACY, **TOOLS_NEW}
|
||||||
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()])
|
||||||
|
|
||||||
system_prompt = f"""Você é o Antigravity, um assistente de IA de alto desempenho operando na VPS do Marcos. Sua natureza é dual:
|
# Identifica o modelo para o prompt do sistema
|
||||||
|
current_model = cfg.get("model") or "qwen/qwen-2.5-72b-instruct"
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Sua natureza é dual:
|
||||||
1. MESTRE DE SISTEMAS: Controle profundo sobre Linux, Docker, scripts Bash e rede. Seja preciso, seguro e eficiente em tarefas técnicas.
|
1. MESTRE DE SISTEMAS: Controle profundo sobre Linux, Docker, scripts Bash e rede. Seja preciso, seguro e eficiente em tarefas técnicas.
|
||||||
2. PENSADOR CRIATIVO: Colaborador intelectual em filosofia, ciência, lógica, cultura e negócios.
|
2. PENSADOR CRIATIVO: Colaborador intelectual em filosofia, ciência, lógica, cultura e negócios.
|
||||||
|
|
||||||
@@ -75,7 +80,22 @@ DIRETRIZES:
|
|||||||
max_iterations = 6
|
max_iterations = 6
|
||||||
for i in range(max_iterations):
|
for i in range(max_iterations):
|
||||||
print(f"[AGENT] Iteração {i+1} - Enviando para {provider} (modelo padrão)...")
|
print(f"[AGENT] Iteração {i+1} - Enviando para {provider} (modelo padrão)...")
|
||||||
response = await get_llm_response_async(system_prompt + current_history, provider, cfg)
|
try:
|
||||||
|
response = await get_llm_response_async(system_prompt + current_history, provider, cfg)
|
||||||
|
|
||||||
|
# Lógica de FALLBACK: Se o Qwen falhar ou retornar erro de API, tenta o Ling-2.6-flash
|
||||||
|
if response.startswith("Erro OpenRouter") and provider == "openrouter" and current_model == "qwen/qwen-2.5-72b-instruct":
|
||||||
|
backup_model = "inclusionai/ling-2.6-flash:free"
|
||||||
|
print(f"⚠️ [FALLBACK CHAT] Falha no Qwen. Tentando {backup_model}...")
|
||||||
|
response = await call_llm("openrouter", backup_model, system_prompt + current_history)
|
||||||
|
except Exception as e:
|
||||||
|
if provider == "openrouter" and current_model == "qwen/qwen-2.5-72b-instruct":
|
||||||
|
backup_model = "inclusionai/ling-2.6-flash:free"
|
||||||
|
print(f"⚠️ [FALLBACK CHAT] Exceção no Qwen ({str(e)}). Tentando {backup_model}...")
|
||||||
|
response = await call_llm("openrouter", backup_model, system_prompt + current_history)
|
||||||
|
else:
|
||||||
|
return f"Erro Crítico no Agente: {str(e)}"
|
||||||
|
|
||||||
print(f"[LLM RESPONSE]: {response}")
|
print(f"[LLM RESPONSE]: {response}")
|
||||||
# Regex mais flexível: tenta casar [TOOL:nome] e extrair o conteúdo até [/TOOL] ou final da string
|
# Regex mais flexível: tenta casar [TOOL:nome] e extrair o conteúdo até [/TOOL] ou final da string
|
||||||
# Regex robusto: captura [TOOL:nome] ou TOOL:nome (sem colchetes como fallback)
|
# Regex robusto: captura [TOOL:nome] ou TOOL:nome (sem colchetes como fallback)
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
CONFIG_FILE = "/app/data/config.json"
|
# Usa o diretório do script para localizar o data/config.json
|
||||||
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
CONFIG_FILE = os.path.join(BASE_DIR, "data", "config.json")
|
||||||
|
|
||||||
def get_config():
|
def get_config():
|
||||||
if not os.path.exists("/app/data"):
|
if not os.path.exists("/app/data"):
|
||||||
|
|||||||
Reference in New Issue
Block a user