prompt-api-polyfill 1.4.0 → 1.6.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.
@@ -27,13 +27,13 @@ class M {
27
27
  if (t instanceof Blob)
28
28
  return this.blobToInlineData(t);
29
29
  if (ArrayBuffer.isView(t) || t instanceof ArrayBuffer) {
30
- const e = t instanceof ArrayBuffer ? new Uint8Array(t) : new Uint8Array(t.buffer, t.byteOffset, t.byteLength), r = e.buffer.slice(
30
+ const e = t instanceof ArrayBuffer ? new Uint8Array(t) : new Uint8Array(t.buffer, t.byteOffset, t.byteLength), n = e.buffer.slice(
31
31
  e.byteOffset,
32
32
  e.byteOffset + e.byteLength
33
- ), o = this.arrayBufferToBase64(r), n = this.#o(e);
34
- if (!n)
33
+ ), r = this.arrayBufferToBase64(n), o = this.#o(e);
34
+ if (!o)
35
35
  throw new DOMException("Invalid image data", "InvalidStateError");
36
- return { inlineData: { data: o, mimeType: n } };
36
+ return { inlineData: { data: r, mimeType: o } };
37
37
  }
38
38
  return this.canvasSourceToInlineData(t);
39
39
  }
@@ -55,20 +55,20 @@ class M {
55
55
  if (t[0] === 73 && t[1] === 73 && t[2] === 42 || t[0] === 77 && t[1] === 77 && t[2] === 42)
56
56
  return "image/tiff";
57
57
  if (t[4] === 102 && t[5] === 116 && t[6] === 121 && t[7] === 112) {
58
- const o = String.fromCharCode(t[8], t[9], t[10], t[11]);
59
- if (o === "avif" || o === "avis")
58
+ const r = String.fromCharCode(t[8], t[9], t[10], t[11]);
59
+ if (r === "avif" || r === "avis")
60
60
  return "image/avif";
61
- if (o === "heic" || o === "heix" || o === "hevc" || o === "hevx")
61
+ if (r === "heic" || r === "heix" || r === "hevc" || r === "hevx")
62
62
  return "image/heic";
63
- if (o === "mif1" || o === "msf1")
63
+ if (r === "mif1" || r === "msf1")
64
64
  return "image/heif";
65
65
  }
66
66
  if (t[0] === 255 && t[1] === 10 || t[0] === 0 && t[4] === 74 && t[5] === 88 && t[6] === 76)
67
67
  return "image/jxl";
68
68
  if (t[0] === 0 && t[4] === 106 && t[5] === 80 && t[6] === 32)
69
69
  return "image/jp2";
70
- const r = String.fromCharCode(...t.slice(0, 100)).toLowerCase();
71
- return r.includes("<svg") || r.includes("<?xml") ? "image/svg+xml" : null;
70
+ const n = String.fromCharCode(...t.slice(0, 100)).toLowerCase();
71
+ return n.includes("<svg") || n.includes("<?xml") ? "image/svg+xml" : null;
72
72
  }
