skills2
This commit is contained in:
65
tools.py
65
tools.py
@@ -189,6 +189,57 @@ def list_gmail_emails(account: str) -> str:
|
||||
except Exception as e:
|
||||
return f"Erro ao listar e-mails: {str(e)}\nResposta bruta: {res[:200]}"
|
||||
|
||||
def drive_find(arg: str) -> str:
|
||||
"""Busca arquivos no Drive por nome. Arg: account query (ex: ma financeiro)"""
|
||||
try:
|
||||
parts = arg.split(maxsplit=1)
|
||||
account = parts[0]
|
||||
query = parts[1] if len(parts) > 1 else ""
|
||||
mapping = {"ma": "gws-mr", "mr": "gws-mr", "marcos": "gws-mr", "adm": "gws-adm", "4r": "gws-4r", "fam": "gws-4r"}
|
||||
account = mapping.get(account.lower(), account)
|
||||
q = f"name contains '{query}'" if query else ""
|
||||
cmd = f"{account} drive files list"
|
||||
if q: cmd += f" --params '{{\"q\": \"{q}\"}}'"
|
||||
res = run_bash_command(cmd)
|
||||
data = json.loads(res)
|
||||
files = data.get("files", [])
|
||||
if not files: return "Nenhum arquivo encontrado."
|
||||
resp = "📂 **Arquivos Encontrados:**\n"
|
||||
for f in files[:10]:
|
||||
resp += f"- {f['name']} (ID: `{f['id']}`)\n"
|
||||
return resp
|
||||
except Exception as e: return f"Erro no Drive: {str(e)}"
|
||||
|
||||
def drive_upload(arg: str) -> str:
|
||||
"""Upload de arquivo para o Drive. Arg: account filepath (ex: ma /tmp/relat.pdf)"""
|
||||
try:
|
||||
parts = arg.split(maxsplit=1)
|
||||
account, filepath = parts[0], parts[1]
|
||||
mapping = {"ma": "gws-mr", "mr": "gws-mr", "adm": "gws-adm", "4r": "gws-4r"}
|
||||
account = mapping.get(account.lower(), account)
|
||||
filename = os.path.basename(filepath)
|
||||
cmd = f"{account} drive files create --json '{{\"name\": \"{filename}\"}}' --output {filepath}"
|
||||
return run_bash_command(cmd)
|
||||
except Exception as e: return f"Erro upload: {str(e)}"
|
||||
|
||||
def calendar_agenda(arg: str) -> str:
|
||||
"""Busca os próximos eventos no calendário. Arg: account timeframe (timeframe: today, tomorrow, week, days=N)"""
|
||||
try:
|
||||
parts = arg.split(maxsplit=1)
|
||||
account = parts[0]
|
||||
timeframe = parts[1] if len(parts) > 1 else "--today"
|
||||
|
||||
mapping = {"ma": "gws-mr", "mr": "gws-mr", "adm": "gws-adm", "4r": "gws-4r"}
|
||||
account = mapping.get(account.lower(), account)
|
||||
|
||||
# Converte timeframe para flag correta
|
||||
if not timeframe.startswith("--"):
|
||||
timeframe = f"--{timeframe}"
|
||||
|
||||
cmd = f"{account} calendar +agenda {timeframe}"
|
||||
return run_bash_command(cmd)
|
||||
except Exception as e: return f"Erro no Calendário: {str(e)}"
|
||||
|
||||
# Mapeamento para o Agente entender quais tools ele possui (será usado no loop ReAct)
|
||||
AVAILABLE_TOOLS = {
|
||||
"run_bash_command": {
|
||||
@@ -196,9 +247,21 @@ AVAILABLE_TOOLS = {
|
||||
"func": run_bash_command
|
||||
},
|
||||
"list_gmail_emails": {
|
||||
"description": "Lista os 5 e-mails mais recentes de uma conta (gws-mr, gws-adm, gws-4r) com título e remetente.",
|
||||
"description": "Lista os 5 e-mails mais recentes de uma conta (ma, adm, 4r) com título e remetente.",
|
||||
"func": list_gmail_emails
|
||||
},
|
||||
"drive_find": {
|
||||
"description": "Busca arquivos no Drive por nome. Ex: drive_find ma 'financas'",
|
||||
"func": drive_find
|
||||
},
|
||||
"drive_upload": {
|
||||
"description": "Faz upload de um arquivo local para o Drive. Ex: drive_upload adm /tmp/doc.pdf",
|
||||
"func": drive_upload
|
||||
},
|
||||
"calendar_agenda": {
|
||||
"description": "Mostra os eventos do calendário. Ex: calendar_agenda ma today / tomorrow / week",
|
||||
"func": calendar_agenda
|
||||
},
|
||||
"get_system_health": {
|
||||
"description": "Verifica RAM, CPU e Disco globais da VPS.",
|
||||
"func": get_system_health
|
||||
|
||||
Reference in New Issue
Block a user