@blank-utils/llm 0.3.6 → 0.3.8

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.
@@ -1105,14 +1105,28 @@ import { RotateCcw, ChevronDown } from "lucide-react";
1105
1105
  import { clsx } from "clsx";
1106
1106
  import { twMerge } from "tailwind-merge";
1107
1107
  import { Streamdown } from "streamdown";
1108
- import { code } from "@streamdown/code";
1109
- import { mermaid } from "@streamdown/mermaid";
1110
- import { math } from "@streamdown/math";
1108
+ import { createCodePlugin } from "@streamdown/code";
1109
+ import { createMermaidPlugin } from "@streamdown/mermaid";
1110
+ import { createMathPlugin } from "@streamdown/math";
1111
1111
  import "streamdown/styles.css";
1112
1112
  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
+ var codePlugin = createCodePlugin({
1117
+ themes: ["github-light", "github-dark"]
1118
+ });
1119
+ var mermaidPlugin = createMermaidPlugin({
1120
+ config: {
1121
+ theme: "base",
1122
+ themeVariables: {
1123
+ fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
1124
+ }
1125
+ }
1126
+ });
1127
+ var mathPlugin = createMathPlugin({
1128
+ singleDollarTextMath: false
1129
+ });
1116
1130
  var DEFAULT_SYSTEM_PROMPT = `You are a helpful AI assistant.
1117
1131
  - You can use full Markdown (bold, italic, headers, lists).
1118
1132
  - You can use Code Blocks with language syntax highlighting.
@@ -1138,12 +1152,7 @@ var markdownComponents = {
1138
1152
  table: ({ children }) => /* @__PURE__ */ jsx3("div", { className: "my-4 w-full overflow-y-auto", children: /* @__PURE__ */ jsx3("table", { className: "w-full text-sm", children }) }),
1139
1153
  tr: ({ children }) => /* @__PURE__ */ jsx3("tr", { className: "m-0 border-t border-zinc-200 dark:border-zinc-800 p-0 even:bg-zinc-50 dark:even:bg-zinc-900/50", children }),
1140
1154
  th: ({ children }) => /* @__PURE__ */ jsx3("th", { className: "border border-zinc-200 dark:border-zinc-700 bg-zinc-50 dark:bg-zinc-900 px-4 py-2 font-semibold text-zinc-900 dark:text-zinc-100 text-left [&[align=center]]:text-center [&[align=right]]:text-right", children }),
1141
- td: ({ children }) => /* @__PURE__ */ jsx3("td", { className: "border border-zinc-200 dark:border-zinc-700 px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right text-zinc-700 dark:text-zinc-300", children }),
1142
- pre: ({ children }) => /* @__PURE__ */ jsx3("pre", { className: "mt-4 mb-4 overflow-x-auto rounded-xl border border-zinc-200 dark:border-zinc-800 bg-zinc-50 dark:bg-zinc-950 p-4 text-[13px] leading-relaxed font-mono shadow-sm", children }),
1143
- code: ({ children, className }) => {
1144
- const isInline = !className;
1145
- return /* @__PURE__ */ jsx3("code", { className: cn("font-mono text-[13px]", isInline ? "bg-zinc-100 dark:bg-zinc-800/60 rounded-md px-1.5 py-0.5 border border-zinc-200 dark:border-zinc-700 text-zinc-800 dark:text-zinc-300" : ""), children });
1146
- }
1155
+ td: ({ children }) => /* @__PURE__ */ jsx3("td", { className: "border border-zinc-200 dark:border-zinc-700 px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right text-zinc-700 dark:text-zinc-300", children })
1147
1156
  };
1148
1157
  function ModelSelector({
1149
1158
  currentModel,
@@ -1272,7 +1281,7 @@ function Chat({
1272
1281
  }
1273
1282
  currentMessages.forEach((m) => {
1274
1283
  let content = m.content;
1275
- if (m.role === "user" && m.images && m.images.length > 0) {
1284
+ if (m.role === "user" && m.images && m.images.length > 0 && isVisionModel2(modelId || "")) {
1276
1285
  if (llm.backend === "webllm") {
1277
1286
  content = [
1278
1287
  { type: "text", text: m.content },
@@ -1288,7 +1297,7 @@ function Chat({
1288
1297
  apiMessages.push({ role: m.role, content });
1289
1298
  });
1290
1299
  let finalUserContent = userContent;
1291
- if (attachedImages.length > 0) {
1300
+ if (attachedImages.length > 0 && isVisionModel2(modelId || "")) {
1292
1301
  if (llm.backend === "webllm") {
1293
1302
  finalUserContent = [
1294
1303
  { type: "text", text: userContent },
@@ -1407,9 +1416,9 @@ function Chat({
1407
1416
  ] }),
1408
1417
  messages.map((msg, i) => /* @__PURE__ */ jsx3("div", { className: cn("flex flex-col max-w-[85%]", msg.role === "user" ? "self-end" : "self-start w-full"), children: msg.role === "user" ? /* @__PURE__ */ jsxs3("div", { className: "bg-zinc-100 dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100 px-5 py-3.5 rounded-[24px] rounded-br-[8px] sm:px-6 shadow-sm border border-zinc-200 dark:border-zinc-700/50", children: [
1409
1418
  msg.images && msg.images.length > 0 && /* @__PURE__ */ jsx3("div", { className: "flex flex-wrap gap-2 mb-3 mt-1", children: msg.images.map((img) => /* @__PURE__ */ jsx3("img", { src: img.dataUrl, className: "w-24 h-24 object-cover rounded-xl border border-zinc-200 dark:border-zinc-700 shadow-sm", alt: "attachment" }, img.id)) }),
1410
- /* @__PURE__ */ jsx3("div", { className: "prose prose-sm dark:prose-invert max-w-none", children: /* @__PURE__ */ jsx3(Streamdown, { plugins: { code, mermaid, math }, components: markdownComponents, animated: true, isAnimating: false, children: msg.content }) })
1411
- ] }) : /* @__PURE__ */ jsx3("div", { className: "prose prose-sm dark:prose-invert max-w-none px-2 w-full min-w-0", children: /* @__PURE__ */ jsx3(Streamdown, { plugins: { code, mermaid, math }, components: markdownComponents, animated: true, isAnimating: false, children: msg.content }) }) }, i)),
1412
- streamingText && /* @__PURE__ */ jsx3("div", { className: "flex flex-col self-start w-full max-w-[85%]", children: /* @__PURE__ */ jsx3("div", { className: "prose prose-sm dark:prose-invert max-w-none px-2 w-full min-w-0", children: /* @__PURE__ */ jsx3(Streamdown, { plugins: { code, mermaid, math }, components: markdownComponents, animated: true, isAnimating: isGenerating, children: streamingText }) }) }),
1419
+ /* @__PURE__ */ jsx3("div", { className: "prose prose-sm dark:prose-invert max-w-none", children: /* @__PURE__ */ jsx3(Streamdown, { plugins: { code: codePlugin, mermaid: mermaidPlugin, math: mathPlugin }, components: markdownComponents, animated: true, isAnimating: false, children: msg.content }) })
1420
+ ] }) : /* @__PURE__ */ jsx3("div", { className: "prose prose-sm dark:prose-invert max-w-none px-2 w-full min-w-0", children: /* @__PURE__ */ jsx3(Streamdown, { plugins: { code: codePlugin, mermaid: mermaidPlugin, math: mathPlugin }, components: markdownComponents, animated: true, isAnimating: false, children: msg.content }) }) }, i)),
1421
+ streamingText && /* @__PURE__ */ jsx3("div", { className: "flex flex-col self-start w-full max-w-[85%]", children: /* @__PURE__ */ jsx3("div", { className: "prose prose-sm dark:prose-invert max-w-none px-2 w-full min-w-0", children: /* @__PURE__ */ jsx3(Streamdown, { plugins: { code: codePlugin, mermaid: mermaidPlugin, math: mathPlugin }, components: markdownComponents, animated: true, isAnimating: isGenerating, children: streamingText }) }) }),
1413
1422
  /* @__PURE__ */ jsx3("div", { ref: messagesEndRef, className: "h-4" })
1414
1423
  ] }),
1415
1424
  /* @__PURE__ */ jsx3("div", { className: "p-4 bg-white/80 dark:bg-zinc-950/80 backdrop-blur-xl border-t border-zinc-100 dark:border-zinc-800/80", children: /* @__PURE__ */ jsx3(