73
73
  static async processAudio(t) {
74
74
  if (t instanceof Blob) {
@@ -77,15 +77,15 @@ class M {
77
77
  return this.blobToInlineData(t);
78
78
  }
79
79
  if (t instanceof AudioBuffer) {
80
- const o = this.audioBufferToWav(t);
81
- return { inlineData: { data: this.arrayBufferToBase64(o), mimeType: "audio/wav" } };
80
+ const r = this.audioBufferToWav(t);
81
+ return { inlineData: { data: this.arrayBufferToBase64(r), mimeType: "audio/wav" } };
82
82
  }
83
- const e = t instanceof ArrayBuffer || t && t.constructor && t.constructor.name === "ArrayBuffer", r = ArrayBuffer.isView(t) || t && t.buffer && (t.buffer instanceof ArrayBuffer || t.buffer.constructor.name === "ArrayBuffer");
84
- if (e || r) {
85
- const o = e ? t : t.buffer;
83
+ const e = t instanceof ArrayBuffer || t && t.constructor && t.constructor.name === "ArrayBuffer", n = ArrayBuffer.isView(t) || t && t.buffer && (t.buffer instanceof ArrayBuffer || t.buffer.constructor.name === "ArrayBuffer");
84
+ if (e || n) {
85
+ const r = e ? t : t.buffer;
86
86
  return {
87
87
  inlineData: {
88
- data: this.arrayBufferToBase64(o),
88
+ data: this.arrayBufferToBase64(r),
89
89
  mimeType: "audio/wav"
90
90
  // Fallback assumption
91
91
  }
@@ -95,89 +95,89 @@ class M {
95
95
  }
96
96
  // Low Level Converters
97
97
  static blobToInlineData(t) {
98
- return new Promise((e, r) => {
99
- const o = new FileReader();
100
- o.onloadend = () => {
101
- o.error ? r(o.error) : e({
98
+ return new Promise((e, n) => {
99
+ const r = new FileReader();
100
+ r.onloadend = () => {
101
+ r.error ? n(r.error) : e({
102
102
  inlineData: {
103
- data: o.result.split(",")[1],
103
+ data: r.result.split(",")[1],
104
104
  mimeType: t.type
105
105
  }
106
106
  });
107
- }, o.readAsDataURL(t);
107
+ }, r.readAsDataURL(t);
108
108
  });
109
109
  }
110
110
  static async canvasSourceToInlineData(t) {
111
111
  typeof HTMLImageElement < "u" && t instanceof HTMLImageElement && !t.complete && await t.decode().catch(() => {
112
112
  });
113
- const e = (a) => {
114
- const l = t[a];
113
+ const e = (c) => {
114
+ const l = t[c];
115
115
  return typeof l == "object" && l !== null && "baseVal" in l ? l.baseVal.value : typeof l == "number" ? l : 0;
116
116
  };
117
- let r = t.displayWidth || t.naturalWidth || t.videoWidth || e("width"), o = t.displayHeight || t.naturalHeight || t.videoHeight || e("height");
118
- if ((!r || !o) && typeof t.getBBox == "function")
117
+ let n = t.displayWidth || t.naturalWidth || t.videoWidth || e("width"), r = t.displayHeight || t.naturalHeight || t.videoHeight || e("height");
118
+ if ((!n || !r) && typeof t.getBBox == "function")
119
119
  try {
120
- const a = t.getBBox();
121
- r = r || a.width, o = o || a.height;
120
+ const c = t.getBBox();
121
+ n = n || c.width, r = r || c.height;
122
122
  } catch {
123
123
  }
124
- if ((!r || !o) && typeof t.getBoundingClientRect == "function")
124
+ if ((!n || !r) && typeof t.getBoundingClientRect == "function")
125
125
  try {
126
- const a = t.getBoundingClientRect();
127
- r = r || a.width, o = o || a.height;
126
+ const c = t.getBoundingClientRect();
127
+ n = n || c.width, r = r || c.height;
128
128
  } catch {
129
129
  }
130
- if (!r || !o)
130
+ if (!n || !r)
131
131
  throw new DOMException("Invalid image dimensions", "InvalidStateError");
132
- const n = document.createElement("canvas");
133
- n.width = r, n.height = o;
134
- const i = n.getContext("2d");
132
+ const o = document.createElement("canvas");
133
+ o.width = n, o.height = r;
134
+ const i = o.getContext("2d");
135
135
  return typeof ImageData < "u" && t instanceof ImageData ? i.putImageData(t, 0, 0) : i.drawImage(t, 0, 0), {
136
136
  inlineData: {
137
- data: n.toDataURL("image/png").split(",")[1],
137
+ data: o.toDataURL("image/png").split(",")[1],
138
138
  mimeType: "image/png"
139
139
  }
140
140
  };
141
141
  }
142
142
  static arrayBufferToBase64(t) {
143
143
  let e = "";
144
- const r = new Uint8Array(t), o = r.byteLength;
145
- for (let n = 0; n < o; n++)
146
- e += String.fromCharCode(r[n]);
144
+ const n = new Uint8Array(t), r = n.byteLength;
145
+ for (let o = 0; o < r; o++)
146
+ e += String.fromCharCode(n[o]);
147
147
  return window.btoa(e);
148
148
  }
149
149
  // Simple WAV Encoder for AudioBuffer
150
150
  static audioBufferToWav(t) {
151
- const e = t.numberOfChannels, r = t.sampleRate, o = 1, n = 16;
151
+ const e = t.numberOfChannels, n = t.sampleRate, r = 1, o = 16;
152
152
  let i;
153
153
  return e === 2 ? i = this.interleave(
154
154
  t.getChannelData(0),
155
155
  t.getChannelData(1)
156
- ) : i = t.getChannelData(0), this.encodeWAV(i, o, r, e, n);
156
+ ) : i = t.getChannelData(0), this.encodeWAV(i, r, n, e, o);
157
157
  }
158
158
  static interleave(t, e) {
159
- const r = t.length + e.length, o = new Float32Array(r);
160
- let n = 0, i = 0;
161
- for (; n < r; )
162
- o[n++] = t[i], o[n++] = e[i], i++;
163
- return o;
159
+ const n = t.length + e.length, r = new Float32Array(n);
160
+ let o = 0, i = 0;
161
+ for (; o < n; )
162
+ r[o++] = t[i], r[o++] = e[i], i++;
163
+ return r;
164
164
  }
165
- static encodeWAV(t, e, r, o, n) {
166
- const i = n / 8, c = o * i, a = new ArrayBuffer(44 + t.length * i), l = new DataView(a);
167
- return this.writeString(l, 0, "RIFF"), l.setUint32(4, 36 + t.length * i, !0), this.writeString(l, 8, "WAVE"), this.writeString(l, 12, "fmt "), l.setUint32(16, 16, !0), l.setUint16(20, e, !0), l.setUint16(22, o, !0), l.setUint32(24, r, !0), l.setUint32(28, r * c, !0), l.setUint16(32, c, !0), l.setUint16(34, n, !0), this.writeString(l, 36, "data"), l.setUint32(40, t.length * i, !0), this.floatTo16BitPCM(l, 44, t), a;
165
+ static encodeWAV(t, e, n, r, o) {
166
+ const i = o / 8, a = r * i, c = new ArrayBuffer(44 + t.length * i), l = new DataView(c);
167
+ return this.writeString(l, 0, "RIFF"), l.setUint32(4, 36 + t.length * i, !0), this.writeString(l, 8, "WAVE"), this.writeString(l, 12, "fmt "), l.setUint32(16, 16, !0), l.setUint16(20, e, !0), l.setUint16(22, r, !0), l.setUint32(24, n, !0), l.setUint32(28, n * a, !0), l.setUint16(32, a, !0), l.setUint16(34, o, !0), this.writeString(l, 36, "data"), l.setUint32(40, t.length * i, !0), this.floatTo16BitPCM(l, 44, t), c;
168
168
  }
169
- static floatTo16BitPCM(t, e, r) {
170
- for (let o = 0; o < r.length; o++, e += 2) {
171
- const n = Math.max(-1, Math.min(1, r[o]));
172
- t.setInt16(e, n < 0 ? n * 32768 : n * 32767, !0);
169
+ static floatTo16BitPCM(t, e, n) {
170
+ for (let r = 0; r < n.length; r++, e += 2) {
171
+ const o = Math.max(-1, Math.min(1, n[r]));
172
+ t.setInt16(e, o < 0 ? o * 32768 : o * 32767, !0);
173
173
  }
174
174
  }
175
- static writeString(t, e, r) {
176
- for (let o = 0; o < r.length; o++)
177
- t.setUint8(e + o, r.charCodeAt(o));
175
+ static writeString(t, e, n) {
176
+ for (let r = 0; r < n.length; r++)
177
+ t.setUint8(e + r, n.charCodeAt(r));
178
178
  }
179
179
  }
180
- function v(s) {
180
+ function O(s) {
181
181
  if (!s)
182
182
  return;
183
183
  const t = {
@@ -201,22 +201,22 @@ function v(s) {
201
201
  return T.array({
202
202
  ...t,
203
203
  // Recursively convert the 'items' schema
204
- items: v(s.items)
204
+ items: O(s.items)
205
205
  });
206
206
  case "object":
207
- const e = {}, r = s.properties ? Object.keys(s.properties) : [];
208
- r.forEach((i) => {
209
- e[i] = v(
207
+ const e = {}, n = s.properties ? Object.keys(s.properties) : [];
208
+ n.forEach((i) => {
209
+ e[i] = O(
210
210
  s.properties[i]
211
211
  );
212
212
  });
213
- const o = s.required || [], n = r.filter(
214
- (i) => !o.includes(i)
213
+ const r = s.required || [], o = n.filter(
214
+ (i) => !r.includes(i)
215
215
  );
216
216
  return T.object({
217
217
  ...t,
218
218
  properties: e,
219
- optionalProperties: n
219
+ optionalProperties: o
220
220
  });
221
221
  default:
222
222
  return console.warn(
@@ -255,46 +255,46 @@ async function I(s) {
255
255
  }
256
256
  async function C(s, t = globalThis) {
257
257
  const e = [];
258
- for (const r of s) {
259
- const o = r.role === "assistant" ? "model" : "user", n = o === "model";
258
+ for (const n of s) {
259
+ const r = n.role === "assistant" ? "model" : "user", o = r === "model";
260
260
  let i = [];
261
- if (Array.isArray(r.content))
262
- for (const c of r.content)
263
- if (c.type === "text") {
264
- const a = c.value || c.text || "";
265
- if (typeof a != "string")
261
+ if (Array.isArray(n.content))
262
+ for (const a of n.content)
263
+ if (a.type === "text") {
264
+ const c = a.value || a.text || "";
265
+ if (typeof c != "string")
266
266
  throw new (t.DOMException || globalThis.DOMException)(
267
267
  'The content type "text" must have a string value.',
268
268
  "SyntaxError"
269
269
  );
270
- i.push({ text: a });
270
+ i.push({ text: c });
271
271
  } else {
272
- if (n)
272
+ if (o)
273
273
  throw new (t.DOMException || globalThis.DOMException)(
274
274
  "Assistant messages only support text content.",
275
275
  "NotSupportedError"
276
276
  );
277
- const a = await M.convert(c.type, c.value);
278
- i.push(a);
277
+ const c = await M.convert(a.type, a.value);
278
+ i.push(c);
279
279
  }
280
280
  else
281
- i.push({ text: r.content });
282
- e.push({ role: o, parts: i });
281
+ i.push({ text: n.content });
282
+ e.push({ role: r, parts: i });
283
283
  }
284
284
  return e;
285
285
  }
286
286
  class d extends EventTarget {
287
287
  #o;
288
288
  #f;
289
- #r;
290
- #s;
291
289
  #e;
290
+ #s;
291
+ #r;
292
292
  #n;
293
293
  #i;
294
294
  #c;
295
295
  #t;
296
- constructor(t, e, r, o = {}, n, i = 0, c = globalThis) {
297
- super(), this.#o = t, this.#f = e, this.#r = r || [], this.#s = o, this.#e = n, this.#n = !1, this.#i = i, this.#c = {}, this.#t = c;
296
+ constructor(t, e, n, r = {}, o, i = 0, a = globalThis) {
297
+ super(), this.#o = t, this.#f = e, this.#e = n || [], this.#s = r, this.#r = o, this.#n = !1, this.#i = i, this.#c = {}, this.#t = a;
298
298
  }
299
299
  get contextUsage() {
300
300
  return this.#i;
@@ -306,10 +306,7 @@ class d extends EventTarget {
306
306
  return this.#c;
307
307
  }
308
308
  set oncontextoverflow(t) {
309
- this.#c && this.removeEventListener(
310
- "contextoverflow",
311
- this.#c
312
- ), this.#c = t, typeof t == "function" && this.addEventListener("contextoverflow", t);
309
+ this.#c && this.removeEventListener("contextoverflow", this.#c), this.#c = t, typeof t == "function" && this.addEventListener("contextoverflow", t);
313
310
  }
314
311
  static #h(t) {
315
312
  try {
@@ -318,8 +315,8 @@ class d extends EventTarget {
318
315
  if (t !== globalThis && t !== t.top && (!t.frameElement || !t.frameElement.isConnected))
319
316
  throw new Error();
320
317
  } catch {
321
- const r = t?.DOMException || globalThis.DOMException;
322
- throw new r(
318
+ const n = t?.DOMException || globalThis.DOMException;
319
+ throw new n(
323
320
  "The execution context is not valid.",
324
321
  "InvalidStateError"
325
322
  );
@@ -333,31 +330,31 @@ class d extends EventTarget {
333
330
  d.#h(e);
334
331
  try {
335
332
  await d.#w(t, e);
336
- } catch (o) {
337
- if (o instanceof RangeError) {
338
- if (o.message.includes("language tag"))
339
- throw o;
333
+ } catch (r) {
334
+ if (r instanceof RangeError) {
335
+ if (r.message.includes("language tag"))
336
+ throw r;
340
337
  return "unavailable";
341
338
  }
342
- if (o.name === "NotSupportedError")
339
+ if (r.name === "NotSupportedError")
343
340
  return "unavailable";
344
- if (o instanceof TypeError) {
345
- if (/system/i.test(o.message))
341
+ if (r instanceof TypeError) {
342
+ if (/system/i.test(r.message))
346
343
  return "unavailable";
347
- throw o;
344
+ throw r;
348
345
  }
349
346
  return "unavailable";
350
347
  }
351
348
  return (await d.#p(e)).availability(t);
352
349
  }
353
- static #x = A;
350
+ static #g = A;
354
351
  static #d(t = globalThis) {
355
- for (const r of d.#x) {
356
- const o = t[r.config] || globalThis[r.config];
357
- if (o && o.apiKey)
358
- return { ...r, configValue: o };
352
+ for (const n of d.#g) {
353
+ const r = t[n.config] || globalThis[n.config];
354
+ if (r && r.apiKey)
355
+ return { ...n, configValue: r };
359
356
  }
360
- const e = d.#x.map((r) => `window.${r.config}`).join(", ");
357
+ const e = d.#g.map((n) => `window.${n.config}`).join(", ");
361
358
  throw new (t.DOMException || globalThis.DOMException)(
362
359
  `Prompt API Polyfill: No backend configuration found. Please set one of: ${e}.`,
363
360
  "NotSupportedError"
@@ -369,43 +366,43 @@ class d extends EventTarget {
369
366
  }
370
367
  static async #w(t = {}, e = globalThis) {
371
368
  if (t.expectedInputs)
372
- for (const o of t.expectedInputs) {
373
- if (o.type !== "text" && o.type !== "image" && o.type !== "audio")
374
- throw new TypeError(`Invalid input type: ${o.type}`);
375
- o.languages && d.#y(o.languages);
369
+ for (const r of t.expectedInputs) {
370
+ if (r.type !== "text" && r.type !== "image" && r.type !== "audio")
371
+ throw new TypeError(`Invalid input type: ${r.type}`);
372
+ r.languages && d.#y(r.languages);
376
373
  }
377
374
  if (t.expectedOutputs)
378
- for (const o of t.expectedOutputs) {
379
- if (o.type !== "text")
380
- throw new RangeError(`Unsupported output type: ${o.type}`);
381
- o.languages && d.#y(o.languages);
375
+ for (const r of t.expectedOutputs) {
376
+ if (r.type !== "text")
377
+ throw new RangeError(`Unsupported output type: ${r.type}`);
378
+ r.languages && d.#y(r.languages);
382
379
  }
383
- const r = t.expectedInputs ? ["text", ...t.expectedInputs.map((o) => o.type)] : ["text"];
380
+ const n = t.expectedInputs ? ["text", ...t.expectedInputs.map((r) => r.type)] : ["text"];
384
381
  if (t.initialPrompts && Array.isArray(t.initialPrompts)) {
385
- let o = !1;
386
- for (let n = 0; n < t.initialPrompts.length; n++) {
387
- const i = t.initialPrompts[n];
382
+ let r = !1;
383
+ for (let o = 0; o < t.initialPrompts.length; o++) {
384
+ const i = t.initialPrompts[o];
388
385
  if (i.role === "system") {
389
- if (n !== 0)
386
+ if (o !== 0)
390
387
  throw new TypeError(
391
388
  "The prompt with 'system' role must be placed at the first entry of initialPrompts."
392
389
  );
393
- if (o)
390
+ if (r)
394
391
  throw new TypeError(
395
392
  "The prompt with 'system' role must be placed at the first entry of initialPrompts."
396
393
  );
397
- o = !0;
394
+ r = !0;
398
395
  }
399
396
  if (Array.isArray(i.content))
400
- for (const c of i.content) {
401
- const a = c.type || "text";
402
- if (!r.includes(a))
397
+ for (const a of i.content) {
398
+ const c = a.type || "text";
399
+ if (!n.includes(c))
403
400
  throw new (e.DOMException || globalThis.DOMException)(
404
- `The content type "${a}" is not in the expectedInputs.`,
401
+ `The content type "${c}" is not in the expectedInputs.`,
405
402
  "NotSupportedError"
406
403
  );
407
404
  }
408
- else if (!r.includes("text"))
405
+ else if (!n.includes("text"))
409
406
  throw new (e.DOMException || globalThis.DOMException)(
410
407
  'The content type "text" is not in the expectedInputs.',
411
408
  "NotSupportedError"
@@ -439,13 +436,13 @@ class d extends EventTarget {
439
436
  "Aborted",
440
437
  "AbortError"
441
438
  );
442
- const r = await this.availability(t);
443
- if (r === "unavailable")
439
+ const n = await this.availability(t);
440
+ if (n === "unavailable")
444
441
  throw new (e.DOMException || globalThis.DOMException)(
445
442
  "The model is not available for the given options.",
446
443
  "NotSupportedError"
447
444
  );
448
- if (r === "downloadable" || r === "downloading")
445
+ if (n === "downloadable" || n === "downloading")
449
446
  throw new (e.DOMException || globalThis.DOMException)(
450
447
  'Requires a user gesture when availability is "downloading" or "downloadable".',
451
448
  "NotAllowedError"
@@ -455,26 +452,26 @@ class d extends EventTarget {
455
452
  "Aborted",
456
453
  "AbortError"
457
454
  );
458
- const o = d.#d(e), n = await d.#p(e), i = new n(o.configValue), c = { ...t };
459
- d.#g(
460
- c.responseConstraint,
455
+ const r = d.#d(e), o = await d.#p(e), i = new o(r.configValue), a = { ...t };
456
+ d.#x(
457
+ a.responseConstraint,
461
458
  e
462
459
  );
463
- const a = {
460
+ const c = {
464
461
  model: i.modelName,
465
462
  generationConfig: {}
466
463
  };
467
464
  let l = [], y = 0;
468
- if (c.initialPrompts && Array.isArray(c.initialPrompts)) {
469
- const w = c.initialPrompts.filter(
465
+ if (a.initialPrompts && Array.isArray(a.initialPrompts)) {
466
+ const w = a.initialPrompts.filter(
470
467
  (f) => f.role === "system"
471
- ), p = c.initialPrompts.filter(
468
+ ), p = a.initialPrompts.filter(
472
469
  (f) => f.role !== "system"
473
470
  );
474
- w.length > 0 && (a.systemInstruction = w.map((f) => typeof f.content == "string" ? f.content : Array.isArray(f.content) ? f.content.filter((h) => h.type === "text").map((h) => h.value || h.text || "").join(`
471
+ w.length > 0 && (c.systemInstruction = w.map((f) => typeof f.content == "string" ? f.content : Array.isArray(f.content) ? f.content.filter((h) => h.type === "text").map((h) => h.value || h.text || "").join(`
475
472
  `) : "").join(`
476
473
  `)), l = await C(p, e);
477
- for (const f of c.initialPrompts) {
474
+ for (const f of a.initialPrompts) {
478
475
  if (typeof f.content != "string")
479
476
  continue;
480
477
  const h = d.#E([
@@ -489,35 +486,35 @@ class d extends EventTarget {
489
486
  value: 22,
490
487
  configurable: !0
491
488
  });
492
- const g = h === "QuotaExceededError" ? 1e7 : 5e5;
493
- throw u.requested = g, u.quota = 1e6, u;
489
+ const x = h === "QuotaExceededError" ? 1e7 : 5e5;
490
+ throw u.requested = x, u.quota = 1e6, u;
494
491
  }
495
492
  }
496
493
  }
497
- let x = null;
498
- if (typeof c.monitor == "function") {
499
- x = new EventTarget();
494
+ let g = null;
495
+ if (typeof a.monitor == "function") {
496
+ g = new EventTarget();
500
497
  try {
501
- c.monitor(x);
498
+ a.monitor(g);
502
499
  } catch (w) {
503
500
  throw w;
504
501
  }
505
502
  }
506
- x && (x.__lastProgressLoaded = -1);
503
+ g && (g.__lastProgressLoaded = -1);
507
504
  const b = async (w) => {
508
- if (!x || t.signal?.aborted)
505
+ if (!g || t.signal?.aborted)
509
506
  return !t.signal?.aborted;
510
507
  const p = 1 / 65536, f = Math.floor(w / p) * p;
511
- if (f <= x.__lastProgressLoaded)
508
+ if (f <= g.__lastProgressLoaded)
512
509
  return !0;
513
510
  try {
514
- x.dispatchEvent(
511
+ g.dispatchEvent(
515
512
  new ProgressEvent("downloadprogress", {
516
513
  loaded: f,
517
514
  total: 1,
518
515
  lengthComputable: !0
519
516
  })
520
- ), x.__lastProgressLoaded = f;
517
+ ), g.__lastProgressLoaded = f;
521
518
  } catch (h) {
522
519
  console.error("Error dispatching downloadprogress events:", h);
523
520
  }
@@ -529,20 +526,20 @@ class d extends EventTarget {
529
526
  "AbortError"
530
527
  );
531
528
  const m = await i.createSession(
532
- c,
533
529
  a,
534
- x
530
+ c,
531
+ g
535
532
  );
536
533
  if (!await b(1))
537
534
  throw t.signal.reason || new (e.DOMException || globalThis.DOMException)(
538
535
  "Aborted",
539
536
  "AbortError"
540
537
  );
541
- if (c.initialPrompts?.length > 0) {
538
+ if (a.initialPrompts?.length > 0) {
542
539
  const w = [...l];
543
- if (a.systemInstruction && w.unshift({
540
+ if (c.systemInstruction && w.unshift({
544
541
  role: "system",
545
- parts: [{ text: a.systemInstruction }]
542
+ parts: [{ text: c.systemInstruction }]
546
543
  }), y = await i.countTokens(w) || 0, y > 1e6) {
547
544
  const p = e.QuotaExceededError || e.DOMException || globalThis.QuotaExceededError || globalThis.DOMException, f = new p(
548
545
  "The initial prompts are too large, they exceed the quota.",
@@ -555,8 +552,8 @@ class d extends EventTarget {
555
552
  i,
556
553
  m,
557
554
  l,
558
- c,
559
555
  a,
556
+ c,
560
557
  y,
561
558
  e
562
559
  );
@@ -573,9 +570,9 @@ class d extends EventTarget {
573
570
  "Aborted",
574
571
  "AbortError"
575
572
  );
576
- const e = JSON.parse(JSON.stringify(this.#r)), r = { ...this.#s, ...t }, o = await d.#p(this.#t), n = d.#d(this.#t), i = new o(n.configValue), c = await i.createSession(
577
- r,
578
- this.#e
573
+ const e = JSON.parse(JSON.stringify(this.#e)), n = { ...this.#s, ...t }, r = await d.#p(this.#t), o = d.#d(this.#t), i = new r(o.configValue), a = await i.createSession(
574
+ n,
575
+ this.#r
579
576
  );
580
577
  if (t.signal?.aborted)
581
578
  throw t.signal.reason || new (this.#t.DOMException || globalThis.DOMException)(
@@ -584,16 +581,16 @@ class d extends EventTarget {
584
581
  );
585
582
  return new this.constructor(
586
583
  i,
587
- c,
584
+ a,
588
585
  e,
589
- r,
590
- this.#e,
586
+ n,
587
+ this.#r,
591
588
  this.#i,
592
589
  this.#t
593
590
  );
594
591
  }
595
592
  destroy() {
596
- this.#a(), this.#n = !0, this.#r = null;
593
+ this.#a(), this.#n = !0, this.#e = null;
597
594
  }
598
595
  async prompt(t, e = {}) {
599
596
  if (this.#a(), this.#n)
@@ -609,25 +606,25 @@ class d extends EventTarget {
609
606
  if (typeof t == "object" && t !== null && !Array.isArray(t) && Object.keys(t).length === 0)
610
607
  return "[object Object]";
611
608
  if (e.responseConstraint) {
612
- d.#g(
609
+ d.#x(
613
610
  e.responseConstraint,
614
611
  this.#t
615
612
  );
616
- const a = v(
613
+ const c = O(
617
614
  e.responseConstraint
618
615
  );
619
- this.#e.generationConfig.responseMimeType = "application/json", this.#e.generationConfig.responseSchema = a, this.#f = this.#o.createSession(
616
+ this.#r.generationConfig.responseMimeType = "application/json", this.#r.generationConfig.responseSchema = c, this.#f = this.#o.createSession(
620
617
  this.#s,
621
- this.#e
618
+ this.#r
622
619
  );
623
620
  }
624
- const r = this.#b(t), o = await this.#l(t);
621
+ const n = this.#b(t), r = await this.#l(t);
625
622
  if (this.#n)
626
623
  throw new (this.#t.DOMException || globalThis.DOMException)(
627
624
  "Session is destroyed",
628
625
  "InvalidStateError"
629
626
  );
630
- const n = { role: "user", parts: o }, i = new Promise((a, l) => {
627
+ const o = { role: "user", parts: r }, i = new Promise((c, l) => {
631
628
  if (e.signal?.aborted) {
632
629
  l(
633
630
  e.signal.reason || new (this.#t.DOMException || globalThis.DOMException)(
@@ -649,9 +646,9 @@ class d extends EventTarget {
649
646
  },
650
647
  { once: !0 }
651
648
  );
652
- }), c = (async () => {
653
- const a = this.#u(o);
654
- if (a === "QuotaExceededError") {
649
+ }), a = (async () => {
650
+ const c = this.#u(r);
651
+ if (c === "QuotaExceededError") {
655
652
  const f = this.#t && this.#t.QuotaExceededError || this.#t && this.#t.DOMException || globalThis.QuotaExceededError || globalThis.DOMException, h = new f(
656
653
  "The prompt is too large, it exceeds the quota.",
657
654
  "QuotaExceededError"
@@ -659,12 +656,12 @@ class d extends EventTarget {
659
656
  Object.defineProperty(h, "code", { value: 22, configurable: !0 });
660
657
  const E = 1e7;
661
658
  throw h.requested = E, h.quota = this.contextWindow, h;
662
- } else if (a === "contextoverflow")
659
+ } else if (c === "contextoverflow")
663
660
  return this.dispatchEvent(new Event("contextoverflow")), "Mock response for quota overflow test.";
664
- const l = [...this.#r, n];
665
- this.#e.systemInstruction && l.unshift({
661
+ const l = [...this.#e, o];
662
+ this.#r.systemInstruction && l.unshift({
666
663
  role: "system",
667
- parts: [{ text: this.#e.systemInstruction }]
664
+ parts: [{ text: this.#r.systemInstruction }]
668
665
  });
669
666
  const y = await this.#o.countTokens(
670
667
  l
@@ -677,25 +674,25 @@ class d extends EventTarget {
677
674
  throw Object.defineProperty(h, "code", { value: 22, configurable: !0 }), h.requested = y, h.quota = this.contextWindow, h;
678
675
  }
679
676
  y > this.contextWindow && this.dispatchEvent(new Event("contextoverflow"));
680
- const x = [...this.#r, n];
677
+ const g = [...this.#e, o];
681
678
  let b;
682
679
  try {
683
- b = await this.#o.generateContent(x);
680
+ b = await this.#o.generateContent(g);
684
681
  } catch (f) {
685
- throw this.#m(f, o), f;
682
+ throw this.#m(f, r), f;
686
683
  }
687
684
  const { text: m, usage: w } = b;
688
685
  let p = m;
689
- if (r) {
686
+ if (n) {
690
687
  const f = p.match(/^\s*{\s*"Rating"\s*:\s*/);
691
688
  f && (p = p.slice(f[0].length));
692
689
  }
693
- return w && (this.#i = w), this.#r.push(n), this.#r.push({ role: "model", parts: [{ text: p }] }), p;
690
+ return w && (this.#i = w), !this.#n && this.#e && (this.#e.push(o), this.#e.push({ role: "model", parts: [{ text: p }] })), p;
694
691
  })();
695
692
  try {
696
- return await Promise.race([c, i]);
697
- } catch (a) {
698
- throw a.name === "AbortError" || console.error("Prompt API Polyfill Error:", a), a;
693
+ return await Promise.race([a, i]);
694
+ } catch (c) {
695
+ throw c.name === "AbortError" || console.error("Prompt API Polyfill Error:", c), c;
699
696
  }
700
697
  }
701
698
  promptStreaming(t, e = {}) {
@@ -711,91 +708,91 @@ class d extends EventTarget {
711
708
  );
712
709
  if (typeof t == "object" && t !== null && !Array.isArray(t) && Object.keys(t).length === 0)
713
710
  return new ReadableStream({
714
- start(n) {
715
- n.enqueue("[object Object]"), n.close();
711
+ start(o) {
712
+ o.enqueue("[object Object]"), o.close();
716
713
  }
717
714
  });
718
- const r = this, o = e.signal;
715
+ const n = this, r = e.signal;
719
716
  return new ReadableStream({
720
- async start(n) {
717
+ async start(o) {
721
718
  let i = !1;
722
- const c = () => {
719
+ const a = () => {
723
720
  i = !0;
724
721
  try {
725
- const a = o?.reason || new (r.#t.DOMException || globalThis.DOMException)(
722
+ const c = r?.reason || new (n.#t.DOMException || globalThis.DOMException)(
726
723
  "Aborted",
727
724
  "AbortError"
728
725
  );
729
- n.error(a);
726
+ o.error(c);
730
727
  } catch {
731
728
  }
732
729
  };
733
- if (o?.aborted) {
734
- c();
730
+ if (r?.aborted) {
731
+ a();
735
732
  return;
736
733
  }
737
- o && o.addEventListener("abort", c);
734
+ r && r.addEventListener("abort", a);
738
735
  try {
739
736
  if (e.responseConstraint) {
740
- d.#g(
737
+ d.#x(
741
738
  e.responseConstraint,
742
- r.#t
739
+ n.#t
743
740
  );
744
- const u = v(
741
+ const u = O(
745
742
  e.responseConstraint
746
743
  );
747
- r.#e.generationConfig.responseMimeType = "application/json", r.#e.generationConfig.responseSchema = u, r.#f = r.#o.createSession(
748
- r.#s,
749
- r.#e
744
+ n.#r.generationConfig.responseMimeType = "application/json", n.#r.generationConfig.responseSchema = u, n.#f = n.#o.createSession(
745
+ n.#s,
746
+ n.#r
750
747
  );
751
748
  }
752
- const a = r.#b(t), l = await r.#l(t);
753
- if (r.#n)
754
- throw new (r.#t.DOMException || globalThis.DOMException)(
749
+ const c = n.#b(t), l = await n.#l(t);
750
+ if (n.#n)
751
+ throw new (n.#t.DOMException || globalThis.DOMException)(
755
752
  "Session is destroyed",
756
753
  "InvalidStateError"
757
754
  );
758
- const y = { role: "user", parts: l }, x = r.#u(l);
759
- if (x === "QuotaExceededError") {
760
- const u = r.#t && r.#t.QuotaExceededError || r.#t && r.#t.DOMException || globalThis.QuotaExceededError || globalThis.DOMException, g = new u(
755
+ const y = { role: "user", parts: l }, g = n.#u(l);
756
+ if (g === "QuotaExceededError") {
757
+ const u = n.#t && n.#t.QuotaExceededError || n.#t && n.#t.DOMException || globalThis.QuotaExceededError || globalThis.DOMException, x = new u(
761
758
  "The prompt is too large, it exceeds the quota.",
762
759
  "QuotaExceededError"
763
760
  );
764
- Object.defineProperty(g, "code", {
761
+ Object.defineProperty(x, "code", {
765
762
  value: 22,
766
763
  configurable: !0
767
764
  });
768
- const O = 1e7;
769
- throw g.requested = O, g.quota = r.contextWindow, g;
770
- } else if (x === "contextoverflow") {
771
- r.dispatchEvent(new Event("contextoverflow")), n.enqueue("Mock response for quota overflow test."), n.close();
765
+ const v = 1e7;
766
+ throw x.requested = v, x.quota = n.contextWindow, x;
767
+ } else if (g === "contextoverflow") {
768
+ n.dispatchEvent(new Event("contextoverflow")), o.enqueue("Mock response for quota overflow test."), o.close();
772
769
  return;
773
770
  }
774
- const b = [...r.#r, y];
775
- r.#e.systemInstruction && b.unshift({
771
+ const b = [...n.#e, y];
772
+ n.#r.systemInstruction && b.unshift({
776
773
  role: "system",
777
- parts: [{ text: r.#e.systemInstruction }]
774
+ parts: [{ text: n.#r.systemInstruction }]
778
775
  });
779
- const m = await r.#o.countTokens(
776
+ const m = await n.#o.countTokens(
780
777
  b
781
778
  );
782
- if (m > r.contextWindow) {
783
- const u = r.#t && r.#t.QuotaExceededError || r.#t && r.#t.DOMException || globalThis.QuotaExceededError || globalThis.DOMException, g = new u(
784
- `The prompt is too large (${m} tokens), it exceeds the quota of ${r.contextWindow} tokens.`,
779
+ if (m > n.contextWindow) {
780
+ const u = n.#t && n.#t.QuotaExceededError || n.#t && n.#t.DOMException || globalThis.QuotaExceededError || globalThis.DOMException, x = new u(
781
+ `The prompt is too large (${m} tokens), it exceeds the quota of ${n.contextWindow} tokens.`,
785
782
  "QuotaExceededError"
786
783
  );
787
- throw Object.defineProperty(g, "code", {
784
+ throw Object.defineProperty(x, "code", {
788
785
  value: 22,
789
786
  configurable: !0
790
- }), g.requested = m, g.quota = r.contextWindow, g;
787
+ }), x.requested = m, x.quota = n.contextWindow, x;
791
788
  }
792
- m > r.contextWindow && r.dispatchEvent(new Event("contextoverflow"));
793
- const w = [...r.#r, y];
789
+ m > n.contextWindow && n.dispatchEvent(new Event("contextoverflow"));
790
+ const w = [...n.#e, y];
794
791
  let p;
795
792
  try {
796
- p = await r.#o.generateContentStream(w);
793
+ p = await n.#o.generateContentStream(w);
797
794
  } catch (u) {
798
- throw r.#m(u, l), u;
795
+ throw n.#m(u, l), u;
799
796
  }
800
797
  let f = "", h = !1, E = "";
801
798
  for await (const u of p) {
@@ -803,27 +800,27 @@ class d extends EventTarget {
803
800
  typeof p.return == "function" && await p.return();
804
801
  return;
805
802
  }
806
- let g = u.text();
807
- if (a && !h) {
808
- E += g;
809
- const O = E.match(/^\s*{\s*"Rating"\s*:\s*/);
810
- if (O)
811
- g = E.slice(O[0].length), h = !0, E = "";
803
+ let x = u.text();
804
+ if (c && !h) {
805
+ E += x;
806
+ const v = E.match(/^\s*{\s*"Rating"\s*:\s*/);
807
+ if (v)
808
+ x = E.slice(v[0].length), h = !0, E = "";
812
809
  else if (E.length > 50)
813
- g = E, h = !0, E = "";
810
+ x = E, h = !0, E = "";
814
811
  else
815
812
  continue;
816
813
  }
817
- f += g, u.usageMetadata?.totalTokenCount && (r.#i = u.usageMetadata.totalTokenCount), n.enqueue(g);
814
+ f += x, u.usageMetadata?.totalTokenCount && (n.#i = u.usageMetadata.totalTokenCount), o.enqueue(x);
818
815
  }
819
- i || (r.#r.push(y), r.#r.push({
816
+ !i && !n.#n && n.#e && (n.#e.push(y), n.#e.push({
820
817
  role: "model",
821
818
  parts: [{ text: f }]
822
- }), n.close());
823
- } catch (a) {
824
- i || n.error(a);
819
+ })), o.close();
820
+ } catch (c) {
821
+ i || o.error(c);
825
822
  } finally {
826
- o && o.removeEventListener("abort", c);
823
+ r && r.removeEventListener("abort", a);
827
824
  }
828
825
  }
829
826
  });
@@ -839,21 +836,21 @@ class d extends EventTarget {
839
836
  "Aborted",
840
837
  "AbortError"
841
838
  );
842
- const r = await this.#l(t);
839
+ const n = await this.#l(t);
843
840
  if (this.#n)
844
841
  throw new (this.#t.DOMException || globalThis.DOMException)(
845
842
  "Session is destroyed",
846
843
  "InvalidStateError"
847
844
  );
848
- const o = { role: "user", parts: r };
849
- this.#r.push(o);
845
+ const r = { role: "user", parts: n };
846
+ this.#e.push(r);
850
847
  try {
851
- const n = [...this.#r];
852
- this.#e.systemInstruction && n.unshift({
848
+ const o = [...this.#e];
849
+ this.#r.systemInstruction && o.unshift({
853
850
  role: "system",
854
- parts: [{ text: this.#e.systemInstruction }]
851
+ parts: [{ text: this.#r.systemInstruction }]
855
852
  });
856
- const i = await this.#o.countTokens(n);
853
+ const i = await this.#o.countTokens(o);
857
854
  this.#i = i || 0;
858
855
  } catch {
859
856
  }
@@ -872,8 +869,8 @@ class d extends EventTarget {
872
869
  "Session is destroyed",
873
870
  "InvalidStateError"
874
871
  );
875
- const r = this.#u(e);
876
- return r === "QuotaExceededError" ? 1e7 : r === "contextoverflow" ? 5e5 : await this.#o.countTokens([
872
+ const n = this.#u(e);
873
+ return n === "QuotaExceededError" ? 1e7 : n === "contextoverflow" ? 5e5 : await this.#o.countTokens([
877
874
  { role: "user", parts: e }
878
875
  ]) || 0;
879
876
  } catch {
@@ -892,7 +889,7 @@ class d extends EventTarget {
892
889
  const e = t[0].text;
893
890
  return typeof e != "string" || !e.startsWith("Please write a sentence in English.") ? null : e.length > 1e7 ? "QuotaExceededError" : e.length > 5e4 ? "contextoverflow" : null;
894
891
  }
895
- static #g(t, e) {
892
+ static #x(t, e) {
896
893
  if (t)
897
894
  try {
898
895
  JSON.stringify(t);
@@ -913,7 +910,7 @@ class d extends EventTarget {
913
910
  }
914
911
  // Private Helper to process diverse input types
915
912
  async #l(t) {
916
- const e = this.#s.expectedInputs ? ["text", ...this.#s.expectedInputs.map((o) => o.type)] : ["text"];
913
+ const e = this.#s.expectedInputs ? ["text", ...this.#s.expectedInputs.map((r) => r.type)] : ["text"];
917
914
  if (typeof t == "string") {
918
915
  if (!e.includes("text"))
919
916
  throw new (this.#t.DOMException || globalThis.DOMException)(
@@ -926,54 +923,85 @@ class d extends EventTarget {
926
923
  if (t.length === 0)
927
924
  return [{ text: " " }];
928
925
  if (t.length > 0 && t[0].role) {
929
- let o = [];
930
- for (const n of t) {
931
- const i = n.role === "assistant" || n.role === "model";
932
- if (typeof n.content == "string") {
926
+ let r = [];
927
+ for (const o of t) {
928
+ const i = o.role === "assistant" || o.role === "model";
929
+ if (typeof o.content == "string") {
933
930
  if (!e.includes("text"))
934
931
  throw new (this.#t.DOMException || globalThis.DOMException)(
935
932
  'The content type "text" is not in the expectedInputs.',
936
933
  "NotSupportedError"
937
934
  );
938
- o.push({ text: n.content }), n.prefix && console.warn(
935
+ r.push({ text: o.content }), o.prefix && console.warn(
939
936
  "The `prefix` flag isn't supported and was ignored."
940
937
  );
941
- } else if (Array.isArray(n.content))
942
- for (const c of n.content) {
943
- const a = c.type || "text";
944
- if (!e.includes(a))
938
+ } else if (Array.isArray(o.content))
939
+ for (const a of o.content) {
940
+ const c = a.type || "text";
941
+ if (!e.includes(c))
945
942
  throw new (this.#t.DOMException || globalThis.DOMException)(
946
- `The content type "${a}" is not in the expectedInputs.`,
943
+ `The content type "${c}" is not in the expectedInputs.`,
947
944
  "NotSupportedError"
948
945
  );
949
- if (a === "text") {
950
- if (typeof c.value != "string")
946
+ if (c === "text") {
947
+ if (typeof a.value != "string")
951
948
  throw new (this.#t.DOMException || globalThis.DOMException)(
952
949
  'The content type "text" must have a string value.',
953
950
  "SyntaxError"
954
951
  );
955
- o.push({ text: c.value });
952
+ r.push({ text: a.value });
956
953
  } else {
957
954
  if (i)
958
955
  throw new (this.#t.DOMException || globalThis.DOMException)(
959
956
  "Assistant messages only support text content.",
960
957
  "NotSupportedError"
961
958
  );
962
- const l = await M.convert(c.type, c.value);
963
- o.push(l);
959
+ const l = a.value && a.value.inlineData ? a.value : await M.convert(a.type, a.value);
960
+ r.push(l);
964
961
  }
965
962
  }
966
963
  }
967
- return o;
964
+ return r;
968
965
  }
969
- return t.map((o) => {
970
- if (!e.includes("text"))
971
- throw new (this.#t.DOMException || globalThis.DOMException)(
972
- 'The content type "text" is not in the expectedInputs.',
973
- "NotSupportedError"
974
- );
975
- return { text: String(o) };
976
- });
966
+ return Promise.all(
967
+ t.map(async (r) => {
968
+ if (typeof r == "string") {
969
+ if (!e.includes("text"))
970
+ throw new (this.#t.DOMException || globalThis.DOMException)(
971
+ 'The content type "text" is not in the expectedInputs.',
972
+ "NotSupportedError"
973
+ );
974
+ return { text: r === "" ? " " : r };
975
+ }
976
+ if (typeof r == "object" && r !== null) {
977
+ if (r.inlineData)
978
+ return r;
979
+ if (r.type && r.value) {
980
+ const o = r.type || "text";
981
+ if (!e.includes(o))
982
+ throw new (this.#t.DOMException || globalThis.DOMException)(
983
+ `The content type "${o}" is not in the expectedInputs.`,
984
+ "NotSupportedError"
985
+ );
986
+ if (o === "text") {
987
+ if (typeof r.value != "string")
988
+ throw new (this.#t.DOMException || globalThis.DOMException)(
989
+ 'The content type "text" must have a string value.',
990
+ "SyntaxError"
991
+ );
992
+ return { text: r.value };
993
+ }
994
+ return r.value && r.value.inlineData ? r.value : await M.convert(r.type, r.value);
995
+ }
996
+ }
997
+ if (!e.includes("text"))
998
+ throw new (this.#t.DOMException || globalThis.DOMException)(
999
+ 'The content type "text" is not in the expectedInputs.',
1000
+ "NotSupportedError"
1001
+ );
1002
+ return { text: String(r) };
1003
+ })
1004
+ );
977
1005
  }
978
1006
  if (!e.includes("text"))
979
1007
  throw new (this.#t.DOMException || globalThis.DOMException)(
@@ -984,16 +1012,16 @@ class d extends EventTarget {
984
1012
  }
985
1013
  // Map backend errors to WPT expectations
986
1014
  #m(t, e) {
987
- const r = String(t.message || t);
988
- if (r.includes("400") || r.toLowerCase().includes("unable to process") || r.toLowerCase().includes("invalid")) {
989
- const o = e.some(
990
- (c) => c.inlineData?.mimeType.startsWith("audio/")
991
- ), n = e.some(
992
- (c) => c.inlineData?.mimeType.startsWith("image/")
1015
+ const n = String(t.message || t);
1016
+ if (n.includes("400") || n.toLowerCase().includes("unable to process") || n.toLowerCase().includes("invalid")) {
1017
+ const r = e.some(
1018
+ (a) => a.inlineData?.mimeType.startsWith("audio/")
1019
+ ), o = e.some(
1020
+ (a) => a.inlineData?.mimeType.startsWith("image/")
993
1021
  ), i = this.#t.DOMException || globalThis.DOMException;
994
- if (o)
1022
+ if (r)
995
1023
  throw new i("Invalid audio data", "DataError");
996
- if (n)
1024
+ if (o)
997
1025
  throw new i("Invalid image data", "InvalidStateError");
998
1026
  }
999
1027
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prompt-api-polyfill",
3
- "version": "1.4.0",
3
+ "version": "1.6.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",
@@ -52,9 +52,9 @@
52
52
  "node-addon-api": "^8.5.0"
53
53
  },
54
54
  "dependencies": {
55
- "@google/genai": "^1.42.0",
55
+ "@google/genai": "^1.43.0",
56
56
  "@huggingface/transformers": "^3.8.1",
57
57
  "firebase": "^12.9.0",
58
- "openai": "^6.22.0"
58
+ "openai": "^6.25.0"
59
59
  }
60
60
  }