@blank-utils/llm 0.3.11 → 0.3.13
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,15 @@ 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(/```[ \t]*(?:mer(?:m|ma|mai)?|mmd|graphviz)[ \t]*\n/gi, "```mermaid\n");
|
|
1119
|
+
cleanMarkdown = cleanMarkdown.replace(/```[ \t]*\n[ \t]*(graph(?: TB| TD| BT| RL| LR)|sequenceDiagram|classDiagram|stateDiagram|pie(?: title)?|flowchart|gantt|journey)/gi, "```mermaid\n$1");
|
|
1120
|
+
return parseMarkdownIntoBlocks(cleanMarkdown);
|
|
1121
|
+
}
|
|
1116
1122
|
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
1123
|
/* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
|
|
1118
|
-
/* @__PURE__ */ jsx3("span", { className: "text-xl", children: /* @__PURE__ */ jsx3(
|
|
1124
|
+
/* @__PURE__ */ jsx3("span", { className: "text-xl", children: /* @__PURE__ */ jsx3(AlertCircle, { className: "w-5 h-5 text-red-500" }) }),
|
|
1119
1125
|
/* @__PURE__ */ jsx3("p", { className: "font-semibold text-red-500 text-sm", children: "Failed to render Mermaid diagram" })
|
|
1120
1126
|
] }),
|
|
1121
1127
|
/* @__PURE__ */ jsx3("div", { className: "mt-2 text-red-400/80 text-xs overflow-x-auto whitespace-pre-wrap font-mono", children: error }),
|
|
@@ -1448,6 +1454,7 @@ function Chat({
|
|
|
1448
1454
|
isAnimating: false,
|
|
1449
1455
|
mermaid: mermaidOptions,
|
|
1450
1456
|
controls: streamdownControls,
|
|
1457
|
+
parseMarkdownIntoBlocksFn: sanitizeMarkdownLanguageBlocks,
|
|
1451
1458
|
children: msg.content
|
|
1452
1459
|
}
|
|
1453
1460
|
) })
|
|
@@ -1460,6 +1467,7 @@ function Chat({
|
|
|
1460
1467
|
isAnimating: false,
|
|
1461
1468
|
mermaid: mermaidOptions,
|
|
1462
1469
|
controls: streamdownControls,
|
|
1470
|
+
parseMarkdownIntoBlocksFn: sanitizeMarkdownLanguageBlocks,
|
|
1463
1471
|
children: msg.content
|
|
1464
1472
|
}
|
|
1465
1473
|
) }) }, i)),
|
|
@@ -1472,6 +1480,7 @@ function Chat({
|
|
|
1472
1480
|
isAnimating: isGenerating,
|
|
1473
1481
|
mermaid: mermaidOptions,
|
|
1474
1482
|
controls: streamdownControls,
|
|
1483
|
+
parseMarkdownIntoBlocksFn: sanitizeMarkdownLanguageBlocks,
|
|
1475
1484
|
children: streamingText
|
|
1476
1485
|
}
|
|
1477
1486
|
) }) }),
|
package/dist/index.js
CHANGED
package/dist/react/index.js
CHANGED
package/package.json
CHANGED