prompt-api-polyfill 1.15.0 → 1.17.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.
@@ -1,4 +1,4 @@
1
- import { n as e, t } from "../chunks/defaults-BHsuqSiF.js";
1
+ import { n as e, t } from "../chunks/defaults-B5W7MP9T.js";
2
2
  import { GoogleGenAI as n } from "@google/genai";
3
3
  //#region backends/gemini.js
4
4
  var r = class extends e {
@@ -1,4 +1,4 @@
1
- import { n as e, t } from "../chunks/defaults-BHsuqSiF.js";
1
+ import { n as e, t } from "../chunks/defaults-B5W7MP9T.js";
2
2
  import n from "openai";
3
3
  //#region backends/openai.js
4
4
  var r = class extends e {
@@ -1,4 +1,4 @@
1
- import { n as e, t } from "../chunks/defaults-BHsuqSiF.js";
1
+ import { n as e, t } from "../chunks/defaults-B5W7MP9T.js";
2
2
  import { TextStreamer as n, env as r, pipeline as i } from "@huggingface/transformers";
3
3
  //#region backends/transformers.js
4
4
  var a = class extends e {
@@ -25,13 +25,13 @@ var a = class extends e {
25
25
  total: 1,
26
26
  lengthComputable: !0
27
27
  })), e.__lastProgressLoaded = r);
28
+ }, n = (e) => {
29
+ e.status === "progress_total" ? t(e.progress / 100) : e.status === "ready" && t(1);
28
30
  };
29
31
  t(0), this.#e = await i("text-generation", this.modelName, {
30
32
  device: this.#n,
31
33
  dtype: this.#r,
32
- progress_callback: (e) => {
33
- e.status === "progress_total" ? t(e.progress / 100) : e.status === "ready" && t(1);
34
- }
34
+ progress_callback: n
35
35
  }), this.#t = this.#e.tokenizer;
36
36
  }
37
37
  return this.#e;
@@ -26,7 +26,7 @@ var e = class {
26
26
  gemini: { modelName: "gemini-2.5-flash-lite" },
27
27
  openai: { modelName: "gpt-4o" },
28
28
  transformers: {
29
- modelName: "onnx-community/gemma-4-E2B-it-ONNX",
29
+ modelName: "onnx-community/gemma-3-1b-it-ONNX-GQA",
30
30
  device: "webgpu",
31
31
  dtype: "q4f16"
32
32
  }
@@ -550,7 +550,9 @@ var i = class i extends EventTarget {
550
550
  this.#r.systemInstruction && e.unshift({
551
551
  role: "system",
552
552
  parts: [{ text: this.#r.systemInstruction }]
553
- }), this.#a = await this.#e.countTokens(e) || 0;
553
+ });
554
+ let t = await this.#e.countTokens(e);
555
+ this.#a = t || 0;
554
556
  } catch {}
555
557
  this.#a > this.contextWindow && this.dispatchEvent(new Event("contextoverflow"));
556
558
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prompt-api-polyfill",
3
- "version": "1.15.0",
3
+ "version": "1.17.0",
4
4
  "description": "Polyfill for the Prompt API (`LanguageModel`) backed by Firebase AI Logic, Gemini API, OpenAI API, or Transformers.js.",
5
5
  "type": "module",
6
6
  "main": "./dist/prompt-api-polyfill.js",
@@ -47,19 +47,19 @@
47
47
  },
48
48
  "devDependencies": {
49
49
  "@eslint/js": "^10.0.1",
50
- "eslint": "^10.2.0",
50
+ "eslint": "^10.3.0",
51
51
  "eslint-config-prettier": "^10.1.8",
52
- "globals": "^17.4.0",
52
+ "globals": "^17.6.0",
53
53
  "node-addon-api": "^8.7.0",
54
- "node-gyp": "^12.2.0",
55
- "prettier": "^3.8.1",
54
+ "node-gyp": "^12.3.0",
55
+ "prettier": "^3.8.3",
56
56
  "prettier-plugin-curly": "^0.4.1",
57
- "vite": "^8.0.7"
57
+ "vite": "^8.0.11"
58
58
  },
59
59
  "dependencies": {
60
- "@google/genai": "^1.48.0",
61
- "@huggingface/transformers": "^4.0.1",
62
- "firebase": "^12.11.0",
63
- "openai": "^6.33.0"
60
+ "@google/genai": "^1.52.0",
61
+ "@huggingface/transformers": "^4.2.0",
62
+ "firebase": "^12.12.1",
63
+ "openai": "^6.36.0"
64
64
  }
65
65
  }