@blank-utils/llm 0.3.11 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1101,10 +1101,10 @@ ${newText}` : newText);
|
|
|
1101
1101
|
}
|
|
1102
1102
|
|
|
1103
1103
|
// src/react/components.tsx
|
|
1104
|
-
import { RotateCcw, ChevronDown,
|
|
1104
|
+
import { RotateCcw, ChevronDown, AlertCircle } from "lucide-react";
|
|
1105
1105
|
import { clsx } from "clsx";
|
|
1106
1106
|
import { twMerge } from "tailwind-merge";
|
|
1107
|
-
import { Streamdown } from "streamdown";
|
|
1107
|
+
import { Streamdown, parseMarkdownIntoBlocks } from "streamdown";
|
|
1108
1108
|
import { code } from "@streamdown/code";
|
|
1109
1109
|
import { mermaid } from "@streamdown/mermaid";
|
|
1110
1110
|
import { math } from "@streamdown/math";
|
|
@@ -1113,9 +1113,14 @@ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
|
1113
1113
|
function cn(...inputs) {
|
|
1114
1114
|
return twMerge(clsx(inputs));
|
|
1115
1115
|
}
|
|
1116
|
+
function sanitizeMarkdownLanguageBlocks(markdown) {
|
|
1117
|
+
let cleanMarkdown = markdown;
|
|
1118
|
+
cleanMarkdown = cleanMarkdown.replace(/```(?:mer|merma|mermai|mmd)\n/gi, "```mermaid\n");
|
|
1119
|
+
return parseMarkdownIntoBlocks(cleanMarkdown);
|
|
1120
|
+
}
|
|
1116
1121
|
var CustomMermaidError = ({ error, retry }) => /* @__PURE__ */ jsxs3("div", { className: "rounded-lg border border-red-500/20 bg-red-500/10 p-4 my-4 font-sans", children: [
|
|
1117
1122
|
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
|
|
1118
|
-
/* @__PURE__ */ jsx3("span", { className: "text-xl", children: /* @__PURE__ */ jsx3(
|
|
1123
|
+
/* @__PURE__ */ jsx3("span", { className: "text-xl", children: /* @__PURE__ */ jsx3(AlertCircle, { className: "w-5 h-5 text-red-500" }) }),
|
|
1119
1124
|
/* @__PURE__ */ jsx3("p", { className: "font-semibold text-red-500 text-sm", children: "Failed to render Mermaid diagram" })
|
|
1120
1125
|
] }),
|
|
1121
1126
|
/* @__PURE__ */ jsx3("div", { className: "mt-2 text-red-400/80 text-xs overflow-x-auto whitespace-pre-wrap font-mono", children: error }),
|
|
@@ -1448,6 +1453,7 @@ function Chat({
|
|
|
1448
1453
|
isAnimating: false,
|
|
1449
1454
|
mermaid: mermaidOptions,
|
|
1450
1455
|
controls: streamdownControls,
|
|
1456
|
+
parseMarkdownIntoBlocksFn: sanitizeMarkdownLanguageBlocks,
|
|
1451
1457
|
children: msg.content
|
|
1452
1458
|
}
|
|
1453
1459
|
) })
|
|
@@ -1460,6 +1466,7 @@ function Chat({
|
|
|
1460
1466
|
isAnimating: false,
|
|
1461
1467
|
mermaid: mermaidOptions,
|
|
1462
1468
|
controls: streamdownControls,
|
|
1469
|
+
parseMarkdownIntoBlocksFn: sanitizeMarkdownLanguageBlocks,
|
|
1463
1470
|
children: msg.content
|
|
1464
1471
|
}
|
|
1465
1472
|
) }) }, i)),
|
|
@@ -1472,6 +1479,7 @@ function Chat({
|
|
|
1472
1479
|
isAnimating: isGenerating,
|
|
1473
1480
|
mermaid: mermaidOptions,
|
|
1474
1481
|
controls: streamdownControls,
|
|
1482
|
+
parseMarkdownIntoBlocksFn: sanitizeMarkdownLanguageBlocks,
|
|
1475
1483
|
children: streamingText
|
|
1476
1484
|
}
|
|
1477
1485
|
) }) }),
|
package/dist/index.js
CHANGED
package/dist/react/index.js
CHANGED
package/package.json
CHANGED