diff --git a/frontend/src/components/ChatInterface.tsx b/frontend/src/components/ChatInterface.tsx index 02f169b..abf5c94 100644 --- a/frontend/src/components/ChatInterface.tsx +++ b/frontend/src/components/ChatInterface.tsx @@ -35,6 +35,21 @@ interface MessageViz { error?: string | null; } +const REPORT_HTML_BLOCK_REGEX = /([\s\S]*?)/i; + +const splitReportHtml = (content: string): { markdown: string; reportHtml: string | null } => { + if (!content) { + return { markdown: "", reportHtml: null }; + } + const match = content.match(REPORT_HTML_BLOCK_REGEX); + if (!match) { + return { markdown: content, reportHtml: null }; + } + const reportHtml = (match[1] || "").trim(); + const markdown = content.replace(REPORT_HTML_BLOCK_REGEX, "").trim(); + return { markdown, reportHtml: reportHtml || null }; +}; + interface ModelConfig { id: string; name?: string; @@ -898,7 +913,9 @@ export function ChatInterface() { ) : (
- {messages.map((msg) => ( + {messages.map((msg) => { + const { markdown, reportHtml } = splitReportHtml(msg.content); + return (
) : ( <> -
- - {msg.content} - -
+ {markdown ? ( +
+ + {markdown} + +
+ ) : null} + {reportHtml ? ( +
+