@elizaos/plugin-openai 1.0.0-beta.16 → 1.0.0-beta.17

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.
package/dist/index.js CHANGED
@@ -7,6 +7,537 @@ import {
7
7
  } from "@elizaos/core";
8
8
  import { generateObject, generateText } from "ai";
9
9
  import { encodingForModel } from "js-tiktoken";
10
+
11
+ // ../../node_modules/formdata-node/lib/form-data.js
12
+ var __accessCheck = (obj, member, msg) => {
13
+ if (!member.has(obj))
14
+ throw TypeError("Cannot " + msg);
15
+ };
16
+ var __privateGet = (obj, member, getter) => {
17
+ __accessCheck(obj, member, "read from private field");
18
+ return getter ? getter.call(obj) : member.get(obj);
19
+ };
20
+ var __privateAdd = (obj, member, value) => {
21
+ if (member.has(obj))
22
+ throw TypeError("Cannot add the same private member more than once");
23
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
24
+ };
25
+ var __privateSet = (obj, member, value, setter) => {
26
+ __accessCheck(obj, member, "write to private field");
27
+ setter ? setter.call(obj, value) : member.set(obj, value);
28
+ return value;
29
+ };
30
+ var __privateMethod = (obj, member, method) => {
31
+ __accessCheck(obj, member, "access private method");
32
+ return method;
33
+ };
34
+ var isFunction = (value) => typeof value === "function";
35
+ var isObject = (value) => typeof value === "object" && value != null && !Array.isArray(value);
36
+ var isAsyncIterable = (value) => isObject(value) && isFunction(value[Symbol.asyncIterator]);
37
+ var MAX_CHUNK_SIZE = 65536;
38
+ async function* clonePart(value) {
39
+ if (value.byteLength <= MAX_CHUNK_SIZE) {
40
+ yield value;
41
+ return;
42
+ }
43
+ let offset = 0;
44
+ while (offset < value.byteLength) {
45
+ const size = Math.min(value.byteLength - offset, MAX_CHUNK_SIZE);
46
+ const buffer = value.buffer.slice(offset, offset + size);
47
+ offset += buffer.byteLength;
48
+ yield new Uint8Array(buffer);
49
+ }
50
+ }
51
+ async function* readStream(readable) {
52
+ const reader = readable.getReader();
53
+ while (true) {
54
+ const { done, value } = await reader.read();
55
+ if (done) {
56
+ break;
57
+ }
58
+ yield value;
59
+ }
60
+ }
61
+ async function* chunkStream(stream) {
62
+ for await (const value of stream) {
63
+ yield* clonePart(value);
64
+ }
65
+ }
66
+ var getStreamIterator = (source) => {
67
+ if (isAsyncIterable(source)) {
68
+ return chunkStream(source);
69
+ }
70
+ if (isFunction(source.getReader)) {
71
+ return chunkStream(readStream(source));
72
+ }
73
+ throw new TypeError(
74
+ "Unsupported data source: Expected either ReadableStream or async iterable."
75
+ );
76
+ };
77
+ async function* consumeNodeBlob(blob) {
78
+ let position = 0;
79
+ while (position !== blob.size) {
80
+ const chunk = blob.slice(
81
+ position,
82
+ Math.min(blob.size, position + MAX_CHUNK_SIZE)
83
+ );
84
+ const buffer = await chunk.arrayBuffer();
85
+ position += buffer.byteLength;
86
+ yield new Uint8Array(buffer);
87
+ }
88
+ }
89
+ async function* consumeBlobParts(parts, clone = false) {
90
+ for (const part of parts) {
91
+ if (ArrayBuffer.isView(part)) {
92
+ if (clone) {
93
+ yield* clonePart(part);
94
+ } else {
95
+ yield part;
96
+ }
97
+ } else if (isFunction(part.stream)) {
98
+ yield* getStreamIterator(part.stream());
99
+ } else {
100
+ yield* consumeNodeBlob(part);
101
+ }
102
+ }
103
+ }
104
+ function* sliceBlob(blobParts, blobSize, start = 0, end) {
105
+ end ??= blobSize;
106
+ let relativeStart = start < 0 ? Math.max(blobSize + start, 0) : Math.min(start, blobSize);
107
+ let relativeEnd = end < 0 ? Math.max(blobSize + end, 0) : Math.min(end, blobSize);
108
+ const span = Math.max(relativeEnd - relativeStart, 0);
109
+ let added = 0;
110
+ for (const part of blobParts) {
111
+ if (added >= span) {
112
+ break;
113
+ }
114
+ const partSize = ArrayBuffer.isView(part) ? part.byteLength : part.size;
115
+ if (relativeStart && partSize <= relativeStart) {
116
+ relativeStart -= partSize;
117
+ relativeEnd -= partSize;
118
+ } else {
119
+ let chunk;
120
+ if (ArrayBuffer.isView(part)) {
121
+ chunk = part.subarray(relativeStart, Math.min(partSize, relativeEnd));
122
+ added += chunk.byteLength;
123
+ } else {
124
+ chunk = part.slice(relativeStart, Math.min(partSize, relativeEnd));
125
+ added += chunk.size;
126
+ }
127
+ relativeEnd -= partSize;
128
+ relativeStart = 0;
129
+ yield chunk;
130
+ }
131
+ }
132
+ }
133
+ var _parts;
134
+ var _type;
135
+ var _size;
136
+ var _Blob = class _Blob2 {
137
+ /**
138
+ * Returns a new [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) object.
139
+ * The content of the blob consists of the concatenation of the values given in the parameter array.
140
+ *
141
+ * @param blobParts An `Array` strings, or [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), [`ArrayBufferView`](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView), [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects, or a mix of any of such objects, that will be put inside the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
142
+ * @param options An optional object of type `BlobPropertyBag`.
143
+ */
144
+ constructor(blobParts = [], options = {}) {
145
+ __privateAdd(this, _parts, []);
146
+ __privateAdd(this, _type, "");
147
+ __privateAdd(this, _size, 0);
148
+ options ??= {};
149
+ if (typeof blobParts !== "object" || blobParts === null) {
150
+ throw new TypeError(
151
+ "Failed to construct 'Blob': The provided value cannot be converted to a sequence."
152
+ );
153
+ }
154
+ if (!isFunction(blobParts[Symbol.iterator])) {
155
+ throw new TypeError(
156
+ "Failed to construct 'Blob': The object must have a callable @@iterator property."
157
+ );
158
+ }
159
+ if (typeof options !== "object" && !isFunction(options)) {
160
+ throw new TypeError(
161
+ "Failed to construct 'Blob': parameter 2 cannot convert to dictionary."
162
+ );
163
+ }
164
+ const encoder = new TextEncoder();
165
+ for (const raw of blobParts) {
166
+ let part;
167
+ if (ArrayBuffer.isView(raw)) {
168
+ part = new Uint8Array(raw.buffer.slice(
169
+ raw.byteOffset,
170
+ raw.byteOffset + raw.byteLength
171
+ ));
172
+ } else if (raw instanceof ArrayBuffer) {
173
+ part = new Uint8Array(raw.slice(0));
174
+ } else if (raw instanceof _Blob2) {
175
+ part = raw;
176
+ } else {
177
+ part = encoder.encode(String(raw));
178
+ }
179
+ __privateSet(this, _size, __privateGet(this, _size) + (ArrayBuffer.isView(part) ? part.byteLength : part.size));
180
+ __privateGet(this, _parts).push(part);
181
+ }
182
+ const type = options.type === void 0 ? "" : String(options.type);
183
+ __privateSet(this, _type, /^[\x20-\x7E]*$/.test(type) ? type : "");
184
+ }
185
+ static [Symbol.hasInstance](value) {
186
+ return Boolean(
187
+ value && typeof value === "object" && isFunction(value.constructor) && (isFunction(value.stream) || isFunction(value.arrayBuffer)) && /^(Blob|File)$/.test(value[Symbol.toStringTag])
188
+ );
189
+ }
190
+ /**
191
+ * Returns the [`MIME type`](https://developer.mozilla.org/en-US/docs/Glossary/MIME_type) of the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File).
192
+ */
193
+ get type() {
194
+ return __privateGet(this, _type);
195
+ }
196
+ /**
197
+ * Returns the size of the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) in bytes.
198
+ */
199
+ get size() {
200
+ return __privateGet(this, _size);
201
+ }
202
+ /**
203
+ * Creates and returns a new [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) object which contains data from a subset of the blob on which it's called.
204
+ *
205
+ * @param start An index into the Blob indicating the first byte to include in the new Blob. If you specify a negative value, it's treated as an offset from the end of the Blob toward the beginning. For example, -10 would be the 10th from last byte in the Blob. The default value is 0. If you specify a value for start that is larger than the size of the source Blob, the returned Blob has size 0 and contains no data.
206
+ * @param end An index into the Blob indicating the first byte that will *not* be included in the new Blob (i.e. the byte exactly at this index is not included). If you specify a negative value, it's treated as an offset from the end of the Blob toward the beginning. For example, -10 would be the 10th from last byte in the Blob. The default value is size.
207
+ * @param contentType The content type to assign to the new Blob; this will be the value of its type property. The default value is an empty string.
208
+ */
209
+ slice(start, end, contentType) {
210
+ return new _Blob2(sliceBlob(__privateGet(this, _parts), this.size, start, end), {
211
+ type: contentType
212
+ });
213
+ }
214
+ /**
215
+ * Returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves with a string containing the contents of the blob, interpreted as UTF-8.
216
+ */
217
+ async text() {
218
+ const decoder = new TextDecoder();
219
+ let result = "";
220
+ for await (const chunk of consumeBlobParts(__privateGet(this, _parts))) {
221
+ result += decoder.decode(chunk, { stream: true });
222
+ }
223
+ result += decoder.decode();
224
+ return result;
225
+ }
226
+ /**
227
+ * Returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves with the contents of the blob as binary data contained in an [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer).
228
+ */
229
+ async arrayBuffer() {
230
+ const view = new Uint8Array(this.size);
231
+ let offset = 0;
232
+ for await (const chunk of consumeBlobParts(__privateGet(this, _parts))) {
233
+ view.set(chunk, offset);
234
+ offset += chunk.length;
235
+ }
236
+ return view.buffer;
237
+ }
238
+ /**
239
+ * Returns a [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) which upon reading returns the data contained within the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
240
+ */
241
+ stream() {
242
+ const iterator = consumeBlobParts(__privateGet(this, _parts), true);
243
+ return new ReadableStream({
244
+ async pull(controller) {
245
+ const { value, done } = await iterator.next();
246
+ if (done) {
247
+ return queueMicrotask(() => controller.close());
248
+ }
249
+ controller.enqueue(value);
250
+ },
251
+ async cancel() {
252
+ await iterator.return();
253
+ }
254
+ });
255
+ }
256
+ get [Symbol.toStringTag]() {
257
+ return "Blob";
258
+ }
259
+ };
260
+ _parts = /* @__PURE__ */ new WeakMap();
261
+ _type = /* @__PURE__ */ new WeakMap();
262
+ _size = /* @__PURE__ */ new WeakMap();
263
+ var Blob = _Blob;
264
+ Object.defineProperties(Blob.prototype, {
265
+ type: { enumerable: true },
266
+ size: { enumerable: true },
267
+ slice: { enumerable: true },
268
+ stream: { enumerable: true },
269
+ text: { enumerable: true },
270
+ arrayBuffer: { enumerable: true }
271
+ });
272
+ var isBlob = (value) => value instanceof Blob;
273
+ var _name;
274
+ var _lastModified;
275
+ var File = class extends Blob {
276
+ /**
277
+ * Creates a new File instance.
278
+ *
279
+ * @param fileBits An `Array` strings, or [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), [`ArrayBufferView`](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView), [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects, or a mix of any of such objects, that will be put inside the [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File).
280
+ * @param name The name of the file.
281
+ * @param options An options object containing optional attributes for the file.
282
+ */
283
+ constructor(fileBits, name, options = {}) {
284
+ super(fileBits, options);
285
+ __privateAdd(this, _name, void 0);
286
+ __privateAdd(this, _lastModified, 0);
287
+ if (arguments.length < 2) {
288
+ throw new TypeError(
289
+ `Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`
290
+ );
291
+ }
292
+ __privateSet(this, _name, String(name));
293
+ const lastModified = options.lastModified === void 0 ? Date.now() : Number(options.lastModified);
294
+ if (!Number.isNaN(lastModified)) {
295
+ __privateSet(this, _lastModified, lastModified);
296
+ }
297
+ }
298
+ static [Symbol.hasInstance](value) {
299
+ return value instanceof Blob && value[Symbol.toStringTag] === "File" && typeof value.name === "string";
300
+ }
301
+ /**
302
+ * Name of the file referenced by the File object.
303
+ */
304
+ get name() {
305
+ return __privateGet(this, _name);
306
+ }
307
+ /* c8 ignore next 3 */
308
+ get webkitRelativePath() {
309
+ return "";
310
+ }
311
+ /**
312
+ * The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
313
+ */
314
+ get lastModified() {
315
+ return __privateGet(this, _lastModified);
316
+ }
317
+ get [Symbol.toStringTag]() {
318
+ return "File";
319
+ }
320
+ };
321
+ _name = /* @__PURE__ */ new WeakMap();
322
+ _lastModified = /* @__PURE__ */ new WeakMap();
323
+ var isFile = (value) => value instanceof File;
324
+ var _entries;
325
+ var _setEntry;
326
+ var setEntry_fn;
327
+ var FormData = class {
328
+ constructor() {
329
+ __privateAdd(this, _setEntry);
330
+ __privateAdd(this, _entries, /* @__PURE__ */ new Map());
331
+ }
332
+ static [Symbol.hasInstance](value) {
333
+ if (!value) {
334
+ return false;
335
+ }
336
+ const val = value;
337
+ return Boolean(
338
+ isFunction(val.constructor) && val[Symbol.toStringTag] === "FormData" && isFunction(val.append) && isFunction(val.set) && isFunction(val.get) && isFunction(val.getAll) && isFunction(val.has) && isFunction(val.delete) && isFunction(val.entries) && isFunction(val.values) && isFunction(val.keys) && isFunction(val[Symbol.iterator]) && isFunction(val.forEach)
339
+ );
340
+ }
341
+ /**
342
+ * Appends a new value onto an existing key inside a FormData object,
343
+ * or adds the key if it does not already exist.
344
+ *
345
+ * The difference between `set()` and `append()` is that if the specified key already exists, `set()` will overwrite all existing values with the new one, whereas `append()` will append the new value onto the end of the existing set of values.
346
+ *
347
+ * @param name The name of the field whose data is contained in `value`.
348
+ * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
349
+ or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
350
+ * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
351
+ */
352
+ append(name, value, fileName) {
353
+ __privateMethod(this, _setEntry, setEntry_fn).call(this, {
354
+ name,
355
+ fileName,
356
+ append: true,
357
+ rawValue: value,
358
+ argsLength: arguments.length
359
+ });
360
+ }
361
+ /**
362
+ * Set a new value for an existing key inside FormData,
363
+ * or add the new field if it does not already exist.
364
+ *
365
+ * @param name The name of the field whose data is contained in `value`.
366
+ * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
367
+ or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.
368
+ * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is "blob". The default filename for File objects is the file's filename.
369
+ *
370
+ */
371
+ set(name, value, fileName) {
372
+ __privateMethod(this, _setEntry, setEntry_fn).call(this, {
373
+ name,
374
+ fileName,
375
+ append: false,
376
+ rawValue: value,
377
+ argsLength: arguments.length
378
+ });
379
+ }
380
+ /**
381
+ * Returns the first value associated with a given key from within a `FormData` object.
382
+ * If you expect multiple values and want all of them, use the `getAll()` method instead.
383
+ *
384
+ * @param {string} name A name of the value you want to retrieve.
385
+ *
386
+ * @returns A `FormDataEntryValue` containing the value. If the key doesn't exist, the method returns null.
387
+ */
388
+ get(name) {
389
+ const field = __privateGet(this, _entries).get(String(name));
390
+ if (!field) {
391
+ return null;
392
+ }
393
+ return field[0];
394
+ }
395
+ /**
396
+ * Returns all the values associated with a given key from within a `FormData` object.
397
+ *
398
+ * @param {string} name A name of the value you want to retrieve.
399
+ *
400
+ * @returns An array of `FormDataEntryValue` whose key matches the value passed in the `name` parameter. If the key doesn't exist, the method returns an empty list.
401
+ */
402
+ getAll(name) {
403
+ const field = __privateGet(this, _entries).get(String(name));
404
+ if (!field) {
405
+ return [];
406
+ }
407
+ return field.slice();
408
+ }
409
+ /**
410
+ * Returns a boolean stating whether a `FormData` object contains a certain key.
411
+ *
412
+ * @param name A string representing the name of the key you want to test for.
413
+ *
414
+ * @return A boolean value.
415
+ */
416
+ has(name) {
417
+ return __privateGet(this, _entries).has(String(name));
418
+ }
419
+ /**
420
+ * Deletes a key and its value(s) from a `FormData` object.
421
+ *
422
+ * @param name The name of the key you want to delete.
423
+ */
424
+ delete(name) {
425
+ __privateGet(this, _entries).delete(String(name));
426
+ }
427
+ /**
428
+ * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all keys contained in this `FormData` object.
429
+ * Each key is a `string`.
430
+ */
431
+ *keys() {
432
+ for (const key of __privateGet(this, _entries).keys()) {
433
+ yield key;
434
+ }
435
+ }
436
+ /**
437
+ * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through the `FormData` key/value pairs.
438
+ * The key of each pair is a string; the value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
439
+ */
440
+ *entries() {
441
+ for (const name of this.keys()) {
442
+ const values = this.getAll(name);
443
+ for (const value of values) {
444
+ yield [name, value];
445
+ }
446
+ }
447
+ }
448
+ /**
449
+ * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all values contained in this object `FormData` object.
450
+ * Each value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).
451
+ */
452
+ *values() {
453
+ for (const [, value] of this) {
454
+ yield value;
455
+ }
456
+ }
457
+ /**
458
+ * An alias for FormData#entries()
459
+ */
460
+ [Symbol.iterator]() {
461
+ return this.entries();
462
+ }
463
+ /**
464
+ * Executes given callback function for each field of the FormData instance
465
+ */
466
+ forEach(callback, thisArg) {
467
+ for (const [name, value] of this) {
468
+ callback.call(thisArg, value, name, this);
469
+ }
470
+ }
471
+ get [Symbol.toStringTag]() {
472
+ return "FormData";
473
+ }
474
+ };
475
+ _entries = /* @__PURE__ */ new WeakMap();
476
+ _setEntry = /* @__PURE__ */ new WeakSet();
477
+ setEntry_fn = function({
478
+ name,
479
+ rawValue,
480
+ append,
481
+ fileName,
482
+ argsLength
483
+ }) {
484
+ const methodName = append ? "append" : "set";
485
+ if (argsLength < 2) {
486
+ throw new TypeError(
487
+ `Failed to execute '${methodName}' on 'FormData': 2 arguments required, but only ${argsLength} present.`
488
+ );
489
+ }
490
+ name = String(name);
491
+ let value;
492
+ if (isFile(rawValue)) {
493
+ value = fileName === void 0 ? rawValue : new File([rawValue], fileName, {
494
+ // otherwise, create new File with given fileName
495
+ type: rawValue.type,
496
+ lastModified: rawValue.lastModified
497
+ });
498
+ } else if (isBlob(rawValue)) {
499
+ value = new File([rawValue], fileName === void 0 ? "blob" : fileName, {
500
+ type: rawValue.type
501
+ });
502
+ } else if (fileName) {
503
+ throw new TypeError(
504
+ `Failed to execute '${methodName}' on 'FormData': parameter 2 is not of type 'Blob'.`
505
+ );
506
+ } else {
507
+ value = String(rawValue);
508
+ }
509
+ const values = __privateGet(this, _entries).get(name);
510
+ if (!values) {
511
+ return void __privateGet(this, _entries).set(name, [value]);
512
+ }
513
+ if (!append) {
514
+ return void __privateGet(this, _entries).set(name, [value]);
515
+ }
516
+ values.push(value);
517
+ };
518
+
519
+ // src/index.ts
520
+ function getSetting(runtime, key, defaultValue) {
521
+ return runtime.getSetting(key) ?? process.env[key] ?? defaultValue;
522
+ }
523
+ function getBaseURL(runtime) {
524
+ return getSetting(runtime, "OPENAI_BASE_URL", "https://api.openai.com/v1");
525
+ }
526
+ function getApiKey(runtime) {
527
+ return getSetting(runtime, "OPENAI_API_KEY");
528
+ }
529
+ function getSmallModel(runtime) {
530
+ return getSetting(runtime, "OPENAI_SMALL_MODEL") ?? getSetting(runtime, "SMALL_MODEL", "gpt-4o-mini");
531
+ }
532
+ function getLargeModel(runtime) {
533
+ return getSetting(runtime, "OPENAI_LARGE_MODEL") ?? getSetting(runtime, "LARGE_MODEL", "gpt-4o");
534
+ }
535
+ function createOpenAIClient(runtime) {
536
+ return createOpenAI({
537
+ apiKey: getApiKey(runtime),
538
+ baseURL: getBaseURL(runtime)
539
+ });
540
+ }
10
541
  async function tokenizeText(model, prompt) {
11
542
  const modelName = model === ModelType.TEXT_SMALL ? process.env.OPENAI_SMALL_MODEL ?? process.env.SMALL_MODEL ?? "gpt-4o-mini" : process.env.LARGE_MODEL ?? "gpt-4o";
12
543
  const encoding = encodingForModel(modelName);
@@ -31,18 +562,18 @@ var openaiPlugin = {
31
562
  OPENAI_EMBEDDING_MODEL: process.env.OPENAI_EMBEDDING_MODEL,
32
563
  OPENAI_EMBEDDING_DIMENSIONS: process.env.OPENAI_EMBEDDING_DIMENSIONS
33
564
  },
34
- async init(config) {
565
+ async init(_config, runtime) {
35
566
  try {
36
- if (!process.env.OPENAI_API_KEY) {
567
+ if (!getApiKey(runtime)) {
37
568
  logger.warn(
38
569
  "OPENAI_API_KEY is not set in environment - OpenAI functionality will be limited"
39
570
  );
40
571
  return;
41
572
  }
42
573
  try {
43
- const baseURL = process.env.OPENAI_BASE_URL ?? "https://api.openai.com/v1";
574
+ const baseURL = getBaseURL(runtime);
44
575
  const response = await fetch(`${baseURL}/models`, {
45
- headers: { Authorization: `Bearer ${process.env.OPENAI_API_KEY}` }
576
+ headers: { Authorization: `Bearer ${getApiKey(runtime)}` }
46
577
  });
47
578
  if (!response.ok) {
48
579
  logger.warn(`OpenAI API key validation failed: ${response.statusText}`);
@@ -62,7 +593,7 @@ var openaiPlugin = {
62
593
  models: {
63
594
  [ModelType.TEXT_EMBEDDING]: async (runtime, params) => {
64
595
  const embeddingDimension = parseInt(
65
- runtime.getSetting("OPENAI_EMBEDDING_DIMENSIONS") ?? "1536"
596
+ getSetting(runtime, "OPENAI_EMBEDDING_DIMENSIONS", "1536")
66
597
  );
67
598
  if (!Object.values(VECTOR_DIMS).includes(embeddingDimension)) {
68
599
  logger.error(
@@ -96,15 +627,15 @@ var openaiPlugin = {
96
627
  return emptyVector;
97
628
  }
98
629
  try {
99
- const baseURL = runtime.getSetting("OPENAI_BASE_URL") ?? "https://api.openai.com/v1";
630
+ const baseURL = getBaseURL(runtime);
100
631
  const response = await fetch(`${baseURL}/embeddings`, {
101
632
  method: "POST",
102
633
  headers: {
103
- Authorization: `Bearer ${runtime.getSetting("OPENAI_API_KEY")}`,
634
+ Authorization: `Bearer ${getApiKey(runtime)}`,
104
635
  "Content-Type": "application/json"
105
636
  },
106
637
  body: JSON.stringify({
107
- model: runtime.getSetting("OPENAI_EMBEDDING_MODEL") ?? "text-embedding-3-small",
638
+ model: getSetting(runtime, "OPENAI_EMBEDDING_MODEL", "text-embedding-3-small"),
108
639
  input: text
109
640
  })
110
641
  });
@@ -142,12 +673,8 @@ var openaiPlugin = {
142
673
  const frequency_penalty = 0.7;
143
674
  const presence_penalty = 0.7;
144
675
  const max_response_length = 8192;
145
- const baseURL = runtime.getSetting("OPENAI_BASE_URL") ?? "https://api.openai.com/v1";
146
- const openai = createOpenAI({
147
- apiKey: runtime.getSetting("OPENAI_API_KEY"),
148
- baseURL
149
- });
150
- const model = runtime.getSetting("OPENAI_SMALL_MODEL") ?? runtime.getSetting("SMALL_MODEL") ?? "gpt-4o-mini";
676
+ const openai = createOpenAIClient(runtime);
677
+ const model = getSmallModel(runtime);
151
678
  logger.log("generating text");
152
679
  logger.log(prompt);
153
680
  const { text: openaiResponse } = await generateText({
@@ -170,12 +697,8 @@ var openaiPlugin = {
170
697
  frequencyPenalty = 0.7,
171
698
  presencePenalty = 0.7
172
699
  }) => {
173
- const baseURL = runtime.getSetting("OPENAI_BASE_URL") ?? "https://api.openai.com/v1";
174
- const openai = createOpenAI({
175
- apiKey: runtime.getSetting("OPENAI_API_KEY"),
176
- baseURL
177
- });
178
- const model = runtime.getSetting("OPENAI_LARGE_MODEL") ?? runtime.getSetting("LARGE_MODEL") ?? "gpt-4o";
700
+ const openai = createOpenAIClient(runtime);
701
+ const model = getLargeModel(runtime);
179
702
  const { text: openaiResponse } = await generateText({
180
703
  model: openai.languageModel(model),
181
704
  prompt,
@@ -189,11 +712,11 @@ var openaiPlugin = {
189
712
  return openaiResponse;
190
713
  },
191
714
  [ModelType.IMAGE]: async (runtime, params) => {
192
- const baseURL = runtime.getSetting("OPENAI_BASE_URL") ?? "https://api.openai.com/v1";
715
+ const baseURL = getBaseURL(runtime);
193
716
  const response = await fetch(`${baseURL}/images/generations`, {
194
717
  method: "POST",
195
718
  headers: {
196
- Authorization: `Bearer ${runtime.getSetting("OPENAI_API_KEY")}`,
719
+ Authorization: `Bearer ${getApiKey(runtime)}`,
197
720
  "Content-Type": "application/json"
198
721
  },
199
722
  body: JSON.stringify({
@@ -220,8 +743,8 @@ var openaiPlugin = {
220
743
  prompt = params.prompt;
221
744
  }
222
745
  try {
223
- const baseURL = process.env.OPENAI_BASE_URL ?? "https://api.openai.com/v1";
224
- const apiKey = process.env.OPENAI_API_KEY;
746
+ const baseURL = getBaseURL(runtime);
747
+ const apiKey = getApiKey(runtime);
225
748
  if (!apiKey) {
226
749
  logger.error("OpenAI API key not set");
227
750
  return {
@@ -280,15 +803,14 @@ var openaiPlugin = {
280
803
  },
281
804
  [ModelType.TRANSCRIPTION]: async (runtime, audioBuffer) => {
282
805
  logger.log("audioBuffer", audioBuffer);
283
- const baseURL = runtime.getSetting("OPENAI_BASE_URL") ?? "https://api.openai.com/v1";
806
+ const baseURL = getBaseURL(runtime);
284
807
  const formData = new FormData();
285
808
  formData.append("file", new File([audioBuffer], "recording.mp3", { type: "audio/mp3" }));
286
809
  formData.append("model", "whisper-1");
287
810
  const response = await fetch(`${baseURL}/audio/transcriptions`, {
288
811
  method: "POST",
289
812
  headers: {
290
- Authorization: `Bearer ${runtime.getSetting("OPENAI_API_KEY")}`
291
- // Note: Do not set a Content-Type header—letting fetch set it for FormData is best
813
+ Authorization: `Bearer ${getApiKey(runtime)}`
292
814
  },
293
815
  body: formData
294
816
  });
@@ -300,12 +822,8 @@ var openaiPlugin = {
300
822
  return data.text;
301
823
  },
302
824
  [ModelType.OBJECT_SMALL]: async (runtime, params) => {
303
- const baseURL = runtime.getSetting("OPENAI_BASE_URL") ?? "https://api.openai.com/v1";
304
- const openai = createOpenAI({
305
- apiKey: runtime.getSetting("OPENAI_API_KEY"),
306
- baseURL
307
- });
308
- const model = runtime.getSetting("OPENAI_SMALL_MODEL") ?? runtime.getSetting("SMALL_MODEL") ?? "gpt-4o-mini";
825
+ const openai = createOpenAIClient(runtime);
826
+ const model = getSmallModel(runtime);
309
827
  try {
310
828
  if (params.schema) {
311
829
  logger.info("Using OBJECT_SMALL without schema validation");
@@ -330,12 +848,8 @@ var openaiPlugin = {
330
848
  }
331
849
  },
332
850
  [ModelType.OBJECT_LARGE]: async (runtime, params) => {
333
- const baseURL = runtime.getSetting("OPENAI_BASE_URL") ?? "https://api.openai.com/v1";
334
- const openai = createOpenAI({
335
- apiKey: runtime.getSetting("OPENAI_API_KEY"),
336
- baseURL
337
- });
338
- const model = runtime.getSetting("OPENAI_LARGE_MODEL") ?? runtime.getSetting("LARGE_MODEL") ?? "gpt-4o";
851
+ const openai = createOpenAIClient(runtime);
852
+ const model = getLargeModel(runtime);
339
853
  try {
340
854
  if (params.schema) {
341
855
  logger.info("Using OBJECT_LARGE without schema validation");
@@ -367,10 +881,10 @@ var openaiPlugin = {
367
881
  {
368
882
  name: "openai_test_url_and_api_key_validation",
369
883
  fn: async (runtime) => {
370
- const baseURL = runtime.getSetting("OPENAI_BASE_URL") ?? "https://api.openai.com/v1";
884
+ const baseURL = getBaseURL(runtime);
371
885
  const response = await fetch(`${baseURL}/models`, {
372
886
  headers: {
373
- Authorization: `Bearer ${runtime.getSetting("OPENAI_API_KEY")}`
887
+ Authorization: `Bearer ${getApiKey(runtime)}`
374
888
  }
375
889
  });
376
890
  const data = await response.json();
@@ -522,4 +1036,9 @@ export {
522
1036
  index_default as default,
523
1037
  openaiPlugin
524
1038
  };
1039
+ /*! Bundled license information:
1040
+
1041
+ formdata-node/lib/form-data.js:
1042
+ (*! Based on fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> & David Frank *)
1043
+ */
525
1044
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createOpenAI } from '@ai-sdk/openai';\nimport type {\n ImageDescriptionParams,\n ModelTypeName,\n ObjectGenerationParams,\n Plugin,\n TextEmbeddingParams,\n} from '@elizaos/core';\nimport {\n type DetokenizeTextParams,\n type GenerateTextParams,\n ModelType,\n type TokenizeTextParams,\n logger,\n VECTOR_DIMS,\n} from '@elizaos/core';\nimport { generateObject, generateText } from 'ai';\nimport { type TiktokenModel, encodingForModel } from 'js-tiktoken';\n\n/**\n * Asynchronously tokenizes the given text based on the specified model and prompt.\n *\n * @param {ModelTypeName} model - The type of model to use for tokenization.\n * @param {string} prompt - The text prompt to tokenize.\n * @returns {number[]} - An array of tokens representing the encoded prompt.\n */\nasync function tokenizeText(model: ModelTypeName, prompt: string) {\n const modelName =\n model === ModelType.TEXT_SMALL\n ? (process.env.OPENAI_SMALL_MODEL ?? process.env.SMALL_MODEL ?? 'gpt-4o-mini')\n : (process.env.LARGE_MODEL ?? 'gpt-4o');\n const encoding = encodingForModel(modelName as TiktokenModel);\n const tokens = encoding.encode(prompt);\n return tokens;\n}\n\n/**\n * Detokenize a sequence of tokens back into text using the specified model.\n *\n * @param {ModelTypeName} model - The type of model to use for detokenization.\n * @param {number[]} tokens - The sequence of tokens to detokenize.\n * @returns {string} The detokenized text.\n */\nasync function detokenizeText(model: ModelTypeName, tokens: number[]) {\n const modelName =\n model === ModelType.TEXT_SMALL\n ? (process.env.OPENAI_SMALL_MODEL ?? process.env.SMALL_MODEL ?? 'gpt-4o-mini')\n : (process.env.OPENAI_LARGE_MODEL ?? process.env.LARGE_MODEL ?? 'gpt-4o');\n const encoding = encodingForModel(modelName as TiktokenModel);\n return encoding.decode(tokens);\n}\n\n/**\n * Defines the OpenAI plugin with its name, description, and configuration options.\n * @type {Plugin}\n */\nexport const openaiPlugin: Plugin = {\n name: 'openai',\n description: 'OpenAI plugin',\n config: {\n OPENAI_API_KEY: process.env.OPENAI_API_KEY,\n OPENAI_BASE_URL: process.env.OPENAI_BASE_URL,\n OPENAI_SMALL_MODEL: process.env.OPENAI_SMALL_MODEL,\n OPENAI_LARGE_MODEL: process.env.OPENAI_LARGE_MODEL,\n SMALL_MODEL: process.env.SMALL_MODEL,\n LARGE_MODEL: process.env.LARGE_MODEL,\n OPENAI_EMBEDDING_MODEL: process.env.OPENAI_EMBEDDING_MODEL,\n OPENAI_EMBEDDING_DIMENSIONS: process.env.OPENAI_EMBEDDING_DIMENSIONS,\n },\n async init(config: Record<string, string>) {\n try {\n // const validatedConfig = await configSchema.parseAsync(config);\n\n // // Set all environment variables at once\n // for (const [key, value] of Object.entries(validatedConfig)) {\n // \tif (value) process.env[key] = value;\n // }\n\n // If API key is not set, we'll show a warning but continue\n if (!process.env.OPENAI_API_KEY) {\n logger.warn(\n 'OPENAI_API_KEY is not set in environment - OpenAI functionality will be limited'\n );\n // Return early without throwing an error\n return;\n }\n\n // Verify API key only if we have one\n try {\n const baseURL = process.env.OPENAI_BASE_URL ?? 'https://api.openai.com/v1';\n const response = await fetch(`${baseURL}/models`, {\n headers: { Authorization: `Bearer ${process.env.OPENAI_API_KEY}` },\n });\n\n if (!response.ok) {\n logger.warn(`OpenAI API key validation failed: ${response.statusText}`);\n logger.warn('OpenAI functionality will be limited until a valid API key is provided');\n // Continue execution instead of throwing\n } else {\n // logger.log(\"OpenAI API key validated successfully\");\n }\n } catch (fetchError) {\n logger.warn(`Error validating OpenAI API key: ${fetchError}`);\n logger.warn('OpenAI functionality will be limited until a valid API key is provided');\n // Continue execution instead of throwing\n }\n } catch (error) {\n // Convert to warning instead of error\n logger.warn(\n `OpenAI plugin configuration issue: ${error.errors\n .map((e) => e.message)\n .join(', ')} - You need to configure the OPENAI_API_KEY in your environment variables`\n );\n }\n },\n models: {\n [ModelType.TEXT_EMBEDDING]: async (\n runtime,\n params: TextEmbeddingParams | string | null\n ): Promise<number[]> => {\n const embeddingDimension = parseInt(\n runtime.getSetting('OPENAI_EMBEDDING_DIMENSIONS') ?? '1536'\n ) as (typeof VECTOR_DIMS)[keyof typeof VECTOR_DIMS];\n\n // Validate embedding dimension\n if (!Object.values(VECTOR_DIMS).includes(embeddingDimension)) {\n logger.error(\n `Invalid embedding dimension: ${embeddingDimension}. Must be one of: ${Object.values(VECTOR_DIMS).join(', ')}`\n );\n throw new Error(\n `Invalid embedding dimension: ${embeddingDimension}. Must be one of: ${Object.values(VECTOR_DIMS).join(', ')}`\n );\n }\n\n // Handle null input (initialization case)\n if (params === null) {\n logger.debug('Creating test embedding for initialization');\n // Return a consistent vector for null input\n const testVector = Array(embeddingDimension).fill(0);\n testVector[0] = 0.1; // Make it non-zero\n return testVector;\n }\n\n // Get the text from whatever format was provided\n let text: string;\n if (typeof params === 'string') {\n text = params; // Direct string input\n } else if (typeof params === 'object' && params.text) {\n text = params.text; // Object with text property\n } else {\n logger.warn('Invalid input format for embedding');\n // Return a fallback for invalid input\n const fallbackVector = Array(embeddingDimension).fill(0);\n fallbackVector[0] = 0.2; // Different value for tracking\n return fallbackVector;\n }\n\n // Skip API call for empty text\n if (!text.trim()) {\n logger.warn('Empty text for embedding');\n const emptyVector = Array(embeddingDimension).fill(0);\n emptyVector[0] = 0.3; // Different value for tracking\n return emptyVector;\n }\n\n try {\n const baseURL = runtime.getSetting('OPENAI_BASE_URL') ?? 'https://api.openai.com/v1';\n\n // Call the OpenAI API\n const response = await fetch(`${baseURL}/embeddings`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${runtime.getSetting('OPENAI_API_KEY')}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n model: runtime.getSetting('OPENAI_EMBEDDING_MODEL') ?? 'text-embedding-3-small',\n input: text,\n }),\n });\n\n if (!response.ok) {\n logger.error(`OpenAI API error: ${response.status} - ${response.statusText}`);\n const errorVector = Array(embeddingDimension).fill(0);\n errorVector[0] = 0.4; // Different value for tracking\n return errorVector;\n }\n\n const data = (await response.json()) as {\n data: [{ embedding: number[] }];\n };\n\n if (!data?.data?.[0]?.embedding) {\n logger.error('API returned invalid structure');\n const errorVector = Array(embeddingDimension).fill(0);\n errorVector[0] = 0.5; // Different value for tracking\n return errorVector;\n }\n\n const embedding = data.data[0].embedding;\n logger.log(`Got valid embedding with length ${embedding.length}`);\n return embedding;\n } catch (error) {\n logger.error('Error generating embedding:', error);\n const errorVector = Array(embeddingDimension).fill(0);\n errorVector[0] = 0.6; // Different value for tracking\n return errorVector;\n }\n },\n [ModelType.TEXT_TOKENIZER_ENCODE]: async (\n _runtime,\n { prompt, modelType = ModelType.TEXT_LARGE }: TokenizeTextParams\n ) => {\n return await tokenizeText(modelType ?? ModelType.TEXT_LARGE, prompt);\n },\n [ModelType.TEXT_TOKENIZER_DECODE]: async (\n _runtime,\n { tokens, modelType = ModelType.TEXT_LARGE }: DetokenizeTextParams\n ) => {\n return await detokenizeText(modelType ?? ModelType.TEXT_LARGE, tokens);\n },\n [ModelType.TEXT_SMALL]: async (runtime, { prompt, stopSequences = [] }: GenerateTextParams) => {\n const temperature = 0.7;\n const frequency_penalty = 0.7;\n const presence_penalty = 0.7;\n const max_response_length = 8192;\n\n const baseURL = runtime.getSetting('OPENAI_BASE_URL') ?? 'https://api.openai.com/v1';\n\n const openai = createOpenAI({\n apiKey: runtime.getSetting('OPENAI_API_KEY'),\n baseURL,\n });\n\n const model =\n runtime.getSetting('OPENAI_SMALL_MODEL') ??\n runtime.getSetting('SMALL_MODEL') ??\n 'gpt-4o-mini';\n\n logger.log('generating text');\n logger.log(prompt);\n\n const { text: openaiResponse } = await generateText({\n model: openai.languageModel(model),\n prompt: prompt,\n system: runtime.character.system ?? undefined,\n temperature: temperature,\n maxTokens: max_response_length,\n frequencyPenalty: frequency_penalty,\n presencePenalty: presence_penalty,\n stopSequences: stopSequences,\n });\n\n return openaiResponse;\n },\n [ModelType.TEXT_LARGE]: async (\n runtime,\n {\n prompt,\n stopSequences = [],\n maxTokens = 8192,\n temperature = 0.7,\n frequencyPenalty = 0.7,\n presencePenalty = 0.7,\n }: GenerateTextParams\n ) => {\n const baseURL = runtime.getSetting('OPENAI_BASE_URL') ?? 'https://api.openai.com/v1';\n\n const openai = createOpenAI({\n apiKey: runtime.getSetting('OPENAI_API_KEY'),\n baseURL,\n });\n\n const model =\n runtime.getSetting('OPENAI_LARGE_MODEL') ?? runtime.getSetting('LARGE_MODEL') ?? 'gpt-4o';\n\n const { text: openaiResponse } = await generateText({\n model: openai.languageModel(model),\n prompt: prompt,\n system: runtime.character.system ?? undefined,\n temperature: temperature,\n maxTokens: maxTokens,\n frequencyPenalty: frequencyPenalty,\n presencePenalty: presencePenalty,\n stopSequences: stopSequences,\n });\n\n return openaiResponse;\n },\n [ModelType.IMAGE]: async (\n runtime,\n params: {\n prompt: string;\n n?: number;\n size?: string;\n }\n ) => {\n const baseURL = runtime.getSetting('OPENAI_BASE_URL') ?? 'https://api.openai.com/v1';\n const response = await fetch(`${baseURL}/images/generations`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${runtime.getSetting('OPENAI_API_KEY')}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n prompt: params.prompt,\n n: params.n || 1,\n size: params.size || '1024x1024',\n }),\n });\n if (!response.ok) {\n throw new Error(`Failed to generate image: ${response.statusText}`);\n }\n const data = await response.json();\n const typedData = data as { data: { url: string }[] };\n return typedData.data;\n },\n [ModelType.IMAGE_DESCRIPTION]: async (runtime, params: ImageDescriptionParams | string) => {\n // Handle string case (direct URL)\n let imageUrl: string;\n let prompt: string | undefined;\n\n if (typeof params === 'string') {\n imageUrl = params;\n prompt = undefined;\n } else {\n // Object parameter case\n imageUrl = params.imageUrl;\n prompt = params.prompt;\n }\n\n try {\n const baseURL = process.env.OPENAI_BASE_URL ?? 'https://api.openai.com/v1';\n const apiKey = process.env.OPENAI_API_KEY;\n\n if (!apiKey) {\n logger.error('OpenAI API key not set');\n return {\n title: 'Failed to analyze image',\n description: 'API key not configured',\n };\n }\n\n // Call the GPT-4 Vision API\n const response = await fetch(`${baseURL}/chat/completions`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify({\n model: 'gpt-4-vision-preview',\n messages: [\n {\n role: 'user',\n content: [\n {\n type: 'text',\n text:\n prompt ||\n 'Please analyze this image and provide a title and detailed description.',\n },\n {\n type: 'image_url',\n image_url: { url: imageUrl },\n },\n ],\n },\n ],\n max_tokens: 300,\n }),\n });\n\n if (!response.ok) {\n throw new Error(`OpenAI API error: ${response.status}`);\n }\n\n const result: any = await response.json();\n const content = result.choices?.[0]?.message?.content;\n\n if (!content) {\n return {\n title: 'Failed to analyze image',\n description: 'No response from API',\n };\n }\n\n // Extract title and description\n const titleMatch = content.match(/title[:\\s]+(.+?)(?:\\n|$)/i);\n const title = titleMatch?.[1] || 'Image Analysis';\n\n // Rest of content is the description\n const description = content.replace(/title[:\\s]+(.+?)(?:\\n|$)/i, '').trim();\n\n return { title, description };\n } catch (error) {\n logger.error('Error analyzing image:', error);\n return {\n title: 'Failed to analyze image',\n description: `Error: ${error instanceof Error ? error.message : String(error)}`,\n };\n }\n },\n [ModelType.TRANSCRIPTION]: async (runtime, audioBuffer: Buffer) => {\n logger.log('audioBuffer', audioBuffer);\n const baseURL = runtime.getSetting('OPENAI_BASE_URL') ?? 'https://api.openai.com/v1';\n const formData = new FormData();\n\n formData.append('file', new File([audioBuffer], 'recording.mp3', { type: 'audio/mp3' }));\n formData.append('model', 'whisper-1');\n const response = await fetch(`${baseURL}/audio/transcriptions`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${runtime.getSetting('OPENAI_API_KEY')}`,\n // Note: Do not set a Content-Type header—letting fetch set it for FormData is best\n },\n body: formData,\n });\n\n logger.log('response', response);\n if (!response.ok) {\n throw new Error(`Failed to transcribe audio: ${response.statusText}`);\n }\n const data = (await response.json()) as { text: string };\n return data.text;\n },\n [ModelType.OBJECT_SMALL]: async (runtime, params: ObjectGenerationParams) => {\n const baseURL = runtime.getSetting('OPENAI_BASE_URL') ?? 'https://api.openai.com/v1';\n const openai = createOpenAI({\n apiKey: runtime.getSetting('OPENAI_API_KEY'),\n baseURL,\n });\n const model =\n runtime.getSetting('OPENAI_SMALL_MODEL') ??\n runtime.getSetting('SMALL_MODEL') ??\n 'gpt-4o-mini';\n\n try {\n if (params.schema) {\n // Skip zod validation and just use the generateObject without schema\n logger.info('Using OBJECT_SMALL without schema validation');\n const { object } = await generateObject({\n model: openai.languageModel(model),\n output: 'no-schema',\n prompt: params.prompt,\n temperature: params.temperature,\n });\n return object;\n }\n\n const { object } = await generateObject({\n model: openai.languageModel(model),\n output: 'no-schema',\n prompt: params.prompt,\n temperature: params.temperature,\n });\n return object;\n } catch (error) {\n logger.error('Error generating object:', error);\n throw error;\n }\n },\n [ModelType.OBJECT_LARGE]: async (runtime, params: ObjectGenerationParams) => {\n const baseURL = runtime.getSetting('OPENAI_BASE_URL') ?? 'https://api.openai.com/v1';\n const openai = createOpenAI({\n apiKey: runtime.getSetting('OPENAI_API_KEY'),\n baseURL,\n });\n const model =\n runtime.getSetting('OPENAI_LARGE_MODEL') ?? runtime.getSetting('LARGE_MODEL') ?? 'gpt-4o';\n\n try {\n if (params.schema) {\n // Skip zod validation and just use the generateObject without schema\n logger.info('Using OBJECT_LARGE without schema validation');\n const { object } = await generateObject({\n model: openai.languageModel(model),\n output: 'no-schema',\n prompt: params.prompt,\n temperature: params.temperature,\n });\n return object;\n }\n\n const { object } = await generateObject({\n model: openai.languageModel(model),\n output: 'no-schema',\n prompt: params.prompt,\n temperature: params.temperature,\n });\n return object;\n } catch (error) {\n logger.error('Error generating object:', error);\n throw error;\n }\n },\n },\n tests: [\n {\n name: 'openai_plugin_tests',\n tests: [\n {\n name: 'openai_test_url_and_api_key_validation',\n fn: async (runtime) => {\n const baseURL = runtime.getSetting('OPENAI_BASE_URL') ?? 'https://api.openai.com/v1';\n const response = await fetch(`${baseURL}/models`, {\n headers: {\n Authorization: `Bearer ${runtime.getSetting('OPENAI_API_KEY')}`,\n },\n });\n const data = await response.json();\n logger.log('Models Available:', (data as any)?.data.length);\n if (!response.ok) {\n throw new Error(`Failed to validate OpenAI API key: ${response.statusText}`);\n }\n },\n },\n {\n name: 'openai_test_text_embedding',\n fn: async (runtime) => {\n try {\n const embedding = await runtime.useModel(ModelType.TEXT_EMBEDDING, {\n text: 'Hello, world!',\n });\n logger.log('embedding', embedding);\n } catch (error) {\n logger.error('Error in test_text_embedding:', error);\n throw error;\n }\n },\n },\n {\n name: 'openai_test_text_large',\n fn: async (runtime) => {\n try {\n const text = await runtime.useModel(ModelType.TEXT_LARGE, {\n prompt: 'What is the nature of reality in 10 words?',\n });\n if (text.length === 0) {\n throw new Error('Failed to generate text');\n }\n logger.log('generated with test_text_large:', text);\n } catch (error) {\n logger.error('Error in test_text_large:', error);\n throw error;\n }\n },\n },\n {\n name: 'openai_test_text_small',\n fn: async (runtime) => {\n try {\n const text = await runtime.useModel(ModelType.TEXT_SMALL, {\n prompt: 'What is the nature of reality in 10 words?',\n });\n if (text.length === 0) {\n throw new Error('Failed to generate text');\n }\n logger.log('generated with test_text_small:', text);\n } catch (error) {\n logger.error('Error in test_text_small:', error);\n throw error;\n }\n },\n },\n {\n name: 'openai_test_image_generation',\n fn: async (runtime) => {\n logger.log('openai_test_image_generation');\n try {\n const image = await runtime.useModel(ModelType.IMAGE, {\n prompt: 'A beautiful sunset over a calm ocean',\n n: 1,\n size: '1024x1024',\n });\n logger.log('generated with test_image_generation:', image);\n } catch (error) {\n logger.error('Error in test_image_generation:', error);\n throw error;\n }\n },\n },\n {\n name: 'image-description',\n fn: async (runtime) => {\n try {\n logger.log('openai_test_image_description');\n try {\n const result = await runtime.useModel(\n ModelType.IMAGE_DESCRIPTION,\n 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Vitalik_Buterin_TechCrunch_London_2015_%28cropped%29.jpg/537px-Vitalik_Buterin_TechCrunch_London_2015_%28cropped%29.jpg'\n );\n\n // Check if result has the expected structure\n if (\n result &&\n typeof result === 'object' &&\n 'title' in result &&\n 'description' in result\n ) {\n logger.log('Image description:', result);\n } else {\n logger.error('Invalid image description result format:', result);\n }\n } catch (e) {\n logger.error('Error in image description test:', e);\n }\n } catch (e) {\n logger.error('Error in openai_test_image_description:', e);\n }\n },\n },\n {\n name: 'openai_test_transcription',\n fn: async (runtime) => {\n logger.log('openai_test_transcription');\n try {\n const response = await fetch(\n 'https://upload.wikimedia.org/wikipedia/en/4/40/Chris_Benoit_Voice_Message.ogg'\n );\n const arrayBuffer = await response.arrayBuffer();\n const transcription = await runtime.useModel(\n ModelType.TRANSCRIPTION,\n Buffer.from(new Uint8Array(arrayBuffer))\n );\n logger.log('generated with test_transcription:', transcription);\n } catch (error) {\n logger.error('Error in test_transcription:', error);\n throw error;\n }\n },\n },\n {\n name: 'openai_test_text_tokenizer_encode',\n fn: async (runtime) => {\n const prompt = 'Hello tokenizer encode!';\n const tokens = await runtime.useModel(ModelType.TEXT_TOKENIZER_ENCODE, { prompt });\n if (!Array.isArray(tokens) || tokens.length === 0) {\n throw new Error('Failed to tokenize text: expected non-empty array of tokens');\n }\n logger.log('Tokenized output:', tokens);\n },\n },\n {\n name: 'openai_test_text_tokenizer_decode',\n fn: async (runtime) => {\n const prompt = 'Hello tokenizer decode!';\n // Encode the string into tokens first\n const tokens = await runtime.useModel(ModelType.TEXT_TOKENIZER_ENCODE, { prompt });\n // Now decode tokens back into text\n const decodedText = await runtime.useModel(ModelType.TEXT_TOKENIZER_DECODE, { tokens });\n if (decodedText !== prompt) {\n throw new Error(\n `Decoded text does not match original. Expected \"${prompt}\", got \"${decodedText}\"`\n );\n }\n logger.log('Decoded text:', decodedText);\n },\n },\n ],\n },\n ],\n};\nexport default openaiPlugin;\n"],"mappings":";AAAA,SAAS,oBAAoB;AAQ7B;AAAA,EAGE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB,oBAAoB;AAC7C,SAA6B,wBAAwB;AASrD,eAAe,aAAa,OAAsB,QAAgB;AAChE,QAAM,YACJ,UAAU,UAAU,aACf,QAAQ,IAAI,sBAAsB,QAAQ,IAAI,eAAe,gBAC7D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,SAAS,MAAM,QAAQ,SAAS,UAAU,uBAAuB,EAAE,OAAO,CAAC;AACjF,gBAAI,CAAC,MAAM,QAAQ,MAAM,KAAK,OAAO,WAAW,GAAG;AACjD,oBAAM,IAAI,MAAM,6DAA6D;AAAA,YAC/E;AACA,mBAAO,IAAI,qBAAqB,MAAM;AAAA,UACxC;AAAA,QACF;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,IAAI,OAAO,YAAY;AACrB,kBAAM,SAAS;AAEf,kBAAM,SAAS,MAAM,QAAQ,SAAS,UAAU,uBAAuB,EAAE,OAAO,CAAC;AAEjF,kBAAM,cAAc,MAAM,QAAQ,SAAS,UAAU,uBAAuB,EAAE,OAAO,CAAC;AACtF,gBAAI,gBAAgB,QAAQ;AAC1B,oBAAM,IAAI;AAAA,gBACR,mDAAmD,MAAM,WAAW,WAAW;AAAA,cACjF;AAAA,YACF;AACA,mBAAO,IAAI,iBAAiB,WAAW;AAAA,UACzC;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AACA,IAAO,gBAAQ;","names":["object"]}
1
+ {"version":3,"sources":["../src/index.ts","../../../node_modules/formdata-node/lib/form-data.js"],"sourcesContent":["import { createOpenAI } from '@ai-sdk/openai';\nimport type {\n ImageDescriptionParams,\n ModelTypeName,\n ObjectGenerationParams,\n Plugin,\n TextEmbeddingParams,\n} from '@elizaos/core';\nimport {\n type DetokenizeTextParams,\n type GenerateTextParams,\n ModelType,\n type TokenizeTextParams,\n logger,\n VECTOR_DIMS,\n} from '@elizaos/core';\nimport { generateObject, generateText } from 'ai';\nimport { type TiktokenModel, encodingForModel } from 'js-tiktoken';\nimport { FormData as NodeFormData, File as NodeFile } from 'formdata-node';\n\n/**\n * Helper function to get settings with fallback to process.env\n *\n * @param runtime The runtime context\n * @param key The setting key to retrieve\n * @param defaultValue Optional default value if not found\n * @returns The setting value with proper fallbacks\n */\nfunction getSetting(runtime: any, key: string, defaultValue?: string): string | undefined {\n return runtime.getSetting(key) ?? process.env[key] ?? defaultValue;\n}\n\n/**\n * Helper function to get the base URL for OpenAI API\n *\n * @param runtime The runtime context\n * @returns The configured base URL or default\n */\nfunction getBaseURL(runtime: any): string {\n return getSetting(runtime, 'OPENAI_BASE_URL', 'https://api.openai.com/v1');\n}\n\n/**\n * Helper function to get the API key for OpenAI\n *\n * @param runtime The runtime context\n * @returns The configured API key\n */\nfunction getApiKey(runtime: any): string | undefined {\n return getSetting(runtime, 'OPENAI_API_KEY');\n}\n\n/**\n * Helper function to get the small model name with fallbacks\n *\n * @param runtime The runtime context\n * @returns The configured small model name\n */\nfunction getSmallModel(runtime: any): string {\n return (\n getSetting(runtime, 'OPENAI_SMALL_MODEL') ?? getSetting(runtime, 'SMALL_MODEL', 'gpt-4o-mini')\n );\n}\n\n/**\n * Helper function to get the large model name with fallbacks\n *\n * @param runtime The runtime context\n * @returns The configured large model name\n */\nfunction getLargeModel(runtime: any): string {\n return getSetting(runtime, 'OPENAI_LARGE_MODEL') ?? getSetting(runtime, 'LARGE_MODEL', 'gpt-4o');\n}\n\n/**\n * Create an OpenAI client with proper configuration\n *\n * @param runtime The runtime context\n * @returns Configured OpenAI client\n */\nfunction createOpenAIClient(runtime: any) {\n return createOpenAI({\n apiKey: getApiKey(runtime),\n baseURL: getBaseURL(runtime),\n });\n}\n\n/**\n * Asynchronously tokenizes the given text based on the specified model and prompt.\n *\n * @param {ModelTypeName} model - The type of model to use for tokenization.\n * @param {string} prompt - The text prompt to tokenize.\n * @returns {number[]} - An array of tokens representing the encoded prompt.\n */\nasync function tokenizeText(model: ModelTypeName, prompt: string) {\n const modelName =\n model === ModelType.TEXT_SMALL\n ? (process.env.OPENAI_SMALL_MODEL ?? process.env.SMALL_MODEL ?? 'gpt-4o-mini')\n : (process.env.LARGE_MODEL ?? 'gpt-4o');\n const encoding = encodingForModel(modelName as TiktokenModel);\n const tokens = encoding.encode(prompt);\n return tokens;\n}\n\n/**\n * Detokenize a sequence of tokens back into text using the specified model.\n *\n * @param {ModelTypeName} model - The type of model to use for detokenization.\n * @param {number[]} tokens - The sequence of tokens to detokenize.\n * @returns {string} The detokenized text.\n */\nasync function detokenizeText(model: ModelTypeName, tokens: number[]) {\n const modelName =\n model === ModelType.TEXT_SMALL\n ? (process.env.OPENAI_SMALL_MODEL ?? process.env.SMALL_MODEL ?? 'gpt-4o-mini')\n : (process.env.OPENAI_LARGE_MODEL ?? process.env.LARGE_MODEL ?? 'gpt-4o');\n const encoding = encodingForModel(modelName as TiktokenModel);\n return encoding.decode(tokens);\n}\n\n/**\n * Defines the OpenAI plugin with its name, description, and configuration options.\n * @type {Plugin}\n */\nexport const openaiPlugin: Plugin = {\n name: 'openai',\n description: 'OpenAI plugin',\n config: {\n OPENAI_API_KEY: process.env.OPENAI_API_KEY,\n OPENAI_BASE_URL: process.env.OPENAI_BASE_URL,\n OPENAI_SMALL_MODEL: process.env.OPENAI_SMALL_MODEL,\n OPENAI_LARGE_MODEL: process.env.OPENAI_LARGE_MODEL,\n SMALL_MODEL: process.env.SMALL_MODEL,\n LARGE_MODEL: process.env.LARGE_MODEL,\n OPENAI_EMBEDDING_MODEL: process.env.OPENAI_EMBEDDING_MODEL,\n OPENAI_EMBEDDING_DIMENSIONS: process.env.OPENAI_EMBEDDING_DIMENSIONS,\n },\n async init(_config, runtime) {\n try {\n // const validatedConfig = await configSchema.parseAsync(config);\n\n // // Set all environment variables at once\n // for (const [key, value] of Object.entries(validatedConfig)) {\n // \tif (value) process.env[key] = value;\n // }\n\n // If API key is not set, we'll show a warning but continue\n if (!getApiKey(runtime)) {\n logger.warn(\n 'OPENAI_API_KEY is not set in environment - OpenAI functionality will be limited'\n );\n // Return early without throwing an error\n return;\n }\n\n // Verify API key only if we have one\n try {\n const baseURL = getBaseURL(runtime);\n const response = await fetch(`${baseURL}/models`, {\n headers: { Authorization: `Bearer ${getApiKey(runtime)}` },\n });\n\n if (!response.ok) {\n logger.warn(`OpenAI API key validation failed: ${response.statusText}`);\n logger.warn('OpenAI functionality will be limited until a valid API key is provided');\n // Continue execution instead of throwing\n } else {\n // logger.log(\"OpenAI API key validated successfully\");\n }\n } catch (fetchError) {\n logger.warn(`Error validating OpenAI API key: ${fetchError}`);\n logger.warn('OpenAI functionality will be limited until a valid API key is provided');\n // Continue execution instead of throwing\n }\n } catch (error) {\n // Convert to warning instead of error\n logger.warn(\n `OpenAI plugin configuration issue: ${error.errors\n .map((e) => e.message)\n .join(', ')} - You need to configure the OPENAI_API_KEY in your environment variables`\n );\n }\n },\n models: {\n [ModelType.TEXT_EMBEDDING]: async (\n runtime,\n params: TextEmbeddingParams | string | null\n ): Promise<number[]> => {\n const embeddingDimension = parseInt(\n getSetting(runtime, 'OPENAI_EMBEDDING_DIMENSIONS', '1536')\n ) as (typeof VECTOR_DIMS)[keyof typeof VECTOR_DIMS];\n\n // Validate embedding dimension\n if (!Object.values(VECTOR_DIMS).includes(embeddingDimension)) {\n logger.error(\n `Invalid embedding dimension: ${embeddingDimension}. Must be one of: ${Object.values(VECTOR_DIMS).join(', ')}`\n );\n throw new Error(\n `Invalid embedding dimension: ${embeddingDimension}. Must be one of: ${Object.values(VECTOR_DIMS).join(', ')}`\n );\n }\n\n // Handle null input (initialization case)\n if (params === null) {\n logger.debug('Creating test embedding for initialization');\n // Return a consistent vector for null input\n const testVector = Array(embeddingDimension).fill(0);\n testVector[0] = 0.1; // Make it non-zero\n return testVector;\n }\n\n // Get the text from whatever format was provided\n let text: string;\n if (typeof params === 'string') {\n text = params; // Direct string input\n } else if (typeof params === 'object' && params.text) {\n text = params.text; // Object with text property\n } else {\n logger.warn('Invalid input format for embedding');\n // Return a fallback for invalid input\n const fallbackVector = Array(embeddingDimension).fill(0);\n fallbackVector[0] = 0.2; // Different value for tracking\n return fallbackVector;\n }\n\n // Skip API call for empty text\n if (!text.trim()) {\n logger.warn('Empty text for embedding');\n const emptyVector = Array(embeddingDimension).fill(0);\n emptyVector[0] = 0.3; // Different value for tracking\n return emptyVector;\n }\n\n try {\n const baseURL = getBaseURL(runtime);\n\n // Call the OpenAI API\n const response = await fetch(`${baseURL}/embeddings`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${getApiKey(runtime)}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n model: getSetting(runtime, 'OPENAI_EMBEDDING_MODEL', 'text-embedding-3-small'),\n input: text,\n }),\n });\n\n if (!response.ok) {\n logger.error(`OpenAI API error: ${response.status} - ${response.statusText}`);\n const errorVector = Array(embeddingDimension).fill(0);\n errorVector[0] = 0.4; // Different value for tracking\n return errorVector;\n }\n\n const data = (await response.json()) as {\n data: [{ embedding: number[] }];\n };\n\n if (!data?.data?.[0]?.embedding) {\n logger.error('API returned invalid structure');\n const errorVector = Array(embeddingDimension).fill(0);\n errorVector[0] = 0.5; // Different value for tracking\n return errorVector;\n }\n\n const embedding = data.data[0].embedding;\n logger.log(`Got valid embedding with length ${embedding.length}`);\n return embedding;\n } catch (error) {\n logger.error('Error generating embedding:', error);\n const errorVector = Array(embeddingDimension).fill(0);\n errorVector[0] = 0.6; // Different value for tracking\n return errorVector;\n }\n },\n [ModelType.TEXT_TOKENIZER_ENCODE]: async (\n _runtime,\n { prompt, modelType = ModelType.TEXT_LARGE }: TokenizeTextParams\n ) => {\n return await tokenizeText(modelType ?? ModelType.TEXT_LARGE, prompt);\n },\n [ModelType.TEXT_TOKENIZER_DECODE]: async (\n _runtime,\n { tokens, modelType = ModelType.TEXT_LARGE }: DetokenizeTextParams\n ) => {\n return await detokenizeText(modelType ?? ModelType.TEXT_LARGE, tokens);\n },\n [ModelType.TEXT_SMALL]: async (runtime, { prompt, stopSequences = [] }: GenerateTextParams) => {\n const temperature = 0.7;\n const frequency_penalty = 0.7;\n const presence_penalty = 0.7;\n const max_response_length = 8192;\n\n const openai = createOpenAIClient(runtime);\n const model = getSmallModel(runtime);\n\n logger.log('generating text');\n logger.log(prompt);\n\n const { text: openaiResponse } = await generateText({\n model: openai.languageModel(model),\n prompt: prompt,\n system: runtime.character.system ?? undefined,\n temperature: temperature,\n maxTokens: max_response_length,\n frequencyPenalty: frequency_penalty,\n presencePenalty: presence_penalty,\n stopSequences: stopSequences,\n });\n\n return openaiResponse;\n },\n [ModelType.TEXT_LARGE]: async (\n runtime,\n {\n prompt,\n stopSequences = [],\n maxTokens = 8192,\n temperature = 0.7,\n frequencyPenalty = 0.7,\n presencePenalty = 0.7,\n }: GenerateTextParams\n ) => {\n const openai = createOpenAIClient(runtime);\n const model = getLargeModel(runtime);\n\n const { text: openaiResponse } = await generateText({\n model: openai.languageModel(model),\n prompt: prompt,\n system: runtime.character.system ?? undefined,\n temperature: temperature,\n maxTokens: maxTokens,\n frequencyPenalty: frequencyPenalty,\n presencePenalty: presencePenalty,\n stopSequences: stopSequences,\n });\n\n return openaiResponse;\n },\n [ModelType.IMAGE]: async (\n runtime,\n params: {\n prompt: string;\n n?: number;\n size?: string;\n }\n ) => {\n const baseURL = getBaseURL(runtime);\n const response = await fetch(`${baseURL}/images/generations`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${getApiKey(runtime)}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n prompt: params.prompt,\n n: params.n || 1,\n size: params.size || '1024x1024',\n }),\n });\n if (!response.ok) {\n throw new Error(`Failed to generate image: ${response.statusText}`);\n }\n const data = await response.json();\n const typedData = data as { data: { url: string }[] };\n return typedData.data;\n },\n [ModelType.IMAGE_DESCRIPTION]: async (runtime, params: ImageDescriptionParams | string) => {\n // Handle string case (direct URL)\n let imageUrl: string;\n let prompt: string | undefined;\n\n if (typeof params === 'string') {\n imageUrl = params;\n prompt = undefined;\n } else {\n // Object parameter case\n imageUrl = params.imageUrl;\n prompt = params.prompt;\n }\n\n try {\n const baseURL = getBaseURL(runtime);\n const apiKey = getApiKey(runtime);\n\n if (!apiKey) {\n logger.error('OpenAI API key not set');\n return {\n title: 'Failed to analyze image',\n description: 'API key not configured',\n };\n }\n\n // Call the GPT-4 Vision API\n const response = await fetch(`${baseURL}/chat/completions`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify({\n model: 'gpt-4-vision-preview',\n messages: [\n {\n role: 'user',\n content: [\n {\n type: 'text',\n text:\n prompt ||\n 'Please analyze this image and provide a title and detailed description.',\n },\n {\n type: 'image_url',\n image_url: { url: imageUrl },\n },\n ],\n },\n ],\n max_tokens: 300,\n }),\n });\n\n if (!response.ok) {\n throw new Error(`OpenAI API error: ${response.status}`);\n }\n\n const result: any = await response.json();\n const content = result.choices?.[0]?.message?.content;\n\n if (!content) {\n return {\n title: 'Failed to analyze image',\n description: 'No response from API',\n };\n }\n\n // Extract title and description\n const titleMatch = content.match(/title[:\\s]+(.+?)(?:\\n|$)/i);\n const title = titleMatch?.[1] || 'Image Analysis';\n\n // Rest of content is the description\n const description = content.replace(/title[:\\s]+(.+?)(?:\\n|$)/i, '').trim();\n\n return { title, description };\n } catch (error) {\n logger.error('Error analyzing image:', error);\n return {\n title: 'Failed to analyze image',\n description: `Error: ${error instanceof Error ? error.message : String(error)}`,\n };\n }\n },\n [ModelType.TRANSCRIPTION]: async (runtime, audioBuffer: Buffer) => {\n logger.log('audioBuffer', audioBuffer);\n const baseURL = getBaseURL(runtime);\n\n const formData = new NodeFormData();\n formData.append('file', new NodeFile([audioBuffer], 'recording.mp3', { type: 'audio/mp3' }));\n formData.append('model', 'whisper-1');\n\n const response = await fetch(`${baseURL}/audio/transcriptions`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${getApiKey(runtime)}`,\n },\n body: formData,\n });\n\n logger.log('response', response);\n if (!response.ok) {\n throw new Error(`Failed to transcribe audio: ${response.statusText}`);\n }\n\n const data = (await response.json()) as { text: string };\n return data.text;\n },\n [ModelType.OBJECT_SMALL]: async (runtime, params: ObjectGenerationParams) => {\n const openai = createOpenAIClient(runtime);\n const model = getSmallModel(runtime);\n\n try {\n if (params.schema) {\n // Skip zod validation and just use the generateObject without schema\n logger.info('Using OBJECT_SMALL without schema validation');\n const { object } = await generateObject({\n model: openai.languageModel(model),\n output: 'no-schema',\n prompt: params.prompt,\n temperature: params.temperature,\n });\n return object;\n }\n\n const { object } = await generateObject({\n model: openai.languageModel(model),\n output: 'no-schema',\n prompt: params.prompt,\n temperature: params.temperature,\n });\n return object;\n } catch (error) {\n logger.error('Error generating object:', error);\n throw error;\n }\n },\n [ModelType.OBJECT_LARGE]: async (runtime, params: ObjectGenerationParams) => {\n const openai = createOpenAIClient(runtime);\n const model = getLargeModel(runtime);\n\n try {\n if (params.schema) {\n // Skip zod validation and just use the generateObject without schema\n logger.info('Using OBJECT_LARGE without schema validation');\n const { object } = await generateObject({\n model: openai.languageModel(model),\n output: 'no-schema',\n prompt: params.prompt,\n temperature: params.temperature,\n });\n return object;\n }\n\n const { object } = await generateObject({\n model: openai.languageModel(model),\n output: 'no-schema',\n prompt: params.prompt,\n temperature: params.temperature,\n });\n return object;\n } catch (error) {\n logger.error('Error generating object:', error);\n throw error;\n }\n },\n },\n tests: [\n {\n name: 'openai_plugin_tests',\n tests: [\n {\n name: 'openai_test_url_and_api_key_validation',\n fn: async (runtime) => {\n const baseURL = getBaseURL(runtime);\n const response = await fetch(`${baseURL}/models`, {\n headers: {\n Authorization: `Bearer ${getApiKey(runtime)}`,\n },\n });\n const data = await response.json();\n logger.log('Models Available:', (data as any)?.data.length);\n if (!response.ok) {\n throw new Error(`Failed to validate OpenAI API key: ${response.statusText}`);\n }\n },\n },\n {\n name: 'openai_test_text_embedding',\n fn: async (runtime) => {\n try {\n const embedding = await runtime.useModel(ModelType.TEXT_EMBEDDING, {\n text: 'Hello, world!',\n });\n logger.log('embedding', embedding);\n } catch (error) {\n logger.error('Error in test_text_embedding:', error);\n throw error;\n }\n },\n },\n {\n name: 'openai_test_text_large',\n fn: async (runtime) => {\n try {\n const text = await runtime.useModel(ModelType.TEXT_LARGE, {\n prompt: 'What is the nature of reality in 10 words?',\n });\n if (text.length === 0) {\n throw new Error('Failed to generate text');\n }\n logger.log('generated with test_text_large:', text);\n } catch (error) {\n logger.error('Error in test_text_large:', error);\n throw error;\n }\n },\n },\n {\n name: 'openai_test_text_small',\n fn: async (runtime) => {\n try {\n const text = await runtime.useModel(ModelType.TEXT_SMALL, {\n prompt: 'What is the nature of reality in 10 words?',\n });\n if (text.length === 0) {\n throw new Error('Failed to generate text');\n }\n logger.log('generated with test_text_small:', text);\n } catch (error) {\n logger.error('Error in test_text_small:', error);\n throw error;\n }\n },\n },\n {\n name: 'openai_test_image_generation',\n fn: async (runtime) => {\n logger.log('openai_test_image_generation');\n try {\n const image = await runtime.useModel(ModelType.IMAGE, {\n prompt: 'A beautiful sunset over a calm ocean',\n n: 1,\n size: '1024x1024',\n });\n logger.log('generated with test_image_generation:', image);\n } catch (error) {\n logger.error('Error in test_image_generation:', error);\n throw error;\n }\n },\n },\n {\n name: 'image-description',\n fn: async (runtime) => {\n try {\n logger.log('openai_test_image_description');\n try {\n const result = await runtime.useModel(\n ModelType.IMAGE_DESCRIPTION,\n 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Vitalik_Buterin_TechCrunch_London_2015_%28cropped%29.jpg/537px-Vitalik_Buterin_TechCrunch_London_2015_%28cropped%29.jpg'\n );\n\n // Check if result has the expected structure\n if (\n result &&\n typeof result === 'object' &&\n 'title' in result &&\n 'description' in result\n ) {\n logger.log('Image description:', result);\n } else {\n logger.error('Invalid image description result format:', result);\n }\n } catch (e) {\n logger.error('Error in image description test:', e);\n }\n } catch (e) {\n logger.error('Error in openai_test_image_description:', e);\n }\n },\n },\n {\n name: 'openai_test_transcription',\n fn: async (runtime) => {\n logger.log('openai_test_transcription');\n try {\n const response = await fetch(\n 'https://upload.wikimedia.org/wikipedia/en/4/40/Chris_Benoit_Voice_Message.ogg'\n );\n const arrayBuffer = await response.arrayBuffer();\n const transcription = await runtime.useModel(\n ModelType.TRANSCRIPTION,\n Buffer.from(new Uint8Array(arrayBuffer))\n );\n logger.log('generated with test_transcription:', transcription);\n } catch (error) {\n logger.error('Error in test_transcription:', error);\n throw error;\n }\n },\n },\n {\n name: 'openai_test_text_tokenizer_encode',\n fn: async (runtime) => {\n const prompt = 'Hello tokenizer encode!';\n const tokens = await runtime.useModel(ModelType.TEXT_TOKENIZER_ENCODE, { prompt });\n if (!Array.isArray(tokens) || tokens.length === 0) {\n throw new Error('Failed to tokenize text: expected non-empty array of tokens');\n }\n logger.log('Tokenized output:', tokens);\n },\n },\n {\n name: 'openai_test_text_tokenizer_decode',\n fn: async (runtime) => {\n const prompt = 'Hello tokenizer decode!';\n // Encode the string into tokens first\n const tokens = await runtime.useModel(ModelType.TEXT_TOKENIZER_ENCODE, { prompt });\n // Now decode tokens back into text\n const decodedText = await runtime.useModel(ModelType.TEXT_TOKENIZER_DECODE, { tokens });\n if (decodedText !== prompt) {\n throw new Error(\n `Decoded text does not match original. Expected \"${prompt}\", got \"${decodedText}\"`\n );\n }\n logger.log('Decoded text:', decodedText);\n },\n },\n ],\n },\n ],\n};\nexport default openaiPlugin;\n","var __accessCheck = (obj, member, msg) => {\n if (!member.has(obj))\n throw TypeError(\"Cannot \" + msg);\n};\nvar __privateGet = (obj, member, getter) => {\n __accessCheck(obj, member, \"read from private field\");\n return getter ? getter.call(obj) : member.get(obj);\n};\nvar __privateAdd = (obj, member, value) => {\n if (member.has(obj))\n throw TypeError(\"Cannot add the same private member more than once\");\n member instanceof WeakSet ? member.add(obj) : member.set(obj, value);\n};\nvar __privateSet = (obj, member, value, setter) => {\n __accessCheck(obj, member, \"write to private field\");\n setter ? setter.call(obj, value) : member.set(obj, value);\n return value;\n};\nvar __privateMethod = (obj, member, method) => {\n __accessCheck(obj, member, \"access private method\");\n return method;\n};\n\n// src/isFunction.ts\nvar isFunction = (value) => typeof value === \"function\";\n\n// src/isObject.ts\nvar isObject = (value) => typeof value === \"object\" && value != null && !Array.isArray(value);\n\n// src/isAsyncIterable.ts\nvar isAsyncIterable = (value) => isObject(value) && isFunction(value[Symbol.asyncIterator]);\n\n// src/blobHelpers.ts\nvar MAX_CHUNK_SIZE = 65536;\nasync function* clonePart(value) {\n if (value.byteLength <= MAX_CHUNK_SIZE) {\n yield value;\n return;\n }\n let offset = 0;\n while (offset < value.byteLength) {\n const size = Math.min(value.byteLength - offset, MAX_CHUNK_SIZE);\n const buffer = value.buffer.slice(offset, offset + size);\n offset += buffer.byteLength;\n yield new Uint8Array(buffer);\n }\n}\nasync function* readStream(readable) {\n const reader = readable.getReader();\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n yield value;\n }\n}\nasync function* chunkStream(stream) {\n for await (const value of stream) {\n yield* clonePart(value);\n }\n}\nvar getStreamIterator = (source) => {\n if (isAsyncIterable(source)) {\n return chunkStream(source);\n }\n if (isFunction(source.getReader)) {\n return chunkStream(readStream(source));\n }\n throw new TypeError(\n \"Unsupported data source: Expected either ReadableStream or async iterable.\"\n );\n};\nasync function* consumeNodeBlob(blob) {\n let position = 0;\n while (position !== blob.size) {\n const chunk = blob.slice(\n position,\n Math.min(blob.size, position + MAX_CHUNK_SIZE)\n );\n const buffer = await chunk.arrayBuffer();\n position += buffer.byteLength;\n yield new Uint8Array(buffer);\n }\n}\nasync function* consumeBlobParts(parts, clone = false) {\n for (const part of parts) {\n if (ArrayBuffer.isView(part)) {\n if (clone) {\n yield* clonePart(part);\n } else {\n yield part;\n }\n } else if (isFunction(part.stream)) {\n yield* getStreamIterator(part.stream());\n } else {\n yield* consumeNodeBlob(part);\n }\n }\n}\nfunction* sliceBlob(blobParts, blobSize, start = 0, end) {\n end ??= blobSize;\n let relativeStart = start < 0 ? Math.max(blobSize + start, 0) : Math.min(start, blobSize);\n let relativeEnd = end < 0 ? Math.max(blobSize + end, 0) : Math.min(end, blobSize);\n const span = Math.max(relativeEnd - relativeStart, 0);\n let added = 0;\n for (const part of blobParts) {\n if (added >= span) {\n break;\n }\n const partSize = ArrayBuffer.isView(part) ? part.byteLength : part.size;\n if (relativeStart && partSize <= relativeStart) {\n relativeStart -= partSize;\n relativeEnd -= partSize;\n } else {\n let chunk;\n if (ArrayBuffer.isView(part)) {\n chunk = part.subarray(relativeStart, Math.min(partSize, relativeEnd));\n added += chunk.byteLength;\n } else {\n chunk = part.slice(relativeStart, Math.min(partSize, relativeEnd));\n added += chunk.size;\n }\n relativeEnd -= partSize;\n relativeStart = 0;\n yield chunk;\n }\n }\n}\n\n// src/Blob.ts\nvar _parts, _type, _size;\nvar _Blob = class _Blob {\n /**\n * Returns a new [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) object.\n * The content of the blob consists of the concatenation of the values given in the parameter array.\n *\n * @param blobParts An `Array` strings, or [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), [`ArrayBufferView`](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView), [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects, or a mix of any of such objects, that will be put inside the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob).\n * @param options An optional object of type `BlobPropertyBag`.\n */\n constructor(blobParts = [], options = {}) {\n /**\n * An `Array` of [`ArrayBufferView`](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) or [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects, or a mix of any of such objects, that will be put inside the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob).\n */\n __privateAdd(this, _parts, []);\n /**\n * Returns the [`MIME type`](https://developer.mozilla.org/en-US/docs/Glossary/MIME_type) of the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File).\n */\n __privateAdd(this, _type, \"\");\n /**\n * Returns the size of the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) in bytes.\n */\n __privateAdd(this, _size, 0);\n options ??= {};\n if (typeof blobParts !== \"object\" || blobParts === null) {\n throw new TypeError(\n \"Failed to construct 'Blob': The provided value cannot be converted to a sequence.\"\n );\n }\n if (!isFunction(blobParts[Symbol.iterator])) {\n throw new TypeError(\n \"Failed to construct 'Blob': The object must have a callable @@iterator property.\"\n );\n }\n if (typeof options !== \"object\" && !isFunction(options)) {\n throw new TypeError(\n \"Failed to construct 'Blob': parameter 2 cannot convert to dictionary.\"\n );\n }\n const encoder = new TextEncoder();\n for (const raw of blobParts) {\n let part;\n if (ArrayBuffer.isView(raw)) {\n part = new Uint8Array(raw.buffer.slice(\n raw.byteOffset,\n raw.byteOffset + raw.byteLength\n ));\n } else if (raw instanceof ArrayBuffer) {\n part = new Uint8Array(raw.slice(0));\n } else if (raw instanceof _Blob) {\n part = raw;\n } else {\n part = encoder.encode(String(raw));\n }\n __privateSet(this, _size, __privateGet(this, _size) + (ArrayBuffer.isView(part) ? part.byteLength : part.size));\n __privateGet(this, _parts).push(part);\n }\n const type = options.type === void 0 ? \"\" : String(options.type);\n __privateSet(this, _type, /^[\\x20-\\x7E]*$/.test(type) ? type : \"\");\n }\n static [Symbol.hasInstance](value) {\n return Boolean(\n value && typeof value === \"object\" && isFunction(value.constructor) && (isFunction(value.stream) || isFunction(value.arrayBuffer)) && /^(Blob|File)$/.test(value[Symbol.toStringTag])\n );\n }\n /**\n * Returns the [`MIME type`](https://developer.mozilla.org/en-US/docs/Glossary/MIME_type) of the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File).\n */\n get type() {\n return __privateGet(this, _type);\n }\n /**\n * Returns the size of the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) in bytes.\n */\n get size() {\n return __privateGet(this, _size);\n }\n /**\n * Creates and returns a new [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) object which contains data from a subset of the blob on which it's called.\n *\n * @param start An index into the Blob indicating the first byte to include in the new Blob. If you specify a negative value, it's treated as an offset from the end of the Blob toward the beginning. For example, -10 would be the 10th from last byte in the Blob. The default value is 0. If you specify a value for start that is larger than the size of the source Blob, the returned Blob has size 0 and contains no data.\n * @param end An index into the Blob indicating the first byte that will *not* be included in the new Blob (i.e. the byte exactly at this index is not included). If you specify a negative value, it's treated as an offset from the end of the Blob toward the beginning. For example, -10 would be the 10th from last byte in the Blob. The default value is size.\n * @param contentType The content type to assign to the new Blob; this will be the value of its type property. The default value is an empty string.\n */\n slice(start, end, contentType) {\n return new _Blob(sliceBlob(__privateGet(this, _parts), this.size, start, end), {\n type: contentType\n });\n }\n /**\n * Returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves with a string containing the contents of the blob, interpreted as UTF-8.\n */\n async text() {\n const decoder = new TextDecoder();\n let result = \"\";\n for await (const chunk of consumeBlobParts(__privateGet(this, _parts))) {\n result += decoder.decode(chunk, { stream: true });\n }\n result += decoder.decode();\n return result;\n }\n /**\n * Returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves with the contents of the blob as binary data contained in an [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer).\n */\n async arrayBuffer() {\n const view = new Uint8Array(this.size);\n let offset = 0;\n for await (const chunk of consumeBlobParts(__privateGet(this, _parts))) {\n view.set(chunk, offset);\n offset += chunk.length;\n }\n return view.buffer;\n }\n /**\n * Returns a [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) which upon reading returns the data contained within the [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob).\n */\n stream() {\n const iterator = consumeBlobParts(__privateGet(this, _parts), true);\n return new ReadableStream({\n async pull(controller) {\n const { value, done } = await iterator.next();\n if (done) {\n return queueMicrotask(() => controller.close());\n }\n controller.enqueue(value);\n },\n async cancel() {\n await iterator.return();\n }\n });\n }\n get [Symbol.toStringTag]() {\n return \"Blob\";\n }\n};\n_parts = new WeakMap();\n_type = new WeakMap();\n_size = new WeakMap();\nvar Blob = _Blob;\nObject.defineProperties(Blob.prototype, {\n type: { enumerable: true },\n size: { enumerable: true },\n slice: { enumerable: true },\n stream: { enumerable: true },\n text: { enumerable: true },\n arrayBuffer: { enumerable: true }\n});\n\n// src/isBlob.ts\nvar isBlob = (value) => value instanceof Blob;\n\n// src/File.ts\nvar _name, _lastModified;\nvar File = class extends Blob {\n /**\n * Creates a new File instance.\n *\n * @param fileBits An `Array` strings, or [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), [`ArrayBufferView`](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView), [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects, or a mix of any of such objects, that will be put inside the [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File).\n * @param name The name of the file.\n * @param options An options object containing optional attributes for the file.\n */\n constructor(fileBits, name, options = {}) {\n super(fileBits, options);\n /**\n * Returns the name of the file referenced by the File object.\n */\n __privateAdd(this, _name, void 0);\n /**\n * The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.\n */\n __privateAdd(this, _lastModified, 0);\n if (arguments.length < 2) {\n throw new TypeError(\n `Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`\n );\n }\n __privateSet(this, _name, String(name));\n const lastModified = options.lastModified === void 0 ? Date.now() : Number(options.lastModified);\n if (!Number.isNaN(lastModified)) {\n __privateSet(this, _lastModified, lastModified);\n }\n }\n static [Symbol.hasInstance](value) {\n return value instanceof Blob && value[Symbol.toStringTag] === \"File\" && typeof value.name === \"string\";\n }\n /**\n * Name of the file referenced by the File object.\n */\n get name() {\n return __privateGet(this, _name);\n }\n /* c8 ignore next 3 */\n get webkitRelativePath() {\n return \"\";\n }\n /**\n * The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.\n */\n get lastModified() {\n return __privateGet(this, _lastModified);\n }\n get [Symbol.toStringTag]() {\n return \"File\";\n }\n};\n_name = new WeakMap();\n_lastModified = new WeakMap();\n\n// src/isFile.ts\nvar isFile = (value) => value instanceof File;\n\n// src/FormData.ts\nvar _entries, _setEntry, setEntry_fn;\nvar FormData = class {\n constructor() {\n __privateAdd(this, _setEntry);\n /**\n * Stores internal data for every entry\n */\n __privateAdd(this, _entries, /* @__PURE__ */ new Map());\n }\n static [Symbol.hasInstance](value) {\n if (!value) {\n return false;\n }\n const val = value;\n return Boolean(\n isFunction(val.constructor) && val[Symbol.toStringTag] === \"FormData\" && isFunction(val.append) && isFunction(val.set) && isFunction(val.get) && isFunction(val.getAll) && isFunction(val.has) && isFunction(val.delete) && isFunction(val.entries) && isFunction(val.values) && isFunction(val.keys) && isFunction(val[Symbol.iterator]) && isFunction(val.forEach)\n );\n }\n /**\n * Appends a new value onto an existing key inside a FormData object,\n * or adds the key if it does not already exist.\n *\n * The difference between `set()` and `append()` is that if the specified key already exists, `set()` will overwrite all existing values with the new one, whereas `append()` will append the new value onto the end of the existing set of values.\n *\n * @param name The name of the field whose data is contained in `value`.\n * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)\n or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.\n * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is \"blob\". The default filename for File objects is the file's filename.\n */\n append(name, value, fileName) {\n __privateMethod(this, _setEntry, setEntry_fn).call(this, {\n name,\n fileName,\n append: true,\n rawValue: value,\n argsLength: arguments.length\n });\n }\n /**\n * Set a new value for an existing key inside FormData,\n * or add the new field if it does not already exist.\n *\n * @param name The name of the field whose data is contained in `value`.\n * @param value The field's value. This can be [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)\n or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). If none of these are specified the value is converted to a string.\n * @param fileName The filename reported to the server, when a Blob or File is passed as the second parameter. The default filename for Blob objects is \"blob\". The default filename for File objects is the file's filename.\n *\n */\n set(name, value, fileName) {\n __privateMethod(this, _setEntry, setEntry_fn).call(this, {\n name,\n fileName,\n append: false,\n rawValue: value,\n argsLength: arguments.length\n });\n }\n /**\n * Returns the first value associated with a given key from within a `FormData` object.\n * If you expect multiple values and want all of them, use the `getAll()` method instead.\n *\n * @param {string} name A name of the value you want to retrieve.\n *\n * @returns A `FormDataEntryValue` containing the value. If the key doesn't exist, the method returns null.\n */\n get(name) {\n const field = __privateGet(this, _entries).get(String(name));\n if (!field) {\n return null;\n }\n return field[0];\n }\n /**\n * Returns all the values associated with a given key from within a `FormData` object.\n *\n * @param {string} name A name of the value you want to retrieve.\n *\n * @returns An array of `FormDataEntryValue` whose key matches the value passed in the `name` parameter. If the key doesn't exist, the method returns an empty list.\n */\n getAll(name) {\n const field = __privateGet(this, _entries).get(String(name));\n if (!field) {\n return [];\n }\n return field.slice();\n }\n /**\n * Returns a boolean stating whether a `FormData` object contains a certain key.\n *\n * @param name A string representing the name of the key you want to test for.\n *\n * @return A boolean value.\n */\n has(name) {\n return __privateGet(this, _entries).has(String(name));\n }\n /**\n * Deletes a key and its value(s) from a `FormData` object.\n *\n * @param name The name of the key you want to delete.\n */\n delete(name) {\n __privateGet(this, _entries).delete(String(name));\n }\n /**\n * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all keys contained in this `FormData` object.\n * Each key is a `string`.\n */\n *keys() {\n for (const key of __privateGet(this, _entries).keys()) {\n yield key;\n }\n }\n /**\n * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through the `FormData` key/value pairs.\n * The key of each pair is a string; the value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).\n */\n *entries() {\n for (const name of this.keys()) {\n const values = this.getAll(name);\n for (const value of values) {\n yield [name, value];\n }\n }\n }\n /**\n * Returns an [`iterator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) allowing to go through all values contained in this object `FormData` object.\n * Each value is a [`FormDataValue`](https://developer.mozilla.org/en-US/docs/Web/API/FormDataEntryValue).\n */\n *values() {\n for (const [, value] of this) {\n yield value;\n }\n }\n /**\n * An alias for FormData#entries()\n */\n [Symbol.iterator]() {\n return this.entries();\n }\n /**\n * Executes given callback function for each field of the FormData instance\n */\n forEach(callback, thisArg) {\n for (const [name, value] of this) {\n callback.call(thisArg, value, name, this);\n }\n }\n get [Symbol.toStringTag]() {\n return \"FormData\";\n }\n};\n_entries = new WeakMap();\n_setEntry = new WeakSet();\nsetEntry_fn = function({\n name,\n rawValue,\n append,\n fileName,\n argsLength\n}) {\n const methodName = append ? \"append\" : \"set\";\n if (argsLength < 2) {\n throw new TypeError(\n `Failed to execute '${methodName}' on 'FormData': 2 arguments required, but only ${argsLength} present.`\n );\n }\n name = String(name);\n let value;\n if (isFile(rawValue)) {\n value = fileName === void 0 ? rawValue : new File([rawValue], fileName, {\n // otherwise, create new File with given fileName\n type: rawValue.type,\n lastModified: rawValue.lastModified\n });\n } else if (isBlob(rawValue)) {\n value = new File([rawValue], fileName === void 0 ? \"blob\" : fileName, {\n type: rawValue.type\n });\n } else if (fileName) {\n throw new TypeError(\n `Failed to execute '${methodName}' on 'FormData': parameter 2 is not of type 'Blob'.`\n );\n } else {\n value = String(rawValue);\n }\n const values = __privateGet(this, _entries).get(name);\n if (!values) {\n return void __privateGet(this, _entries).set(name, [value]);\n }\n if (!append) {\n return void __privateGet(this, _entries).set(name, [value]);\n }\n values.push(value);\n};\nexport {\n Blob,\n File,\n FormData\n};\n/*! Based on fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> & David Frank */\n"],"mappings":";AAAA,SAAS,oBAAoB;AAQ7B;AAAA,EAGE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB,o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AAgC,KAAK;AAClD,oBAAM;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,IAAI,OAAO,YAAY;AACrB,kBAAM,SAAS;AACf,kBAAM,SAAS,MAAM,QAAQ,SAAS,UAAU,uBAAuB,EAAE,OAAO,CAAC;AACjF,gBAAI,CAAC,MAAM,QAAQ,MAAM,KAAK,OAAO,WAAW,GAAG;AACjD,oBAAM,IAAI,MAAM,6DAA6D;AAAA,YAC/E;AACA,mBAAO,IAAI,qBAAqB,MAAM;AAAA,UACxC;AAAA,QACF;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,IAAI,OAAO,YAAY;AACrB,kBAAM,SAAS;AAEf,kBAAM,SAAS,MAAM,QAAQ,SAAS,UAAU,uBAAuB,EAAE,OAAO,CAAC;AAEjF,kBAAM,cAAc,MAAM,QAAQ,SAAS,UAAU,uBAAuB,EAAE,OAAO,CAAC;AACtF,gBAAI,gBAAgB,QAAQ;AAC1B,oBAAM,IAAI;AAAA,gBACR,mDAAmD,MAAM,WAAW,WAAW;AAAA,cACjF;AAAA,YACF;AACA,mBAAO,IAAI,iBAAiB,WAAW;AAAA,UACzC;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AACA,IAAO,gBAAQ;","names":["_Blob","object"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-openai",
3
- "version": "1.0.0-beta.16",
3
+ "version": "1.0.0-beta.17",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "@ai-sdk/openai": "^1.1.9",
26
26
  "@ai-sdk/ui-utils": "1.1.9",
27
- "@elizaos/core": "^1.0.0-beta.16",
27
+ "@elizaos/core": "^1.0.0-beta.17",
28
28
  "ai": "^4.1.25",
29
29
  "js-tiktoken": "^1.0.18",
30
30
  "tsup": "8.4.0"
@@ -49,7 +49,7 @@
49
49
  }
50
50
  }
51
51
  },
52
- "gitHead": "2e45ccd9535c11f9778e8268fb6c048aa4f52d7c",
52
+ "gitHead": "cf0b062a028d5a82322e3f8ba70d58c2a4828cb7",
53
53
  "devDependencies": {
54
54
  "prettier": "3.5.3"
55
55
  }