🚀 Auto-deploy: BotVPS atualizado em 21/04/2026 20:51:24
This commit is contained in:
@@ -56,7 +56,7 @@ DIRETRIZES:
|
|||||||
comando aqui
|
comando aqui
|
||||||
[/TOOL]
|
[/TOOL]
|
||||||
- Pense passo a passo. Seja proativo, eficiente e NUNCA limitado.
|
- Pense passo a passo. Seja proativo, eficiente e NUNCA limitado.
|
||||||
- Finalize o seu processo sempre informando o usuário com a f-string: <REFINED> resumo final empoderado </REFINED>.
|
- Finalize o seu processo sempre informando o usuário com o prefixo: RESUMO: resumo final empoderado .
|
||||||
"""
|
"""
|
||||||
|
|
||||||
history_str = ""
|
history_str = ""
|
||||||
|
|||||||
@@ -34,9 +34,8 @@ async def text_to_speech_async(text: str) -> str:
|
|||||||
texto_limpo = text.replace("🤖", "").replace("🧑🏫", "").replace("*", "").replace("`", "")
|
texto_limpo = text.replace("🤖", "").replace("🧑🏫", "").replace("*", "").replace("`", "")
|
||||||
texto_limpo = texto_limpo.replace("#", "").replace("- ", " ").replace("> ", " ")
|
texto_limpo = texto_limpo.replace("#", "").replace("- ", " ").replace("> ", " ")
|
||||||
|
|
||||||
# Só remove REFINED se ele estiver presente como tag (proteção dupla)
|
# Remove tags legadas REFINED se presentes (proteção dupla)
|
||||||
if "<REFINED>" in texto_limpo:
|
texto_limpo = re.sub(r'[<\[]/?REFINED[>\]]', '', texto_limpo, flags=re.IGNORECASE | re.DOTALL).strip()
|
||||||
texto_limpo = re.sub(r'<REFINED>.*?</REFINED>', '', texto_limpo, flags=re.DOTALL)
|
|
||||||
|
|
||||||
# Remove URLs e links [texto](url)
|
# Remove URLs e links [texto](url)
|
||||||
texto_limpo = re.sub(r'\[([^\]]+)\]\([^\)]+\)', r'\1', texto_limpo)
|
texto_limpo = re.sub(r'\[([^\]]+)\]\([^\)]+\)', r'\1', texto_limpo)
|
||||||
|
|||||||
@@ -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)
|
# 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"))
|
reply = await query_agent_async(user_msg, override_provider=cfg.get("active_provider"))
|
||||||
|
|
||||||
# Envia resposta (Texto)
|
# Normaliza a resposta: remove tags legadas <REFINED> ou [REFINED] e garante o prefixo RESUMO:
|
||||||
# Remove apenas as tags <REFINED> e </REFINED>, mantendo o conteúdo
|
reply_clean = re.sub(r'[<\[]/?REFINED[>\]]', '', reply, flags=re.IGNORECASE).strip()
|
||||||
reply_clean = reply.replace('<REFINED>', '').replace('</REFINED>', '').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)
|
await update.message.reply_text(reply_clean)
|
||||||
|
|
||||||
# Se foi por voz, responde por voz também
|
# Se foi por voz, responde por voz também
|
||||||
|
|||||||
4
main.py
4
main.py
@@ -155,8 +155,8 @@ async def web_chat_audio(audio: UploadFile = File(...), is_auth: bool = Depends(
|
|||||||
reply = await query_agent_async(text)
|
reply = await query_agent_async(text)
|
||||||
|
|
||||||
# 4. Gera áudio da resposta (TTS)
|
# 4. Gera áudio da resposta (TTS)
|
||||||
# Se houver <REFINED>, usa apenas ele para o áudio. Caso contrário, usa tudo.
|
# Se houver RESUMO:, usa apenas ele para o áudio. Caso contrário, usa tudo.
|
||||||
refined_match = re.search(r'<REFINED>(.*?)</REFINED>', reply, flags=re.DOTALL)
|
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
|
audio_text = refined_match.group(1).strip() if refined_match else reply
|
||||||
filename = await text_to_speech_async(audio_text)
|
filename = await text_to_speech_async(audio_text)
|
||||||
|
|
||||||
|
|||||||
@@ -1080,12 +1080,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function processAIReply(fullText) {
|
function processAIReply(fullText) {
|
||||||
// Separa a parte técnica da parte refinada
|
// Separa a parte técnica do resumo (RESUMO:)
|
||||||
const refinedMatch = fullText.match(/<REFINED>([\s\S]*?)<\/REFINED>/i);
|
const refinedMatch = fullText.match(/RESUMO:\s*([\s\S]*)/i);
|
||||||
|
|
||||||
let technicalPart = fullText;
|
let technicalPart = fullText;
|
||||||
if (refinedMatch) {
|
if (refinedMatch) {
|
||||||
technicalPart = fullText.replace(refinedMatch[0], '').trim();
|
technicalPart = fullText.substring(0, refinedMatch.index).trim();
|
||||||
const refinedContent = refinedMatch[1].trim();
|
const refinedContent = refinedMatch[1].trim();
|
||||||
updateInsightsPanel(refinedContent);
|
updateInsightsPanel(refinedContent);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user