@blank-utils/llm 0.4.14 → 0.4.15
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.
|
@@ -920,6 +920,7 @@ function ChatInput({
|
|
|
920
920
|
let mounted = true;
|
|
921
921
|
const initCaptioner = async () => {
|
|
922
922
|
try {
|
|
923
|
+
console.log("[ImagePipeline] Initializing Transformers.js background captioner...");
|
|
923
924
|
const { pipeline: pipeline2, env } = await import("@huggingface/transformers");
|
|
924
925
|
env.allowLocalModels = false;
|
|
925
926
|
env.useBrowserCache = true;
|
|
@@ -927,7 +928,10 @@ function ChatInput({
|
|
|
927
928
|
device: "wasm",
|
|
928
929
|
dtype: "q8"
|
|
929
930
|
});
|
|
930
|
-
if (mounted)
|
|
931
|
+
if (mounted) {
|
|
932
|
+
console.log("[ImagePipeline] Captioner loaded successfully!");
|
|
933
|
+
captionerRef.current = captioner;
|
|
934
|
+
}
|
|
931
935
|
} catch (err) {
|
|
932
936
|
console.warn("Failed to initialize background captioner:", err);
|
|
933
937
|
}
|
|
@@ -1056,16 +1060,21 @@ ${newText}` : newText);
|
|
|
1056
1060
|
const dataUrl = e.target.result;
|
|
1057
1061
|
let extractedText;
|
|
1058
1062
|
if (captionerRef.current) {
|
|
1063
|
+
console.log(`[ImagePipeline] Generating caption for ${file.name}...`);
|
|
1059
1064
|
try {
|
|
1060
1065
|
const out = await captionerRef.current(dataUrl);
|
|
1066
|
+
console.log("[ImagePipeline] Raw captioner output:", out);
|
|
1061
1067
|
if (Array.isArray(out) && out[0] && out[0].generated_text) {
|
|
1062
1068
|
extractedText = out[0].generated_text;
|
|
1063
1069
|
} else if (!Array.isArray(out) && out.generated_text) {
|
|
1064
1070
|
extractedText = out.generated_text;
|
|
1065
1071
|
}
|
|
1072
|
+
console.log("[ImagePipeline] Extracted caption text:", extractedText);
|
|
1066
1073
|
} catch (err) {
|
|
1067
|
-
console.warn("Background captioning failed for image:", err);
|
|
1074
|
+
console.warn("[ImagePipeline] Background captioning failed for image:", err);
|
|
1068
1075
|
}
|
|
1076
|
+
} else {
|
|
1077
|
+
console.log("[ImagePipeline] Captioner ref is null, skipping caption generation.");
|
|
1069
1078
|
}
|
|
1070
1079
|
onImageAdd?.({ id, dataUrl, file, name: file.name, extractedText });
|
|
1071
1080
|
}
|
package/dist/index.js
CHANGED
package/dist/react/index.js
CHANGED
package/package.json
CHANGED