From 8161c35655004722240cb427b45673e768e60eab Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Tue, 21 Apr 2026 20:51:24 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Auto-deploy:=20BotVPS=20atualiza?= =?UTF-8?q?do=20em=2021/04/2026=2020:51:24?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ai_agent.py | 2 +- audio_handler.py | 5 ++--- bot_logic.py | 8 +++++--- main.py | 4 ++-- templates/index.html | 6 +++--- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ai_agent.py b/ai_agent.py index 3b562ec..2afc056 100644 --- a/ai_agent.py +++ b/ai_agent.py @@ -56,7 +56,7 @@ DIRETRIZES: comando aqui [/TOOL] - Pense passo a passo. Seja proativo, eficiente e NUNCA limitado. -- Finalize o seu processo sempre informando o usuário com a f-string: resumo final empoderado . +- Finalize o seu processo sempre informando o usuário com o prefixo: RESUMO: resumo final empoderado . """ history_str = "" diff --git a/audio_handler.py b/audio_handler.py index 4b42a20..46b5448 100644 --- a/audio_handler.py +++ b/audio_handler.py @@ -34,9 +34,8 @@ async def text_to_speech_async(text: str) -> str: texto_limpo = text.replace("🤖", "").replace("🧑‍🏫", "").replace("*", "").replace("`", "") texto_limpo = texto_limpo.replace("#", "").replace("- ", " ").replace("> ", " ") - # Só remove REFINED se ele estiver presente como tag (proteção dupla) - if "" in texto_limpo: - texto_limpo = re.sub(r'.*?', '', texto_limpo, flags=re.DOTALL) + # Remove tags legadas REFINED se presentes (proteção dupla) + texto_limpo = re.sub(r'[<\[]/?REFINED[>\]]', '', texto_limpo, flags=re.IGNORECASE | re.DOTALL).strip() # Remove URLs e links [texto](url) texto_limpo = re.sub(r'\[([^\]]+)\]\([^\)]+\)', r'\1', texto_limpo) diff --git a/bot_logic.py b/bot_logic.py index fb50fde..9dc5be8 100644 --- a/bot_logic.py +++ b/bot_logic.py @@ -112,9 +112,11 @@ async def process_logic(update: Update, context: ContextTypes.DEFAULT_TYPE, user # No Telegram, ainda não estamos mantendo histórico complexo no bot_data (pode ser futuro) reply = await query_agent_async(user_msg, override_provider=cfg.get("active_provider")) - # Envia resposta (Texto) - # Remove apenas as tags e , mantendo o conteúdo - reply_clean = reply.replace('', '').replace('', '').strip() + # Normaliza a resposta: remove tags legadas ou [REFINED] e garante o prefixo RESUMO: + reply_clean = re.sub(r'[<\[]/?REFINED[>\]]', '', reply, flags=re.IGNORECASE).strip() + + # Se a resposta não tiver "RESUMO:" mas tiver conteúdo, o orquestrador/IA já deve ter colocado. + # Se por algum motivo não houver, mantemos o texto limpo. await update.message.reply_text(reply_clean) # Se foi por voz, responde por voz também diff --git a/main.py b/main.py index e188fa9..4b5b96f 100644 --- a/main.py +++ b/main.py @@ -155,8 +155,8 @@ async def web_chat_audio(audio: UploadFile = File(...), is_auth: bool = Depends( reply = await query_agent_async(text) # 4. Gera áudio da resposta (TTS) - # Se houver , usa apenas ele para o áudio. Caso contrário, usa tudo. - refined_match = re.search(r'(.*?)', reply, flags=re.DOTALL) + # 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) diff --git a/templates/index.html b/templates/index.html index fe42e94..fd63c53 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1080,12 +1080,12 @@ } function processAIReply(fullText) { - // Separa a parte técnica da parte refinada - const refinedMatch = fullText.match(/([\s\S]*?)<\/REFINED>/i); + // Separa a parte técnica do resumo (RESUMO:) + const refinedMatch = fullText.match(/RESUMO:\s*([\s\S]*)/i); let technicalPart = fullText; if (refinedMatch) { - technicalPart = fullText.replace(refinedMatch[0], '').trim(); + technicalPart = fullText.substring(0, refinedMatch.index).trim(); const refinedContent = refinedMatch[1].trim(); updateInsightsPanel(refinedContent); }