@blank-utils/llm 0.4.21 → 0.5.0

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.
@@ -34,15 +34,8 @@ function checkWasm() {
34
34
  async function detectCapabilities() {
35
35
  const webgpu = await checkWebGPU();
36
36
  const wasm = checkWasm();
37
- let recommendedBackend = "transformers";
38
- let recommendedDevice = "wasm";
39
- if (webgpu) {
40
- recommendedBackend = "webllm";
41
- recommendedDevice = "webgpu";
42
- } else if (wasm) {
43
- recommendedBackend = "transformers";
44
- recommendedDevice = "wasm";
45
- }
37
+ let recommendedBackend = "webllm";
38
+ let recommendedDevice = "webgpu";
46
39
  return {
47
40
  webgpu,
48
41
  wasm,
@@ -101,21 +94,6 @@ var WEBLLM_MODELS = {
101
94
  "hermes-3-llama-3.2-3b": "Hermes-3-Llama-3.2-3B-q4f16_1-MLC",
102
95
  "hermes-3-llama-3.1-8b": "Hermes-3-Llama-3.1-8B-q4f16_1-MLC"
103
96
  };
104
- var DEFAULT_TRANSFORMERS_MODEL = "onnx-community/Qwen2.5-0.5B-Instruct";
105
- var TRANSFORMERS_MODELS = {
106
- // === Qwen 2.5 Models (Alibaba) - Excellent quality ===
107
- "qwen-2.5-0.5b": "onnx-community/Qwen2.5-0.5B-Instruct",
108
- "qwen-2.5-1.5b": "onnx-community/Qwen2.5-1.5B-Instruct",
109
- "qwen-2.5-coder-0.5b": "onnx-community/Qwen2.5-Coder-0.5B-Instruct",
110
- "qwen-2.5-coder-1.5b": "onnx-community/Qwen2.5-Coder-1.5B-Instruct",
111
- // === Vision Models ===
112
- "phi-3.5-vision": "onnx-community/Phi-3.5-vision-instruct",
113
- // === SmolLM2 Models (HuggingFace) - Ultra lightweight ===
114
- "smollm2-135m": "HuggingFaceTB/SmolLM2-135M-Instruct",
115
- "smollm2-1.7b": "HuggingFaceTB/SmolLM2-1.7B-Instruct",
116
- // === Phi Models (Microsoft) ===
117
- "phi-3-mini": "Xenova/Phi-3-mini-4k-instruct"
118
- };
119
97
 
120
98
  // src/backends/webllm.ts
121
99
  function resolveModelId(model) {
@@ -206,119 +184,6 @@ function createWebLLMProvider() {
206
184
  return new WebLLMProvider();
207
185
  }
208
186
 
209
- // src/backends/transformers.ts
210
- import "@huggingface/transformers";
211
- function isVisionModel(modelId) {
212
- const lower = modelId.toLowerCase();
213
- return lower.includes("vl") || lower.includes("vision") || lower.includes("moondream");
214
- }
215
- function mapQuantization(quantization) {
216
- const map = {
217
- q4: "q4",
218
- q8: "q8",
219
- fp16: "fp16",
220
- fp32: "fp32"
221
- };
222
- return map[quantization] ?? "q4";
223
- }
224
- var TransformersProvider = class {
225
- backend = "transformers";
226
- pipeline = null;
227
- currentModel = null;
228
- device;
229
- quantization;
230
- constructor(config = {}) {
231
- this.device = config.device ?? "auto";
232
- this.quantization = config.quantization ?? "q4";
233
- }
234
- get isReady() {
235
- return this.pipeline !== null && this.currentModel !== null;
236
- }
237
- get modelId() {
238
- return this.currentModel;
239
- }
240
- async load(modelId, onProgress) {
241
- const resolvedModel = modelId in TRANSFORMERS_MODELS ? TRANSFORMERS_MODELS[modelId] : modelId;
242
- const { pipeline: pipeline2, env } = await import("@huggingface/transformers");
243
- env.allowLocalModels = false;
244
- env.useBrowserCache = true;
245
- let deviceOption = "wasm";
246
- if (this.device === "auto" || this.device === "webgpu") {
247
- if (typeof navigator !== "undefined" && "gpu" in navigator) {
248
- try {
249
- const gpu = navigator.gpu;
250
- const adapter = await gpu.requestAdapter();
251
- if (adapter) {
252
- deviceOption = "webgpu";
253
- }
254
- } catch {
255
- }
256
- }
257
- }
258
- const task = isVisionModel(resolvedModel) ? "image-text-to-text" : "text-generation";
259
- const dtype = mapQuantization(this.quantization);
260
- this.pipeline = await pipeline2(task, resolvedModel, {
261
- dtype,
262
- device: deviceOption,
263
- progress_callback: (progress) => {
264
- if (onProgress) {
265
- const loadProgress = {
266
- progress: Math.round((progress.progress ?? 0) * 100),
267
- status: progress.status
268
- };
269
- onProgress(loadProgress);
270
- }
271
- }
272
- });
273
- this.currentModel = resolvedModel;
274
- }
275
- async chat(messages, options) {
276
- if (!this.pipeline || !this.currentModel) {
277
- throw new Error("Model not loaded. Call load() first.");
278
- }
279
- const result = await this.pipeline(messages, {
280
- max_new_tokens: options?.maxTokens ?? 512,
281
- temperature: options?.temperature ?? 0.7,
282
- top_p: options?.topP ?? 0.95,
283
- do_sample: true,
284
- return_full_text: false
285
- });
286
- const output = Array.isArray(result) ? result[0] : result;
287
- return output.generated_text ?? "";
288
- }
289
- async stream(messages, onToken, options) {
290
- if (!this.pipeline || !this.currentModel) {
291
- throw new Error("Model not loaded. Call load() first.");
292
- }
293
- const { TextStreamer } = await import("@huggingface/transformers");
294
- let fullText = "";
295
- const streamer = new TextStreamer(this.pipeline.tokenizer, {
296
- skip_prompt: true,
297
- skip_special_tokens: true,
298
- callback_function: (token) => {
299
- fullText += token;
300
- onToken(token, fullText);
301
- }
302
- });
303
- await this.pipeline(messages, {
304
- max_new_tokens: options?.maxTokens ?? 512,
305
- temperature: options?.temperature ?? 0.7,
306
- top_p: options?.topP ?? 0.95,
307
- do_sample: true,
308
- return_full_text: false,
309
- streamer
310
- });
311
- return fullText;
312
- }
313
- async unload() {
314
- this.pipeline = null;
315
- this.currentModel = null;
316
- }
317
- };
318
- function createTransformersProvider(config) {
319
- return new TransformersProvider(config);
320
- }
321
-
322
187
  // src/helpers.ts
323
188
  function getElement(selector) {
324
189
  if (typeof selector === "string") {
@@ -475,37 +340,15 @@ async function createLLM(config = {}) {
475
340
  onLoadProgress
476
341
  } = config;
477
342
  const capabilities = await detectCapabilities();
478
- let useBackend;
479
343
  const explicitModel = config.model;
480
- const isWebLLMValue = explicitModel && (Object.values(WEBLLM_MODELS).includes(explicitModel) || Object.keys(WEBLLM_MODELS).includes(explicitModel));
481
- const isTransformersValue = explicitModel && (Object.values(TRANSFORMERS_MODELS).includes(explicitModel) || Object.keys(TRANSFORMERS_MODELS).includes(explicitModel));
482
- if (requestedBackend === "auto") {
483
- if (explicitModel && isTransformersValue && !isWebLLMValue) {
484
- useBackend = "transformers";
485
- } else {
486
- useBackend = capabilities.webgpu ? "webllm" : "transformers";
487
- }
488
- } else if (requestedBackend === "webllm") {
489
- if (!capabilities.webgpu) {
490
- console.warn("[LocalLLM] WebLLM requested but WebGPU not available. Falling back to Transformers.js");
491
- useBackend = "transformers";
492
- } else if (explicitModel && isTransformersValue && !isWebLLMValue) {
493
- console.warn("[LocalLLM] Model specified is only compatible with Transformers.js. Falling back from explicit WebLLM.");
494
- useBackend = "transformers";
495
- } else {
496
- useBackend = "webllm";
497
- }
498
- } else {
499
- useBackend = "transformers";
344
+ if (requestedBackend === "webllm" && !capabilities.webgpu) {
345
+ console.warn("[LocalLLM] WebLLM requested but WebGPU not available. May fail.");
500
346
  }
501
- const model = config.model ?? (useBackend === "webllm" ? DEFAULT_WEBLLM_MODEL : DEFAULT_TRANSFORMERS_MODEL);
347
+ const useBackend = "webllm";
348
+ const model = config.model ?? DEFAULT_WEBLLM_MODEL;
502
349
  console.log(`[LocalLLM] Using ${useBackend} backend with model: ${model}`);
503
350
  let provider;
504
- if (useBackend === "webllm") {
505
- provider = new WebLLMProvider();
506
- } else {
507
- provider = new TransformersProvider({ device, quantization });
508
- }
351
+ provider = new WebLLMProvider();
509
352
  await provider.load(model, onLoadProgress);
510
353
  const llm = {
511
354
  get isReady() {
@@ -989,7 +832,8 @@ ${fullText}`;
989
832
  dataUrl,
990
833
  file: imgFile,
991
834
  name: imgFile.name,
992
- extractedText: i === 1 ? newText : void 0
835
+ extractedText: i === 1 ? newText : void 0,
836
+ isPdf: true
993
837
  });
994
838
  }
995
839
  }
@@ -1019,7 +863,8 @@ ${newText}` : newText);
1019
863
  dataUrl,
1020
864
  file,
1021
865
  name: file.name,
1022
- extractedText: text
866
+ extractedText: text,
867
+ isSvg: true
1023
868
  });
1024
869
  }
1025
870
  };
@@ -1223,8 +1068,8 @@ var DEFAULT_SYSTEM_PROMPT = `You are a helpful AI assistant.
1223
1068
  B -- No --> D[Error]
1224
1069
  \`\`\`
1225
1070
  - You can use LaTeX math ($$ ... $$).`;
1226
- var ALL_MODELS = { ...WEBLLM_MODELS, ...TRANSFORMERS_MODELS };
1227
- function isVisionModel2(modelId) {
1071
+ var ALL_MODELS = { ...WEBLLM_MODELS };
1072
+ function isVisionModel(modelId) {
1228
1073
  if (!modelId) return false;
1229
1074
  const lower = modelId.toLowerCase();
1230
1075
  return lower.includes("vl") || lower.includes("vision") || lower.includes("moondream");
@@ -1265,7 +1110,7 @@ function ModelSelector({
1265
1110
  if (!currentModel) return "Select Model";
1266
1111
  const id = currentModel.split("/").pop() || currentModel;
1267
1112
  let label = id.length > 25 ? id.substring(0, 25) + "..." : id;
1268
- if (isVisionModel2(currentModel)) {
1113
+ if (isVisionModel(currentModel)) {
1269
1114
  label += " [VISION]";
1270
1115
  }
1271
1116
  return label;
@@ -1303,27 +1148,7 @@ function ModelSelector({
1303
1148
  children: [
1304
1149
  key,
1305
1150
  " ",
1306
- isVisionModel2(value) && /* @__PURE__ */ jsx3("span", { className: "ml-2 text-[9px] opacity-50", children: "[VISION]" })
1307
- ]
1308
- },
1309
- key
1310
- )),
1311
- /* @__PURE__ */ jsx3("div", { className: "px-3 py-2 text-[10px] font-light text-current opacity-50 uppercase tracking-widest mt-4 border-b border-current/10 mb-1", children: "Transformers.js" }),
1312
- Object.entries(TRANSFORMERS_MODELS).map(([key, value]) => /* @__PURE__ */ jsxs3(
1313
- "button",
1314
- {
1315
- className: cn(
1316
- "block w-full text-left px-3 py-2.5 text-[11px] font-light uppercase tracking-widest truncate transition-colors text-current",
1317
- currentModel === value ? theme === "dark" ? "bg-white text-black" : "bg-black text-white" : "hover:opacity-60"
1318
- ),
1319
- onClick: () => {
1320
- onSelect(value);
1321
- setIsOpen(false);
1322
- },
1323
- children: [
1324
- key,
1325
- " ",
1326
- isVisionModel2(value) && /* @__PURE__ */ jsx3("span", { className: "ml-2 text-[9px] opacity-50", children: "[VISION]" })
1151
+ isVisionModel(value) && /* @__PURE__ */ jsx3("span", { className: "ml-2 text-[9px] opacity-50", children: "[VISION]" })
1327
1152
  ]
1328
1153
  },
1329
1154
  key
@@ -1389,7 +1214,7 @@ ${systemPrompt}` : systemPrompt;
1389
1214
  }
1390
1215
  currentMessages.forEach((m) => {
1391
1216
  let content = m.content;
1392
- if (m.role === "user" && m.images && m.images.length > 0 && isVisionModel2(modelId || "")) {
1217
+ if (m.role === "user" && m.images && m.images.length > 0 && isVisionModel(modelId || "")) {
1393
1218
  if (llm.backend === "webllm") {
1394
1219
  content = [
1395
1220
  { type: "text", text: m.content },
@@ -1405,7 +1230,7 @@ ${systemPrompt}` : systemPrompt;
1405
1230
  apiMessages.push({ role: m.role, content });
1406
1231
  });
1407
1232
  let finalUserContent = userContent;
1408
- if (attachedImages.length > 0 && isVisionModel2(modelId || "")) {
1233
+ if (attachedImages.length > 0 && isVisionModel(modelId || "")) {
1409
1234
  if (llm.backend === "webllm") {
1410
1235
  finalUserContent = [
1411
1236
  { type: "text", text: userContent },
@@ -1452,16 +1277,16 @@ ${systemPrompt}` : systemPrompt;
1452
1277
  setInput("");
1453
1278
  setImages([]);
1454
1279
  abortRef.current = false;
1455
- if (!isVisionModel2(modelId || "")) {
1456
- const needsCaptioning = currentImages.filter((img) => !img.extractedText && !img.name.toLowerCase().endsWith(".svg") && !img.name.toLowerCase().endsWith(".pdf"));
1280
+ if (!isVisionModel(modelId || "")) {
1281
+ const needsCaptioning = currentImages.filter((img) => !img.extractedText && !img.isSvg && !img.isPdf);
1457
1282
  if (needsCaptioning.length > 0) {
1458
1283
  setIsGenerating(true);
1459
1284
  setStreamingText("[System: Initializing detailed image-to-text captioning pipeline (Florence-2)...]\n");
1460
1285
  try {
1461
- const { pipeline: pipeline2, env } = await import("@huggingface/transformers");
1286
+ const { pipeline, env } = await import("@huggingface/transformers");
1462
1287
  env.allowLocalModels = false;
1463
1288
  env.useBrowserCache = true;
1464
- const captioner = await pipeline2("image-to-text", "Xenova/vit-gpt2-image-captioning", { device: "wasm", dtype: "q8" });
1289
+ const captioner = await pipeline("image-to-text", "Xenova/vit-gpt2-image-captioning", { device: "wasm", dtype: "q8" });
1465
1290
  for (let i = 0; i < needsCaptioning.length; i++) {
1466
1291
  if (abortRef.current) break;
1467
1292
  const img = needsCaptioning[i];
@@ -1496,19 +1321,19 @@ ${systemPrompt}` : systemPrompt;
1496
1321
  for (const img of currentImages) {
1497
1322
  if (img.extractedText) {
1498
1323
  let prefix = "";
1499
- if (img.name.toLowerCase().endsWith(".svg")) {
1324
+ if (img.isSvg) {
1500
1325
  prefix = `
1501
1326
 
1502
1327
  \u{1F4C4} SVG Source Code (${img.name}):
1503
1328
  `;
1504
- } else if (!isVisionModel2(modelId || "")) {
1329
+ } else if (!img.isPdf && !isVisionModel(modelId || "")) {
1505
1330
  prefix = `
1506
1331
 
1507
1332
  \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:]
1508
1333
  `;
1509
1334
  }
1510
- if (prefix || img.name.toLowerCase().endsWith(".pdf")) {
1511
- finalText += `${prefix}${img.extractedText}`;
1335
+ if (prefix || img.isPdf) {
1336
+ finalText += `${prefix}${img.isPdf ? "\n\n" : ""}${img.extractedText}`;
1512
1337
  }
1513
1338
  }
1514
1339
  }
@@ -1683,7 +1508,7 @@ ${systemPrompt}` : systemPrompt;
1683
1508
  }
1684
1509
  function ChatApp({
1685
1510
  defaultModel = "qwen-2.5-0.5b",
1686
- defaultBackend = "auto",
1511
+ defaultBackend = "webllm",
1687
1512
  autoLoad = true,
1688
1513
  onModelChange,
1689
1514
  ...chatProps
@@ -1718,12 +1543,8 @@ export {
1718
1543
  logCapabilities,
1719
1544
  DEFAULT_WEBLLM_MODEL,
1720
1545
  WEBLLM_MODELS,
1721
- DEFAULT_TRANSFORMERS_MODEL,
1722
- TRANSFORMERS_MODELS,
1723
1546
  WebLLMProvider,
1724
1547
  createWebLLMProvider,
1725
- TransformersProvider,
1726
- createTransformersProvider,
1727
1548
  createOutputStreamer,
1728
1549
  attachToElements,
1729
1550
  createChatUI,
@@ -41,33 +41,11 @@ declare const WEBLLM_MODELS: {
41
41
  readonly 'hermes-3-llama-3.2-3b': "Hermes-3-Llama-3.2-3B-q4f16_1-MLC";
42
42
  readonly 'hermes-3-llama-3.1-8b': "Hermes-3-Llama-3.1-8B-q4f16_1-MLC";
43
43
  };
44
- /**
45
- * Default model for Transformers.js backend
46
- * Using Qwen2.5 0.5B as it's well-tested with ONNX
47
- */
48
- declare const DEFAULT_TRANSFORMERS_MODEL = "onnx-community/Qwen2.5-0.5B-Instruct";
49
- /**
50
- * Transformers.js compatible models (must have ONNX weights)
51
- * These are specifically converted for browser use via transformers.js
52
- *
53
- * @see https://huggingface.co/onnx-community for more models
54
- */
55
- declare const TRANSFORMERS_MODELS: {
56
- readonly 'qwen-2.5-0.5b': "onnx-community/Qwen2.5-0.5B-Instruct";
57
- readonly 'qwen-2.5-1.5b': "onnx-community/Qwen2.5-1.5B-Instruct";
58
- readonly 'qwen-2.5-coder-0.5b': "onnx-community/Qwen2.5-Coder-0.5B-Instruct";
59
- readonly 'qwen-2.5-coder-1.5b': "onnx-community/Qwen2.5-Coder-1.5B-Instruct";
60
- readonly 'phi-3.5-vision': "onnx-community/Phi-3.5-vision-instruct";
61
- readonly 'smollm2-135m': "HuggingFaceTB/SmolLM2-135M-Instruct";
62
- readonly 'smollm2-1.7b': "HuggingFaceTB/SmolLM2-1.7B-Instruct";
63
- readonly 'phi-3-mini': "Xenova/Phi-3-mini-4k-instruct";
64
- };
65
44
  type WebLLMModelID = keyof typeof WEBLLM_MODELS;
66
- type TransformersModelID = keyof typeof TRANSFORMERS_MODELS;
67
45
  /**
68
46
  * Union of all supported model IDs for type safety
69
47
  */
70
- type SupportedModel = WebLLMModelID | TransformersModelID | (string & {});
48
+ type SupportedModel = WebLLMModelID | (string & {});
71
49
 
72
50
  /**
73
51
  * Local LLM - Browser-based LLM inference library
@@ -76,7 +54,7 @@ type SupportedModel = WebLLMModelID | TransformersModelID | (string & {});
76
54
  /**
77
55
  * Supported backend engines
78
56
  */
79
- type Backend = 'webllm' | 'transformers' | 'auto';
57
+ type Backend = 'webllm';
80
58
  /**
81
59
  * Device to run inference on
82
60
  */
@@ -92,7 +70,7 @@ type Quantization = 'q4' | 'q8' | 'fp16' | 'fp32';
92
70
  interface LLMConfig {
93
71
  /**
94
72
  * Model identifier. For WebLLM, use MLC model IDs.
95
- * For Transformers.js, use HuggingFace model IDs.
73
+ * Use WebLLM compatible model IDs.
96
74
  * @default 'Phi-3-mini-4k-instruct-q4f16_1-MLC' for WebLLM
97
75
  */
98
76
  model?: SupportedModel;
@@ -270,7 +248,7 @@ interface LocalLLM {
270
248
  /**
271
249
  * The backend being used
272
250
  */
273
- readonly backend: 'webllm' | 'transformers';
251
+ readonly backend: 'webllm';
274
252
  /**
275
253
  * Generate a chat response
276
254
  */
@@ -608,7 +586,7 @@ interface ChatProps {
608
586
  }
609
587
  interface ChatAppProps extends ChatProps {
610
588
  defaultModel?: SupportedModel;
611
- defaultBackend?: 'webllm' | 'transformers' | 'auto';
589
+ defaultBackend?: 'webllm';
612
590
  autoLoad?: boolean;
613
591
  }
614
592
  declare function Chat({ systemPrompt, placeholder, theme, className, maxHeight, inputActions, onSend: onSendProp, onResponse, onError: onErrorProp, showHeader, showProgress, welcomeMessage, onModelChange, }: ChatProps): React.JSX.Element;
@@ -620,6 +598,8 @@ interface ImageAttachment {
620
598
  file: File;
621
599
  name: string;
622
600
  extractedText?: string;
601
+ isPdf?: boolean;
602
+ isSvg?: boolean;
623
603
  }
624
604
  interface ChatInputProps {
625
605
  value: string;
@@ -640,4 +620,4 @@ interface ChatInputProps {
640
620
  }
641
621
  declare function ChatInput({ value, onChange, onSend, onStop, disabled, isGenerating, placeholder, maxRows, actions, className, images, onImageAdd, onImageRemove, modelSelector, theme, }: ChatInputProps): react_jsx_runtime.JSX.Element;
642
622
 
643
- export { type AttachOptions as A, type BrowserCapabilities as B, type ChatMessage as C, type Device as D, useCompletion as E, useLLM as F, type GenerateOptions as G, useStream as H, ChatApp as I, type ChatAppProps as J, type ImageAttachment as K, type LLMProvider$1 as L, type MessageRole as M, type Quantization as Q, type StreamCallback as S, TRANSFORMERS_MODELS as T, type UseChatOptions as U, WEBLLM_MODELS as W, type Backend as a, type LoadProgressCallback as b, Chat as c, ChatInput as d, type ChatInputProps as e, type ChatProps as f, DEFAULT_TRANSFORMERS_MODEL as g, DEFAULT_WEBLLM_MODEL as h, type LLMConfig as i, type LLMContextValue as j, LLMLoading as k, type LLMLoadingProps as l, LLMProvider as m, type LLMProviderProps as n, LLMReady as o, type LLMReadyProps as p, type LoadProgress as q, type LocalLLM as r, type UseChatReturn as s, type UseCompletionOptions as t, type UseCompletionReturn as u, type UseStreamOptions as v, type UseStreamReturn as w, createLLM as x, isWebGPUSupported as y, useChat as z };
623
+ export { type AttachOptions as A, type BrowserCapabilities as B, type ChatMessage as C, DEFAULT_WEBLLM_MODEL as D, useLLM as E, useStream as F, type GenerateOptions as G, ChatApp as H, type ChatAppProps as I, type ImageAttachment as J, type LLMProvider$1 as L, type MessageRole as M, type Quantization as Q, type StreamCallback as S, type UseChatOptions as U, WEBLLM_MODELS as W, type Backend as a, type LoadProgressCallback as b, Chat as c, ChatInput as d, type ChatInputProps as e, type ChatProps as f, type Device as g, type LLMConfig as h, type LLMContextValue as i, LLMLoading as j, type LLMLoadingProps as k, LLMProvider as l, type LLMProviderProps as m, LLMReady as n, type LLMReadyProps as o, type LoadProgress as p, type LocalLLM as q, type UseChatReturn as r, type UseCompletionOptions as s, type UseCompletionReturn as t, type UseStreamOptions as u, type UseStreamReturn as v, createLLM as w, isWebGPUSupported as x, useChat as y, useCompletion as z };
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-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';
1
+ import { B as BrowserCapabilities, L as LLMProvider, a as Backend, b as LoadProgressCallback, C as ChatMessage, G as GenerateOptions, S as StreamCallback, A as AttachOptions } from './index-DJmiDzY3.js';
2
+ export { c as Chat, d as ChatInput, e as ChatInputProps, f as ChatProps, D as DEFAULT_WEBLLM_MODEL, g as Device, h as LLMConfig, i as LLMContextValue, j as LLMLoading, k as LLMLoadingProps, l as LLMProvider, m as LLMProviderProps, n as LLMReady, o as LLMReadyProps, p as LoadProgress, q as LocalLLM, M as MessageRole, Q as Quantization, U as UseChatOptions, r as UseChatReturn, s as UseCompletionOptions, t as UseCompletionReturn, u as UseStreamOptions, v as UseStreamReturn, W as WEBLLM_MODELS, w as createLLM, w as default, x as isWebGPUSupported, y as useChat, z as useCompletion, E as useLLM, F as useStream } from './index-DJmiDzY3.js';
3
3
  import 'react/jsx-runtime';
4
4
  import 'react';
5
5
 
@@ -48,40 +48,6 @@ declare class WebLLMProvider implements LLMProvider {
48
48
  */
49
49
  declare function createWebLLMProvider(): WebLLMProvider;
50
50
 
51
- /**
52
- * Transformers.js Backend Implementation
53
- * Fallback backend using HuggingFace Transformers.js with ONNX runtime
54
- */
55
-
56
- /**
57
- * Configuration for TransformersProvider
58
- */
59
- interface TransformersProviderConfig {
60
- device?: Device;
61
- quantization?: Quantization;
62
- }
63
- /**
64
- * Transformers.js provider implementation
65
- */
66
- declare class TransformersProvider implements LLMProvider {
67
- readonly backend: Backend;
68
- private pipeline;
69
- private currentModel;
70
- private device;
71
- private quantization;
72
- constructor(config?: TransformersProviderConfig);
73
- get isReady(): boolean;
74
- get modelId(): string | null;
75
- load(modelId: string, onProgress?: LoadProgressCallback): Promise<void>;
76
- chat(messages: ChatMessage[], options?: GenerateOptions): Promise<string>;
77
- stream(messages: ChatMessage[], onToken: StreamCallback, options?: GenerateOptions): Promise<string>;
78
- unload(): Promise<void>;
79
- }
80
- /**
81
- * Create a Transformers.js provider instance
82
- */
83
- declare function createTransformersProvider(config?: TransformersProviderConfig): TransformersProvider;
84
-
85
51
  /**
86
52
  * DOM Helper Utilities
87
53
  * Easy integration with HTML input/output elements
@@ -117,4 +83,4 @@ declare function createLoadingIndicator(containerSelector: string | HTMLElement)
117
83
  element: HTMLDivElement;
118
84
  };
119
85
 
120
- export { AttachOptions, Backend, BrowserCapabilities, ChatMessage, Device, GenerateOptions, LLMProvider as LLMProviderInterface, LoadProgressCallback, Quantization, StreamCallback, TransformersProvider, WebLLMProvider, attachToElements, checkWasm, checkWebGPU, createChatUI, createLoadingIndicator, createOutputStreamer, createTransformersProvider, createWebLLMProvider, detectCapabilities, logCapabilities };
86
+ export { AttachOptions, Backend, BrowserCapabilities, ChatMessage, GenerateOptions, LLMProvider as LLMProviderInterface, LoadProgressCallback, StreamCallback, WebLLMProvider, attachToElements, checkWasm, checkWebGPU, createChatUI, createLoadingIndicator, createOutputStreamer, createWebLLMProvider, detectCapabilities, logCapabilities };
package/dist/index.js CHANGED
@@ -1,13 +1,10 @@
1
1
  import {
2
2
  Chat,
3
3
  ChatInput,
4
- DEFAULT_TRANSFORMERS_MODEL,
5
4
  DEFAULT_WEBLLM_MODEL,
6
5
  LLMLoading,
7
6
  LLMProvider,
8
7
  LLMReady,
9
- TRANSFORMERS_MODELS,
10
- TransformersProvider,
11
8
  WEBLLM_MODELS,
12
9
  WebLLMProvider,
13
10
  attachToElements,
@@ -17,7 +14,6 @@ import {
17
14
  createLLM,
18
15
  createLoadingIndicator,
19
16
  createOutputStreamer,
20
- createTransformersProvider,
21
17
  createWebLLMProvider,
22
18
  detectCapabilities,
23
19
  isWebGPUSupported,
@@ -26,17 +22,14 @@ import {
26
22
  useCompletion,
27
23
  useLLM,
28
24
  useStream
29
- } from "./chunk-XKJ4QQ34.js";
25
+ } from "./chunk-A7TUIC5G.js";
30
26
  export {
31
27
  Chat,
32
28
  ChatInput,
33
- DEFAULT_TRANSFORMERS_MODEL,
34
29
  DEFAULT_WEBLLM_MODEL,
35
30
  LLMLoading,
36
31
  LLMProvider,
37
32
  LLMReady,
38
- TRANSFORMERS_MODELS,
39
- TransformersProvider,
40
33
  WEBLLM_MODELS,
41
34
  WebLLMProvider,
42
35
  attachToElements,
@@ -46,7 +39,6 @@ export {
46
39
  createLLM,
47
40
  createLoadingIndicator,
48
41
  createOutputStreamer,
49
- createTransformersProvider,
50
42
  createWebLLMProvider,
51
43
  createLLM as default,
52
44
  detectCapabilities,
@@ -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-DxcdKb-M.js';
1
+ export { c as Chat, H as ChatApp, I as ChatAppProps, d as ChatInput, e as ChatInputProps, f as ChatProps, J as ImageAttachment, i as LLMContextValue, j as LLMLoading, k as LLMLoadingProps, l as LLMProvider, m as LLMProviderProps, n as LLMReady, o as LLMReadyProps, U as UseChatOptions, r as UseChatReturn, s as UseCompletionOptions, t as UseCompletionReturn, u as UseStreamOptions, v as UseStreamReturn, y as useChat, z as useCompletion, E as useLLM, F as useStream } from '../index-DJmiDzY3.js';
2
2
  import 'react/jsx-runtime';
3
3
  import 'react';
@@ -9,7 +9,7 @@ import {
9
9
  useCompletion,
10
10
  useLLM,
11
11
  useStream
12
- } from "../chunk-XKJ4QQ34.js";
12
+ } from "../chunk-A7TUIC5G.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.21",
3
+ "version": "0.5.0",
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",