@blank-utils/llm 0.3.10 → 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, AlertCircleIcon } from "lucide-react";
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(AlertCircleIcon, { className: "text-red-500" }) }),
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 }),
@@ -1139,7 +1144,13 @@ var streamdownControls = {
1139
1144
  var DEFAULT_SYSTEM_PROMPT = `You are a helpful AI assistant.
1140
1145
  - You can use full Markdown (bold, italic, headers, lists).
1141
1146
  - You can use Code Blocks with language syntax highlighting.
1142
- - You can use Mermaid diagrams (\`\`\`mermaid ... \`\`\`).
1147
+ - You can use Mermaid diagrams to visualize structured data, processes, and architectures.
1148
+ - IMPORTANT: ALWAYS use exactly \`\`\`mermaid as the language tag. NEVER use \`\`\`mer, \`\`\`mmd, etc.
1149
+ - For example:
1150
+ \`\`\`mermaid
1151
+ graph TD
1152
+ A --> B
1153
+ \`\`\`
1143
1154
  - You can use LaTeX math ($$ ... $$).`;
1144
1155
  var ALL_MODELS = { ...WEBLLM_MODELS, ...TRANSFORMERS_MODELS };
1145
1156
  function isVisionModel2(modelId) {
@@ -1442,6 +1453,7 @@ function Chat({
1442
1453
  isAnimating: false,
1443
1454
  mermaid: mermaidOptions,
1444
1455
  controls: streamdownControls,
1456
+ parseMarkdownIntoBlocksFn: sanitizeMarkdownLanguageBlocks,
1445
1457
  children: msg.content
1446
1458
  }
1447
1459
  ) })
@@ -1454,6 +1466,7 @@ function Chat({
1454
1466
  isAnimating: false,
1455
1467
  mermaid: mermaidOptions,
1456
1468
  controls: streamdownControls,
1469
+ parseMarkdownIntoBlocksFn: sanitizeMarkdownLanguageBlocks,
1457
1470
  children: msg.content
1458
1471
  }
1459
1472
  ) }) }, i)),
@@ -1466,6 +1479,7 @@ function Chat({
1466
1479
  isAnimating: isGenerating,
1467
1480
  mermaid: mermaidOptions,
1468
1481
  controls: streamdownControls,
1482
+ parseMarkdownIntoBlocksFn: sanitizeMarkdownLanguageBlocks,
1469
1483
  children: streamingText
1470
1484
  }
1471
1485
  ) }) }),
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@ import {
26
26
  useCompletion,
27
27
  useLLM,
28
28
  useStream
29
- } from "./chunk-AIJOKRQN.js";
29
+ } from "./chunk-NTJ4KYT3.js";
30
30
  export {
31
31
  Chat,
32
32
  ChatInput,
@@ -9,7 +9,7 @@ import {
9
9
  useCompletion,
10
10
  useLLM,
11
11
  useStream
12
- } from "../chunk-AIJOKRQN.js";
12
+ } from "../chunk-NTJ4KYT3.js";
13
13
  export {
14
14
  Chat,
15
15
  ChatApp,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blank-utils/llm",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "description": "Run LLMs directly in your browser with WebGPU acceleration. Supports React hooks and eager background loading.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",