@blank-utils/llm 0.5.0 → 0.5.2

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.
@@ -1067,7 +1067,8 @@ var DEFAULT_SYSTEM_PROMPT = `You are a helpful AI assistant.
1067
1067
  B -- Yes --> C[Continue]
1068
1068
  B -- No --> D[Error]
1069
1069
  \`\`\`
1070
- - You can use LaTeX math ($$ ... $$).`;
1070
+ - You can use LaTeX math ($$ ... $$).
1071
+ - IF you are provided an uploaded image, your primary task is strictly to analyze the contents of that specific image in natural language. Do not hallucinate that the user desires a Mermaid diagram unless they specifically ask for one.`;
1071
1072
  var ALL_MODELS = { ...WEBLLM_MODELS };
1072
1073
  function isVisionModel(modelId) {
1073
1074
  if (!modelId) return false;
@@ -1215,33 +1216,19 @@ ${systemPrompt}` : systemPrompt;
1215
1216
  currentMessages.forEach((m) => {
1216
1217
  let content = m.content;
1217
1218
  if (m.role === "user" && m.images && m.images.length > 0 && isVisionModel(modelId || "")) {
1218
- if (llm.backend === "webllm") {
1219
- content = [
1220
- { type: "text", text: m.content },
1221
- ...m.images.map((img) => ({ type: "image_url", image_url: { url: img.dataUrl } }))
1222
- ];
1223
- } else {
1224
- content = [
1225
- ...m.images.map((img) => ({ type: "image", image: img.dataUrl })),
1226
- { type: "text", text: m.content }
1227
- ];
1228
- }
1219
+ content = [
1220
+ { type: "text", text: m.content },
1221
+ ...m.images.map((img) => ({ type: "image_url", image_url: { url: img.dataUrl } }))
1222
+ ];
1229
1223
  }
1230
1224
  apiMessages.push({ role: m.role, content });
1231
1225
  });
1232
1226
  let finalUserContent = userContent;
1233
1227
  if (attachedImages.length > 0 && isVisionModel(modelId || "")) {
1234
- if (llm.backend === "webllm") {
1235
- finalUserContent = [
1236
- { type: "text", text: userContent },
1237
- ...attachedImages.map((img) => ({ type: "image_url", image_url: { url: img.dataUrl } }))
1238
- ];
1239
- } else {
1240
- finalUserContent = [
1241
- ...attachedImages.map((img) => ({ type: "image", image: img.dataUrl })),
1242
- { type: "text", text: userContent }
1243
- ];
1244
- }
1228
+ finalUserContent = [
1229
+ { type: "text", text: userContent },
1230
+ ...attachedImages.map((img) => ({ type: "image_url", image_url: { url: img.dataUrl } }))
1231
+ ];
1245
1232
  }
1246
1233
  apiMessages.push({ role: "user", content: finalUserContent });
1247
1234
  try {
package/dist/index.css CHANGED
@@ -2290,6 +2290,9 @@ video {
2290
2290
  .table-row {
2291
2291
  display: table-row;
2292
2292
  }
2293
+ .contents {
2294
+ display: contents;
2295
+ }
2293
2296
  .list-item {
2294
2297
  display: list-item;
2295
2298
  }
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ import {
22
22
  useCompletion,
23
23
  useLLM,
24
24
  useStream
25
- } from "./chunk-A7TUIC5G.js";
25
+ } from "./chunk-QUWLNQIN.js";
26
26
  export {
27
27
  Chat,
28
28
  ChatInput,
@@ -2290,6 +2290,9 @@ video {
2290
2290
  .table-row {
2291
2291
  display: table-row;
2292
2292
  }
2293
+ .contents {
2294
+ display: contents;
2295
+ }
2293
2296
  .list-item {
2294
2297
  display: list-item;
2295
2298
  }
@@ -9,7 +9,7 @@ import {
9
9
  useCompletion,
10
10
  useLLM,
11
11
  useStream
12
- } from "../chunk-A7TUIC5G.js";
12
+ } from "../chunk-QUWLNQIN.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.5.0",
3
+ "version": "0.5.2",
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",
@@ -101,7 +101,7 @@
101
101
  },
102
102
  "dependencies": {
103
103
  "@huggingface/transformers": "^3.8.1",
104
- "@mlc-ai/web-llm": "^0.2.80",
104
+ "@mlc-ai/web-llm": "^0.2.81",
105
105
  "@streamdown/code": "^1.0.3",
106
106
  "@streamdown/math": "^1.0.2",
107
107
  "@streamdown/mermaid": "^1.0.2",