Update Hermes integration

This commit is contained in:
Antigravity
2026-05-10 00:37:18 -03:00
parent 7b31435895
commit 8b577242ff
3 changed files with 54 additions and 12 deletions

16
main.py
View File

@@ -177,11 +177,21 @@ async def web_chat_audio(audio: UploadFile = File(...), is_auth: bool = Depends(
if not text:
return {"reply": "Não entendi seu áudio.", "text": ""}
# 3. Processa na IA
reply = await query_agent_async(text)
# 3. Verifica se é para o Hermes
text_clean = text.lower().strip()
is_hermes = text_clean.startswith('hermes') or text_clean.startswith('h ')
if is_hermes:
# Extrai a tarefa
task = text[6:].strip() if text_clean.startswith('hermes') else text[2:].strip()
from core_tools import delegate_to_hermes
reply = await run_in_threadpool(delegate_to_hermes, f"[Áudio] {task}")
reply = f"🤖 **Hermes Agent:**\n\n{reply}"
else:
# Processa na IA padrão do BotVPS
reply = await query_agent_async(text)
# 4. Gera áudio da resposta (TTS)
# Se houver RESUMO:, usa apenas ele para o áudio. Caso contrário, usa tudo.
refined_match = re.search(r'RESUMO:\s*(.*)', reply, flags=re.DOTALL | re.IGNORECASE)
audio_text = refined_match.group(1).strip() if refined_match else reply
filename = await text_to_speech_async(audio_text)