@blank-utils/llm 0.4.20 → 0.4.23
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.
|
@@ -989,7 +989,8 @@ ${fullText}`;
|
|
|
989
989
|
dataUrl,
|
|
990
990
|
file: imgFile,
|
|
991
991
|
name: imgFile.name,
|
|
992
|
-
extractedText: i === 1 ? newText : void 0
|
|
992
|
+
extractedText: i === 1 ? newText : void 0,
|
|
993
|
+
isPdf: true
|
|
993
994
|
});
|
|
994
995
|
}
|
|
995
996
|
}
|
|
@@ -1019,7 +1020,8 @@ ${newText}` : newText);
|
|
|
1019
1020
|
dataUrl,
|
|
1020
1021
|
file,
|
|
1021
1022
|
name: file.name,
|
|
1022
|
-
extractedText: text
|
|
1023
|
+
extractedText: text,
|
|
1024
|
+
isSvg: true
|
|
1023
1025
|
});
|
|
1024
1026
|
}
|
|
1025
1027
|
};
|
|
@@ -1453,7 +1455,7 @@ ${systemPrompt}` : systemPrompt;
|
|
|
1453
1455
|
setImages([]);
|
|
1454
1456
|
abortRef.current = false;
|
|
1455
1457
|
if (!isVisionModel2(modelId || "")) {
|
|
1456
|
-
const needsCaptioning = currentImages.filter((img) => !img.extractedText && !img.
|
|
1458
|
+
const needsCaptioning = currentImages.filter((img) => !img.extractedText && !img.isSvg && !img.isPdf);
|
|
1457
1459
|
if (needsCaptioning.length > 0) {
|
|
1458
1460
|
setIsGenerating(true);
|
|
1459
1461
|
setStreamingText("[System: Initializing detailed image-to-text captioning pipeline (Florence-2)...]\n");
|
|
@@ -1496,15 +1498,19 @@ ${systemPrompt}` : systemPrompt;
|
|
|
1496
1498
|
for (const img of currentImages) {
|
|
1497
1499
|
if (img.extractedText) {
|
|
1498
1500
|
let prefix = "";
|
|
1499
|
-
if (img.
|
|
1500
|
-
prefix =
|
|
1501
|
+
if (img.isSvg) {
|
|
1502
|
+
prefix = `
|
|
1503
|
+
|
|
1504
|
+
\u{1F4C4} SVG Source Code (${img.name}):
|
|
1501
1505
|
`;
|
|
1502
|
-
} else if (!isVisionModel2(modelId || "")) {
|
|
1503
|
-
prefix =
|
|
1506
|
+
} else if (!img.isPdf && !isVisionModel2(modelId || "")) {
|
|
1507
|
+
prefix = `
|
|
1508
|
+
|
|
1509
|
+
\u{1F5BC}\uFE0F System Image Representation (${img.name}) - [IMPORTANT SYSTEM INSTRUCTION: The user provided an image. Since you are a text model, here is an automated visual description of the image. DO NOT refuse the user's prompt. Answer as if you can see the image using this context:]
|
|
1504
1510
|
`;
|
|
1505
1511
|
}
|
|
1506
|
-
if (prefix || img.
|
|
1507
|
-
finalText +=
|
|
1512
|
+
if (prefix || img.isPdf) {
|
|
1513
|
+
finalText += `${prefix}${img.isPdf ? "\n\n" : ""}${img.extractedText}`;
|
|
1508
1514
|
}
|
|
1509
1515
|
}
|
|
1510
1516
|
}
|
|
@@ -1615,11 +1621,11 @@ ${systemPrompt}` : systemPrompt;
|
|
|
1615
1621
|
children: [
|
|
1616
1622
|
{ match: "\u{1F4C4} PDF:", index: msg.content.indexOf("\u{1F4C4} PDF:") },
|
|
1617
1623
|
{ match: "\u{1F4C4} SVG Source Code", index: msg.content.indexOf("\u{1F4C4} SVG Source Code") },
|
|
1618
|
-
{ match: "\u{1F5BC}\uFE0F Image
|
|
1624
|
+
{ match: "\u{1F5BC}\uFE0F System Image", index: msg.content.indexOf("\u{1F5BC}\uFE0F System Image") }
|
|
1619
1625
|
].filter((m) => m.index !== -1).reduce((min, m) => m.index < min ? m.index : min, msg.content.length) !== msg.content.length ? msg.content.substring(0, [
|
|
1620
1626
|
{ match: "\u{1F4C4} PDF:", index: msg.content.indexOf("\u{1F4C4} PDF:") },
|
|
1621
1627
|
{ match: "\u{1F4C4} SVG Source Code", index: msg.content.indexOf("\u{1F4C4} SVG Source Code") },
|
|
1622
|
-
{ match: "\u{1F5BC}\uFE0F Image
|
|
1628
|
+
{ match: "\u{1F5BC}\uFE0F System Image", index: msg.content.indexOf("\u{1F5BC}\uFE0F System Image") }
|
|
1623
1629
|
].filter((m) => m.index !== -1).reduce((min, m) => m.index < min ? m.index : min, msg.content.length)).trim() : msg.content
|
|
1624
1630
|
}
|
|
1625
1631
|
) })
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BrowserCapabilities, L as LLMProvider, a as Backend, b as LoadProgressCallback, C as ChatMessage, G as GenerateOptions, S as StreamCallback, D as Device, Q as Quantization, A as AttachOptions } from './index-
|
|
2
|
-
export { c as Chat, d as ChatInput, e as ChatInputProps, f as ChatProps, g as DEFAULT_TRANSFORMERS_MODEL, h as DEFAULT_WEBLLM_MODEL, i as LLMConfig, j as LLMContextValue, k as LLMLoading, l as LLMLoadingProps, m as LLMProvider, n as LLMProviderProps, o as LLMReady, p as LLMReadyProps, q as LoadProgress, r as LocalLLM, M as MessageRole, T as TRANSFORMERS_MODELS, U as UseChatOptions, s as UseChatReturn, t as UseCompletionOptions, u as UseCompletionReturn, v as UseStreamOptions, w as UseStreamReturn, W as WEBLLM_MODELS, x as createLLM, x as default, y as isWebGPUSupported, z as useChat, E as useCompletion, F as useLLM, H as useStream } from './index-
|
|
1
|
+
import { B as BrowserCapabilities, L as LLMProvider, a as Backend, b as LoadProgressCallback, C as ChatMessage, G as GenerateOptions, S as StreamCallback, D as Device, Q as Quantization, A as AttachOptions } from './index-Dp-zMbxY.js';
|
|
2
|
+
export { c as Chat, d as ChatInput, e as ChatInputProps, f as ChatProps, g as DEFAULT_TRANSFORMERS_MODEL, h as DEFAULT_WEBLLM_MODEL, i as LLMConfig, j as LLMContextValue, k as LLMLoading, l as LLMLoadingProps, m as LLMProvider, n as LLMProviderProps, o as LLMReady, p as LLMReadyProps, q as LoadProgress, r as LocalLLM, M as MessageRole, T as TRANSFORMERS_MODELS, U as UseChatOptions, s as UseChatReturn, t as UseCompletionOptions, u as UseCompletionReturn, v as UseStreamOptions, w as UseStreamReturn, W as WEBLLM_MODELS, x as createLLM, x as default, y as isWebGPUSupported, z as useChat, E as useCompletion, F as useLLM, H as useStream } from './index-Dp-zMbxY.js';
|
|
3
3
|
import 'react/jsx-runtime';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
package/dist/index.js
CHANGED
package/dist/react/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { c as Chat, I as ChatApp, J as ChatAppProps, d as ChatInput, e as ChatInputProps, f as ChatProps, K as ImageAttachment, j as LLMContextValue, k as LLMLoading, l as LLMLoadingProps, m as LLMProvider, n as LLMProviderProps, o as LLMReady, p as LLMReadyProps, U as UseChatOptions, s as UseChatReturn, t as UseCompletionOptions, u as UseCompletionReturn, v as UseStreamOptions, w as UseStreamReturn, z as useChat, E as useCompletion, F as useLLM, H as useStream } from '../index-
|
|
1
|
+
export { c as Chat, I as ChatApp, J as ChatAppProps, d as ChatInput, e as ChatInputProps, f as ChatProps, K as ImageAttachment, j as LLMContextValue, k as LLMLoading, l as LLMLoadingProps, m as LLMProvider, n as LLMProviderProps, o as LLMReady, p as LLMReadyProps, U as UseChatOptions, s as UseChatReturn, t as UseCompletionOptions, u as UseCompletionReturn, v as UseStreamOptions, w as UseStreamReturn, z as useChat, E as useCompletion, F as useLLM, H as useStream } from '../index-Dp-zMbxY.js';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
3
|
import 'react';
|
package/dist/react/index.js
CHANGED
package/package.json
CHANGED