@blank-utils/llm 0.4.10 → 0.4.11
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.
|
@@ -954,7 +954,14 @@ function ChatInput({
|
|
|
954
954
|
${pageText}
|
|
955
955
|
|
|
956
956
|
`;
|
|
957
|
-
|
|
957
|
+
}
|
|
958
|
+
const newText = `\u{1F4C4} PDF: ${file.name} (${pdf.numPages} pages total, showing images for first ${maxPages} pages)
|
|
959
|
+
|
|
960
|
+
Extracted Text:
|
|
961
|
+
${fullText}`;
|
|
962
|
+
if (onImageAdd) {
|
|
963
|
+
for (let i = 1; i <= maxPages; i++) {
|
|
964
|
+
const page = await pdf.getPage(i);
|
|
958
965
|
const viewport = page.getViewport({ scale: 2 });
|
|
959
966
|
const canvas = document.createElement("canvas");
|
|
960
967
|
const context = canvas.getContext("2d");
|
|
@@ -977,19 +984,22 @@ ${pageText}
|
|
|
977
984
|
}
|
|
978
985
|
const imgFile = new File([u8arr], `__PDF__${file.name}__page${i}.jpg`, { type: mime });
|
|
979
986
|
const id = Math.random().toString(36).substring(7);
|
|
980
|
-
onImageAdd({
|
|
987
|
+
onImageAdd({
|
|
988
|
+
id,
|
|
989
|
+
dataUrl,
|
|
990
|
+
file: imgFile,
|
|
991
|
+
name: imgFile.name,
|
|
992
|
+
extractedText: i === 1 ? newText : void 0
|
|
993
|
+
});
|
|
981
994
|
}
|
|
982
995
|
}
|
|
983
996
|
}
|
|
984
997
|
}
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
Extracted Text:
|
|
989
|
-
${fullText}`;
|
|
990
|
-
onChange(value ? `${value}
|
|
998
|
+
} else {
|
|
999
|
+
onChange(value ? `${value}
|
|
991
1000
|
|
|
992
1001
|
${newText}` : newText);
|
|
1002
|
+
}
|
|
993
1003
|
} catch (err) {
|
|
994
1004
|
console.error("Error extracting PDF:", err);
|
|
995
1005
|
}
|
|
@@ -1419,13 +1429,19 @@ ${systemPrompt}` : systemPrompt;
|
|
|
1419
1429
|
const text = input.trim();
|
|
1420
1430
|
if (!text && images.length === 0) return;
|
|
1421
1431
|
const currentImages = [...images];
|
|
1432
|
+
let finalText = text;
|
|
1433
|
+
for (const img of currentImages) {
|
|
1434
|
+
if (img.extractedText) {
|
|
1435
|
+
finalText += (finalText ? "\n\n" : "") + img.extractedText;
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1422
1438
|
setInput("");
|
|
1423
1439
|
setImages([]);
|
|
1424
|
-
onSendProp?.(
|
|
1440
|
+
onSendProp?.(finalText);
|
|
1425
1441
|
if (llm && isReady) {
|
|
1426
|
-
generate(
|
|
1442
|
+
generate(finalText, messages, currentImages);
|
|
1427
1443
|
} else if (isLoading) {
|
|
1428
|
-
setPendingMessage(
|
|
1444
|
+
setPendingMessage(finalText);
|
|
1429
1445
|
}
|
|
1430
1446
|
};
|
|
1431
1447
|
const handleStop = () => {
|
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-DxcdKb-M.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-DxcdKb-M.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-DxcdKb-M.js';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
3
|
import 'react';
|
package/dist/react/index.js
CHANGED
package/package.json
CHANGED