From c8a02b65be95c267dc5676c77c172249b95d903c Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Wed, 22 Apr 2026 20:15:21 +0000 Subject: [PATCH] fix: HTML rendering in chat + improved PROMPT.md for ramal queries - Detect HTML content (starts with <) in streaming messages and bypass marked.parse() to render directly as innerHTML - marked.parse() was corrupting the LLM's raw HTML output by treating it as Markdown (escaping tags, wrapping in

, etc.) - Updated PROMPT.md for Salesianos to be more explicit about returning ramal data directly from KB context without asking for unnecessary clarification - Fixed ramais.bas tool (removed invalid BEGIN/END syntax) --- botui/ui/minimal/index.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/botui/ui/minimal/index.html b/botui/ui/minimal/index.html index 8c16c21d..bfc1e312 100644 --- a/botui/ui/minimal/index.html +++ b/botui/ui/minimal/index.html @@ -1371,7 +1371,9 @@ m.innerHTML = `

${escapeHtml(content)}
`; updateContextUsage(contextUsage + 0.05); } else if (role === "assistant") { - m.innerHTML = `
${streaming ? "" : marked.parse(content)}
`; + const isHtml = content.trim().startsWith('<'); + const rendered = streaming ? "" : (isHtml ? content : marked.parse(content)); + m.innerHTML = `
${rendered}
`; updateContextUsage(contextUsage + 0.03); } else if (role === "voice") { m.innerHTML = `
🎤
${content}
`; @@ -1393,7 +1395,8 @@ function updateStreamingMessage(c) { const m = document.getElementById(streamingMessageId); if (m) { - m.innerHTML = marked.parse(c); + const isHtmlStream = c.trim().startsWith('<'); + m.innerHTML = isHtmlStream ? c : marked.parse(c); if (!isUserScrolling) { scrollToBottom(); } @@ -1403,7 +1406,8 @@ function finalizeStreamingMessage() { const m = document.getElementById(streamingMessageId); if (m) { - m.innerHTML = marked.parse(currentStreamingContent); + const isHtmlFinal = currentStreamingContent.trim().startsWith('<'); + m.innerHTML = isHtmlFinal ? currentStreamingContent : marked.parse(currentStreamingContent); m.removeAttribute("id"); if (!isUserScrolling) { scrollToBottom();