@blank-utils/llm 0.4.13 → 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,14 +920,18 @@ 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;
926
927
  const captioner = await pipeline2("image-to-text", "Xenova/vit-gpt2-image-captioning", {
927
928
  device: "wasm",
928
- dtype: "q4"
929
+ dtype: "q8"
929
930
  });
930
- if (mounted) captionerRef.current = captioner;
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
@@ -26,7 +26,7 @@ import {
26
26
  useCompletion,
27
27
  useLLM,
28
28
  useStream
29
- } from "./chunk-45KYY5JJ.js";
29
+ } from "./chunk-AUJSSEB5.js";
30
30
  export {
31
31
  Chat,
32
32
  ChatInput,
@@ -9,7 +9,7 @@ import {
9
9
  useCompletion,
10
10
  useLLM,
11
11
  useStream
12
- } from "../chunk-45KYY5JJ.js";
12
+ } from "../chunk-AUJSSEB5.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.4.13",
3
+ "version": "0.4.15",
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",