evals 1.0.2 → 1.0.4
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 +1149 -1427
- package/package.json +1 -1
- package/src/index.js +181 -9
package/dist/index.js
CHANGED
|
@@ -3,7 +3,6 @@ var __create = Object.create;
|
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getProtoOf = Object.getPrototypeOf;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
7
|
var __toESM = (mod, isNodeMode, target) => {
|
|
9
8
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
@@ -16,24 +15,6 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
16
15
|
});
|
|
17
16
|
return to;
|
|
18
17
|
};
|
|
19
|
-
var __toCommonJS = (from) => {
|
|
20
|
-
const moduleCache = __toCommonJS.moduleCache ??= new WeakMap;
|
|
21
|
-
var cached = moduleCache.get(from);
|
|
22
|
-
if (cached)
|
|
23
|
-
return cached;
|
|
24
|
-
var to = __defProp({}, "__esModule", { value: true });
|
|
25
|
-
var desc = { enumerable: false };
|
|
26
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
-
for (let key of __getOwnPropNames(from))
|
|
28
|
-
if (!__hasOwnProp.call(to, key))
|
|
29
|
-
__defProp(to, key, {
|
|
30
|
-
get: () => from[key],
|
|
31
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
moduleCache.set(from, to);
|
|
35
|
-
return to;
|
|
36
|
-
};
|
|
37
18
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
38
19
|
var __require = (id) => {
|
|
39
20
|
return import.meta.require(id);
|
|
@@ -1812,108 +1793,6 @@ var require_commander = __commonJS((exports, module) => {
|
|
|
1812
1793
|
exports.InvalidOptionArgumentError = InvalidArgumentError;
|
|
1813
1794
|
});
|
|
1814
1795
|
|
|
1815
|
-
// src/fetchEvals.js
|
|
1816
|
-
var exports_fetchEvals = {};
|
|
1817
|
-
import fs from "fs";
|
|
1818
|
-
var UMBRAGE_EVALS_API_KEY, fetchEvals, processPromptFile;
|
|
1819
|
-
var init_fetchEvals = __esm(() => {
|
|
1820
|
-
if (!process.env.UMBRAGE_EVALS_API_KEY) {
|
|
1821
|
-
throw new Error("UMBRAGE_EVALS_API_KEY is not set in the environment variables.");
|
|
1822
|
-
}
|
|
1823
|
-
UMBRAGE_EVALS_API_KEY = process.env.UMBRAGE_EVALS_API_KEY;
|
|
1824
|
-
fetchEvals = async () => {
|
|
1825
|
-
const url = new URL("https://api-gateway.groff.workers.dev/evals");
|
|
1826
|
-
url.searchParams.append("page", 0);
|
|
1827
|
-
url.searchParams.append("pageSize", 100);
|
|
1828
|
-
url.searchParams.append("eval_type", "OpenAI-GPT-4");
|
|
1829
|
-
try {
|
|
1830
|
-
const response = await fetch(url, {
|
|
1831
|
-
method: "GET",
|
|
1832
|
-
headers: {
|
|
1833
|
-
Authorization: `Bearer ${UMBRAGE_EVALS_API_KEY}`
|
|
1834
|
-
}
|
|
1835
|
-
});
|
|
1836
|
-
if (!response.ok) {
|
|
1837
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
1838
|
-
}
|
|
1839
|
-
const data = await response.json();
|
|
1840
|
-
return data.evals;
|
|
1841
|
-
} catch (error) {
|
|
1842
|
-
console.error("Error fetching evals:", error);
|
|
1843
|
-
return [];
|
|
1844
|
-
}
|
|
1845
|
-
};
|
|
1846
|
-
processPromptFile = async (file) => {
|
|
1847
|
-
const promptFilename = file.split(".prompt.js")[0];
|
|
1848
|
-
const evalsFolder = `${promptFilename}_evals`;
|
|
1849
|
-
if (!fs.existsSync(evalsFolder)) {
|
|
1850
|
-
fs.mkdirSync(evalsFolder, { recursive: true });
|
|
1851
|
-
}
|
|
1852
|
-
const evalsForPrompt = await fetchEvals();
|
|
1853
|
-
for (const evalObject of evalsForPrompt) {
|
|
1854
|
-
const { name: evalName, eval_code } = evalObject;
|
|
1855
|
-
const markdownFileName = `${evalsFolder}/${evalName.replace(/[^a-z0-9]/gi, "_")}.md`;
|
|
1856
|
-
fs.writeFileSync(markdownFileName, eval_code);
|
|
1857
|
-
}
|
|
1858
|
-
};
|
|
1859
|
-
try {
|
|
1860
|
-
const promptsDir = "./prompts/";
|
|
1861
|
-
const promptFiles = fs.readdirSync(promptsDir).filter((file) => file.endsWith(".prompt.js"));
|
|
1862
|
-
const processingPromises = promptFiles.map(processPromptFile);
|
|
1863
|
-
await Promise.all(processingPromises);
|
|
1864
|
-
console.log("Done fetching evals!");
|
|
1865
|
-
} catch (error) {
|
|
1866
|
-
console.error("An error occurred:", error);
|
|
1867
|
-
}
|
|
1868
|
-
});
|
|
1869
|
-
|
|
1870
|
-
// node_modules/openai/version.mjs
|
|
1871
|
-
var VERSION;
|
|
1872
|
-
var init_version = __esm(() => {
|
|
1873
|
-
VERSION = "4.24.1";
|
|
1874
|
-
});
|
|
1875
|
-
|
|
1876
|
-
// node_modules/openai/_shims/registry.mjs
|
|
1877
|
-
function setShims(shims, options = { auto: false }) {
|
|
1878
|
-
if (auto) {
|
|
1879
|
-
throw new Error(`you must \`import 'openai/shims/${shims.kind}'\` before importing anything else from openai`);
|
|
1880
|
-
}
|
|
1881
|
-
if (kind) {
|
|
1882
|
-
throw new Error(`can't \`import 'openai/shims/${shims.kind}'\` after \`import 'openai/shims/${kind}'\``);
|
|
1883
|
-
}
|
|
1884
|
-
auto = options.auto;
|
|
1885
|
-
kind = shims.kind;
|
|
1886
|
-
fetch2 = shims.fetch;
|
|
1887
|
-
Request = shims.Request;
|
|
1888
|
-
Response = shims.Response;
|
|
1889
|
-
Headers = shims.Headers;
|
|
1890
|
-
FormData = shims.FormData;
|
|
1891
|
-
Blob = shims.Blob;
|
|
1892
|
-
File = shims.File;
|
|
1893
|
-
ReadableStream = shims.ReadableStream;
|
|
1894
|
-
getMultipartRequestOptions = shims.getMultipartRequestOptions;
|
|
1895
|
-
getDefaultAgent = shims.getDefaultAgent;
|
|
1896
|
-
fileFromPath = shims.fileFromPath;
|
|
1897
|
-
isFsReadStream = shims.isFsReadStream;
|
|
1898
|
-
}
|
|
1899
|
-
var auto, kind, fetch2, Request, Response, Headers, FormData, Blob, File, ReadableStream, getMultipartRequestOptions, getDefaultAgent, fileFromPath, isFsReadStream;
|
|
1900
|
-
var init_registry = __esm(() => {
|
|
1901
|
-
auto = false;
|
|
1902
|
-
kind = undefined;
|
|
1903
|
-
fetch2 = undefined;
|
|
1904
|
-
Request = undefined;
|
|
1905
|
-
Response = undefined;
|
|
1906
|
-
Headers = undefined;
|
|
1907
|
-
FormData = undefined;
|
|
1908
|
-
Blob = undefined;
|
|
1909
|
-
File = undefined;
|
|
1910
|
-
ReadableStream = undefined;
|
|
1911
|
-
getMultipartRequestOptions = undefined;
|
|
1912
|
-
getDefaultAgent = undefined;
|
|
1913
|
-
fileFromPath = undefined;
|
|
1914
|
-
isFsReadStream = undefined;
|
|
1915
|
-
});
|
|
1916
|
-
|
|
1917
1796
|
// node_modules/webidl-conversions/lib/index.js
|
|
1918
1797
|
var require_lib = __commonJS((exports, module) => {
|
|
1919
1798
|
var sign = function(x) {
|
|
@@ -7058,159 +6937,6 @@ var init_isFile = __esm(() => {
|
|
|
7058
6937
|
isFile = (value) => value instanceof File2;
|
|
7059
6938
|
});
|
|
7060
6939
|
|
|
7061
|
-
// node_modules/formdata-node/lib/esm/isBlob.js
|
|
7062
|
-
var isBlob;
|
|
7063
|
-
var init_isBlob = __esm(() => {
|
|
7064
|
-
init_Blob();
|
|
7065
|
-
isBlob = (value) => value instanceof Blob2;
|
|
7066
|
-
});
|
|
7067
|
-
|
|
7068
|
-
// node_modules/formdata-node/lib/esm/deprecateConstructorEntries.js
|
|
7069
|
-
import {deprecate} from "util";
|
|
7070
|
-
var deprecateConstructorEntries;
|
|
7071
|
-
var init_deprecateConstructorEntries = __esm(() => {
|
|
7072
|
-
deprecateConstructorEntries = deprecate(() => {
|
|
7073
|
-
}, "Constructor \"entries\" argument is not spec-compliant and will be removed in next major release.");
|
|
7074
|
-
});
|
|
7075
|
-
|
|
7076
|
-
// node_modules/formdata-node/lib/esm/FormData.js
|
|
7077
|
-
import {inspect} from "util";
|
|
7078
|
-
|
|
7079
|
-
class FormData2 {
|
|
7080
|
-
constructor(entries) {
|
|
7081
|
-
_FormData_instances.add(this);
|
|
7082
|
-
_FormData_entries.set(this, new Map);
|
|
7083
|
-
if (entries) {
|
|
7084
|
-
deprecateConstructorEntries();
|
|
7085
|
-
entries.forEach(({ name, value, fileName }) => this.append(name, value, fileName));
|
|
7086
|
-
}
|
|
7087
|
-
}
|
|
7088
|
-
static [(_FormData_entries = new WeakMap, _FormData_instances = new WeakSet, Symbol.hasInstance)](value) {
|
|
7089
|
-
return Boolean(value && isFunction(value.constructor) && value[Symbol.toStringTag] === "FormData" && isFunction(value.append) && isFunction(value.set) && isFunction(value.get) && isFunction(value.getAll) && isFunction(value.has) && isFunction(value.delete) && isFunction(value.entries) && isFunction(value.values) && isFunction(value.keys) && isFunction(value[Symbol.iterator]) && isFunction(value.forEach));
|
|
7090
|
-
}
|
|
7091
|
-
append(name, value, fileName) {
|
|
7092
|
-
__classPrivateFieldGet3(this, _FormData_instances, "m", _FormData_setEntry).call(this, {
|
|
7093
|
-
name,
|
|
7094
|
-
fileName,
|
|
7095
|
-
append: true,
|
|
7096
|
-
rawValue: value,
|
|
7097
|
-
argsLength: arguments.length
|
|
7098
|
-
});
|
|
7099
|
-
}
|
|
7100
|
-
set(name, value, fileName) {
|
|
7101
|
-
__classPrivateFieldGet3(this, _FormData_instances, "m", _FormData_setEntry).call(this, {
|
|
7102
|
-
name,
|
|
7103
|
-
fileName,
|
|
7104
|
-
append: false,
|
|
7105
|
-
rawValue: value,
|
|
7106
|
-
argsLength: arguments.length
|
|
7107
|
-
});
|
|
7108
|
-
}
|
|
7109
|
-
get(name) {
|
|
7110
|
-
const field = __classPrivateFieldGet3(this, _FormData_entries, "f").get(String(name));
|
|
7111
|
-
if (!field) {
|
|
7112
|
-
return null;
|
|
7113
|
-
}
|
|
7114
|
-
return field[0];
|
|
7115
|
-
}
|
|
7116
|
-
getAll(name) {
|
|
7117
|
-
const field = __classPrivateFieldGet3(this, _FormData_entries, "f").get(String(name));
|
|
7118
|
-
if (!field) {
|
|
7119
|
-
return [];
|
|
7120
|
-
}
|
|
7121
|
-
return field.slice();
|
|
7122
|
-
}
|
|
7123
|
-
has(name) {
|
|
7124
|
-
return __classPrivateFieldGet3(this, _FormData_entries, "f").has(String(name));
|
|
7125
|
-
}
|
|
7126
|
-
delete(name) {
|
|
7127
|
-
__classPrivateFieldGet3(this, _FormData_entries, "f").delete(String(name));
|
|
7128
|
-
}
|
|
7129
|
-
*keys() {
|
|
7130
|
-
for (const key of __classPrivateFieldGet3(this, _FormData_entries, "f").keys()) {
|
|
7131
|
-
yield key;
|
|
7132
|
-
}
|
|
7133
|
-
}
|
|
7134
|
-
*entries() {
|
|
7135
|
-
for (const name of this.keys()) {
|
|
7136
|
-
const values = this.getAll(name);
|
|
7137
|
-
for (const value of values) {
|
|
7138
|
-
yield [name, value];
|
|
7139
|
-
}
|
|
7140
|
-
}
|
|
7141
|
-
}
|
|
7142
|
-
*values() {
|
|
7143
|
-
for (const [, value] of this) {
|
|
7144
|
-
yield value;
|
|
7145
|
-
}
|
|
7146
|
-
}
|
|
7147
|
-
[(_FormData_setEntry = function _FormData_setEntry({ name, rawValue, append, fileName, argsLength }) {
|
|
7148
|
-
const methodName = append ? "append" : "set";
|
|
7149
|
-
if (argsLength < 2) {
|
|
7150
|
-
throw new TypeError(`Failed to execute '${methodName}' on 'FormData': ` + `2 arguments required, but only ${argsLength} present.`);
|
|
7151
|
-
}
|
|
7152
|
-
name = String(name);
|
|
7153
|
-
let value;
|
|
7154
|
-
if (isFile(rawValue)) {
|
|
7155
|
-
value = fileName === undefined ? rawValue : new File2([rawValue], fileName, {
|
|
7156
|
-
type: rawValue.type,
|
|
7157
|
-
lastModified: rawValue.lastModified
|
|
7158
|
-
});
|
|
7159
|
-
} else if (isBlob(rawValue)) {
|
|
7160
|
-
value = new File2([rawValue], fileName === undefined ? "blob" : fileName, {
|
|
7161
|
-
type: rawValue.type
|
|
7162
|
-
});
|
|
7163
|
-
} else if (fileName) {
|
|
7164
|
-
throw new TypeError(`Failed to execute '${methodName}' on 'FormData': ` + "parameter 2 is not of type 'Blob'.");
|
|
7165
|
-
} else {
|
|
7166
|
-
value = String(rawValue);
|
|
7167
|
-
}
|
|
7168
|
-
const values = __classPrivateFieldGet3(this, _FormData_entries, "f").get(name);
|
|
7169
|
-
if (!values) {
|
|
7170
|
-
return void __classPrivateFieldGet3(this, _FormData_entries, "f").set(name, [value]);
|
|
7171
|
-
}
|
|
7172
|
-
if (!append) {
|
|
7173
|
-
return void __classPrivateFieldGet3(this, _FormData_entries, "f").set(name, [value]);
|
|
7174
|
-
}
|
|
7175
|
-
values.push(value);
|
|
7176
|
-
}, Symbol.iterator)]() {
|
|
7177
|
-
return this.entries();
|
|
7178
|
-
}
|
|
7179
|
-
forEach(callback, thisArg) {
|
|
7180
|
-
for (const [name, value] of this) {
|
|
7181
|
-
callback.call(thisArg, value, name, this);
|
|
7182
|
-
}
|
|
7183
|
-
}
|
|
7184
|
-
get [Symbol.toStringTag]() {
|
|
7185
|
-
return "FormData";
|
|
7186
|
-
}
|
|
7187
|
-
[inspect.custom]() {
|
|
7188
|
-
return this[Symbol.toStringTag];
|
|
7189
|
-
}
|
|
7190
|
-
}
|
|
7191
|
-
var __classPrivateFieldGet3, _FormData_instances, _FormData_entries, _FormData_setEntry;
|
|
7192
|
-
var init_FormData = __esm(() => {
|
|
7193
|
-
init_File();
|
|
7194
|
-
init_isFile();
|
|
7195
|
-
init_isBlob();
|
|
7196
|
-
init_isFunction();
|
|
7197
|
-
init_deprecateConstructorEntries();
|
|
7198
|
-
__classPrivateFieldGet3 = function(receiver, state, kind2, f2) {
|
|
7199
|
-
if (kind2 === "a" && !f2)
|
|
7200
|
-
throw new TypeError("Private accessor was defined without a getter");
|
|
7201
|
-
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
7202
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
7203
|
-
return kind2 === "m" ? f2 : kind2 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
7204
|
-
};
|
|
7205
|
-
});
|
|
7206
|
-
|
|
7207
|
-
// node_modules/formdata-node/lib/esm/index.js
|
|
7208
|
-
var init_esm = __esm(() => {
|
|
7209
|
-
init_FormData();
|
|
7210
|
-
init_Blob();
|
|
7211
|
-
init_File();
|
|
7212
|
-
});
|
|
7213
|
-
|
|
7214
6940
|
// node_modules/ms/index.js
|
|
7215
6941
|
var require_ms = __commonJS((exports, module) => {
|
|
7216
6942
|
var parse = function(str) {
|
|
@@ -8206,260 +7932,33 @@ var require_abort_controller = __commonJS((exports, module) => {
|
|
|
8206
7932
|
module.exports.AbortSignal = AbortSignal;
|
|
8207
7933
|
});
|
|
8208
7934
|
|
|
8209
|
-
// node_modules/
|
|
8210
|
-
var
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
7935
|
+
// node_modules/web-streams-polyfill/dist/ponyfill.es2018.js
|
|
7936
|
+
var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
7937
|
+
(function(global2, factory) {
|
|
7938
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.WebStreamsPolyfill = {}));
|
|
7939
|
+
})(exports, function(exports2) {
|
|
7940
|
+
const SymbolPolyfill = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? Symbol : (description) => `Symbol(${description})`;
|
|
7941
|
+
function noop() {
|
|
7942
|
+
return;
|
|
8217
7943
|
}
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
8221
|
-
createBoundary_default = createBoundary;
|
|
8222
|
-
});
|
|
8223
|
-
|
|
8224
|
-
// node_modules/form-data-encoder/lib/esm/util/isPlainObject.js
|
|
8225
|
-
var isPlainObject, getType, isPlainObject_default;
|
|
8226
|
-
var init_isPlainObject = __esm(() => {
|
|
8227
|
-
isPlainObject = function(value) {
|
|
8228
|
-
if (getType(value) !== "object") {
|
|
8229
|
-
return false;
|
|
7944
|
+
function typeIsObject(x2) {
|
|
7945
|
+
return typeof x2 === "object" && x2 !== null || typeof x2 === "function";
|
|
8230
7946
|
}
|
|
8231
|
-
const
|
|
8232
|
-
|
|
8233
|
-
|
|
7947
|
+
const rethrowAssertionErrorRejection = noop;
|
|
7948
|
+
function setFunctionName(fn, name) {
|
|
7949
|
+
try {
|
|
7950
|
+
Object.defineProperty(fn, "name", {
|
|
7951
|
+
value: name,
|
|
7952
|
+
configurable: true
|
|
7953
|
+
});
|
|
7954
|
+
} catch (_a) {
|
|
7955
|
+
}
|
|
8234
7956
|
}
|
|
8235
|
-
const
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
});
|
|
8241
|
-
|
|
8242
|
-
// node_modules/form-data-encoder/lib/esm/util/normalizeValue.js
|
|
8243
|
-
var normalizeValue, normalizeValue_default;
|
|
8244
|
-
var init_normalizeValue = __esm(() => {
|
|
8245
|
-
normalizeValue = (value) => String(value).replace(/\r|\n/g, (match, i2, str) => {
|
|
8246
|
-
if (match === "\r" && str[i2 + 1] !== "\n" || match === "\n" && str[i2 - 1] !== "\r") {
|
|
8247
|
-
return "\r\n";
|
|
8248
|
-
}
|
|
8249
|
-
return match;
|
|
8250
|
-
});
|
|
8251
|
-
normalizeValue_default = normalizeValue;
|
|
8252
|
-
});
|
|
8253
|
-
|
|
8254
|
-
// node_modules/form-data-encoder/lib/esm/util/escapeName.js
|
|
8255
|
-
var escapeName, escapeName_default;
|
|
8256
|
-
var init_escapeName = __esm(() => {
|
|
8257
|
-
escapeName = (name) => String(name).replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/"/g, "%22");
|
|
8258
|
-
escapeName_default = escapeName;
|
|
8259
|
-
});
|
|
8260
|
-
|
|
8261
|
-
// node_modules/form-data-encoder/lib/esm/util/isFunction.js
|
|
8262
|
-
var isFunction5, isFunction_default;
|
|
8263
|
-
var init_isFunction2 = __esm(() => {
|
|
8264
|
-
isFunction5 = (value) => typeof value === "function";
|
|
8265
|
-
isFunction_default = isFunction5;
|
|
8266
|
-
});
|
|
8267
|
-
|
|
8268
|
-
// node_modules/form-data-encoder/lib/esm/util/isFileLike.js
|
|
8269
|
-
var isFileLike;
|
|
8270
|
-
var init_isFileLike = __esm(() => {
|
|
8271
|
-
init_isFunction2();
|
|
8272
|
-
isFileLike = (value) => Boolean(value && typeof value === "object" && isFunction_default(value.constructor) && value[Symbol.toStringTag] === "File" && isFunction_default(value.stream) && value.name != null && value.size != null && value.lastModified != null);
|
|
8273
|
-
});
|
|
8274
|
-
|
|
8275
|
-
// node_modules/form-data-encoder/lib/esm/util/isFormData.js
|
|
8276
|
-
var isFormData;
|
|
8277
|
-
var init_isFormData = __esm(() => {
|
|
8278
|
-
init_isFunction2();
|
|
8279
|
-
isFormData = (value) => Boolean(value && isFunction_default(value.constructor) && value[Symbol.toStringTag] === "FormData" && isFunction_default(value.append) && isFunction_default(value.getAll) && isFunction_default(value.entries) && isFunction_default(value[Symbol.iterator]));
|
|
8280
|
-
});
|
|
8281
|
-
|
|
8282
|
-
// node_modules/form-data-encoder/lib/esm/FormDataEncoder.js
|
|
8283
|
-
class FormDataEncoder {
|
|
8284
|
-
constructor(form, boundaryOrOptions, options) {
|
|
8285
|
-
_FormDataEncoder_instances.add(this);
|
|
8286
|
-
_FormDataEncoder_CRLF.set(this, "\r\n");
|
|
8287
|
-
_FormDataEncoder_CRLF_BYTES.set(this, undefined);
|
|
8288
|
-
_FormDataEncoder_CRLF_BYTES_LENGTH.set(this, undefined);
|
|
8289
|
-
_FormDataEncoder_DASHES.set(this, "-".repeat(2));
|
|
8290
|
-
_FormDataEncoder_encoder.set(this, new TextEncoder);
|
|
8291
|
-
_FormDataEncoder_footer.set(this, undefined);
|
|
8292
|
-
_FormDataEncoder_form.set(this, undefined);
|
|
8293
|
-
_FormDataEncoder_options.set(this, undefined);
|
|
8294
|
-
if (!isFormData(form)) {
|
|
8295
|
-
throw new TypeError("Expected first argument to be a FormData instance.");
|
|
8296
|
-
}
|
|
8297
|
-
let boundary;
|
|
8298
|
-
if (isPlainObject_default(boundaryOrOptions)) {
|
|
8299
|
-
options = boundaryOrOptions;
|
|
8300
|
-
} else {
|
|
8301
|
-
boundary = boundaryOrOptions;
|
|
8302
|
-
}
|
|
8303
|
-
if (!boundary) {
|
|
8304
|
-
boundary = createBoundary_default();
|
|
8305
|
-
}
|
|
8306
|
-
if (typeof boundary !== "string") {
|
|
8307
|
-
throw new TypeError("Expected boundary argument to be a string.");
|
|
8308
|
-
}
|
|
8309
|
-
if (options && !isPlainObject_default(options)) {
|
|
8310
|
-
throw new TypeError("Expected options argument to be an object.");
|
|
8311
|
-
}
|
|
8312
|
-
__classPrivateFieldSet3(this, _FormDataEncoder_form, form, "f");
|
|
8313
|
-
__classPrivateFieldSet3(this, _FormDataEncoder_options, { ...defaultOptions, ...options }, "f");
|
|
8314
|
-
__classPrivateFieldSet3(this, _FormDataEncoder_CRLF_BYTES, __classPrivateFieldGet4(this, _FormDataEncoder_encoder, "f").encode(__classPrivateFieldGet4(this, _FormDataEncoder_CRLF, "f")), "f");
|
|
8315
|
-
__classPrivateFieldSet3(this, _FormDataEncoder_CRLF_BYTES_LENGTH, __classPrivateFieldGet4(this, _FormDataEncoder_CRLF_BYTES, "f").byteLength, "f");
|
|
8316
|
-
this.boundary = `form-data-boundary-${boundary}`;
|
|
8317
|
-
this.contentType = `multipart/form-data; boundary=${this.boundary}`;
|
|
8318
|
-
__classPrivateFieldSet3(this, _FormDataEncoder_footer, __classPrivateFieldGet4(this, _FormDataEncoder_encoder, "f").encode(`${__classPrivateFieldGet4(this, _FormDataEncoder_DASHES, "f")}${this.boundary}${__classPrivateFieldGet4(this, _FormDataEncoder_DASHES, "f")}${__classPrivateFieldGet4(this, _FormDataEncoder_CRLF, "f").repeat(2)}`), "f");
|
|
8319
|
-
this.contentLength = String(this.getContentLength());
|
|
8320
|
-
this.headers = Object.freeze({
|
|
8321
|
-
"Content-Type": this.contentType,
|
|
8322
|
-
"Content-Length": this.contentLength
|
|
8323
|
-
});
|
|
8324
|
-
Object.defineProperties(this, {
|
|
8325
|
-
boundary: { writable: false, configurable: false },
|
|
8326
|
-
contentType: { writable: false, configurable: false },
|
|
8327
|
-
contentLength: { writable: false, configurable: false },
|
|
8328
|
-
headers: { writable: false, configurable: false }
|
|
8329
|
-
});
|
|
8330
|
-
}
|
|
8331
|
-
getContentLength() {
|
|
8332
|
-
let length = 0;
|
|
8333
|
-
for (const [name, raw] of __classPrivateFieldGet4(this, _FormDataEncoder_form, "f")) {
|
|
8334
|
-
const value = isFileLike(raw) ? raw : __classPrivateFieldGet4(this, _FormDataEncoder_encoder, "f").encode(normalizeValue_default(raw));
|
|
8335
|
-
length += __classPrivateFieldGet4(this, _FormDataEncoder_instances, "m", _FormDataEncoder_getFieldHeader).call(this, name, value).byteLength;
|
|
8336
|
-
length += isFileLike(value) ? value.size : value.byteLength;
|
|
8337
|
-
length += __classPrivateFieldGet4(this, _FormDataEncoder_CRLF_BYTES_LENGTH, "f");
|
|
8338
|
-
}
|
|
8339
|
-
return length + __classPrivateFieldGet4(this, _FormDataEncoder_footer, "f").byteLength;
|
|
8340
|
-
}
|
|
8341
|
-
*values() {
|
|
8342
|
-
for (const [name, raw] of __classPrivateFieldGet4(this, _FormDataEncoder_form, "f").entries()) {
|
|
8343
|
-
const value = isFileLike(raw) ? raw : __classPrivateFieldGet4(this, _FormDataEncoder_encoder, "f").encode(normalizeValue_default(raw));
|
|
8344
|
-
yield __classPrivateFieldGet4(this, _FormDataEncoder_instances, "m", _FormDataEncoder_getFieldHeader).call(this, name, value);
|
|
8345
|
-
yield value;
|
|
8346
|
-
yield __classPrivateFieldGet4(this, _FormDataEncoder_CRLF_BYTES, "f");
|
|
8347
|
-
}
|
|
8348
|
-
yield __classPrivateFieldGet4(this, _FormDataEncoder_footer, "f");
|
|
8349
|
-
}
|
|
8350
|
-
async* encode() {
|
|
8351
|
-
for (const part of this.values()) {
|
|
8352
|
-
if (isFileLike(part)) {
|
|
8353
|
-
yield* part.stream();
|
|
8354
|
-
} else {
|
|
8355
|
-
yield part;
|
|
8356
|
-
}
|
|
8357
|
-
}
|
|
8358
|
-
}
|
|
8359
|
-
[(_FormDataEncoder_CRLF = new WeakMap, _FormDataEncoder_CRLF_BYTES = new WeakMap, _FormDataEncoder_CRLF_BYTES_LENGTH = new WeakMap, _FormDataEncoder_DASHES = new WeakMap, _FormDataEncoder_encoder = new WeakMap, _FormDataEncoder_footer = new WeakMap, _FormDataEncoder_form = new WeakMap, _FormDataEncoder_options = new WeakMap, _FormDataEncoder_instances = new WeakSet, _FormDataEncoder_getFieldHeader = function _FormDataEncoder_getFieldHeader(name, value) {
|
|
8360
|
-
let header = "";
|
|
8361
|
-
header += `${__classPrivateFieldGet4(this, _FormDataEncoder_DASHES, "f")}${this.boundary}${__classPrivateFieldGet4(this, _FormDataEncoder_CRLF, "f")}`;
|
|
8362
|
-
header += `Content-Disposition: form-data; name="${escapeName_default(name)}"`;
|
|
8363
|
-
if (isFileLike(value)) {
|
|
8364
|
-
header += `; filename="${escapeName_default(value.name)}"${__classPrivateFieldGet4(this, _FormDataEncoder_CRLF, "f")}`;
|
|
8365
|
-
header += `Content-Type: ${value.type || "application/octet-stream"}`;
|
|
8366
|
-
}
|
|
8367
|
-
if (__classPrivateFieldGet4(this, _FormDataEncoder_options, "f").enableAdditionalHeaders === true) {
|
|
8368
|
-
header += `${__classPrivateFieldGet4(this, _FormDataEncoder_CRLF, "f")}Content-Length: ${isFileLike(value) ? value.size : value.byteLength}`;
|
|
8369
|
-
}
|
|
8370
|
-
return __classPrivateFieldGet4(this, _FormDataEncoder_encoder, "f").encode(`${header}${__classPrivateFieldGet4(this, _FormDataEncoder_CRLF, "f").repeat(2)}`);
|
|
8371
|
-
}, Symbol.iterator)]() {
|
|
8372
|
-
return this.values();
|
|
8373
|
-
}
|
|
8374
|
-
[Symbol.asyncIterator]() {
|
|
8375
|
-
return this.encode();
|
|
8376
|
-
}
|
|
8377
|
-
}
|
|
8378
|
-
var __classPrivateFieldSet3, __classPrivateFieldGet4, _FormDataEncoder_instances, _FormDataEncoder_CRLF, _FormDataEncoder_CRLF_BYTES, _FormDataEncoder_CRLF_BYTES_LENGTH, _FormDataEncoder_DASHES, _FormDataEncoder_encoder, _FormDataEncoder_footer, _FormDataEncoder_form, _FormDataEncoder_options, _FormDataEncoder_getFieldHeader, defaultOptions;
|
|
8379
|
-
var init_FormDataEncoder = __esm(() => {
|
|
8380
|
-
init_createBoundary();
|
|
8381
|
-
init_isPlainObject();
|
|
8382
|
-
init_normalizeValue();
|
|
8383
|
-
init_escapeName();
|
|
8384
|
-
init_isFileLike();
|
|
8385
|
-
init_isFormData();
|
|
8386
|
-
__classPrivateFieldSet3 = function(receiver, state, value, kind2, f2) {
|
|
8387
|
-
if (kind2 === "m")
|
|
8388
|
-
throw new TypeError("Private method is not writable");
|
|
8389
|
-
if (kind2 === "a" && !f2)
|
|
8390
|
-
throw new TypeError("Private accessor was defined without a setter");
|
|
8391
|
-
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
8392
|
-
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
8393
|
-
return kind2 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
8394
|
-
};
|
|
8395
|
-
__classPrivateFieldGet4 = function(receiver, state, kind2, f2) {
|
|
8396
|
-
if (kind2 === "a" && !f2)
|
|
8397
|
-
throw new TypeError("Private accessor was defined without a getter");
|
|
8398
|
-
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
8399
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
8400
|
-
return kind2 === "m" ? f2 : kind2 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
8401
|
-
};
|
|
8402
|
-
defaultOptions = {
|
|
8403
|
-
enableAdditionalHeaders: false
|
|
8404
|
-
};
|
|
8405
|
-
});
|
|
8406
|
-
|
|
8407
|
-
// node_modules/form-data-encoder/lib/esm/FileLike.js
|
|
8408
|
-
var init_FileLike = __esm(() => {
|
|
8409
|
-
});
|
|
8410
|
-
|
|
8411
|
-
// node_modules/form-data-encoder/lib/esm/FormDataLike.js
|
|
8412
|
-
var init_FormDataLike = __esm(() => {
|
|
8413
|
-
});
|
|
8414
|
-
|
|
8415
|
-
// node_modules/form-data-encoder/lib/esm/index.js
|
|
8416
|
-
var init_esm2 = __esm(() => {
|
|
8417
|
-
init_FormDataEncoder();
|
|
8418
|
-
init_FileLike();
|
|
8419
|
-
init_FormDataLike();
|
|
8420
|
-
init_isFileLike();
|
|
8421
|
-
init_isFormData();
|
|
8422
|
-
});
|
|
8423
|
-
|
|
8424
|
-
// node_modules/openai/_shims/MultipartBody.mjs
|
|
8425
|
-
class MultipartBody {
|
|
8426
|
-
constructor(body) {
|
|
8427
|
-
this.body = body;
|
|
8428
|
-
}
|
|
8429
|
-
get [Symbol.toStringTag]() {
|
|
8430
|
-
return "MultipartBody";
|
|
8431
|
-
}
|
|
8432
|
-
}
|
|
8433
|
-
var init_MultipartBody = __esm(() => {
|
|
8434
|
-
});
|
|
8435
|
-
|
|
8436
|
-
// node_modules/web-streams-polyfill/dist/ponyfill.es2018.js
|
|
8437
|
-
var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
8438
|
-
(function(global2, factory) {
|
|
8439
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.WebStreamsPolyfill = {}));
|
|
8440
|
-
})(exports, function(exports2) {
|
|
8441
|
-
const SymbolPolyfill = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? Symbol : (description) => `Symbol(${description})`;
|
|
8442
|
-
function noop() {
|
|
8443
|
-
return;
|
|
8444
|
-
}
|
|
8445
|
-
function typeIsObject(x2) {
|
|
8446
|
-
return typeof x2 === "object" && x2 !== null || typeof x2 === "function";
|
|
8447
|
-
}
|
|
8448
|
-
const rethrowAssertionErrorRejection = noop;
|
|
8449
|
-
function setFunctionName(fn, name) {
|
|
8450
|
-
try {
|
|
8451
|
-
Object.defineProperty(fn, "name", {
|
|
8452
|
-
value: name,
|
|
8453
|
-
configurable: true
|
|
8454
|
-
});
|
|
8455
|
-
} catch (_a) {
|
|
8456
|
-
}
|
|
8457
|
-
}
|
|
8458
|
-
const originalPromise = Promise;
|
|
8459
|
-
const originalPromiseThen = Promise.prototype.then;
|
|
8460
|
-
const originalPromiseReject = Promise.reject.bind(originalPromise);
|
|
8461
|
-
function newPromise(executor) {
|
|
8462
|
-
return new originalPromise(executor);
|
|
7957
|
+
const originalPromise = Promise;
|
|
7958
|
+
const originalPromiseThen = Promise.prototype.then;
|
|
7959
|
+
const originalPromiseReject = Promise.reject.bind(originalPromise);
|
|
7960
|
+
function newPromise(executor) {
|
|
7961
|
+
return new originalPromise(executor);
|
|
8463
7962
|
}
|
|
8464
7963
|
function promiseResolvedWith(value) {
|
|
8465
7964
|
return newPromise((resolve) => resolve(value));
|
|
@@ -12516,7 +12015,7 @@ var require_node_domexception = __commonJS((exports, module) => {
|
|
|
12516
12015
|
|
|
12517
12016
|
// node_modules/formdata-node/lib/esm/isPlainObject.js
|
|
12518
12017
|
var isPlainObject3, getType2, isPlainObject_default2;
|
|
12519
|
-
var
|
|
12018
|
+
var init_isPlainObject = __esm(() => {
|
|
12520
12019
|
isPlainObject3 = function(value) {
|
|
12521
12020
|
if (getType2(value) !== "object") {
|
|
12522
12021
|
return false;
|
|
@@ -12551,14 +12050,14 @@ __export(exports_fileFromPath, {
|
|
|
12551
12050
|
}
|
|
12552
12051
|
}
|
|
12553
12052
|
});
|
|
12554
|
-
import {statSync, createReadStream, promises as
|
|
12053
|
+
import {statSync, createReadStream, promises as fs} from "fs";
|
|
12555
12054
|
import {basename} from "path";
|
|
12556
12055
|
function fileFromPathSync(path, filenameOrOptions, options = {}) {
|
|
12557
12056
|
const stats = statSync(path);
|
|
12558
12057
|
return createFileFromPath(path, stats, filenameOrOptions, options);
|
|
12559
12058
|
}
|
|
12560
12059
|
async function fileFromPath2(path, filenameOrOptions, options) {
|
|
12561
|
-
const stats = await
|
|
12060
|
+
const stats = await fs.stat(path);
|
|
12562
12061
|
return createFileFromPath(path, stats, filenameOrOptions, options);
|
|
12563
12062
|
}
|
|
12564
12063
|
|
|
@@ -12581,7 +12080,7 @@ class FileFromPath {
|
|
|
12581
12080
|
});
|
|
12582
12081
|
}
|
|
12583
12082
|
async* stream() {
|
|
12584
|
-
const { mtimeMs } = await
|
|
12083
|
+
const { mtimeMs } = await fs.stat(__classPrivateFieldGet5(this, _FileFromPath_path, "f"));
|
|
12585
12084
|
if (mtimeMs > this.lastModified) {
|
|
12586
12085
|
throw new import_node_domexception.default(MESSAGE, "NotReadableError");
|
|
12587
12086
|
}
|
|
@@ -12600,7 +12099,7 @@ var import_node_domexception, createFileFromPath, __classPrivateFieldSet4, __cla
|
|
|
12600
12099
|
var init_fileFromPath = __esm(() => {
|
|
12601
12100
|
import_node_domexception = __toESM(require_node_domexception(), 1);
|
|
12602
12101
|
init_File();
|
|
12603
|
-
|
|
12102
|
+
init_isPlainObject();
|
|
12604
12103
|
init_isFile();
|
|
12605
12104
|
createFileFromPath = function(path, { mtimeMs, size }, filenameOrOptions, options = {}) {
|
|
12606
12105
|
let filename;
|
|
@@ -12637,92 +12136,471 @@ var init_fileFromPath = __esm(() => {
|
|
|
12637
12136
|
MESSAGE = "The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.";
|
|
12638
12137
|
});
|
|
12639
12138
|
|
|
12640
|
-
// node_modules/
|
|
12641
|
-
|
|
12642
|
-
|
|
12643
|
-
|
|
12644
|
-
|
|
12645
|
-
|
|
12646
|
-
|
|
12647
|
-
|
|
12139
|
+
// node_modules/commander/esm.mjs
|
|
12140
|
+
var import_ = __toESM(require_commander(), 1);
|
|
12141
|
+
var {
|
|
12142
|
+
program,
|
|
12143
|
+
createCommand,
|
|
12144
|
+
createArgument,
|
|
12145
|
+
createOption,
|
|
12146
|
+
CommanderError,
|
|
12147
|
+
InvalidArgumentError,
|
|
12148
|
+
InvalidOptionArgumentError,
|
|
12149
|
+
Command,
|
|
12150
|
+
Argument,
|
|
12151
|
+
Option,
|
|
12152
|
+
Help
|
|
12153
|
+
} = import_.default;
|
|
12154
|
+
|
|
12155
|
+
// src/index.js
|
|
12156
|
+
import fs2 from "fs";
|
|
12157
|
+
|
|
12158
|
+
// node_modules/openai/version.mjs
|
|
12159
|
+
var VERSION = "4.24.1";
|
|
12160
|
+
|
|
12161
|
+
// node_modules/openai/_shims/registry.mjs
|
|
12162
|
+
function setShims(shims, options = { auto: false }) {
|
|
12163
|
+
if (auto) {
|
|
12164
|
+
throw new Error(`you must \`import 'openai/shims/${shims.kind}'\` before importing anything else from openai`);
|
|
12648
12165
|
}
|
|
12649
|
-
|
|
12650
|
-
}
|
|
12651
|
-
async function getMultipartRequestOptions2(form, opts) {
|
|
12652
|
-
const encoder = new FormDataEncoder(form);
|
|
12653
|
-
const readable = Readable.from(encoder);
|
|
12654
|
-
const body = new MultipartBody(readable);
|
|
12655
|
-
const headers = {
|
|
12656
|
-
...opts.headers,
|
|
12657
|
-
...encoder.headers,
|
|
12658
|
-
"Content-Length": encoder.contentLength
|
|
12659
|
-
};
|
|
12660
|
-
return { ...opts, body, headers };
|
|
12661
|
-
}
|
|
12662
|
-
function getRuntime() {
|
|
12663
|
-
if (typeof AbortController === "undefined") {
|
|
12664
|
-
globalThis.AbortController = import_abort_controller.AbortController;
|
|
12166
|
+
if (kind) {
|
|
12167
|
+
throw new Error(`can't \`import 'openai/shims/${shims.kind}'\` after \`import 'openai/shims/${kind}'\``);
|
|
12665
12168
|
}
|
|
12666
|
-
|
|
12667
|
-
|
|
12668
|
-
|
|
12669
|
-
|
|
12670
|
-
|
|
12671
|
-
|
|
12672
|
-
|
|
12673
|
-
|
|
12674
|
-
|
|
12675
|
-
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
};
|
|
12169
|
+
auto = options.auto;
|
|
12170
|
+
kind = shims.kind;
|
|
12171
|
+
fetch2 = shims.fetch;
|
|
12172
|
+
Request = shims.Request;
|
|
12173
|
+
Response = shims.Response;
|
|
12174
|
+
Headers = shims.Headers;
|
|
12175
|
+
FormData = shims.FormData;
|
|
12176
|
+
Blob = shims.Blob;
|
|
12177
|
+
File = shims.File;
|
|
12178
|
+
ReadableStream = shims.ReadableStream;
|
|
12179
|
+
getMultipartRequestOptions = shims.getMultipartRequestOptions;
|
|
12180
|
+
getDefaultAgent = shims.getDefaultAgent;
|
|
12181
|
+
fileFromPath = shims.fileFromPath;
|
|
12182
|
+
isFsReadStream = shims.isFsReadStream;
|
|
12681
12183
|
}
|
|
12682
|
-
var
|
|
12683
|
-
var
|
|
12684
|
-
|
|
12685
|
-
|
|
12686
|
-
|
|
12687
|
-
|
|
12688
|
-
|
|
12689
|
-
|
|
12690
|
-
|
|
12691
|
-
|
|
12692
|
-
|
|
12693
|
-
|
|
12694
|
-
|
|
12184
|
+
var auto = false;
|
|
12185
|
+
var kind = undefined;
|
|
12186
|
+
var fetch2 = undefined;
|
|
12187
|
+
var Request = undefined;
|
|
12188
|
+
var Response = undefined;
|
|
12189
|
+
var Headers = undefined;
|
|
12190
|
+
var FormData = undefined;
|
|
12191
|
+
var Blob = undefined;
|
|
12192
|
+
var File = undefined;
|
|
12193
|
+
var ReadableStream = undefined;
|
|
12194
|
+
var getMultipartRequestOptions = undefined;
|
|
12195
|
+
var getDefaultAgent = undefined;
|
|
12196
|
+
var fileFromPath = undefined;
|
|
12197
|
+
var isFsReadStream = undefined;
|
|
12695
12198
|
|
|
12696
|
-
// node_modules/openai/_shims/
|
|
12697
|
-
var
|
|
12698
|
-
init_node_runtime();
|
|
12699
|
-
});
|
|
12199
|
+
// node_modules/openai/_shims/node-runtime.mjs
|
|
12200
|
+
var nf = __toESM(require_lib2(), 1);
|
|
12700
12201
|
|
|
12701
|
-
// node_modules/
|
|
12702
|
-
|
|
12703
|
-
|
|
12704
|
-
|
|
12705
|
-
init_registry();
|
|
12706
|
-
if (!kind)
|
|
12707
|
-
setShims(getRuntime(), { auto: true });
|
|
12708
|
-
});
|
|
12202
|
+
// node_modules/formdata-node/lib/esm/FormData.js
|
|
12203
|
+
init_File();
|
|
12204
|
+
init_isFile();
|
|
12205
|
+
import {inspect} from "util";
|
|
12709
12206
|
|
|
12710
|
-
// node_modules/
|
|
12711
|
-
|
|
12712
|
-
|
|
12207
|
+
// node_modules/formdata-node/lib/esm/isBlob.js
|
|
12208
|
+
init_Blob();
|
|
12209
|
+
var isBlob = (value) => value instanceof Blob2;
|
|
12713
12210
|
|
|
12714
|
-
|
|
12715
|
-
|
|
12716
|
-
|
|
12717
|
-
|
|
12718
|
-
|
|
12719
|
-
|
|
12720
|
-
|
|
12721
|
-
|
|
12722
|
-
|
|
12723
|
-
|
|
12724
|
-
|
|
12725
|
-
|
|
12211
|
+
// node_modules/formdata-node/lib/esm/FormData.js
|
|
12212
|
+
init_isFunction();
|
|
12213
|
+
|
|
12214
|
+
// node_modules/formdata-node/lib/esm/deprecateConstructorEntries.js
|
|
12215
|
+
import {deprecate} from "util";
|
|
12216
|
+
var deprecateConstructorEntries = deprecate(() => {
|
|
12217
|
+
}, "Constructor \"entries\" argument is not spec-compliant and will be removed in next major release.");
|
|
12218
|
+
|
|
12219
|
+
// node_modules/formdata-node/lib/esm/FormData.js
|
|
12220
|
+
var __classPrivateFieldGet3 = function(receiver, state, kind2, f2) {
|
|
12221
|
+
if (kind2 === "a" && !f2)
|
|
12222
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
12223
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
12224
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
12225
|
+
return kind2 === "m" ? f2 : kind2 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
12226
|
+
};
|
|
12227
|
+
var _FormData_instances;
|
|
12228
|
+
var _FormData_entries;
|
|
12229
|
+
var _FormData_setEntry;
|
|
12230
|
+
|
|
12231
|
+
class FormData2 {
|
|
12232
|
+
constructor(entries) {
|
|
12233
|
+
_FormData_instances.add(this);
|
|
12234
|
+
_FormData_entries.set(this, new Map);
|
|
12235
|
+
if (entries) {
|
|
12236
|
+
deprecateConstructorEntries();
|
|
12237
|
+
entries.forEach(({ name, value, fileName }) => this.append(name, value, fileName));
|
|
12238
|
+
}
|
|
12239
|
+
}
|
|
12240
|
+
static [(_FormData_entries = new WeakMap, _FormData_instances = new WeakSet, Symbol.hasInstance)](value) {
|
|
12241
|
+
return Boolean(value && isFunction(value.constructor) && value[Symbol.toStringTag] === "FormData" && isFunction(value.append) && isFunction(value.set) && isFunction(value.get) && isFunction(value.getAll) && isFunction(value.has) && isFunction(value.delete) && isFunction(value.entries) && isFunction(value.values) && isFunction(value.keys) && isFunction(value[Symbol.iterator]) && isFunction(value.forEach));
|
|
12242
|
+
}
|
|
12243
|
+
append(name, value, fileName) {
|
|
12244
|
+
__classPrivateFieldGet3(this, _FormData_instances, "m", _FormData_setEntry).call(this, {
|
|
12245
|
+
name,
|
|
12246
|
+
fileName,
|
|
12247
|
+
append: true,
|
|
12248
|
+
rawValue: value,
|
|
12249
|
+
argsLength: arguments.length
|
|
12250
|
+
});
|
|
12251
|
+
}
|
|
12252
|
+
set(name, value, fileName) {
|
|
12253
|
+
__classPrivateFieldGet3(this, _FormData_instances, "m", _FormData_setEntry).call(this, {
|
|
12254
|
+
name,
|
|
12255
|
+
fileName,
|
|
12256
|
+
append: false,
|
|
12257
|
+
rawValue: value,
|
|
12258
|
+
argsLength: arguments.length
|
|
12259
|
+
});
|
|
12260
|
+
}
|
|
12261
|
+
get(name) {
|
|
12262
|
+
const field = __classPrivateFieldGet3(this, _FormData_entries, "f").get(String(name));
|
|
12263
|
+
if (!field) {
|
|
12264
|
+
return null;
|
|
12265
|
+
}
|
|
12266
|
+
return field[0];
|
|
12267
|
+
}
|
|
12268
|
+
getAll(name) {
|
|
12269
|
+
const field = __classPrivateFieldGet3(this, _FormData_entries, "f").get(String(name));
|
|
12270
|
+
if (!field) {
|
|
12271
|
+
return [];
|
|
12272
|
+
}
|
|
12273
|
+
return field.slice();
|
|
12274
|
+
}
|
|
12275
|
+
has(name) {
|
|
12276
|
+
return __classPrivateFieldGet3(this, _FormData_entries, "f").has(String(name));
|
|
12277
|
+
}
|
|
12278
|
+
delete(name) {
|
|
12279
|
+
__classPrivateFieldGet3(this, _FormData_entries, "f").delete(String(name));
|
|
12280
|
+
}
|
|
12281
|
+
*keys() {
|
|
12282
|
+
for (const key of __classPrivateFieldGet3(this, _FormData_entries, "f").keys()) {
|
|
12283
|
+
yield key;
|
|
12284
|
+
}
|
|
12285
|
+
}
|
|
12286
|
+
*entries() {
|
|
12287
|
+
for (const name of this.keys()) {
|
|
12288
|
+
const values = this.getAll(name);
|
|
12289
|
+
for (const value of values) {
|
|
12290
|
+
yield [name, value];
|
|
12291
|
+
}
|
|
12292
|
+
}
|
|
12293
|
+
}
|
|
12294
|
+
*values() {
|
|
12295
|
+
for (const [, value] of this) {
|
|
12296
|
+
yield value;
|
|
12297
|
+
}
|
|
12298
|
+
}
|
|
12299
|
+
[(_FormData_setEntry = function _FormData_setEntry({ name, rawValue, append, fileName, argsLength }) {
|
|
12300
|
+
const methodName = append ? "append" : "set";
|
|
12301
|
+
if (argsLength < 2) {
|
|
12302
|
+
throw new TypeError(`Failed to execute '${methodName}' on 'FormData': ` + `2 arguments required, but only ${argsLength} present.`);
|
|
12303
|
+
}
|
|
12304
|
+
name = String(name);
|
|
12305
|
+
let value;
|
|
12306
|
+
if (isFile(rawValue)) {
|
|
12307
|
+
value = fileName === undefined ? rawValue : new File2([rawValue], fileName, {
|
|
12308
|
+
type: rawValue.type,
|
|
12309
|
+
lastModified: rawValue.lastModified
|
|
12310
|
+
});
|
|
12311
|
+
} else if (isBlob(rawValue)) {
|
|
12312
|
+
value = new File2([rawValue], fileName === undefined ? "blob" : fileName, {
|
|
12313
|
+
type: rawValue.type
|
|
12314
|
+
});
|
|
12315
|
+
} else if (fileName) {
|
|
12316
|
+
throw new TypeError(`Failed to execute '${methodName}' on 'FormData': ` + "parameter 2 is not of type 'Blob'.");
|
|
12317
|
+
} else {
|
|
12318
|
+
value = String(rawValue);
|
|
12319
|
+
}
|
|
12320
|
+
const values = __classPrivateFieldGet3(this, _FormData_entries, "f").get(name);
|
|
12321
|
+
if (!values) {
|
|
12322
|
+
return void __classPrivateFieldGet3(this, _FormData_entries, "f").set(name, [value]);
|
|
12323
|
+
}
|
|
12324
|
+
if (!append) {
|
|
12325
|
+
return void __classPrivateFieldGet3(this, _FormData_entries, "f").set(name, [value]);
|
|
12326
|
+
}
|
|
12327
|
+
values.push(value);
|
|
12328
|
+
}, Symbol.iterator)]() {
|
|
12329
|
+
return this.entries();
|
|
12330
|
+
}
|
|
12331
|
+
forEach(callback, thisArg) {
|
|
12332
|
+
for (const [name, value] of this) {
|
|
12333
|
+
callback.call(thisArg, value, name, this);
|
|
12334
|
+
}
|
|
12335
|
+
}
|
|
12336
|
+
get [Symbol.toStringTag]() {
|
|
12337
|
+
return "FormData";
|
|
12338
|
+
}
|
|
12339
|
+
[inspect.custom]() {
|
|
12340
|
+
return this[Symbol.toStringTag];
|
|
12341
|
+
}
|
|
12342
|
+
}
|
|
12343
|
+
|
|
12344
|
+
// node_modules/openai/_shims/node-runtime.mjs
|
|
12345
|
+
var import_agentkeepalive = __toESM(require_agentkeepalive(), 1);
|
|
12346
|
+
var import_abort_controller = __toESM(require_abort_controller(), 1);
|
|
12347
|
+
import {ReadStream as FsReadStream} from "node:fs";
|
|
12348
|
+
|
|
12349
|
+
// node_modules/form-data-encoder/lib/esm/util/createBoundary.js
|
|
12350
|
+
var createBoundary = function() {
|
|
12351
|
+
let size = 16;
|
|
12352
|
+
let res = "";
|
|
12353
|
+
while (size--) {
|
|
12354
|
+
res += alphabet[Math.random() * alphabet.length << 0];
|
|
12355
|
+
}
|
|
12356
|
+
return res;
|
|
12357
|
+
};
|
|
12358
|
+
var alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
12359
|
+
var createBoundary_default = createBoundary;
|
|
12360
|
+
|
|
12361
|
+
// node_modules/form-data-encoder/lib/esm/util/isPlainObject.js
|
|
12362
|
+
var isPlainObject = function(value) {
|
|
12363
|
+
if (getType(value) !== "object") {
|
|
12364
|
+
return false;
|
|
12365
|
+
}
|
|
12366
|
+
const pp = Object.getPrototypeOf(value);
|
|
12367
|
+
if (pp === null || pp === undefined) {
|
|
12368
|
+
return true;
|
|
12369
|
+
}
|
|
12370
|
+
const Ctor = pp.constructor && pp.constructor.toString();
|
|
12371
|
+
return Ctor === Object.toString();
|
|
12372
|
+
};
|
|
12373
|
+
var getType = (value) => Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
|
|
12374
|
+
var isPlainObject_default = isPlainObject;
|
|
12375
|
+
|
|
12376
|
+
// node_modules/form-data-encoder/lib/esm/util/normalizeValue.js
|
|
12377
|
+
var normalizeValue = (value) => String(value).replace(/\r|\n/g, (match, i2, str) => {
|
|
12378
|
+
if (match === "\r" && str[i2 + 1] !== "\n" || match === "\n" && str[i2 - 1] !== "\r") {
|
|
12379
|
+
return "\r\n";
|
|
12380
|
+
}
|
|
12381
|
+
return match;
|
|
12382
|
+
});
|
|
12383
|
+
var normalizeValue_default = normalizeValue;
|
|
12384
|
+
|
|
12385
|
+
// node_modules/form-data-encoder/lib/esm/util/escapeName.js
|
|
12386
|
+
var escapeName = (name) => String(name).replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/"/g, "%22");
|
|
12387
|
+
var escapeName_default = escapeName;
|
|
12388
|
+
|
|
12389
|
+
// node_modules/form-data-encoder/lib/esm/util/isFunction.js
|
|
12390
|
+
var isFunction5 = (value) => typeof value === "function";
|
|
12391
|
+
var isFunction_default = isFunction5;
|
|
12392
|
+
|
|
12393
|
+
// node_modules/form-data-encoder/lib/esm/util/isFileLike.js
|
|
12394
|
+
var isFileLike = (value) => Boolean(value && typeof value === "object" && isFunction_default(value.constructor) && value[Symbol.toStringTag] === "File" && isFunction_default(value.stream) && value.name != null && value.size != null && value.lastModified != null);
|
|
12395
|
+
|
|
12396
|
+
// node_modules/form-data-encoder/lib/esm/util/isFormData.js
|
|
12397
|
+
var isFormData = (value) => Boolean(value && isFunction_default(value.constructor) && value[Symbol.toStringTag] === "FormData" && isFunction_default(value.append) && isFunction_default(value.getAll) && isFunction_default(value.entries) && isFunction_default(value[Symbol.iterator]));
|
|
12398
|
+
|
|
12399
|
+
// node_modules/form-data-encoder/lib/esm/FormDataEncoder.js
|
|
12400
|
+
var __classPrivateFieldSet3 = function(receiver, state, value, kind2, f2) {
|
|
12401
|
+
if (kind2 === "m")
|
|
12402
|
+
throw new TypeError("Private method is not writable");
|
|
12403
|
+
if (kind2 === "a" && !f2)
|
|
12404
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
12405
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
12406
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
12407
|
+
return kind2 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
12408
|
+
};
|
|
12409
|
+
var __classPrivateFieldGet4 = function(receiver, state, kind2, f2) {
|
|
12410
|
+
if (kind2 === "a" && !f2)
|
|
12411
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
12412
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
12413
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
12414
|
+
return kind2 === "m" ? f2 : kind2 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
12415
|
+
};
|
|
12416
|
+
var _FormDataEncoder_instances;
|
|
12417
|
+
var _FormDataEncoder_CRLF;
|
|
12418
|
+
var _FormDataEncoder_CRLF_BYTES;
|
|
12419
|
+
var _FormDataEncoder_CRLF_BYTES_LENGTH;
|
|
12420
|
+
var _FormDataEncoder_DASHES;
|
|
12421
|
+
var _FormDataEncoder_encoder;
|
|
12422
|
+
var _FormDataEncoder_footer;
|
|
12423
|
+
var _FormDataEncoder_form;
|
|
12424
|
+
var _FormDataEncoder_options;
|
|
12425
|
+
var _FormDataEncoder_getFieldHeader;
|
|
12426
|
+
var defaultOptions = {
|
|
12427
|
+
enableAdditionalHeaders: false
|
|
12428
|
+
};
|
|
12429
|
+
|
|
12430
|
+
class FormDataEncoder {
|
|
12431
|
+
constructor(form, boundaryOrOptions, options) {
|
|
12432
|
+
_FormDataEncoder_instances.add(this);
|
|
12433
|
+
_FormDataEncoder_CRLF.set(this, "\r\n");
|
|
12434
|
+
_FormDataEncoder_CRLF_BYTES.set(this, undefined);
|
|
12435
|
+
_FormDataEncoder_CRLF_BYTES_LENGTH.set(this, undefined);
|
|
12436
|
+
_FormDataEncoder_DASHES.set(this, "-".repeat(2));
|
|
12437
|
+
_FormDataEncoder_encoder.set(this, new TextEncoder);
|
|
12438
|
+
_FormDataEncoder_footer.set(this, undefined);
|
|
12439
|
+
_FormDataEncoder_form.set(this, undefined);
|
|
12440
|
+
_FormDataEncoder_options.set(this, undefined);
|
|
12441
|
+
if (!isFormData(form)) {
|
|
12442
|
+
throw new TypeError("Expected first argument to be a FormData instance.");
|
|
12443
|
+
}
|
|
12444
|
+
let boundary;
|
|
12445
|
+
if (isPlainObject_default(boundaryOrOptions)) {
|
|
12446
|
+
options = boundaryOrOptions;
|
|
12447
|
+
} else {
|
|
12448
|
+
boundary = boundaryOrOptions;
|
|
12449
|
+
}
|
|
12450
|
+
if (!boundary) {
|
|
12451
|
+
boundary = createBoundary_default();
|
|
12452
|
+
}
|
|
12453
|
+
if (typeof boundary !== "string") {
|
|
12454
|
+
throw new TypeError("Expected boundary argument to be a string.");
|
|
12455
|
+
}
|
|
12456
|
+
if (options && !isPlainObject_default(options)) {
|
|
12457
|
+
throw new TypeError("Expected options argument to be an object.");
|
|
12458
|
+
}
|
|
12459
|
+
__classPrivateFieldSet3(this, _FormDataEncoder_form, form, "f");
|
|
12460
|
+
__classPrivateFieldSet3(this, _FormDataEncoder_options, { ...defaultOptions, ...options }, "f");
|
|
12461
|
+
__classPrivateFieldSet3(this, _FormDataEncoder_CRLF_BYTES, __classPrivateFieldGet4(this, _FormDataEncoder_encoder, "f").encode(__classPrivateFieldGet4(this, _FormDataEncoder_CRLF, "f")), "f");
|
|
12462
|
+
__classPrivateFieldSet3(this, _FormDataEncoder_CRLF_BYTES_LENGTH, __classPrivateFieldGet4(this, _FormDataEncoder_CRLF_BYTES, "f").byteLength, "f");
|
|
12463
|
+
this.boundary = `form-data-boundary-${boundary}`;
|
|
12464
|
+
this.contentType = `multipart/form-data; boundary=${this.boundary}`;
|
|
12465
|
+
__classPrivateFieldSet3(this, _FormDataEncoder_footer, __classPrivateFieldGet4(this, _FormDataEncoder_encoder, "f").encode(`${__classPrivateFieldGet4(this, _FormDataEncoder_DASHES, "f")}${this.boundary}${__classPrivateFieldGet4(this, _FormDataEncoder_DASHES, "f")}${__classPrivateFieldGet4(this, _FormDataEncoder_CRLF, "f").repeat(2)}`), "f");
|
|
12466
|
+
this.contentLength = String(this.getContentLength());
|
|
12467
|
+
this.headers = Object.freeze({
|
|
12468
|
+
"Content-Type": this.contentType,
|
|
12469
|
+
"Content-Length": this.contentLength
|
|
12470
|
+
});
|
|
12471
|
+
Object.defineProperties(this, {
|
|
12472
|
+
boundary: { writable: false, configurable: false },
|
|
12473
|
+
contentType: { writable: false, configurable: false },
|
|
12474
|
+
contentLength: { writable: false, configurable: false },
|
|
12475
|
+
headers: { writable: false, configurable: false }
|
|
12476
|
+
});
|
|
12477
|
+
}
|
|
12478
|
+
getContentLength() {
|
|
12479
|
+
let length = 0;
|
|
12480
|
+
for (const [name, raw] of __classPrivateFieldGet4(this, _FormDataEncoder_form, "f")) {
|
|
12481
|
+
const value = isFileLike(raw) ? raw : __classPrivateFieldGet4(this, _FormDataEncoder_encoder, "f").encode(normalizeValue_default(raw));
|
|
12482
|
+
length += __classPrivateFieldGet4(this, _FormDataEncoder_instances, "m", _FormDataEncoder_getFieldHeader).call(this, name, value).byteLength;
|
|
12483
|
+
length += isFileLike(value) ? value.size : value.byteLength;
|
|
12484
|
+
length += __classPrivateFieldGet4(this, _FormDataEncoder_CRLF_BYTES_LENGTH, "f");
|
|
12485
|
+
}
|
|
12486
|
+
return length + __classPrivateFieldGet4(this, _FormDataEncoder_footer, "f").byteLength;
|
|
12487
|
+
}
|
|
12488
|
+
*values() {
|
|
12489
|
+
for (const [name, raw] of __classPrivateFieldGet4(this, _FormDataEncoder_form, "f").entries()) {
|
|
12490
|
+
const value = isFileLike(raw) ? raw : __classPrivateFieldGet4(this, _FormDataEncoder_encoder, "f").encode(normalizeValue_default(raw));
|
|
12491
|
+
yield __classPrivateFieldGet4(this, _FormDataEncoder_instances, "m", _FormDataEncoder_getFieldHeader).call(this, name, value);
|
|
12492
|
+
yield value;
|
|
12493
|
+
yield __classPrivateFieldGet4(this, _FormDataEncoder_CRLF_BYTES, "f");
|
|
12494
|
+
}
|
|
12495
|
+
yield __classPrivateFieldGet4(this, _FormDataEncoder_footer, "f");
|
|
12496
|
+
}
|
|
12497
|
+
async* encode() {
|
|
12498
|
+
for (const part of this.values()) {
|
|
12499
|
+
if (isFileLike(part)) {
|
|
12500
|
+
yield* part.stream();
|
|
12501
|
+
} else {
|
|
12502
|
+
yield part;
|
|
12503
|
+
}
|
|
12504
|
+
}
|
|
12505
|
+
}
|
|
12506
|
+
[(_FormDataEncoder_CRLF = new WeakMap, _FormDataEncoder_CRLF_BYTES = new WeakMap, _FormDataEncoder_CRLF_BYTES_LENGTH = new WeakMap, _FormDataEncoder_DASHES = new WeakMap, _FormDataEncoder_encoder = new WeakMap, _FormDataEncoder_footer = new WeakMap, _FormDataEncoder_form = new WeakMap, _FormDataEncoder_options = new WeakMap, _FormDataEncoder_instances = new WeakSet, _FormDataEncoder_getFieldHeader = function _FormDataEncoder_getFieldHeader(name, value) {
|
|
12507
|
+
let header = "";
|
|
12508
|
+
header += `${__classPrivateFieldGet4(this, _FormDataEncoder_DASHES, "f")}${this.boundary}${__classPrivateFieldGet4(this, _FormDataEncoder_CRLF, "f")}`;
|
|
12509
|
+
header += `Content-Disposition: form-data; name="${escapeName_default(name)}"`;
|
|
12510
|
+
if (isFileLike(value)) {
|
|
12511
|
+
header += `; filename="${escapeName_default(value.name)}"${__classPrivateFieldGet4(this, _FormDataEncoder_CRLF, "f")}`;
|
|
12512
|
+
header += `Content-Type: ${value.type || "application/octet-stream"}`;
|
|
12513
|
+
}
|
|
12514
|
+
if (__classPrivateFieldGet4(this, _FormDataEncoder_options, "f").enableAdditionalHeaders === true) {
|
|
12515
|
+
header += `${__classPrivateFieldGet4(this, _FormDataEncoder_CRLF, "f")}Content-Length: ${isFileLike(value) ? value.size : value.byteLength}`;
|
|
12516
|
+
}
|
|
12517
|
+
return __classPrivateFieldGet4(this, _FormDataEncoder_encoder, "f").encode(`${header}${__classPrivateFieldGet4(this, _FormDataEncoder_CRLF, "f").repeat(2)}`);
|
|
12518
|
+
}, Symbol.iterator)]() {
|
|
12519
|
+
return this.values();
|
|
12520
|
+
}
|
|
12521
|
+
[Symbol.asyncIterator]() {
|
|
12522
|
+
return this.encode();
|
|
12523
|
+
}
|
|
12524
|
+
}
|
|
12525
|
+
|
|
12526
|
+
// node_modules/openai/_shims/node-runtime.mjs
|
|
12527
|
+
import {Readable} from "node:stream";
|
|
12528
|
+
|
|
12529
|
+
// node_modules/openai/_shims/MultipartBody.mjs
|
|
12530
|
+
class MultipartBody {
|
|
12531
|
+
constructor(body) {
|
|
12532
|
+
this.body = body;
|
|
12533
|
+
}
|
|
12534
|
+
get [Symbol.toStringTag]() {
|
|
12535
|
+
return "MultipartBody";
|
|
12536
|
+
}
|
|
12537
|
+
}
|
|
12538
|
+
|
|
12539
|
+
// node_modules/openai/_shims/node-runtime.mjs
|
|
12540
|
+
var ponyfill_es2018 = __toESM(require_ponyfill_es2018(), 1);
|
|
12541
|
+
async function fileFromPath3(path, ...args) {
|
|
12542
|
+
const { fileFromPath: _fileFromPath } = await Promise.resolve().then(() => (init_fileFromPath(), exports_fileFromPath));
|
|
12543
|
+
if (!fileFromPathWarned) {
|
|
12544
|
+
console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path)}) instead`);
|
|
12545
|
+
fileFromPathWarned = true;
|
|
12546
|
+
}
|
|
12547
|
+
return await _fileFromPath(path, ...args);
|
|
12548
|
+
}
|
|
12549
|
+
async function getMultipartRequestOptions2(form, opts) {
|
|
12550
|
+
const encoder = new FormDataEncoder(form);
|
|
12551
|
+
const readable = Readable.from(encoder);
|
|
12552
|
+
const body = new MultipartBody(readable);
|
|
12553
|
+
const headers = {
|
|
12554
|
+
...opts.headers,
|
|
12555
|
+
...encoder.headers,
|
|
12556
|
+
"Content-Length": encoder.contentLength
|
|
12557
|
+
};
|
|
12558
|
+
return { ...opts, body, headers };
|
|
12559
|
+
}
|
|
12560
|
+
function getRuntime() {
|
|
12561
|
+
if (typeof AbortController === "undefined") {
|
|
12562
|
+
globalThis.AbortController = import_abort_controller.AbortController;
|
|
12563
|
+
}
|
|
12564
|
+
return {
|
|
12565
|
+
kind: "node",
|
|
12566
|
+
fetch: nf.default,
|
|
12567
|
+
Request: nf.Request,
|
|
12568
|
+
Response: nf.Response,
|
|
12569
|
+
Headers: nf.Headers,
|
|
12570
|
+
FormData: FormData2,
|
|
12571
|
+
Blob: Blob2,
|
|
12572
|
+
File: File2,
|
|
12573
|
+
ReadableStream: ponyfill_es2018.ReadableStream,
|
|
12574
|
+
getMultipartRequestOptions: getMultipartRequestOptions2,
|
|
12575
|
+
getDefaultAgent: (url) => url.startsWith("https") ? defaultHttpsAgent : defaultHttpAgent,
|
|
12576
|
+
fileFromPath: fileFromPath3,
|
|
12577
|
+
isFsReadStream: (value) => value instanceof FsReadStream
|
|
12578
|
+
};
|
|
12579
|
+
}
|
|
12580
|
+
var fileFromPathWarned = false;
|
|
12581
|
+
var defaultHttpAgent = new import_agentkeepalive.default({ keepAlive: true, timeout: 5 * 60 * 1000 });
|
|
12582
|
+
var defaultHttpsAgent = new import_agentkeepalive.default.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1000 });
|
|
12583
|
+
|
|
12584
|
+
// node_modules/openai/_shims/index.mjs
|
|
12585
|
+
if (!kind)
|
|
12586
|
+
setShims(getRuntime(), { auto: true });
|
|
12587
|
+
|
|
12588
|
+
// node_modules/openai/error.mjs
|
|
12589
|
+
class OpenAIError extends Error {
|
|
12590
|
+
}
|
|
12591
|
+
|
|
12592
|
+
class APIError extends OpenAIError {
|
|
12593
|
+
constructor(status, error, message, headers) {
|
|
12594
|
+
super(`${APIError.makeMessage(status, error, message)}`);
|
|
12595
|
+
this.status = status;
|
|
12596
|
+
this.headers = headers;
|
|
12597
|
+
const data = error;
|
|
12598
|
+
this.error = data;
|
|
12599
|
+
this.code = data?.["code"];
|
|
12600
|
+
this.param = data?.["param"];
|
|
12601
|
+
this.type = data?.["type"];
|
|
12602
|
+
}
|
|
12603
|
+
static makeMessage(status, error, message) {
|
|
12726
12604
|
const msg = error?.message ? typeof error.message === "string" ? error.message : JSON.stringify(error.message) : error ? JSON.stringify(error) : message;
|
|
12727
12605
|
if (status && msg) {
|
|
12728
12606
|
return `${status} ${msg}`;
|
|
@@ -12841,11 +12719,43 @@ class RateLimitError extends APIError {
|
|
|
12841
12719
|
|
|
12842
12720
|
class InternalServerError extends APIError {
|
|
12843
12721
|
}
|
|
12844
|
-
var init_error = __esm(() => {
|
|
12845
|
-
init_core();
|
|
12846
|
-
});
|
|
12847
12722
|
|
|
12848
12723
|
// node_modules/openai/streaming.mjs
|
|
12724
|
+
var partition = function(str, delimiter) {
|
|
12725
|
+
const index = str.indexOf(delimiter);
|
|
12726
|
+
if (index !== -1) {
|
|
12727
|
+
return [str.substring(0, index), delimiter, str.substring(index + delimiter.length)];
|
|
12728
|
+
}
|
|
12729
|
+
return [str, "", ""];
|
|
12730
|
+
};
|
|
12731
|
+
var readableStreamAsyncIterable = function(stream) {
|
|
12732
|
+
if (stream[Symbol.asyncIterator])
|
|
12733
|
+
return stream;
|
|
12734
|
+
const reader = stream.getReader();
|
|
12735
|
+
return {
|
|
12736
|
+
async next() {
|
|
12737
|
+
try {
|
|
12738
|
+
const result = await reader.read();
|
|
12739
|
+
if (result?.done)
|
|
12740
|
+
reader.releaseLock();
|
|
12741
|
+
return result;
|
|
12742
|
+
} catch (e2) {
|
|
12743
|
+
reader.releaseLock();
|
|
12744
|
+
throw e2;
|
|
12745
|
+
}
|
|
12746
|
+
},
|
|
12747
|
+
async return() {
|
|
12748
|
+
const cancelPromise = reader.cancel();
|
|
12749
|
+
reader.releaseLock();
|
|
12750
|
+
await cancelPromise;
|
|
12751
|
+
return { done: true, value: undefined };
|
|
12752
|
+
},
|
|
12753
|
+
[Symbol.asyncIterator]() {
|
|
12754
|
+
return this;
|
|
12755
|
+
}
|
|
12756
|
+
};
|
|
12757
|
+
};
|
|
12758
|
+
|
|
12849
12759
|
class Stream {
|
|
12850
12760
|
constructor(iterator, controller) {
|
|
12851
12761
|
this.iterator = iterator;
|
|
@@ -13110,48 +13020,8 @@ class LineDecoder {
|
|
|
13110
13020
|
return lines;
|
|
13111
13021
|
}
|
|
13112
13022
|
}
|
|
13113
|
-
|
|
13114
|
-
|
|
13115
|
-
init__shims();
|
|
13116
|
-
init_error();
|
|
13117
|
-
init_error();
|
|
13118
|
-
partition = function(str, delimiter) {
|
|
13119
|
-
const index = str.indexOf(delimiter);
|
|
13120
|
-
if (index !== -1) {
|
|
13121
|
-
return [str.substring(0, index), delimiter, str.substring(index + delimiter.length)];
|
|
13122
|
-
}
|
|
13123
|
-
return [str, "", ""];
|
|
13124
|
-
};
|
|
13125
|
-
readableStreamAsyncIterable = function(stream) {
|
|
13126
|
-
if (stream[Symbol.asyncIterator])
|
|
13127
|
-
return stream;
|
|
13128
|
-
const reader = stream.getReader();
|
|
13129
|
-
return {
|
|
13130
|
-
async next() {
|
|
13131
|
-
try {
|
|
13132
|
-
const result = await reader.read();
|
|
13133
|
-
if (result?.done)
|
|
13134
|
-
reader.releaseLock();
|
|
13135
|
-
return result;
|
|
13136
|
-
} catch (e2) {
|
|
13137
|
-
reader.releaseLock();
|
|
13138
|
-
throw e2;
|
|
13139
|
-
}
|
|
13140
|
-
},
|
|
13141
|
-
async return() {
|
|
13142
|
-
const cancelPromise = reader.cancel();
|
|
13143
|
-
reader.releaseLock();
|
|
13144
|
-
await cancelPromise;
|
|
13145
|
-
return { done: true, value: undefined };
|
|
13146
|
-
},
|
|
13147
|
-
[Symbol.asyncIterator]() {
|
|
13148
|
-
return this;
|
|
13149
|
-
}
|
|
13150
|
-
};
|
|
13151
|
-
};
|
|
13152
|
-
LineDecoder.NEWLINE_CHARS = new Set(["\n", "\r", "\v", "\f", "\x1C", "\x1D", "\x1E", "\x85", "\u2028", "\u2029"]);
|
|
13153
|
-
LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r\x0b\x0c\x1c\x1d\x1e\x85\u2028\u2029]/g;
|
|
13154
|
-
});
|
|
13023
|
+
LineDecoder.NEWLINE_CHARS = new Set(["\n", "\r", "\v", "\f", "\x1C", "\x1D", "\x1E", "\x85", "\u2028", "\u2029"]);
|
|
13024
|
+
LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r\x0b\x0c\x1c\x1d\x1e\x85\u2028\u2029]/g;
|
|
13155
13025
|
|
|
13156
13026
|
// node_modules/openai/uploads.mjs
|
|
13157
13027
|
async function toFile(value, name, options = {}) {
|
|
@@ -13186,61 +13056,56 @@ async function getBytes(value) {
|
|
|
13186
13056
|
}
|
|
13187
13057
|
return parts;
|
|
13188
13058
|
}
|
|
13189
|
-
var propsForError
|
|
13190
|
-
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
|
|
13194
|
-
|
|
13195
|
-
|
|
13196
|
-
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13200
|
-
|
|
13201
|
-
|
|
13202
|
-
|
|
13203
|
-
|
|
13204
|
-
return
|
|
13205
|
-
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
|
|
13059
|
+
var propsForError = function(value) {
|
|
13060
|
+
const props = Object.getOwnPropertyNames(value);
|
|
13061
|
+
return `[${props.map((p2) => `"${p2}"`).join(", ")}]`;
|
|
13062
|
+
};
|
|
13063
|
+
var getName = function(value) {
|
|
13064
|
+
return getStringFromMaybeBuffer(value.name) || getStringFromMaybeBuffer(value.filename) || getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop();
|
|
13065
|
+
};
|
|
13066
|
+
var isResponseLike = (value) => value != null && typeof value === "object" && typeof value.url === "string" && typeof value.blob === "function";
|
|
13067
|
+
var isFileLike3 = (value) => value != null && typeof value === "object" && typeof value.name === "string" && typeof value.lastModified === "number" && isBlobLike(value);
|
|
13068
|
+
var isBlobLike = (value) => value != null && typeof value === "object" && typeof value.size === "number" && typeof value.type === "string" && typeof value.text === "function" && typeof value.slice === "function" && typeof value.arrayBuffer === "function";
|
|
13069
|
+
var isUploadable = (value) => {
|
|
13070
|
+
return isFileLike3(value) || isResponseLike(value) || isFsReadStream(value);
|
|
13071
|
+
};
|
|
13072
|
+
var getStringFromMaybeBuffer = (x2) => {
|
|
13073
|
+
if (typeof x2 === "string")
|
|
13074
|
+
return x2;
|
|
13075
|
+
if (typeof Buffer !== "undefined" && x2 instanceof Buffer)
|
|
13076
|
+
return String(x2);
|
|
13077
|
+
return;
|
|
13078
|
+
};
|
|
13079
|
+
var isAsyncIterableIterator = (value) => value != null && typeof value === "object" && typeof value[Symbol.asyncIterator] === "function";
|
|
13080
|
+
var isMultipartBody = (body) => body && typeof body === "object" && body.body && body[Symbol.toStringTag] === "MultipartBody";
|
|
13081
|
+
var multipartFormRequestOptions = async (opts) => {
|
|
13082
|
+
const form = await createForm(opts.body);
|
|
13083
|
+
return getMultipartRequestOptions(form, opts);
|
|
13084
|
+
};
|
|
13085
|
+
var createForm = async (body) => {
|
|
13086
|
+
const form = new FormData;
|
|
13087
|
+
await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value)));
|
|
13088
|
+
return form;
|
|
13089
|
+
};
|
|
13090
|
+
var addFormValue = async (form, key, value) => {
|
|
13091
|
+
if (value === undefined)
|
|
13211
13092
|
return;
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
|
|
13215
|
-
|
|
13216
|
-
|
|
13217
|
-
|
|
13218
|
-
|
|
13219
|
-
|
|
13220
|
-
|
|
13221
|
-
await Promise.all(
|
|
13222
|
-
|
|
13223
|
-
|
|
13224
|
-
|
|
13225
|
-
|
|
13226
|
-
|
|
13227
|
-
|
|
13228
|
-
throw new TypeError(`Received null for "${key}"; to pass null in FormData, you must use the string 'null'`);
|
|
13229
|
-
}
|
|
13230
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
13231
|
-
form.append(key, String(value));
|
|
13232
|
-
} else if (isUploadable(value)) {
|
|
13233
|
-
const file = await toFile(value);
|
|
13234
|
-
form.append(key, file);
|
|
13235
|
-
} else if (Array.isArray(value)) {
|
|
13236
|
-
await Promise.all(value.map((entry) => addFormValue(form, key + "[]", entry)));
|
|
13237
|
-
} else if (typeof value === "object") {
|
|
13238
|
-
await Promise.all(Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)));
|
|
13239
|
-
} else {
|
|
13240
|
-
throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`);
|
|
13241
|
-
}
|
|
13242
|
-
};
|
|
13243
|
-
});
|
|
13093
|
+
if (value == null) {
|
|
13094
|
+
throw new TypeError(`Received null for "${key}"; to pass null in FormData, you must use the string 'null'`);
|
|
13095
|
+
}
|
|
13096
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
13097
|
+
form.append(key, String(value));
|
|
13098
|
+
} else if (isUploadable(value)) {
|
|
13099
|
+
const file = await toFile(value);
|
|
13100
|
+
form.append(key, file);
|
|
13101
|
+
} else if (Array.isArray(value)) {
|
|
13102
|
+
await Promise.all(value.map((entry) => addFormValue(form, key + "[]", entry)));
|
|
13103
|
+
} else if (typeof value === "object") {
|
|
13104
|
+
await Promise.all(Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)));
|
|
13105
|
+
} else {
|
|
13106
|
+
throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`);
|
|
13107
|
+
}
|
|
13108
|
+
};
|
|
13244
13109
|
|
|
13245
13110
|
// node_modules/openai/core.mjs
|
|
13246
13111
|
async function defaultParseResponse(props) {
|
|
@@ -13265,6 +13130,29 @@ async function defaultParseResponse(props) {
|
|
|
13265
13130
|
debug("response", response.status, response.url, response.headers, text);
|
|
13266
13131
|
return text;
|
|
13267
13132
|
}
|
|
13133
|
+
var getBrowserInfo = function() {
|
|
13134
|
+
if (typeof navigator === "undefined" || !navigator) {
|
|
13135
|
+
return null;
|
|
13136
|
+
}
|
|
13137
|
+
const browserPatterns = [
|
|
13138
|
+
{ key: "edge", pattern: /Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
13139
|
+
{ key: "ie", pattern: /MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
13140
|
+
{ key: "ie", pattern: /Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
13141
|
+
{ key: "chrome", pattern: /Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
13142
|
+
{ key: "firefox", pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
13143
|
+
{ key: "safari", pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/ }
|
|
13144
|
+
];
|
|
13145
|
+
for (const { key, pattern } of browserPatterns) {
|
|
13146
|
+
const match = pattern.exec(navigator.userAgent);
|
|
13147
|
+
if (match) {
|
|
13148
|
+
const major = match[1] || 0;
|
|
13149
|
+
const minor = match[2] || 0;
|
|
13150
|
+
const patch = match[3] || 0;
|
|
13151
|
+
return { browser: key, version: `${major}.${minor}.${patch}` };
|
|
13152
|
+
}
|
|
13153
|
+
}
|
|
13154
|
+
return null;
|
|
13155
|
+
};
|
|
13268
13156
|
function isEmptyObj(obj) {
|
|
13269
13157
|
if (!obj)
|
|
13270
13158
|
return true;
|
|
@@ -13280,6 +13168,23 @@ function debug(action, ...args) {
|
|
|
13280
13168
|
console.log(`OpenAI:DEBUG:${action}`, ...args);
|
|
13281
13169
|
}
|
|
13282
13170
|
}
|
|
13171
|
+
var __classPrivateFieldSet5 = function(receiver, state, value, kind2, f2) {
|
|
13172
|
+
if (kind2 === "m")
|
|
13173
|
+
throw new TypeError("Private method is not writable");
|
|
13174
|
+
if (kind2 === "a" && !f2)
|
|
13175
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
13176
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
13177
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
13178
|
+
return kind2 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
13179
|
+
};
|
|
13180
|
+
var __classPrivateFieldGet6 = function(receiver, state, kind2, f2) {
|
|
13181
|
+
if (kind2 === "a" && !f2)
|
|
13182
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
13183
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
13184
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
13185
|
+
return kind2 === "m" ? f2 : kind2 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
13186
|
+
};
|
|
13187
|
+
var _AbstractPage_client;
|
|
13283
13188
|
|
|
13284
13189
|
class APIPromise extends Promise {
|
|
13285
13190
|
constructor(responsePromise, parseResponse = defaultParseResponse) {
|
|
@@ -13592,232 +13497,185 @@ class AbstractPage {
|
|
|
13592
13497
|
page = await page.getNextPage();
|
|
13593
13498
|
yield page;
|
|
13594
13499
|
}
|
|
13595
|
-
}
|
|
13596
|
-
async* [(_AbstractPage_client = new WeakMap, Symbol.asyncIterator)]() {
|
|
13597
|
-
for await (const page of this.iterPages()) {
|
|
13598
|
-
for (const item of page.getPaginatedItems()) {
|
|
13599
|
-
yield item;
|
|
13600
|
-
}
|
|
13601
|
-
}
|
|
13602
|
-
}
|
|
13603
|
-
}
|
|
13604
|
-
|
|
13605
|
-
class PagePromise extends APIPromise {
|
|
13606
|
-
constructor(client, request, Page) {
|
|
13607
|
-
super(request, async (props) => new Page(client, props.response, await defaultParseResponse(props), props.options));
|
|
13608
|
-
}
|
|
13609
|
-
async* [Symbol.asyncIterator]() {
|
|
13610
|
-
const page = await this;
|
|
13611
|
-
for await (const item of page) {
|
|
13612
|
-
yield item;
|
|
13613
|
-
}
|
|
13614
|
-
}
|
|
13615
|
-
}
|
|
13616
|
-
var getBrowserInfo, __classPrivateFieldSet5, __classPrivateFieldGet6, _AbstractPage_client, createResponseHeaders, requestOptionsKeys, isRequestOptions, getPlatformProperties, normalizeArch, normalizePlatform, _platformHeaders, getPlatformHeaders, safeJSON, startsWithSchemeRegexp, isAbsoluteURL, sleep, validatePositiveInteger, castToError, readEnv, uuid4, isRunningInBrowser;
|
|
13617
|
-
var init_core = __esm(() => {
|
|
13618
|
-
init_version();
|
|
13619
|
-
init_streaming();
|
|
13620
|
-
init_error();
|
|
13621
|
-
init__shims();
|
|
13622
|
-
init_uploads();
|
|
13623
|
-
init_uploads();
|
|
13624
|
-
getBrowserInfo = function() {
|
|
13625
|
-
if (typeof navigator === "undefined" || !navigator) {
|
|
13626
|
-
return null;
|
|
13627
|
-
}
|
|
13628
|
-
const browserPatterns = [
|
|
13629
|
-
{ key: "edge", pattern: /Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
13630
|
-
{ key: "ie", pattern: /MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
13631
|
-
{ key: "ie", pattern: /Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
13632
|
-
{ key: "chrome", pattern: /Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
13633
|
-
{ key: "firefox", pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
13634
|
-
{ key: "safari", pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/ }
|
|
13635
|
-
];
|
|
13636
|
-
for (const { key, pattern } of browserPatterns) {
|
|
13637
|
-
const match = pattern.exec(navigator.userAgent);
|
|
13638
|
-
if (match) {
|
|
13639
|
-
const major = match[1] || 0;
|
|
13640
|
-
const minor = match[2] || 0;
|
|
13641
|
-
const patch = match[3] || 0;
|
|
13642
|
-
return { browser: key, version: `${major}.${minor}.${patch}` };
|
|
13643
|
-
}
|
|
13644
|
-
}
|
|
13645
|
-
return null;
|
|
13646
|
-
};
|
|
13647
|
-
__classPrivateFieldSet5 = function(receiver, state, value, kind2, f2) {
|
|
13648
|
-
if (kind2 === "m")
|
|
13649
|
-
throw new TypeError("Private method is not writable");
|
|
13650
|
-
if (kind2 === "a" && !f2)
|
|
13651
|
-
throw new TypeError("Private accessor was defined without a setter");
|
|
13652
|
-
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
13653
|
-
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
13654
|
-
return kind2 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
13655
|
-
};
|
|
13656
|
-
__classPrivateFieldGet6 = function(receiver, state, kind2, f2) {
|
|
13657
|
-
if (kind2 === "a" && !f2)
|
|
13658
|
-
throw new TypeError("Private accessor was defined without a getter");
|
|
13659
|
-
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
13660
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
13661
|
-
return kind2 === "m" ? f2 : kind2 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
13662
|
-
};
|
|
13663
|
-
createResponseHeaders = (headers) => {
|
|
13664
|
-
return new Proxy(Object.fromEntries(headers.entries()), {
|
|
13665
|
-
get(target, name) {
|
|
13666
|
-
const key = name.toString();
|
|
13667
|
-
return target[key.toLowerCase()] || target[key];
|
|
13668
|
-
}
|
|
13669
|
-
});
|
|
13670
|
-
};
|
|
13671
|
-
requestOptionsKeys = {
|
|
13672
|
-
method: true,
|
|
13673
|
-
path: true,
|
|
13674
|
-
query: true,
|
|
13675
|
-
body: true,
|
|
13676
|
-
headers: true,
|
|
13677
|
-
maxRetries: true,
|
|
13678
|
-
stream: true,
|
|
13679
|
-
timeout: true,
|
|
13680
|
-
httpAgent: true,
|
|
13681
|
-
signal: true,
|
|
13682
|
-
idempotencyKey: true,
|
|
13683
|
-
__binaryResponse: true
|
|
13684
|
-
};
|
|
13685
|
-
isRequestOptions = (obj) => {
|
|
13686
|
-
return typeof obj === "object" && obj !== null && !isEmptyObj(obj) && Object.keys(obj).every((k2) => hasOwn(requestOptionsKeys, k2));
|
|
13687
|
-
};
|
|
13688
|
-
getPlatformProperties = () => {
|
|
13689
|
-
if (typeof Deno !== "undefined" && Deno.build != null) {
|
|
13690
|
-
return {
|
|
13691
|
-
"X-Stainless-Lang": "js",
|
|
13692
|
-
"X-Stainless-Package-Version": VERSION,
|
|
13693
|
-
"X-Stainless-OS": normalizePlatform(Deno.build.os),
|
|
13694
|
-
"X-Stainless-Arch": normalizeArch(Deno.build.arch),
|
|
13695
|
-
"X-Stainless-Runtime": "deno",
|
|
13696
|
-
"X-Stainless-Runtime-Version": Deno.version
|
|
13697
|
-
};
|
|
13698
|
-
}
|
|
13699
|
-
if (typeof EdgeRuntime !== "undefined") {
|
|
13700
|
-
return {
|
|
13701
|
-
"X-Stainless-Lang": "js",
|
|
13702
|
-
"X-Stainless-Package-Version": VERSION,
|
|
13703
|
-
"X-Stainless-OS": "Unknown",
|
|
13704
|
-
"X-Stainless-Arch": `other:${EdgeRuntime}`,
|
|
13705
|
-
"X-Stainless-Runtime": "edge",
|
|
13706
|
-
"X-Stainless-Runtime-Version": process.version
|
|
13707
|
-
};
|
|
13500
|
+
}
|
|
13501
|
+
async* [(_AbstractPage_client = new WeakMap, Symbol.asyncIterator)]() {
|
|
13502
|
+
for await (const page of this.iterPages()) {
|
|
13503
|
+
for (const item of page.getPaginatedItems()) {
|
|
13504
|
+
yield item;
|
|
13505
|
+
}
|
|
13708
13506
|
}
|
|
13709
|
-
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13507
|
+
}
|
|
13508
|
+
}
|
|
13509
|
+
|
|
13510
|
+
class PagePromise extends APIPromise {
|
|
13511
|
+
constructor(client, request, Page) {
|
|
13512
|
+
super(request, async (props) => new Page(client, props.response, await defaultParseResponse(props), props.options));
|
|
13513
|
+
}
|
|
13514
|
+
async* [Symbol.asyncIterator]() {
|
|
13515
|
+
const page = await this;
|
|
13516
|
+
for await (const item of page) {
|
|
13517
|
+
yield item;
|
|
13718
13518
|
}
|
|
13719
|
-
|
|
13720
|
-
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
|
|
13726
|
-
"X-Stainless-Runtime": `browser:${browserInfo.browser}`,
|
|
13727
|
-
"X-Stainless-Runtime-Version": browserInfo.version
|
|
13728
|
-
};
|
|
13519
|
+
}
|
|
13520
|
+
}
|
|
13521
|
+
var createResponseHeaders = (headers) => {
|
|
13522
|
+
return new Proxy(Object.fromEntries(headers.entries()), {
|
|
13523
|
+
get(target, name) {
|
|
13524
|
+
const key = name.toString();
|
|
13525
|
+
return target[key.toLowerCase()] || target[key];
|
|
13729
13526
|
}
|
|
13527
|
+
});
|
|
13528
|
+
};
|
|
13529
|
+
var requestOptionsKeys = {
|
|
13530
|
+
method: true,
|
|
13531
|
+
path: true,
|
|
13532
|
+
query: true,
|
|
13533
|
+
body: true,
|
|
13534
|
+
headers: true,
|
|
13535
|
+
maxRetries: true,
|
|
13536
|
+
stream: true,
|
|
13537
|
+
timeout: true,
|
|
13538
|
+
httpAgent: true,
|
|
13539
|
+
signal: true,
|
|
13540
|
+
idempotencyKey: true,
|
|
13541
|
+
__binaryResponse: true
|
|
13542
|
+
};
|
|
13543
|
+
var isRequestOptions = (obj) => {
|
|
13544
|
+
return typeof obj === "object" && obj !== null && !isEmptyObj(obj) && Object.keys(obj).every((k2) => hasOwn(requestOptionsKeys, k2));
|
|
13545
|
+
};
|
|
13546
|
+
var getPlatformProperties = () => {
|
|
13547
|
+
if (typeof Deno !== "undefined" && Deno.build != null) {
|
|
13548
|
+
return {
|
|
13549
|
+
"X-Stainless-Lang": "js",
|
|
13550
|
+
"X-Stainless-Package-Version": VERSION,
|
|
13551
|
+
"X-Stainless-OS": normalizePlatform(Deno.build.os),
|
|
13552
|
+
"X-Stainless-Arch": normalizeArch(Deno.build.arch),
|
|
13553
|
+
"X-Stainless-Runtime": "deno",
|
|
13554
|
+
"X-Stainless-Runtime-Version": Deno.version
|
|
13555
|
+
};
|
|
13556
|
+
}
|
|
13557
|
+
if (typeof EdgeRuntime !== "undefined") {
|
|
13558
|
+
return {
|
|
13559
|
+
"X-Stainless-Lang": "js",
|
|
13560
|
+
"X-Stainless-Package-Version": VERSION,
|
|
13561
|
+
"X-Stainless-OS": "Unknown",
|
|
13562
|
+
"X-Stainless-Arch": `other:${EdgeRuntime}`,
|
|
13563
|
+
"X-Stainless-Runtime": "edge",
|
|
13564
|
+
"X-Stainless-Runtime-Version": process.version
|
|
13565
|
+
};
|
|
13566
|
+
}
|
|
13567
|
+
if (Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]") {
|
|
13568
|
+
return {
|
|
13569
|
+
"X-Stainless-Lang": "js",
|
|
13570
|
+
"X-Stainless-Package-Version": VERSION,
|
|
13571
|
+
"X-Stainless-OS": normalizePlatform(process.platform),
|
|
13572
|
+
"X-Stainless-Arch": normalizeArch(process.arch),
|
|
13573
|
+
"X-Stainless-Runtime": "node",
|
|
13574
|
+
"X-Stainless-Runtime-Version": process.version
|
|
13575
|
+
};
|
|
13576
|
+
}
|
|
13577
|
+
const browserInfo = getBrowserInfo();
|
|
13578
|
+
if (browserInfo) {
|
|
13730
13579
|
return {
|
|
13731
13580
|
"X-Stainless-Lang": "js",
|
|
13732
13581
|
"X-Stainless-Package-Version": VERSION,
|
|
13733
13582
|
"X-Stainless-OS": "Unknown",
|
|
13734
13583
|
"X-Stainless-Arch": "unknown",
|
|
13735
|
-
"X-Stainless-Runtime":
|
|
13736
|
-
"X-Stainless-Runtime-Version":
|
|
13584
|
+
"X-Stainless-Runtime": `browser:${browserInfo.browser}`,
|
|
13585
|
+
"X-Stainless-Runtime-Version": browserInfo.version
|
|
13737
13586
|
};
|
|
13587
|
+
}
|
|
13588
|
+
return {
|
|
13589
|
+
"X-Stainless-Lang": "js",
|
|
13590
|
+
"X-Stainless-Package-Version": VERSION,
|
|
13591
|
+
"X-Stainless-OS": "Unknown",
|
|
13592
|
+
"X-Stainless-Arch": "unknown",
|
|
13593
|
+
"X-Stainless-Runtime": "unknown",
|
|
13594
|
+
"X-Stainless-Runtime-Version": "unknown"
|
|
13738
13595
|
};
|
|
13739
|
-
|
|
13740
|
-
|
|
13741
|
-
|
|
13742
|
-
|
|
13743
|
-
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
|
|
13749
|
-
|
|
13750
|
-
return
|
|
13751
|
-
|
|
13752
|
-
|
|
13753
|
-
|
|
13754
|
-
|
|
13755
|
-
|
|
13756
|
-
|
|
13757
|
-
|
|
13758
|
-
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
return
|
|
13771
|
-
|
|
13772
|
-
|
|
13773
|
-
|
|
13774
|
-
|
|
13775
|
-
|
|
13776
|
-
|
|
13777
|
-
|
|
13778
|
-
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
};
|
|
13782
|
-
startsWithSchemeRegexp = new RegExp("^(?:[a-z]+:)?//", "i");
|
|
13783
|
-
isAbsoluteURL = (url) => {
|
|
13784
|
-
return startsWithSchemeRegexp.test(url);
|
|
13785
|
-
};
|
|
13786
|
-
sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
13787
|
-
validatePositiveInteger = (name, n2) => {
|
|
13788
|
-
if (typeof n2 !== "number" || !Number.isInteger(n2)) {
|
|
13789
|
-
throw new OpenAIError(`${name} must be an integer`);
|
|
13790
|
-
}
|
|
13791
|
-
if (n2 < 0) {
|
|
13792
|
-
throw new OpenAIError(`${name} must be a positive integer`);
|
|
13793
|
-
}
|
|
13794
|
-
return n2;
|
|
13795
|
-
};
|
|
13796
|
-
castToError = (err) => {
|
|
13797
|
-
if (err instanceof Error)
|
|
13798
|
-
return err;
|
|
13799
|
-
return new Error(err);
|
|
13800
|
-
};
|
|
13801
|
-
readEnv = (env) => {
|
|
13802
|
-
if (typeof process !== "undefined") {
|
|
13803
|
-
return process.env?.[env] ?? undefined;
|
|
13804
|
-
}
|
|
13805
|
-
if (typeof Deno !== "undefined") {
|
|
13806
|
-
return Deno.env?.get?.(env);
|
|
13807
|
-
}
|
|
13596
|
+
};
|
|
13597
|
+
var normalizeArch = (arch) => {
|
|
13598
|
+
if (arch === "x32")
|
|
13599
|
+
return "x32";
|
|
13600
|
+
if (arch === "x86_64" || arch === "x64")
|
|
13601
|
+
return "x64";
|
|
13602
|
+
if (arch === "arm")
|
|
13603
|
+
return "arm";
|
|
13604
|
+
if (arch === "aarch64" || arch === "arm64")
|
|
13605
|
+
return "arm64";
|
|
13606
|
+
if (arch)
|
|
13607
|
+
return `other:${arch}`;
|
|
13608
|
+
return "unknown";
|
|
13609
|
+
};
|
|
13610
|
+
var normalizePlatform = (platform) => {
|
|
13611
|
+
platform = platform.toLowerCase();
|
|
13612
|
+
if (platform.includes("ios"))
|
|
13613
|
+
return "iOS";
|
|
13614
|
+
if (platform === "android")
|
|
13615
|
+
return "Android";
|
|
13616
|
+
if (platform === "darwin")
|
|
13617
|
+
return "MacOS";
|
|
13618
|
+
if (platform === "win32")
|
|
13619
|
+
return "Windows";
|
|
13620
|
+
if (platform === "freebsd")
|
|
13621
|
+
return "FreeBSD";
|
|
13622
|
+
if (platform === "openbsd")
|
|
13623
|
+
return "OpenBSD";
|
|
13624
|
+
if (platform === "linux")
|
|
13625
|
+
return "Linux";
|
|
13626
|
+
if (platform)
|
|
13627
|
+
return `Other:${platform}`;
|
|
13628
|
+
return "Unknown";
|
|
13629
|
+
};
|
|
13630
|
+
var _platformHeaders;
|
|
13631
|
+
var getPlatformHeaders = () => {
|
|
13632
|
+
return _platformHeaders ?? (_platformHeaders = getPlatformProperties());
|
|
13633
|
+
};
|
|
13634
|
+
var safeJSON = (text) => {
|
|
13635
|
+
try {
|
|
13636
|
+
return JSON.parse(text);
|
|
13637
|
+
} catch (err) {
|
|
13808
13638
|
return;
|
|
13809
|
-
}
|
|
13810
|
-
|
|
13811
|
-
|
|
13812
|
-
|
|
13813
|
-
|
|
13814
|
-
|
|
13815
|
-
|
|
13816
|
-
|
|
13817
|
-
|
|
13818
|
-
|
|
13819
|
-
}
|
|
13820
|
-
|
|
13639
|
+
}
|
|
13640
|
+
};
|
|
13641
|
+
var startsWithSchemeRegexp = new RegExp("^(?:[a-z]+:)?//", "i");
|
|
13642
|
+
var isAbsoluteURL = (url) => {
|
|
13643
|
+
return startsWithSchemeRegexp.test(url);
|
|
13644
|
+
};
|
|
13645
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
13646
|
+
var validatePositiveInteger = (name, n2) => {
|
|
13647
|
+
if (typeof n2 !== "number" || !Number.isInteger(n2)) {
|
|
13648
|
+
throw new OpenAIError(`${name} must be an integer`);
|
|
13649
|
+
}
|
|
13650
|
+
if (n2 < 0) {
|
|
13651
|
+
throw new OpenAIError(`${name} must be a positive integer`);
|
|
13652
|
+
}
|
|
13653
|
+
return n2;
|
|
13654
|
+
};
|
|
13655
|
+
var castToError = (err) => {
|
|
13656
|
+
if (err instanceof Error)
|
|
13657
|
+
return err;
|
|
13658
|
+
return new Error(err);
|
|
13659
|
+
};
|
|
13660
|
+
var readEnv = (env) => {
|
|
13661
|
+
if (typeof process !== "undefined") {
|
|
13662
|
+
return process.env?.[env] ?? undefined;
|
|
13663
|
+
}
|
|
13664
|
+
if (typeof Deno !== "undefined") {
|
|
13665
|
+
return Deno.env?.get?.(env);
|
|
13666
|
+
}
|
|
13667
|
+
return;
|
|
13668
|
+
};
|
|
13669
|
+
var uuid4 = () => {
|
|
13670
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c2) => {
|
|
13671
|
+
const r2 = Math.random() * 16 | 0;
|
|
13672
|
+
const v2 = c2 === "x" ? r2 : r2 & 3 | 8;
|
|
13673
|
+
return v2.toString(16);
|
|
13674
|
+
});
|
|
13675
|
+
};
|
|
13676
|
+
var isRunningInBrowser = () => {
|
|
13677
|
+
return typeof window !== "undefined" && typeof window.document !== "undefined" && typeof navigator !== "undefined";
|
|
13678
|
+
};
|
|
13821
13679
|
|
|
13822
13680
|
// node_modules/openai/pagination.mjs
|
|
13823
13681
|
class Page extends AbstractPage {
|
|
@@ -13868,9 +13726,6 @@ class CursorPage extends AbstractPage {
|
|
|
13868
13726
|
return { params: { after: id } };
|
|
13869
13727
|
}
|
|
13870
13728
|
}
|
|
13871
|
-
var init_pagination = __esm(() => {
|
|
13872
|
-
init_core();
|
|
13873
|
-
});
|
|
13874
13729
|
|
|
13875
13730
|
// node_modules/openai/resource.mjs
|
|
13876
13731
|
class APIResource {
|
|
@@ -13878,8 +13733,6 @@ class APIResource {
|
|
|
13878
13733
|
this._client = client;
|
|
13879
13734
|
}
|
|
13880
13735
|
}
|
|
13881
|
-
var init_resource = __esm(() => {
|
|
13882
|
-
});
|
|
13883
13736
|
|
|
13884
13737
|
// node_modules/openai/resources/chat/completions.mjs
|
|
13885
13738
|
class Completions extends APIResource {
|
|
@@ -13887,11 +13740,8 @@ class Completions extends APIResource {
|
|
|
13887
13740
|
return this._client.post("/chat/completions", { body, ...options, stream: body.stream ?? false });
|
|
13888
13741
|
}
|
|
13889
13742
|
}
|
|
13890
|
-
|
|
13891
|
-
|
|
13892
|
-
(function(Completions2) {
|
|
13893
|
-
})(Completions || (Completions = {}));
|
|
13894
|
-
});
|
|
13743
|
+
(function(Completions2) {
|
|
13744
|
+
})(Completions || (Completions = {}));
|
|
13895
13745
|
|
|
13896
13746
|
// node_modules/openai/resources/chat/chat.mjs
|
|
13897
13747
|
class Chat extends APIResource {
|
|
@@ -13900,34 +13750,17 @@ class Chat extends APIResource {
|
|
|
13900
13750
|
this.completions = new Completions(this._client);
|
|
13901
13751
|
}
|
|
13902
13752
|
}
|
|
13903
|
-
|
|
13904
|
-
|
|
13905
|
-
|
|
13906
|
-
(function(Chat2) {
|
|
13907
|
-
Chat2.Completions = Completions;
|
|
13908
|
-
})(Chat || (Chat = {}));
|
|
13909
|
-
});
|
|
13910
|
-
|
|
13911
|
-
// node_modules/openai/resources/chat/index.mjs
|
|
13912
|
-
var init_chat2 = __esm(() => {
|
|
13913
|
-
init_chat();
|
|
13914
|
-
});
|
|
13915
|
-
|
|
13916
|
-
// node_modules/openai/resources/shared.mjs
|
|
13917
|
-
var init_shared = __esm(() => {
|
|
13918
|
-
});
|
|
13919
|
-
|
|
13753
|
+
(function(Chat2) {
|
|
13754
|
+
Chat2.Completions = Completions;
|
|
13755
|
+
})(Chat || (Chat = {}));
|
|
13920
13756
|
// node_modules/openai/resources/audio/speech.mjs
|
|
13921
13757
|
class Speech extends APIResource {
|
|
13922
13758
|
create(body, options) {
|
|
13923
13759
|
return this._client.post("/audio/speech", { body, ...options, __binaryResponse: true });
|
|
13924
13760
|
}
|
|
13925
13761
|
}
|
|
13926
|
-
|
|
13927
|
-
|
|
13928
|
-
(function(Speech2) {
|
|
13929
|
-
})(Speech || (Speech = {}));
|
|
13930
|
-
});
|
|
13762
|
+
(function(Speech2) {
|
|
13763
|
+
})(Speech || (Speech = {}));
|
|
13931
13764
|
|
|
13932
13765
|
// node_modules/openai/resources/audio/transcriptions.mjs
|
|
13933
13766
|
class Transcriptions extends APIResource {
|
|
@@ -13935,12 +13768,8 @@ class Transcriptions extends APIResource {
|
|
|
13935
13768
|
return this._client.post("/audio/transcriptions", multipartFormRequestOptions({ body, ...options }));
|
|
13936
13769
|
}
|
|
13937
13770
|
}
|
|
13938
|
-
|
|
13939
|
-
|
|
13940
|
-
init_core();
|
|
13941
|
-
(function(Transcriptions2) {
|
|
13942
|
-
})(Transcriptions || (Transcriptions = {}));
|
|
13943
|
-
});
|
|
13771
|
+
(function(Transcriptions2) {
|
|
13772
|
+
})(Transcriptions || (Transcriptions = {}));
|
|
13944
13773
|
|
|
13945
13774
|
// node_modules/openai/resources/audio/translations.mjs
|
|
13946
13775
|
class Translations extends APIResource {
|
|
@@ -13948,12 +13777,8 @@ class Translations extends APIResource {
|
|
|
13948
13777
|
return this._client.post("/audio/translations", multipartFormRequestOptions({ body, ...options }));
|
|
13949
13778
|
}
|
|
13950
13779
|
}
|
|
13951
|
-
|
|
13952
|
-
|
|
13953
|
-
init_core();
|
|
13954
|
-
(function(Translations2) {
|
|
13955
|
-
})(Translations || (Translations = {}));
|
|
13956
|
-
});
|
|
13780
|
+
(function(Translations2) {
|
|
13781
|
+
})(Translations || (Translations = {}));
|
|
13957
13782
|
|
|
13958
13783
|
// node_modules/openai/resources/audio/audio.mjs
|
|
13959
13784
|
class Audio extends APIResource {
|
|
@@ -13964,18 +13789,11 @@ class Audio extends APIResource {
|
|
|
13964
13789
|
this.speech = new Speech(this._client);
|
|
13965
13790
|
}
|
|
13966
13791
|
}
|
|
13967
|
-
|
|
13968
|
-
|
|
13969
|
-
|
|
13970
|
-
|
|
13971
|
-
|
|
13972
|
-
(function(Audio2) {
|
|
13973
|
-
Audio2.Transcriptions = Transcriptions;
|
|
13974
|
-
Audio2.Translations = Translations;
|
|
13975
|
-
Audio2.Speech = Speech;
|
|
13976
|
-
})(Audio || (Audio = {}));
|
|
13977
|
-
});
|
|
13978
|
-
|
|
13792
|
+
(function(Audio2) {
|
|
13793
|
+
Audio2.Transcriptions = Transcriptions;
|
|
13794
|
+
Audio2.Translations = Translations;
|
|
13795
|
+
Audio2.Speech = Speech;
|
|
13796
|
+
})(Audio || (Audio = {}));
|
|
13979
13797
|
// node_modules/openai/resources/beta/assistants/files.mjs
|
|
13980
13798
|
class Files extends APIResource {
|
|
13981
13799
|
create(assistantId, body, options) {
|
|
@@ -14011,15 +13829,9 @@ class Files extends APIResource {
|
|
|
14011
13829
|
|
|
14012
13830
|
class AssistantFilesPage extends CursorPage {
|
|
14013
13831
|
}
|
|
14014
|
-
|
|
14015
|
-
|
|
14016
|
-
|
|
14017
|
-
init_files();
|
|
14018
|
-
init_pagination();
|
|
14019
|
-
(function(Files2) {
|
|
14020
|
-
Files2.AssistantFilesPage = AssistantFilesPage;
|
|
14021
|
-
})(Files || (Files = {}));
|
|
14022
|
-
});
|
|
13832
|
+
(function(Files2) {
|
|
13833
|
+
Files2.AssistantFilesPage = AssistantFilesPage;
|
|
13834
|
+
})(Files || (Files = {}));
|
|
14023
13835
|
|
|
14024
13836
|
// node_modules/openai/resources/beta/assistants/assistants.mjs
|
|
14025
13837
|
class Assistants extends APIResource {
|
|
@@ -14067,41 +13879,67 @@ class Assistants extends APIResource {
|
|
|
14067
13879
|
|
|
14068
13880
|
class AssistantsPage extends CursorPage {
|
|
14069
13881
|
}
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
init_pagination();
|
|
14076
|
-
(function(Assistants2) {
|
|
14077
|
-
Assistants2.AssistantsPage = AssistantsPage;
|
|
14078
|
-
Assistants2.Files = Files;
|
|
14079
|
-
Assistants2.AssistantFilesPage = AssistantFilesPage;
|
|
14080
|
-
})(Assistants || (Assistants = {}));
|
|
14081
|
-
});
|
|
13882
|
+
(function(Assistants2) {
|
|
13883
|
+
Assistants2.AssistantsPage = AssistantsPage;
|
|
13884
|
+
Assistants2.Files = Files;
|
|
13885
|
+
Assistants2.AssistantFilesPage = AssistantFilesPage;
|
|
13886
|
+
})(Assistants || (Assistants = {}));
|
|
14082
13887
|
|
|
14083
13888
|
// node_modules/openai/lib/RunnableFunction.mjs
|
|
14084
13889
|
function isRunnableFunctionWithParse(fn) {
|
|
14085
13890
|
return typeof fn.parse === "function";
|
|
14086
13891
|
}
|
|
14087
|
-
var init_RunnableFunction = __esm(() => {
|
|
14088
|
-
});
|
|
14089
13892
|
|
|
14090
13893
|
// node_modules/openai/lib/chatCompletionUtils.mjs
|
|
14091
|
-
var isAssistantMessage
|
|
14092
|
-
|
|
14093
|
-
|
|
14094
|
-
|
|
14095
|
-
|
|
14096
|
-
|
|
14097
|
-
|
|
14098
|
-
|
|
14099
|
-
|
|
14100
|
-
return message?.role === "tool";
|
|
14101
|
-
};
|
|
14102
|
-
});
|
|
13894
|
+
var isAssistantMessage = (message) => {
|
|
13895
|
+
return message?.role === "assistant";
|
|
13896
|
+
};
|
|
13897
|
+
var isFunctionMessage = (message) => {
|
|
13898
|
+
return message?.role === "function";
|
|
13899
|
+
};
|
|
13900
|
+
var isToolMessage = (message) => {
|
|
13901
|
+
return message?.role === "tool";
|
|
13902
|
+
};
|
|
14103
13903
|
|
|
14104
13904
|
// node_modules/openai/lib/AbstractChatCompletionRunner.mjs
|
|
13905
|
+
var __classPrivateFieldSet6 = function(receiver, state, value, kind2, f2) {
|
|
13906
|
+
if (kind2 === "m")
|
|
13907
|
+
throw new TypeError("Private method is not writable");
|
|
13908
|
+
if (kind2 === "a" && !f2)
|
|
13909
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
13910
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
13911
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
13912
|
+
return kind2 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
13913
|
+
};
|
|
13914
|
+
var __classPrivateFieldGet7 = function(receiver, state, kind2, f2) {
|
|
13915
|
+
if (kind2 === "a" && !f2)
|
|
13916
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
13917
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
13918
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
13919
|
+
return kind2 === "m" ? f2 : kind2 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
13920
|
+
};
|
|
13921
|
+
var _AbstractChatCompletionRunner_instances;
|
|
13922
|
+
var _AbstractChatCompletionRunner_connectedPromise;
|
|
13923
|
+
var _AbstractChatCompletionRunner_resolveConnectedPromise;
|
|
13924
|
+
var _AbstractChatCompletionRunner_rejectConnectedPromise;
|
|
13925
|
+
var _AbstractChatCompletionRunner_endPromise;
|
|
13926
|
+
var _AbstractChatCompletionRunner_resolveEndPromise;
|
|
13927
|
+
var _AbstractChatCompletionRunner_rejectEndPromise;
|
|
13928
|
+
var _AbstractChatCompletionRunner_listeners;
|
|
13929
|
+
var _AbstractChatCompletionRunner_ended;
|
|
13930
|
+
var _AbstractChatCompletionRunner_errored;
|
|
13931
|
+
var _AbstractChatCompletionRunner_aborted;
|
|
13932
|
+
var _AbstractChatCompletionRunner_catchingPromiseCreated;
|
|
13933
|
+
var _AbstractChatCompletionRunner_getFinalContent;
|
|
13934
|
+
var _AbstractChatCompletionRunner_getFinalMessage;
|
|
13935
|
+
var _AbstractChatCompletionRunner_getFinalFunctionCall;
|
|
13936
|
+
var _AbstractChatCompletionRunner_getFinalFunctionCallResult;
|
|
13937
|
+
var _AbstractChatCompletionRunner_calculateTotalUsage;
|
|
13938
|
+
var _AbstractChatCompletionRunner_handleError;
|
|
13939
|
+
var _AbstractChatCompletionRunner_validateParams;
|
|
13940
|
+
var _AbstractChatCompletionRunner_stringifyFunctionCallResult;
|
|
13941
|
+
var DEFAULT_MAX_CHAT_COMPLETIONS = 10;
|
|
13942
|
+
|
|
14105
13943
|
class AbstractChatCompletionRunner {
|
|
14106
13944
|
constructor() {
|
|
14107
13945
|
_AbstractChatCompletionRunner_instances.add(this);
|
|
@@ -14469,83 +14307,60 @@ class AbstractChatCompletionRunner {
|
|
|
14469
14307
|
return;
|
|
14470
14308
|
}
|
|
14471
14309
|
}
|
|
14472
|
-
|
|
14473
|
-
|
|
14474
|
-
|
|
14475
|
-
|
|
14476
|
-
|
|
14477
|
-
|
|
14478
|
-
if (
|
|
14479
|
-
|
|
14480
|
-
|
|
14481
|
-
|
|
14482
|
-
|
|
14483
|
-
|
|
14484
|
-
|
|
14485
|
-
|
|
14486
|
-
|
|
14487
|
-
|
|
14488
|
-
|
|
14489
|
-
if (
|
|
14490
|
-
|
|
14491
|
-
|
|
14492
|
-
}
|
|
14493
|
-
|
|
14494
|
-
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
|
|
14498
|
-
|
|
14499
|
-
|
|
14500
|
-
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
|
|
14505
|
-
|
|
14506
|
-
|
|
14507
|
-
|
|
14508
|
-
|
|
14509
|
-
|
|
14510
|
-
|
|
14511
|
-
|
|
14512
|
-
|
|
14513
|
-
|
|
14514
|
-
|
|
14515
|
-
|
|
14516
|
-
|
|
14517
|
-
|
|
14518
|
-
|
|
14519
|
-
|
|
14520
|
-
|
|
14521
|
-
|
|
14522
|
-
|
|
14523
|
-
|
|
14524
|
-
|
|
14525
|
-
|
|
14526
|
-
return;
|
|
14527
|
-
}, _AbstractChatCompletionRunner_calculateTotalUsage = function _AbstractChatCompletionRunner_calculateTotalUsage2() {
|
|
14528
|
-
const total = {
|
|
14529
|
-
completion_tokens: 0,
|
|
14530
|
-
prompt_tokens: 0,
|
|
14531
|
-
total_tokens: 0
|
|
14532
|
-
};
|
|
14533
|
-
for (const { usage } of this._chatCompletions) {
|
|
14534
|
-
if (usage) {
|
|
14535
|
-
total.completion_tokens += usage.completion_tokens;
|
|
14536
|
-
total.prompt_tokens += usage.prompt_tokens;
|
|
14537
|
-
total.total_tokens += usage.total_tokens;
|
|
14538
|
-
}
|
|
14539
|
-
}
|
|
14540
|
-
return total;
|
|
14541
|
-
}, _AbstractChatCompletionRunner_validateParams = function _AbstractChatCompletionRunner_validateParams2(params) {
|
|
14542
|
-
if (params.n != null && params.n > 1) {
|
|
14543
|
-
throw new OpenAIError("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.");
|
|
14544
|
-
}
|
|
14545
|
-
}, _AbstractChatCompletionRunner_stringifyFunctionCallResult = function _AbstractChatCompletionRunner_stringifyFunctionCallResult2(rawContent) {
|
|
14546
|
-
return typeof rawContent === "string" ? rawContent : rawContent === undefined ? "undefined" : JSON.stringify(rawContent);
|
|
14547
|
-
};
|
|
14548
|
-
});
|
|
14310
|
+
_AbstractChatCompletionRunner_connectedPromise = new WeakMap, _AbstractChatCompletionRunner_resolveConnectedPromise = new WeakMap, _AbstractChatCompletionRunner_rejectConnectedPromise = new WeakMap, _AbstractChatCompletionRunner_endPromise = new WeakMap, _AbstractChatCompletionRunner_resolveEndPromise = new WeakMap, _AbstractChatCompletionRunner_rejectEndPromise = new WeakMap, _AbstractChatCompletionRunner_listeners = new WeakMap, _AbstractChatCompletionRunner_ended = new WeakMap, _AbstractChatCompletionRunner_errored = new WeakMap, _AbstractChatCompletionRunner_aborted = new WeakMap, _AbstractChatCompletionRunner_catchingPromiseCreated = new WeakMap, _AbstractChatCompletionRunner_handleError = new WeakMap, _AbstractChatCompletionRunner_instances = new WeakSet, _AbstractChatCompletionRunner_getFinalContent = function _AbstractChatCompletionRunner_getFinalContent2() {
|
|
14311
|
+
return __classPrivateFieldGet7(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this).content ?? null;
|
|
14312
|
+
}, _AbstractChatCompletionRunner_getFinalMessage = function _AbstractChatCompletionRunner_getFinalMessage2() {
|
|
14313
|
+
let i2 = this.messages.length;
|
|
14314
|
+
while (i2-- > 0) {
|
|
14315
|
+
const message = this.messages[i2];
|
|
14316
|
+
if (isAssistantMessage(message)) {
|
|
14317
|
+
return { ...message, content: message.content ?? null };
|
|
14318
|
+
}
|
|
14319
|
+
}
|
|
14320
|
+
throw new OpenAIError("stream ended without producing a ChatCompletionMessage with role=assistant");
|
|
14321
|
+
}, _AbstractChatCompletionRunner_getFinalFunctionCall = function _AbstractChatCompletionRunner_getFinalFunctionCall2() {
|
|
14322
|
+
for (let i2 = this.messages.length - 1;i2 >= 0; i2--) {
|
|
14323
|
+
const message = this.messages[i2];
|
|
14324
|
+
if (isAssistantMessage(message) && message?.function_call) {
|
|
14325
|
+
return message.function_call;
|
|
14326
|
+
}
|
|
14327
|
+
if (isAssistantMessage(message) && message?.tool_calls?.length) {
|
|
14328
|
+
return message.tool_calls.at(-1)?.function;
|
|
14329
|
+
}
|
|
14330
|
+
}
|
|
14331
|
+
return;
|
|
14332
|
+
}, _AbstractChatCompletionRunner_getFinalFunctionCallResult = function _AbstractChatCompletionRunner_getFinalFunctionCallResult2() {
|
|
14333
|
+
for (let i2 = this.messages.length - 1;i2 >= 0; i2--) {
|
|
14334
|
+
const message = this.messages[i2];
|
|
14335
|
+
if (isFunctionMessage(message) && message.content != null) {
|
|
14336
|
+
return message.content;
|
|
14337
|
+
}
|
|
14338
|
+
if (isToolMessage(message) && message.content != null && this.messages.some((x2) => x2.role === "assistant" && x2.tool_calls?.some((y2) => y2.type === "function" && y2.id === message.tool_call_id))) {
|
|
14339
|
+
return message.content;
|
|
14340
|
+
}
|
|
14341
|
+
}
|
|
14342
|
+
return;
|
|
14343
|
+
}, _AbstractChatCompletionRunner_calculateTotalUsage = function _AbstractChatCompletionRunner_calculateTotalUsage2() {
|
|
14344
|
+
const total = {
|
|
14345
|
+
completion_tokens: 0,
|
|
14346
|
+
prompt_tokens: 0,
|
|
14347
|
+
total_tokens: 0
|
|
14348
|
+
};
|
|
14349
|
+
for (const { usage } of this._chatCompletions) {
|
|
14350
|
+
if (usage) {
|
|
14351
|
+
total.completion_tokens += usage.completion_tokens;
|
|
14352
|
+
total.prompt_tokens += usage.prompt_tokens;
|
|
14353
|
+
total.total_tokens += usage.total_tokens;
|
|
14354
|
+
}
|
|
14355
|
+
}
|
|
14356
|
+
return total;
|
|
14357
|
+
}, _AbstractChatCompletionRunner_validateParams = function _AbstractChatCompletionRunner_validateParams2(params) {
|
|
14358
|
+
if (params.n != null && params.n > 1) {
|
|
14359
|
+
throw new OpenAIError("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.");
|
|
14360
|
+
}
|
|
14361
|
+
}, _AbstractChatCompletionRunner_stringifyFunctionCallResult = function _AbstractChatCompletionRunner_stringifyFunctionCallResult2(rawContent) {
|
|
14362
|
+
return typeof rawContent === "string" ? rawContent : rawContent === undefined ? "undefined" : JSON.stringify(rawContent);
|
|
14363
|
+
};
|
|
14549
14364
|
|
|
14550
14365
|
// node_modules/openai/lib/ChatCompletionRunner.mjs
|
|
14551
14366
|
class ChatCompletionRunner extends AbstractChatCompletionRunner {
|
|
@@ -14574,12 +14389,89 @@ class ChatCompletionRunner extends AbstractChatCompletionRunner {
|
|
|
14574
14389
|
}
|
|
14575
14390
|
}
|
|
14576
14391
|
}
|
|
14577
|
-
var init_ChatCompletionRunner = __esm(() => {
|
|
14578
|
-
init_AbstractChatCompletionRunner();
|
|
14579
|
-
init_chatCompletionUtils();
|
|
14580
|
-
});
|
|
14581
14392
|
|
|
14582
14393
|
// node_modules/openai/lib/ChatCompletionStream.mjs
|
|
14394
|
+
var finalizeChatCompletion = function(snapshot) {
|
|
14395
|
+
const { id, choices, created, model } = snapshot;
|
|
14396
|
+
return {
|
|
14397
|
+
id,
|
|
14398
|
+
choices: choices.map(({ message, finish_reason, index, logprobs }) => {
|
|
14399
|
+
if (!finish_reason)
|
|
14400
|
+
throw new OpenAIError(`missing finish_reason for choice ${index}`);
|
|
14401
|
+
const { content = null, function_call, tool_calls } = message;
|
|
14402
|
+
const role = message.role;
|
|
14403
|
+
if (!role)
|
|
14404
|
+
throw new OpenAIError(`missing role for choice ${index}`);
|
|
14405
|
+
if (function_call) {
|
|
14406
|
+
const { arguments: args, name } = function_call;
|
|
14407
|
+
if (args == null)
|
|
14408
|
+
throw new OpenAIError(`missing function_call.arguments for choice ${index}`);
|
|
14409
|
+
if (!name)
|
|
14410
|
+
throw new OpenAIError(`missing function_call.name for choice ${index}`);
|
|
14411
|
+
return {
|
|
14412
|
+
message: { content, function_call: { arguments: args, name }, role },
|
|
14413
|
+
finish_reason,
|
|
14414
|
+
index,
|
|
14415
|
+
logprobs
|
|
14416
|
+
};
|
|
14417
|
+
}
|
|
14418
|
+
if (tool_calls) {
|
|
14419
|
+
return {
|
|
14420
|
+
index,
|
|
14421
|
+
finish_reason,
|
|
14422
|
+
logprobs,
|
|
14423
|
+
message: {
|
|
14424
|
+
role,
|
|
14425
|
+
content,
|
|
14426
|
+
tool_calls: tool_calls.map((tool_call, i2) => {
|
|
14427
|
+
const { function: fn, type, id: id2 } = tool_call;
|
|
14428
|
+
const { arguments: args, name } = fn || {};
|
|
14429
|
+
if (id2 == null)
|
|
14430
|
+
throw new OpenAIError(`missing choices[${index}].tool_calls[${i2}].id\n${str(snapshot)}`);
|
|
14431
|
+
if (type == null)
|
|
14432
|
+
throw new OpenAIError(`missing choices[${index}].tool_calls[${i2}].type\n${str(snapshot)}`);
|
|
14433
|
+
if (name == null)
|
|
14434
|
+
throw new OpenAIError(`missing choices[${index}].tool_calls[${i2}].function.name\n${str(snapshot)}`);
|
|
14435
|
+
if (args == null)
|
|
14436
|
+
throw new OpenAIError(`missing choices[${index}].tool_calls[${i2}].function.arguments\n${str(snapshot)}`);
|
|
14437
|
+
return { id: id2, type, function: { name, arguments: args } };
|
|
14438
|
+
})
|
|
14439
|
+
}
|
|
14440
|
+
};
|
|
14441
|
+
}
|
|
14442
|
+
return { message: { content, role }, finish_reason, index, logprobs };
|
|
14443
|
+
}),
|
|
14444
|
+
created,
|
|
14445
|
+
model,
|
|
14446
|
+
object: "chat.completion"
|
|
14447
|
+
};
|
|
14448
|
+
};
|
|
14449
|
+
var str = function(x2) {
|
|
14450
|
+
return JSON.stringify(x2);
|
|
14451
|
+
};
|
|
14452
|
+
var __classPrivateFieldGet8 = function(receiver, state, kind2, f2) {
|
|
14453
|
+
if (kind2 === "a" && !f2)
|
|
14454
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
14455
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
14456
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
14457
|
+
return kind2 === "m" ? f2 : kind2 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
14458
|
+
};
|
|
14459
|
+
var __classPrivateFieldSet7 = function(receiver, state, value, kind2, f2) {
|
|
14460
|
+
if (kind2 === "m")
|
|
14461
|
+
throw new TypeError("Private method is not writable");
|
|
14462
|
+
if (kind2 === "a" && !f2)
|
|
14463
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
14464
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
14465
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
14466
|
+
return kind2 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
14467
|
+
};
|
|
14468
|
+
var _ChatCompletionStream_instances;
|
|
14469
|
+
var _ChatCompletionStream_currentChatCompletionSnapshot;
|
|
14470
|
+
var _ChatCompletionStream_beginRequest;
|
|
14471
|
+
var _ChatCompletionStream_addChunk;
|
|
14472
|
+
var _ChatCompletionStream_endRequest;
|
|
14473
|
+
var _ChatCompletionStream_accumulateChatCompletion;
|
|
14474
|
+
|
|
14583
14475
|
class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
14584
14476
|
constructor() {
|
|
14585
14477
|
super(...arguments);
|
|
@@ -14768,86 +14660,6 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
14768
14660
|
return stream.toReadableStream();
|
|
14769
14661
|
}
|
|
14770
14662
|
}
|
|
14771
|
-
var finalizeChatCompletion, str, __classPrivateFieldGet8, __classPrivateFieldSet7, _ChatCompletionStream_instances, _ChatCompletionStream_currentChatCompletionSnapshot, _ChatCompletionStream_beginRequest, _ChatCompletionStream_addChunk, _ChatCompletionStream_endRequest, _ChatCompletionStream_accumulateChatCompletion;
|
|
14772
|
-
var init_ChatCompletionStream = __esm(() => {
|
|
14773
|
-
init_error();
|
|
14774
|
-
init_AbstractChatCompletionRunner();
|
|
14775
|
-
init_streaming();
|
|
14776
|
-
finalizeChatCompletion = function(snapshot) {
|
|
14777
|
-
const { id, choices, created, model } = snapshot;
|
|
14778
|
-
return {
|
|
14779
|
-
id,
|
|
14780
|
-
choices: choices.map(({ message, finish_reason, index, logprobs }) => {
|
|
14781
|
-
if (!finish_reason)
|
|
14782
|
-
throw new OpenAIError(`missing finish_reason for choice ${index}`);
|
|
14783
|
-
const { content = null, function_call, tool_calls } = message;
|
|
14784
|
-
const role = message.role;
|
|
14785
|
-
if (!role)
|
|
14786
|
-
throw new OpenAIError(`missing role for choice ${index}`);
|
|
14787
|
-
if (function_call) {
|
|
14788
|
-
const { arguments: args, name } = function_call;
|
|
14789
|
-
if (args == null)
|
|
14790
|
-
throw new OpenAIError(`missing function_call.arguments for choice ${index}`);
|
|
14791
|
-
if (!name)
|
|
14792
|
-
throw new OpenAIError(`missing function_call.name for choice ${index}`);
|
|
14793
|
-
return {
|
|
14794
|
-
message: { content, function_call: { arguments: args, name }, role },
|
|
14795
|
-
finish_reason,
|
|
14796
|
-
index,
|
|
14797
|
-
logprobs
|
|
14798
|
-
};
|
|
14799
|
-
}
|
|
14800
|
-
if (tool_calls) {
|
|
14801
|
-
return {
|
|
14802
|
-
index,
|
|
14803
|
-
finish_reason,
|
|
14804
|
-
logprobs,
|
|
14805
|
-
message: {
|
|
14806
|
-
role,
|
|
14807
|
-
content,
|
|
14808
|
-
tool_calls: tool_calls.map((tool_call, i2) => {
|
|
14809
|
-
const { function: fn, type, id: id2 } = tool_call;
|
|
14810
|
-
const { arguments: args, name } = fn || {};
|
|
14811
|
-
if (id2 == null)
|
|
14812
|
-
throw new OpenAIError(`missing choices[${index}].tool_calls[${i2}].id\n${str(snapshot)}`);
|
|
14813
|
-
if (type == null)
|
|
14814
|
-
throw new OpenAIError(`missing choices[${index}].tool_calls[${i2}].type\n${str(snapshot)}`);
|
|
14815
|
-
if (name == null)
|
|
14816
|
-
throw new OpenAIError(`missing choices[${index}].tool_calls[${i2}].function.name\n${str(snapshot)}`);
|
|
14817
|
-
if (args == null)
|
|
14818
|
-
throw new OpenAIError(`missing choices[${index}].tool_calls[${i2}].function.arguments\n${str(snapshot)}`);
|
|
14819
|
-
return { id: id2, type, function: { name, arguments: args } };
|
|
14820
|
-
})
|
|
14821
|
-
}
|
|
14822
|
-
};
|
|
14823
|
-
}
|
|
14824
|
-
return { message: { content, role }, finish_reason, index, logprobs };
|
|
14825
|
-
}),
|
|
14826
|
-
created,
|
|
14827
|
-
model,
|
|
14828
|
-
object: "chat.completion"
|
|
14829
|
-
};
|
|
14830
|
-
};
|
|
14831
|
-
str = function(x2) {
|
|
14832
|
-
return JSON.stringify(x2);
|
|
14833
|
-
};
|
|
14834
|
-
__classPrivateFieldGet8 = function(receiver, state, kind2, f2) {
|
|
14835
|
-
if (kind2 === "a" && !f2)
|
|
14836
|
-
throw new TypeError("Private accessor was defined without a getter");
|
|
14837
|
-
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
14838
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
14839
|
-
return kind2 === "m" ? f2 : kind2 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
14840
|
-
};
|
|
14841
|
-
__classPrivateFieldSet7 = function(receiver, state, value, kind2, f2) {
|
|
14842
|
-
if (kind2 === "m")
|
|
14843
|
-
throw new TypeError("Private method is not writable");
|
|
14844
|
-
if (kind2 === "a" && !f2)
|
|
14845
|
-
throw new TypeError("Private accessor was defined without a setter");
|
|
14846
|
-
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
14847
|
-
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
14848
|
-
return kind2 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
14849
|
-
};
|
|
14850
|
-
});
|
|
14851
14663
|
|
|
14852
14664
|
// node_modules/openai/lib/ChatCompletionStreamingRunner.mjs
|
|
14853
14665
|
class ChatCompletionStreamingRunner extends ChatCompletionStream {
|
|
@@ -14875,9 +14687,6 @@ class ChatCompletionStreamingRunner extends ChatCompletionStream {
|
|
|
14875
14687
|
return runner;
|
|
14876
14688
|
}
|
|
14877
14689
|
}
|
|
14878
|
-
var init_ChatCompletionStreamingRunner = __esm(() => {
|
|
14879
|
-
init_ChatCompletionStream();
|
|
14880
|
-
});
|
|
14881
14690
|
|
|
14882
14691
|
// node_modules/openai/resources/beta/chat/completions.mjs
|
|
14883
14692
|
class Completions2 extends APIResource {
|
|
@@ -14897,12 +14706,6 @@ class Completions2 extends APIResource {
|
|
|
14897
14706
|
return ChatCompletionStream.createChatCompletion(this._client.chat.completions, body, options);
|
|
14898
14707
|
}
|
|
14899
14708
|
}
|
|
14900
|
-
var init_completions2 = __esm(() => {
|
|
14901
|
-
init_resource();
|
|
14902
|
-
init_ChatCompletionRunner();
|
|
14903
|
-
init_ChatCompletionStreamingRunner();
|
|
14904
|
-
init_ChatCompletionStream();
|
|
14905
|
-
});
|
|
14906
14709
|
|
|
14907
14710
|
// node_modules/openai/resources/beta/chat/chat.mjs
|
|
14908
14711
|
class Chat2 extends APIResource {
|
|
@@ -14911,13 +14714,9 @@ class Chat2 extends APIResource {
|
|
|
14911
14714
|
this.completions = new Completions2(this._client);
|
|
14912
14715
|
}
|
|
14913
14716
|
}
|
|
14914
|
-
|
|
14915
|
-
|
|
14916
|
-
|
|
14917
|
-
(function(Chat3) {
|
|
14918
|
-
Chat3.Completions = Completions2;
|
|
14919
|
-
})(Chat2 || (Chat2 = {}));
|
|
14920
|
-
});
|
|
14717
|
+
(function(Chat3) {
|
|
14718
|
+
Chat3.Completions = Completions2;
|
|
14719
|
+
})(Chat2 || (Chat2 = {}));
|
|
14921
14720
|
|
|
14922
14721
|
// node_modules/openai/resources/beta/threads/messages/files.mjs
|
|
14923
14722
|
class Files2 extends APIResource {
|
|
@@ -14941,15 +14740,9 @@ class Files2 extends APIResource {
|
|
|
14941
14740
|
|
|
14942
14741
|
class MessageFilesPage extends CursorPage {
|
|
14943
14742
|
}
|
|
14944
|
-
|
|
14945
|
-
|
|
14946
|
-
|
|
14947
|
-
init_files2();
|
|
14948
|
-
init_pagination();
|
|
14949
|
-
(function(Files3) {
|
|
14950
|
-
Files3.MessageFilesPage = MessageFilesPage;
|
|
14951
|
-
})(Files2 || (Files2 = {}));
|
|
14952
|
-
});
|
|
14743
|
+
(function(Files3) {
|
|
14744
|
+
Files3.MessageFilesPage = MessageFilesPage;
|
|
14745
|
+
})(Files2 || (Files2 = {}));
|
|
14953
14746
|
|
|
14954
14747
|
// node_modules/openai/resources/beta/threads/messages/messages.mjs
|
|
14955
14748
|
class Messages extends APIResource {
|
|
@@ -14991,18 +14784,11 @@ class Messages extends APIResource {
|
|
|
14991
14784
|
|
|
14992
14785
|
class ThreadMessagesPage extends CursorPage {
|
|
14993
14786
|
}
|
|
14994
|
-
|
|
14995
|
-
|
|
14996
|
-
|
|
14997
|
-
|
|
14998
|
-
|
|
14999
|
-
init_pagination();
|
|
15000
|
-
(function(Messages2) {
|
|
15001
|
-
Messages2.ThreadMessagesPage = ThreadMessagesPage;
|
|
15002
|
-
Messages2.Files = Files2;
|
|
15003
|
-
Messages2.MessageFilesPage = MessageFilesPage;
|
|
15004
|
-
})(Messages || (Messages = {}));
|
|
15005
|
-
});
|
|
14787
|
+
(function(Messages2) {
|
|
14788
|
+
Messages2.ThreadMessagesPage = ThreadMessagesPage;
|
|
14789
|
+
Messages2.Files = Files2;
|
|
14790
|
+
Messages2.MessageFilesPage = MessageFilesPage;
|
|
14791
|
+
})(Messages || (Messages = {}));
|
|
15006
14792
|
|
|
15007
14793
|
// node_modules/openai/resources/beta/threads/runs/steps.mjs
|
|
15008
14794
|
class Steps extends APIResource {
|
|
@@ -15026,15 +14812,9 @@ class Steps extends APIResource {
|
|
|
15026
14812
|
|
|
15027
14813
|
class RunStepsPage extends CursorPage {
|
|
15028
14814
|
}
|
|
15029
|
-
|
|
15030
|
-
|
|
15031
|
-
|
|
15032
|
-
init_steps();
|
|
15033
|
-
init_pagination();
|
|
15034
|
-
(function(Steps2) {
|
|
15035
|
-
Steps2.RunStepsPage = RunStepsPage;
|
|
15036
|
-
})(Steps || (Steps = {}));
|
|
15037
|
-
});
|
|
14815
|
+
(function(Steps2) {
|
|
14816
|
+
Steps2.RunStepsPage = RunStepsPage;
|
|
14817
|
+
})(Steps || (Steps = {}));
|
|
15038
14818
|
|
|
15039
14819
|
// node_modules/openai/resources/beta/threads/runs/runs.mjs
|
|
15040
14820
|
class Runs extends APIResource {
|
|
@@ -15089,18 +14869,11 @@ class Runs extends APIResource {
|
|
|
15089
14869
|
|
|
15090
14870
|
class RunsPage extends CursorPage {
|
|
15091
14871
|
}
|
|
15092
|
-
|
|
15093
|
-
|
|
15094
|
-
|
|
15095
|
-
|
|
15096
|
-
|
|
15097
|
-
init_pagination();
|
|
15098
|
-
(function(Runs2) {
|
|
15099
|
-
Runs2.RunsPage = RunsPage;
|
|
15100
|
-
Runs2.Steps = Steps;
|
|
15101
|
-
Runs2.RunStepsPage = RunStepsPage;
|
|
15102
|
-
})(Runs || (Runs = {}));
|
|
15103
|
-
});
|
|
14872
|
+
(function(Runs2) {
|
|
14873
|
+
Runs2.RunsPage = RunsPage;
|
|
14874
|
+
Runs2.Steps = Steps;
|
|
14875
|
+
Runs2.RunStepsPage = RunStepsPage;
|
|
14876
|
+
})(Runs || (Runs = {}));
|
|
15104
14877
|
|
|
15105
14878
|
// node_modules/openai/resources/beta/threads/threads.mjs
|
|
15106
14879
|
class Threads extends APIResource {
|
|
@@ -15146,18 +14919,12 @@ class Threads extends APIResource {
|
|
|
15146
14919
|
});
|
|
15147
14920
|
}
|
|
15148
14921
|
}
|
|
15149
|
-
|
|
15150
|
-
|
|
15151
|
-
|
|
15152
|
-
|
|
15153
|
-
|
|
15154
|
-
|
|
15155
|
-
Threads2.Runs = Runs;
|
|
15156
|
-
Threads2.RunsPage = RunsPage;
|
|
15157
|
-
Threads2.Messages = Messages;
|
|
15158
|
-
Threads2.ThreadMessagesPage = ThreadMessagesPage;
|
|
15159
|
-
})(Threads || (Threads = {}));
|
|
15160
|
-
});
|
|
14922
|
+
(function(Threads2) {
|
|
14923
|
+
Threads2.Runs = Runs;
|
|
14924
|
+
Threads2.RunsPage = RunsPage;
|
|
14925
|
+
Threads2.Messages = Messages;
|
|
14926
|
+
Threads2.ThreadMessagesPage = ThreadMessagesPage;
|
|
14927
|
+
})(Threads || (Threads = {}));
|
|
15161
14928
|
|
|
15162
14929
|
// node_modules/openai/resources/beta/beta.mjs
|
|
15163
14930
|
class Beta extends APIResource {
|
|
@@ -15168,55 +14935,36 @@ class Beta extends APIResource {
|
|
|
15168
14935
|
this.threads = new Threads(this._client);
|
|
15169
14936
|
}
|
|
15170
14937
|
}
|
|
15171
|
-
|
|
15172
|
-
|
|
15173
|
-
|
|
15174
|
-
|
|
15175
|
-
|
|
15176
|
-
|
|
15177
|
-
Beta2.Chat = Chat2;
|
|
15178
|
-
Beta2.Assistants = Assistants;
|
|
15179
|
-
Beta2.AssistantsPage = AssistantsPage;
|
|
15180
|
-
Beta2.Threads = Threads;
|
|
15181
|
-
})(Beta || (Beta = {}));
|
|
15182
|
-
});
|
|
15183
|
-
|
|
14938
|
+
(function(Beta2) {
|
|
14939
|
+
Beta2.Chat = Chat2;
|
|
14940
|
+
Beta2.Assistants = Assistants;
|
|
14941
|
+
Beta2.AssistantsPage = AssistantsPage;
|
|
14942
|
+
Beta2.Threads = Threads;
|
|
14943
|
+
})(Beta || (Beta = {}));
|
|
15184
14944
|
// node_modules/openai/resources/completions.mjs
|
|
15185
14945
|
class Completions3 extends APIResource {
|
|
15186
14946
|
create(body, options) {
|
|
15187
14947
|
return this._client.post("/completions", { body, ...options, stream: body.stream ?? false });
|
|
15188
14948
|
}
|
|
15189
14949
|
}
|
|
15190
|
-
|
|
15191
|
-
|
|
15192
|
-
(function(Completions4) {
|
|
15193
|
-
})(Completions3 || (Completions3 = {}));
|
|
15194
|
-
});
|
|
15195
|
-
|
|
14950
|
+
(function(Completions4) {
|
|
14951
|
+
})(Completions3 || (Completions3 = {}));
|
|
15196
14952
|
// node_modules/openai/resources/embeddings.mjs
|
|
15197
14953
|
class Embeddings extends APIResource {
|
|
15198
14954
|
create(body, options) {
|
|
15199
14955
|
return this._client.post("/embeddings", { body, ...options });
|
|
15200
14956
|
}
|
|
15201
14957
|
}
|
|
15202
|
-
|
|
15203
|
-
|
|
15204
|
-
(function(Embeddings2) {
|
|
15205
|
-
})(Embeddings || (Embeddings = {}));
|
|
15206
|
-
});
|
|
15207
|
-
|
|
14958
|
+
(function(Embeddings2) {
|
|
14959
|
+
})(Embeddings || (Embeddings = {}));
|
|
15208
14960
|
// node_modules/openai/resources/edits.mjs
|
|
15209
14961
|
class Edits extends APIResource {
|
|
15210
14962
|
create(body, options) {
|
|
15211
14963
|
return this._client.post("/edits", { body, ...options });
|
|
15212
14964
|
}
|
|
15213
14965
|
}
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
(function(Edits2) {
|
|
15217
|
-
})(Edits || (Edits = {}));
|
|
15218
|
-
});
|
|
15219
|
-
|
|
14966
|
+
(function(Edits2) {
|
|
14967
|
+
})(Edits || (Edits = {}));
|
|
15220
14968
|
// node_modules/openai/resources/files.mjs
|
|
15221
14969
|
class Files3 extends APIResource {
|
|
15222
14970
|
create(body, options) {
|
|
@@ -15262,19 +15010,9 @@ class Files3 extends APIResource {
|
|
|
15262
15010
|
|
|
15263
15011
|
class FileObjectsPage extends Page {
|
|
15264
15012
|
}
|
|
15265
|
-
|
|
15266
|
-
|
|
15267
|
-
|
|
15268
|
-
init_core();
|
|
15269
|
-
init_error();
|
|
15270
|
-
init_files3();
|
|
15271
|
-
init_core();
|
|
15272
|
-
init_pagination();
|
|
15273
|
-
(function(Files4) {
|
|
15274
|
-
Files4.FileObjectsPage = FileObjectsPage;
|
|
15275
|
-
})(Files3 || (Files3 = {}));
|
|
15276
|
-
});
|
|
15277
|
-
|
|
15013
|
+
(function(Files4) {
|
|
15014
|
+
Files4.FileObjectsPage = FileObjectsPage;
|
|
15015
|
+
})(Files3 || (Files3 = {}));
|
|
15278
15016
|
// node_modules/openai/resources/fine-tunes.mjs
|
|
15279
15017
|
class FineTunes extends APIResource {
|
|
15280
15018
|
create(body, options) {
|
|
@@ -15301,15 +15039,9 @@ class FineTunes extends APIResource {
|
|
|
15301
15039
|
|
|
15302
15040
|
class FineTunesPage extends Page {
|
|
15303
15041
|
}
|
|
15304
|
-
|
|
15305
|
-
|
|
15306
|
-
|
|
15307
|
-
init_pagination();
|
|
15308
|
-
(function(FineTunes2) {
|
|
15309
|
-
FineTunes2.FineTunesPage = FineTunesPage;
|
|
15310
|
-
})(FineTunes || (FineTunes = {}));
|
|
15311
|
-
});
|
|
15312
|
-
|
|
15042
|
+
(function(FineTunes2) {
|
|
15043
|
+
FineTunes2.FineTunesPage = FineTunesPage;
|
|
15044
|
+
})(FineTunes || (FineTunes = {}));
|
|
15313
15045
|
// node_modules/openai/resources/fine-tuning/jobs.mjs
|
|
15314
15046
|
class Jobs extends APIResource {
|
|
15315
15047
|
create(body, options) {
|
|
@@ -15343,16 +15075,10 @@ class FineTuningJobsPage extends CursorPage {
|
|
|
15343
15075
|
|
|
15344
15076
|
class FineTuningJobEventsPage extends CursorPage {
|
|
15345
15077
|
}
|
|
15346
|
-
|
|
15347
|
-
|
|
15348
|
-
|
|
15349
|
-
|
|
15350
|
-
init_pagination();
|
|
15351
|
-
(function(Jobs2) {
|
|
15352
|
-
Jobs2.FineTuningJobsPage = FineTuningJobsPage;
|
|
15353
|
-
Jobs2.FineTuningJobEventsPage = FineTuningJobEventsPage;
|
|
15354
|
-
})(Jobs || (Jobs = {}));
|
|
15355
|
-
});
|
|
15078
|
+
(function(Jobs2) {
|
|
15079
|
+
Jobs2.FineTuningJobsPage = FineTuningJobsPage;
|
|
15080
|
+
Jobs2.FineTuningJobEventsPage = FineTuningJobEventsPage;
|
|
15081
|
+
})(Jobs || (Jobs = {}));
|
|
15356
15082
|
|
|
15357
15083
|
// node_modules/openai/resources/fine-tuning/fine-tuning.mjs
|
|
15358
15084
|
class FineTuning extends APIResource {
|
|
@@ -15361,16 +15087,11 @@ class FineTuning extends APIResource {
|
|
|
15361
15087
|
this.jobs = new Jobs(this._client);
|
|
15362
15088
|
}
|
|
15363
15089
|
}
|
|
15364
|
-
|
|
15365
|
-
|
|
15366
|
-
|
|
15367
|
-
|
|
15368
|
-
|
|
15369
|
-
FineTuning2.FineTuningJobsPage = FineTuningJobsPage;
|
|
15370
|
-
FineTuning2.FineTuningJobEventsPage = FineTuningJobEventsPage;
|
|
15371
|
-
})(FineTuning || (FineTuning = {}));
|
|
15372
|
-
});
|
|
15373
|
-
|
|
15090
|
+
(function(FineTuning2) {
|
|
15091
|
+
FineTuning2.Jobs = Jobs;
|
|
15092
|
+
FineTuning2.FineTuningJobsPage = FineTuningJobsPage;
|
|
15093
|
+
FineTuning2.FineTuningJobEventsPage = FineTuningJobEventsPage;
|
|
15094
|
+
})(FineTuning || (FineTuning = {}));
|
|
15374
15095
|
// node_modules/openai/resources/images.mjs
|
|
15375
15096
|
class Images extends APIResource {
|
|
15376
15097
|
createVariation(body, options) {
|
|
@@ -15383,13 +15104,8 @@ class Images extends APIResource {
|
|
|
15383
15104
|
return this._client.post("/images/generations", { body, ...options });
|
|
15384
15105
|
}
|
|
15385
15106
|
}
|
|
15386
|
-
|
|
15387
|
-
|
|
15388
|
-
init_core();
|
|
15389
|
-
(function(Images2) {
|
|
15390
|
-
})(Images || (Images = {}));
|
|
15391
|
-
});
|
|
15392
|
-
|
|
15107
|
+
(function(Images2) {
|
|
15108
|
+
})(Images || (Images = {}));
|
|
15393
15109
|
// node_modules/openai/resources/models.mjs
|
|
15394
15110
|
class Models extends APIResource {
|
|
15395
15111
|
retrieve(model, options) {
|
|
@@ -15405,45 +15121,20 @@ class Models extends APIResource {
|
|
|
15405
15121
|
|
|
15406
15122
|
class ModelsPage extends Page {
|
|
15407
15123
|
}
|
|
15408
|
-
|
|
15409
|
-
|
|
15410
|
-
|
|
15411
|
-
init_pagination();
|
|
15412
|
-
(function(Models2) {
|
|
15413
|
-
Models2.ModelsPage = ModelsPage;
|
|
15414
|
-
})(Models || (Models = {}));
|
|
15415
|
-
});
|
|
15416
|
-
|
|
15124
|
+
(function(Models2) {
|
|
15125
|
+
Models2.ModelsPage = ModelsPage;
|
|
15126
|
+
})(Models || (Models = {}));
|
|
15417
15127
|
// node_modules/openai/resources/moderations.mjs
|
|
15418
15128
|
class Moderations extends APIResource {
|
|
15419
15129
|
create(body, options) {
|
|
15420
15130
|
return this._client.post("/moderations", { body, ...options });
|
|
15421
15131
|
}
|
|
15422
15132
|
}
|
|
15423
|
-
|
|
15424
|
-
|
|
15425
|
-
(function(Moderations2) {
|
|
15426
|
-
})(Moderations || (Moderations = {}));
|
|
15427
|
-
});
|
|
15428
|
-
|
|
15429
|
-
// node_modules/openai/resources/index.mjs
|
|
15430
|
-
var init_resources = __esm(() => {
|
|
15431
|
-
init_chat2();
|
|
15432
|
-
init_shared();
|
|
15433
|
-
init_audio();
|
|
15434
|
-
init_beta();
|
|
15435
|
-
init_completions3();
|
|
15436
|
-
init_embeddings();
|
|
15437
|
-
init_edits();
|
|
15438
|
-
init_files3();
|
|
15439
|
-
init_fine_tunes();
|
|
15440
|
-
init_fine_tuning();
|
|
15441
|
-
init_images();
|
|
15442
|
-
init_models();
|
|
15443
|
-
init_moderations();
|
|
15444
|
-
});
|
|
15445
|
-
|
|
15133
|
+
(function(Moderations2) {
|
|
15134
|
+
})(Moderations || (Moderations = {}));
|
|
15446
15135
|
// node_modules/openai/index.mjs
|
|
15136
|
+
var _a;
|
|
15137
|
+
|
|
15447
15138
|
class OpenAI extends APIClient {
|
|
15448
15139
|
constructor({ baseURL = readEnv("OPENAI_BASE_URL"), apiKey = readEnv("OPENAI_API_KEY"), organization = readEnv("OPENAI_ORG_ID") ?? null, ...opts } = {}) {
|
|
15449
15140
|
if (apiKey === undefined) {
|
|
@@ -15495,69 +15186,107 @@ class OpenAI extends APIClient {
|
|
|
15495
15186
|
return { Authorization: `Bearer ${this.apiKey}` };
|
|
15496
15187
|
}
|
|
15497
15188
|
}
|
|
15498
|
-
|
|
15499
|
-
|
|
15500
|
-
|
|
15501
|
-
|
|
15502
|
-
|
|
15503
|
-
|
|
15504
|
-
|
|
15505
|
-
|
|
15506
|
-
|
|
15507
|
-
|
|
15508
|
-
|
|
15509
|
-
|
|
15510
|
-
|
|
15511
|
-
|
|
15512
|
-
|
|
15513
|
-
|
|
15514
|
-
|
|
15515
|
-
|
|
15516
|
-
|
|
15517
|
-
|
|
15518
|
-
|
|
15519
|
-
|
|
15520
|
-
|
|
15521
|
-
|
|
15522
|
-
|
|
15523
|
-
|
|
15524
|
-
|
|
15525
|
-
|
|
15526
|
-
|
|
15527
|
-
|
|
15528
|
-
|
|
15529
|
-
|
|
15530
|
-
|
|
15531
|
-
|
|
15532
|
-
|
|
15533
|
-
|
|
15534
|
-
|
|
15535
|
-
OpenAI2.ModelsPage = ModelsPage;
|
|
15536
|
-
OpenAI2.FineTuning = FineTuning;
|
|
15537
|
-
OpenAI2.FineTunes = FineTunes;
|
|
15538
|
-
OpenAI2.FineTunesPage = FineTunesPage;
|
|
15539
|
-
OpenAI2.Beta = Beta;
|
|
15540
|
-
})(OpenAI || (OpenAI = {}));
|
|
15541
|
-
openai_default = OpenAI;
|
|
15542
|
-
});
|
|
15189
|
+
_a = OpenAI;
|
|
15190
|
+
OpenAI.OpenAI = _a;
|
|
15191
|
+
OpenAI.OpenAIError = OpenAIError;
|
|
15192
|
+
OpenAI.APIError = APIError;
|
|
15193
|
+
OpenAI.APIConnectionError = APIConnectionError;
|
|
15194
|
+
OpenAI.APIConnectionTimeoutError = APIConnectionTimeoutError;
|
|
15195
|
+
OpenAI.APIUserAbortError = APIUserAbortError;
|
|
15196
|
+
OpenAI.NotFoundError = NotFoundError;
|
|
15197
|
+
OpenAI.ConflictError = ConflictError;
|
|
15198
|
+
OpenAI.RateLimitError = RateLimitError;
|
|
15199
|
+
OpenAI.BadRequestError = BadRequestError;
|
|
15200
|
+
OpenAI.AuthenticationError = AuthenticationError;
|
|
15201
|
+
OpenAI.InternalServerError = InternalServerError;
|
|
15202
|
+
OpenAI.PermissionDeniedError = PermissionDeniedError;
|
|
15203
|
+
OpenAI.UnprocessableEntityError = UnprocessableEntityError;
|
|
15204
|
+
(function(OpenAI2) {
|
|
15205
|
+
OpenAI2.toFile = toFile;
|
|
15206
|
+
OpenAI2.fileFromPath = fileFromPath;
|
|
15207
|
+
OpenAI2.Page = Page;
|
|
15208
|
+
OpenAI2.CursorPage = CursorPage;
|
|
15209
|
+
OpenAI2.Completions = Completions3;
|
|
15210
|
+
OpenAI2.Chat = Chat;
|
|
15211
|
+
OpenAI2.Edits = Edits;
|
|
15212
|
+
OpenAI2.Embeddings = Embeddings;
|
|
15213
|
+
OpenAI2.Files = Files3;
|
|
15214
|
+
OpenAI2.FileObjectsPage = FileObjectsPage;
|
|
15215
|
+
OpenAI2.Images = Images;
|
|
15216
|
+
OpenAI2.Audio = Audio;
|
|
15217
|
+
OpenAI2.Moderations = Moderations;
|
|
15218
|
+
OpenAI2.Models = Models;
|
|
15219
|
+
OpenAI2.ModelsPage = ModelsPage;
|
|
15220
|
+
OpenAI2.FineTuning = FineTuning;
|
|
15221
|
+
OpenAI2.FineTunes = FineTunes;
|
|
15222
|
+
OpenAI2.FineTunesPage = FineTunesPage;
|
|
15223
|
+
OpenAI2.Beta = Beta;
|
|
15224
|
+
})(OpenAI || (OpenAI = {}));
|
|
15225
|
+
var openai_default = OpenAI;
|
|
15543
15226
|
|
|
15544
|
-
// src/
|
|
15545
|
-
|
|
15546
|
-
|
|
15547
|
-
|
|
15548
|
-
|
|
15549
|
-
|
|
15227
|
+
// src/index.js
|
|
15228
|
+
program.command("fetch-evals").description("Fetch the latest evals for the project").action(async () => {
|
|
15229
|
+
if (!process.env.UMBRAGE_EVALS_API_KEY) {
|
|
15230
|
+
throw new Error("UMBRAGE_EVALS_API_KEY is not set in the environment variables.");
|
|
15231
|
+
}
|
|
15232
|
+
const UMBRAGE_EVALS_API_KEY = process.env.UMBRAGE_EVALS_API_KEY;
|
|
15233
|
+
const fetchEvals = async () => {
|
|
15234
|
+
const url = new URL("https://api-gateway.groff.workers.dev/evals");
|
|
15235
|
+
url.searchParams.append("page", 0);
|
|
15236
|
+
url.searchParams.append("pageSize", 100);
|
|
15237
|
+
url.searchParams.append("eval_type", "OpenAI-GPT-4");
|
|
15238
|
+
try {
|
|
15239
|
+
const response = await fetch(url, {
|
|
15240
|
+
method: "GET",
|
|
15241
|
+
headers: {
|
|
15242
|
+
"X-API-KEY": UMBRAGE_EVALS_API_KEY
|
|
15243
|
+
}
|
|
15244
|
+
});
|
|
15245
|
+
if (!response.ok) {
|
|
15246
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
15247
|
+
}
|
|
15248
|
+
const data = await response.json();
|
|
15249
|
+
return data.evals;
|
|
15250
|
+
} catch (error7) {
|
|
15251
|
+
console.error("Error fetching evals:", error7);
|
|
15252
|
+
return [];
|
|
15253
|
+
}
|
|
15254
|
+
};
|
|
15255
|
+
const processPromptFile = async (file) => {
|
|
15256
|
+
const promptFilename = file.split(".prompt.js")[0];
|
|
15257
|
+
const evalsFolder = `${promptFilename}_evals`;
|
|
15258
|
+
if (!fs2.existsSync(evalsFolder)) {
|
|
15259
|
+
fs2.mkdirSync(evalsFolder, { recursive: true });
|
|
15260
|
+
}
|
|
15261
|
+
const evalsForPrompt = await fetchEvals();
|
|
15262
|
+
for (const evalObject of evalsForPrompt) {
|
|
15263
|
+
const { name: evalName, eval_code } = evalObject;
|
|
15264
|
+
const markdownFileName = `${evalsFolder}/${evalName.replace(/[^a-z0-9]/gi, "_")}.md`;
|
|
15265
|
+
fs2.writeFileSync(markdownFileName, eval_code);
|
|
15266
|
+
}
|
|
15267
|
+
};
|
|
15268
|
+
try {
|
|
15269
|
+
const promptsDir = "./prompts/";
|
|
15270
|
+
const promptFiles = fs2.readdirSync(promptsDir).filter((file) => file.endsWith(".prompt.js"));
|
|
15271
|
+
const processingPromises = promptFiles.map(processPromptFile);
|
|
15272
|
+
await Promise.all(processingPromises);
|
|
15273
|
+
console.log("Done fetching evals!");
|
|
15274
|
+
} catch (error7) {
|
|
15275
|
+
console.error("An error occurred:", error7);
|
|
15276
|
+
}
|
|
15277
|
+
});
|
|
15278
|
+
program.command("run-evals").description("Run evals in the current directory and log results").action(async () => {
|
|
15550
15279
|
if (!process.env.OPENAI_API_KEY) {
|
|
15551
15280
|
throw new Error("OPENAI_API_KEY is not set in the environment variables.");
|
|
15552
15281
|
}
|
|
15553
|
-
openai = new openai_default;
|
|
15554
|
-
promptsDir = "./prompts/";
|
|
15555
|
-
model = "gpt-4-1106-preview";
|
|
15556
|
-
temperature = 0;
|
|
15557
|
-
processMarkdownFile = async (evalsFolder, evalFile, promptInstance) => {
|
|
15282
|
+
const openai = new openai_default;
|
|
15283
|
+
const promptsDir = "./prompts/";
|
|
15284
|
+
const model = "gpt-4-1106-preview";
|
|
15285
|
+
const temperature = 0;
|
|
15286
|
+
const processMarkdownFile = async (evalsFolder, evalFile, promptInstance) => {
|
|
15558
15287
|
console.log(`\nEvaluating: ${evalFile}`);
|
|
15559
15288
|
const evalName = evalFile.split(".md")[0];
|
|
15560
|
-
const eval_code =
|
|
15289
|
+
const eval_code = fs2.readFileSync(`${evalsFolder}/${evalFile}`, "utf-8");
|
|
15561
15290
|
console.time("Model response time");
|
|
15562
15291
|
const { response: modelResponse, prompts: evalPrompts } = await promptInstance.callModel("Hi! What is your name?");
|
|
15563
15292
|
console.timeEnd("Model response time");
|
|
@@ -15586,16 +15315,16 @@ var init_runEvals = __esm(() => {
|
|
|
15586
15315
|
isValid: evalResult.grade && evalResult.explanation && evalResult.suggestions
|
|
15587
15316
|
};
|
|
15588
15317
|
};
|
|
15589
|
-
|
|
15318
|
+
const processPromptFile = async (file) => {
|
|
15590
15319
|
const promptFilename = file.split(".prompt.js")[0];
|
|
15591
15320
|
const evalsFolder = `${promptsDir}/${promptFilename}_evals`;
|
|
15592
|
-
if (!
|
|
15321
|
+
if (!fs2.existsSync(evalsFolder)) {
|
|
15593
15322
|
console.error(`Evals folder not found for ${promptFilename}, please run fetch_latest_evals.js first.`);
|
|
15594
15323
|
return;
|
|
15595
15324
|
}
|
|
15596
15325
|
const promptInstance = await import(`${promptsDir}${file}`).then((mod) => mod.default);
|
|
15597
15326
|
const evaluations = [];
|
|
15598
|
-
const evalMarkdownFiles =
|
|
15327
|
+
const evalMarkdownFiles = fs2.readdirSync(evalsFolder).filter((f2) => f2.endsWith(".md"));
|
|
15599
15328
|
for (const evalFile of evalMarkdownFiles) {
|
|
15600
15329
|
const result = await processMarkdownFile(evalsFolder, evalFile, promptInstance);
|
|
15601
15330
|
if (result.isValid) {
|
|
@@ -15627,22 +15356,15 @@ var init_runEvals = __esm(() => {
|
|
|
15627
15356
|
}
|
|
15628
15357
|
}
|
|
15629
15358
|
const jsonFilePath = `${evalsFolder}/${promptFilename}_evals_results_${new Date().toISOString()}.json`;
|
|
15630
|
-
|
|
15359
|
+
fs2.writeFileSync(jsonFilePath, JSON.stringify(evaluations, null, 4));
|
|
15631
15360
|
};
|
|
15632
15361
|
try {
|
|
15633
|
-
const promptFiles =
|
|
15634
|
-
const processingPromises = promptFiles.map(
|
|
15362
|
+
const promptFiles = fs2.readdirSync(promptsDir).filter((file) => file.endsWith(".prompt.js"));
|
|
15363
|
+
const processingPromises = promptFiles.map(processPromptFile);
|
|
15635
15364
|
await Promise.all(processingPromises);
|
|
15636
15365
|
console.log("Done processing evals!");
|
|
15637
15366
|
} catch (error7) {
|
|
15638
15367
|
console.error("An error occurred:", error7);
|
|
15639
15368
|
}
|
|
15640
15369
|
});
|
|
15641
|
-
|
|
15642
|
-
// src/index.js
|
|
15643
|
-
var { program } = require_commander();
|
|
15644
|
-
var fetchEvals2 = (init_fetchEvals(), __toCommonJS(exports_fetchEvals));
|
|
15645
|
-
var runEvals = (init_runEvals(), __toCommonJS(exports_runEvals));
|
|
15646
|
-
program.command("fetch-evals").description("Fetch the latest evals for the project").action(fetchEvals2);
|
|
15647
|
-
program.command("run-evals").description("Run evals in the current directory and log results").action(runEvals);
|
|
15648
15370
|
program.parse(process.argv);
|