Render streamed assistant responses as Markdown

This commit is contained in:
yuxuanhui
2026-09-08 14:36:05 +08:00
parent aef8e1d310
commit 80cb7d2b80
7 changed files with 363 additions and 4 deletions
+24
View File
@@ -0,0 +1,24 @@
import { memo } from "react";
import MarkdownRender from "markstream-react";
/** Render one assistant text part; final also settles interrupted streams. */
export const MessageMarkdown = memo(function MessageMarkdown({
content,
final,
}: {
content: string;
final: boolean;
}) {
return (
<div className="ai-markdown">
<MarkdownRender
content={content}
final={final}
fade={false}
htmlPolicy="escape"
renderCodeBlocksAsPre
batchRendering={false}
/>
</div>
);
});