drizzle-cube 0.5.0 → 0.5.3
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/README.md +4 -0
- package/dist/adapters/express/index.cjs +2 -2
- package/dist/adapters/express/index.js +106 -102
- package/dist/adapters/fastify/index.cjs +2 -2
- package/dist/adapters/fastify/index.js +109 -105
- package/dist/adapters/{handler-3LGcjLtr.js → handler-BC3nFNxV.js} +2 -2
- package/dist/adapters/{handler-BzzbVpcl.cjs → handler-Cqf-CqAS.cjs} +2 -2
- package/dist/adapters/hono/index.cjs +1 -1
- package/dist/adapters/hono/index.js +41 -45
- package/dist/adapters/locale-BoiA6WiV.cjs +198 -0
- package/dist/adapters/{locale-DTnJrxm1.js → locale-D9VQkLXt.js} +442 -404
- package/dist/adapters/mcp-tools.cjs +1 -1
- package/dist/adapters/mcp-tools.d.ts +7 -3
- package/dist/adapters/mcp-tools.js +28 -28
- package/dist/adapters/mcp-transport-B0mgxRnJ.js +579 -0
- package/dist/adapters/mcp-transport-irsahKmD.cjs +39 -0
- package/dist/adapters/mcp-transport.d.ts +14 -2
- package/dist/adapters/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.js +140 -136
- package/dist/adapters/{openai-C4BD8xnN.cjs → openai-B4N3KfTG.cjs} +1 -1
- package/dist/adapters/{openai-CaSQEduB.js → openai-BWdm0JvG.js} +1 -1
- package/dist/adapters/openai-CoqT_FM5.cjs +16 -0
- package/dist/{server/openai-CqZg6zYL.js → adapters/openai-D0Nsvc9L.js} +824 -720
- package/dist/adapters/{utils-DOg9oGdt.js → utils-CTYvfZ3I.js} +711 -713
- package/dist/adapters/{utils-DNrj-ryp.cjs → utils-XPOzzMdY.cjs} +5 -5
- package/dist/adapters/utils.cjs +1 -1
- package/dist/adapters/utils.d.ts +38 -2
- package/dist/adapters/utils.js +1 -1
- package/dist/cli/index.cjs +2 -2
- package/dist/client/charts.js +10 -10
- package/dist/client/chunks/{DashboardEditModal-cSSIAZGy.js → DashboardEditModal-IU_0dgfC.js} +12 -12
- package/dist/client/chunks/{DashboardEditModal-cSSIAZGy.js.map → DashboardEditModal-IU_0dgfC.js.map} +1 -1
- package/dist/client/chunks/{FieldSearchModal-CZNo4pNK.js → FieldSearchModal-BCWanpPX.js} +3 -3
- package/dist/client/chunks/{FieldSearchModal-CZNo4pNK.js.map → FieldSearchModal-BCWanpPX.js.map} +1 -1
- package/dist/client/chunks/KpiDelta-_igN6cJa.js +2 -0
- package/dist/client/chunks/KpiNumber-t5n8PtRU.js +2 -0
- package/dist/client/chunks/KpiText-BCZJJ6a0.js +2 -0
- package/dist/client/chunks/{RetentionCombinedChart-BD8tGeM_.js → RetentionCombinedChart-CQMBODsK.js} +2 -2
- package/dist/client/chunks/{RetentionCombinedChart-BD8tGeM_.js.map → RetentionCombinedChart-CQMBODsK.js.map} +1 -1
- package/dist/client/chunks/SchemaVisualization-BUUhlOvG.js +2 -0
- package/dist/client/chunks/SchemaVisualizationLazy-CwaPCUL0.js +2 -0
- package/dist/client/chunks/{analysis-builder-BeVZhiQ5.js → analysis-builder-Dm6eD_AX.js} +6 -6
- package/dist/client/chunks/{analysis-builder-BeVZhiQ5.js.map → analysis-builder-Dm6eD_AX.js.map} +1 -1
- package/dist/client/chunks/{analysis-builder-shared-BWc7ZZnG.js → analysis-builder-shared-DT5bXwCA.js} +6 -6
- package/dist/client/chunks/{analysis-builder-shared-BWc7ZZnG.js.map → analysis-builder-shared-DT5bXwCA.js.map} +1 -1
- package/dist/client/chunks/{chart-area-D63kG8OT.js → chart-area-DDti9Qtp.js} +2 -2
- package/dist/client/chunks/{chart-area-D63kG8OT.js.map → chart-area-DDti9Qtp.js.map} +1 -1
- package/dist/client/chunks/{chart-bar-BEfsCLjl.js → chart-bar-B3s9qDlh.js} +2 -2
- package/dist/client/chunks/{chart-bar-BEfsCLjl.js.map → chart-bar-B3s9qDlh.js.map} +1 -1
- package/dist/client/chunks/{chart-data-table-C3Xh9jwL.js → chart-data-table-Qrt6EAno.js} +17 -17
- package/dist/client/chunks/{chart-data-table-C3Xh9jwL.js.map → chart-data-table-Qrt6EAno.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-delta-CYE0S1x_.js → chart-kpi-delta-CgldZ7zO.js} +3 -3
- package/dist/client/chunks/{chart-kpi-delta-CYE0S1x_.js.map → chart-kpi-delta-CgldZ7zO.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-number-BlZ79xHW.js → chart-kpi-number-ByfuX1ki.js} +5 -5
- package/dist/client/chunks/{chart-kpi-number-BlZ79xHW.js.map → chart-kpi-number-ByfuX1ki.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-text-DY1BnxPe.js → chart-kpi-text-DeNuDraJ.js} +2 -2
- package/dist/client/chunks/{chart-kpi-text-DY1BnxPe.js.map → chart-kpi-text-DeNuDraJ.js.map} +1 -1
- package/dist/client/chunks/{chart-line-CBsTThTv.js → chart-line-RdZwtk27.js} +2 -2
- package/dist/client/chunks/{chart-line-CBsTThTv.js.map → chart-line-RdZwtk27.js.map} +1 -1
- package/dist/client/chunks/{chart-markdown-BWaWVkuz.js → chart-markdown-CiGRZdJj.js} +1203 -1139
- package/dist/client/chunks/chart-markdown-CiGRZdJj.js.map +1 -0
- package/dist/client/chunks/{chart-measure-profile-B41qCTBG.js → chart-measure-profile-Ckjw9bX6.js} +2 -2
- package/dist/client/chunks/{chart-measure-profile-B41qCTBG.js.map → chart-measure-profile-Ckjw9bX6.js.map} +1 -1
- package/dist/client/chunks/{chart-pie-Djbu8x2v.js → chart-pie-BvY4FY__.js} +2 -2
- package/dist/client/chunks/{chart-pie-Djbu8x2v.js.map → chart-pie-BvY4FY__.js.map} +1 -1
- package/dist/client/chunks/{chart-radar-BsTcKV0K.js → chart-radar-DjiiEAmc.js} +2 -2
- package/dist/client/chunks/{chart-radar-BsTcKV0K.js.map → chart-radar-DjiiEAmc.js.map} +1 -1
- package/dist/client/chunks/{chart-radial-bar-Du7XNnwE.js → chart-radial-bar-lla_JEYu.js} +2 -2
- package/dist/client/chunks/{chart-radial-bar-Du7XNnwE.js.map → chart-radial-bar-lla_JEYu.js.map} +1 -1
- package/dist/client/chunks/{chart-scatter-D8krEYsA.js → chart-scatter-DwXnI0rr.js} +2 -2
- package/dist/client/chunks/{chart-scatter-D8krEYsA.js.map → chart-scatter-DwXnI0rr.js.map} +1 -1
- package/dist/client/chunks/{chart-tree-map-C5C2iaWM.js → chart-tree-map-DJHoA26f.js} +2 -2
- package/dist/client/chunks/{chart-tree-map-C5C2iaWM.js.map → chart-tree-map-DJHoA26f.js.map} +1 -1
- package/dist/client/chunks/{chart-waterfall-BGdPrJ5Y.js → chart-waterfall-Y7c8csO5.js} +2 -2
- package/dist/client/chunks/{chart-waterfall-BGdPrJ5Y.js.map → chart-waterfall-Y7c8csO5.js.map} +1 -1
- package/dist/client/chunks/{core-DcfMGTVa.js → core-Dk6z6kC0.js} +2 -2
- package/dist/client/chunks/{core-DcfMGTVa.js.map → core-Dk6z6kC0.js.map} +1 -1
- package/dist/client/chunks/{exceljs.min-CcjgM-qg.js → exceljs.min-DaJsLlWM.js} +24 -24
- package/dist/client/chunks/{exceljs.min-CcjgM-qg.js.map → exceljs.min-DaJsLlWM.js.map} +1 -1
- package/dist/client/chunks/{schema-visualization-Xp60Ff2W.js → schema-visualization-DWwJukK7.js} +8 -8
- package/dist/client/chunks/{schema-visualization-Xp60Ff2W.js.map → schema-visualization-DWwJukK7.js.map} +1 -1
- package/dist/client/chunks/{syntaxHighlighting-CnDujqwg.js → syntaxHighlighting-D8J6Yt9j.js} +2 -2
- package/dist/client/chunks/{syntaxHighlighting-CnDujqwg.js.map → syntaxHighlighting-D8J6Yt9j.js.map} +1 -1
- package/dist/client/chunks/{useDebounce-CfmUMFau.js → useDebounce-DyJVREop.js} +2 -2
- package/dist/client/chunks/{useDebounce-CfmUMFau.js.map → useDebounce-DyJVREop.js.map} +1 -1
- package/dist/client/chunks/{useExplainAI-BKGmejIj.js → useExplainAI-CxSkjocM.js} +4 -4
- package/dist/client/chunks/{useExplainAI-BKGmejIj.js.map → useExplainAI-CxSkjocM.js.map} +1 -1
- package/dist/client/chunks/{utils-BldkcRHv.js → utils-BHZdKxua.js} +2 -2
- package/dist/client/chunks/{utils-BldkcRHv.js.map → utils-BHZdKxua.js.map} +1 -1
- package/dist/client/chunks/{vendor-ClXpIiea.js → vendor-CBD_Olr0.js} +8 -8
- package/dist/client/chunks/{vendor-ClXpIiea.js.map → vendor-CBD_Olr0.js.map} +1 -1
- package/dist/client/components.js +3 -3
- package/dist/client/hooks.js +3 -3
- package/dist/client/icons.js +1 -1
- package/dist/client/index.js +11 -11
- package/dist/client/providers.js +1 -1
- package/dist/client/schema.js +1 -1
- package/dist/client/utils.js +5 -5
- package/dist/client-bundle-stats.html +1 -1
- package/dist/mcp-app/mcp-app.html +39 -37
- package/dist/server/index.cjs +42 -42
- package/dist/server/index.js +1009 -971
- package/dist/server/{openai-D9Zjuby1.cjs → openai-BfiZU0rG.cjs} +1 -1
- package/dist/server/openai-BwsBio1K.cjs +16 -0
- package/dist/server/{openai-rwauPzCT.js → openai-CLWSwD-D.js} +1 -1
- package/dist/{adapters/openai-BAnEZgKZ.js → server/openai-zpXlGbbF.js} +824 -720
- package/package.json +2 -2
- package/dist/adapters/locale-DueXjqMh.cjs +0 -198
- package/dist/adapters/mcp-transport-45SiFcCH.cjs +0 -39
- package/dist/adapters/mcp-transport-Bxpc4mRy.js +0 -553
- package/dist/adapters/openai-4JP2B6pB.cjs +0 -16
- package/dist/client/chunks/KpiDelta-Dll_eCV1.js +0 -2
- package/dist/client/chunks/KpiNumber-BPlR92hI.js +0 -2
- package/dist/client/chunks/KpiText-BIxq7Jso.js +0 -2
- package/dist/client/chunks/SchemaVisualization-CCICjhvv.js +0 -2
- package/dist/client/chunks/SchemaVisualizationLazy-DraGsMx6.js +0 -2
- package/dist/client/chunks/chart-markdown-BWaWVkuz.js.map +0 -1
- package/dist/server/openai-DmuEbFd6.cjs +0 -16
|
@@ -79,48 +79,63 @@ var i = (e) => {
|
|
|
79
79
|
constructor(e) {
|
|
80
80
|
super(e);
|
|
81
81
|
}
|
|
82
|
-
},
|
|
83
|
-
|
|
82
|
+
}, x = class extends o {
|
|
83
|
+
constructor(e, t, n) {
|
|
84
|
+
let r = "OAuth2 authentication error", i;
|
|
85
|
+
if (t && typeof t == "object") {
|
|
86
|
+
let e = t;
|
|
87
|
+
i = e.error;
|
|
88
|
+
let n = e.error_description;
|
|
89
|
+
n && typeof n == "string" ? r = n : i && (r = i);
|
|
90
|
+
}
|
|
91
|
+
super(e, t, r, n), this.error_code = i;
|
|
92
|
+
}
|
|
93
|
+
}, ee = class extends a {
|
|
94
|
+
constructor(e, t, n) {
|
|
95
|
+
super(e), this.provider = t, this.cause = n;
|
|
96
|
+
}
|
|
97
|
+
}, S = /^[a-z][a-z0-9+.-]*:/i, C = (e) => S.test(e), w = (e) => (w = Array.isArray, w(e)), T = w;
|
|
98
|
+
function te(e) {
|
|
84
99
|
return typeof e == "object" ? e ?? {} : {};
|
|
85
100
|
}
|
|
86
|
-
function
|
|
101
|
+
function ne(e) {
|
|
87
102
|
if (!e) return !0;
|
|
88
103
|
for (let t in e) return !1;
|
|
89
104
|
return !0;
|
|
90
105
|
}
|
|
91
|
-
function
|
|
106
|
+
function re(e, t) {
|
|
92
107
|
return Object.prototype.hasOwnProperty.call(e, t);
|
|
93
108
|
}
|
|
94
|
-
function
|
|
109
|
+
function ie(e) {
|
|
95
110
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
96
111
|
}
|
|
97
|
-
var
|
|
112
|
+
var ae = (e, t) => {
|
|
98
113
|
if (typeof t != "number" || !Number.isInteger(t)) throw new a(`${e} must be an integer`);
|
|
99
114
|
if (t < 0) throw new a(`${e} must be a positive integer`);
|
|
100
115
|
return t;
|
|
101
|
-
},
|
|
116
|
+
}, oe = (e) => {
|
|
102
117
|
try {
|
|
103
118
|
return JSON.parse(e);
|
|
104
119
|
} catch {
|
|
105
120
|
return;
|
|
106
121
|
}
|
|
107
|
-
},
|
|
108
|
-
function
|
|
122
|
+
}, se = (e) => new Promise((t) => setTimeout(t, e)), ce = "6.34.0", le = () => typeof window < "u" && window.document !== void 0 && typeof navigator < "u";
|
|
123
|
+
function ue() {
|
|
109
124
|
return typeof Deno < "u" && Deno.build != null ? "deno" : typeof EdgeRuntime < "u" ? "edge" : Object.prototype.toString.call(globalThis.process === void 0 ? 0 : globalThis.process) === "[object process]" ? "node" : "unknown";
|
|
110
125
|
}
|
|
111
|
-
var
|
|
112
|
-
let e =
|
|
126
|
+
var de = () => {
|
|
127
|
+
let e = ue();
|
|
113
128
|
if (e === "deno") return {
|
|
114
129
|
"X-Stainless-Lang": "js",
|
|
115
|
-
"X-Stainless-Package-Version":
|
|
116
|
-
"X-Stainless-OS":
|
|
117
|
-
"X-Stainless-Arch":
|
|
130
|
+
"X-Stainless-Package-Version": ce,
|
|
131
|
+
"X-Stainless-OS": me(Deno.build.os),
|
|
132
|
+
"X-Stainless-Arch": pe(Deno.build.arch),
|
|
118
133
|
"X-Stainless-Runtime": "deno",
|
|
119
134
|
"X-Stainless-Runtime-Version": typeof Deno.version == "string" ? Deno.version : Deno.version?.deno ?? "unknown"
|
|
120
135
|
};
|
|
121
136
|
if (typeof EdgeRuntime < "u") return {
|
|
122
137
|
"X-Stainless-Lang": "js",
|
|
123
|
-
"X-Stainless-Package-Version":
|
|
138
|
+
"X-Stainless-Package-Version": ce,
|
|
124
139
|
"X-Stainless-OS": "Unknown",
|
|
125
140
|
"X-Stainless-Arch": `other:${EdgeRuntime}`,
|
|
126
141
|
"X-Stainless-Runtime": "edge",
|
|
@@ -128,30 +143,30 @@ var le = () => {
|
|
|
128
143
|
};
|
|
129
144
|
if (e === "node") return {
|
|
130
145
|
"X-Stainless-Lang": "js",
|
|
131
|
-
"X-Stainless-Package-Version":
|
|
132
|
-
"X-Stainless-OS":
|
|
133
|
-
"X-Stainless-Arch":
|
|
146
|
+
"X-Stainless-Package-Version": ce,
|
|
147
|
+
"X-Stainless-OS": me(globalThis.process.platform ?? "unknown"),
|
|
148
|
+
"X-Stainless-Arch": pe(globalThis.process.arch ?? "unknown"),
|
|
134
149
|
"X-Stainless-Runtime": "node",
|
|
135
150
|
"X-Stainless-Runtime-Version": globalThis.process.version ?? "unknown"
|
|
136
151
|
};
|
|
137
|
-
let t =
|
|
152
|
+
let t = fe();
|
|
138
153
|
return t ? {
|
|
139
154
|
"X-Stainless-Lang": "js",
|
|
140
|
-
"X-Stainless-Package-Version":
|
|
155
|
+
"X-Stainless-Package-Version": ce,
|
|
141
156
|
"X-Stainless-OS": "Unknown",
|
|
142
157
|
"X-Stainless-Arch": "unknown",
|
|
143
158
|
"X-Stainless-Runtime": `browser:${t.browser}`,
|
|
144
159
|
"X-Stainless-Runtime-Version": t.version
|
|
145
160
|
} : {
|
|
146
161
|
"X-Stainless-Lang": "js",
|
|
147
|
-
"X-Stainless-Package-Version":
|
|
162
|
+
"X-Stainless-Package-Version": ce,
|
|
148
163
|
"X-Stainless-OS": "Unknown",
|
|
149
164
|
"X-Stainless-Arch": "unknown",
|
|
150
165
|
"X-Stainless-Runtime": "unknown",
|
|
151
166
|
"X-Stainless-Runtime-Version": "unknown"
|
|
152
167
|
};
|
|
153
168
|
};
|
|
154
|
-
function
|
|
169
|
+
function fe() {
|
|
155
170
|
if (typeof navigator > "u" || !navigator) return null;
|
|
156
171
|
for (let { key: e, pattern: t } of [
|
|
157
172
|
{
|
|
@@ -187,21 +202,21 @@ function ue() {
|
|
|
187
202
|
}
|
|
188
203
|
return null;
|
|
189
204
|
}
|
|
190
|
-
var
|
|
205
|
+
var pe = (e) => e === "x32" ? "x32" : e === "x86_64" || e === "x64" ? "x64" : e === "arm" ? "arm" : e === "aarch64" || e === "arm64" ? "arm64" : e ? `other:${e}` : "unknown", me = (e) => (e = e.toLowerCase(), e.includes("ios") ? "iOS" : e === "android" ? "Android" : e === "darwin" ? "MacOS" : e === "win32" ? "Windows" : e === "freebsd" ? "FreeBSD" : e === "openbsd" ? "OpenBSD" : e === "linux" ? "Linux" : e ? `Other:${e}` : "Unknown"), he, ge = () => he ??= de();
|
|
191
206
|
//#endregion
|
|
192
207
|
//#region node_modules/openai/internal/shims.mjs
|
|
193
|
-
function
|
|
208
|
+
function _e() {
|
|
194
209
|
if (typeof fetch < "u") return fetch;
|
|
195
210
|
throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`");
|
|
196
211
|
}
|
|
197
|
-
function
|
|
212
|
+
function ve(...e) {
|
|
198
213
|
let t = globalThis.ReadableStream;
|
|
199
214
|
if (t === void 0) throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");
|
|
200
215
|
return new t(...e);
|
|
201
216
|
}
|
|
202
|
-
function
|
|
217
|
+
function ye(e) {
|
|
203
218
|
let t = Symbol.asyncIterator in e ? e[Symbol.asyncIterator]() : e[Symbol.iterator]();
|
|
204
|
-
return
|
|
219
|
+
return ve({
|
|
205
220
|
start() {},
|
|
206
221
|
async pull(e) {
|
|
207
222
|
let { done: n, value: r } = await t.next();
|
|
@@ -212,7 +227,7 @@ function _e(e) {
|
|
|
212
227
|
}
|
|
213
228
|
});
|
|
214
229
|
}
|
|
215
|
-
function
|
|
230
|
+
function be(e) {
|
|
216
231
|
if (e[Symbol.asyncIterator]) return e;
|
|
217
232
|
let t = e.getReader();
|
|
218
233
|
return {
|
|
@@ -236,7 +251,7 @@ function ve(e) {
|
|
|
236
251
|
}
|
|
237
252
|
};
|
|
238
253
|
}
|
|
239
|
-
async function
|
|
254
|
+
async function xe(e) {
|
|
240
255
|
if (typeof e != "object" || !e) return;
|
|
241
256
|
if (e[Symbol.asyncIterator]) {
|
|
242
257
|
await e[Symbol.asyncIterator]().return?.();
|
|
@@ -247,25 +262,25 @@ async function ye(e) {
|
|
|
247
262
|
}
|
|
248
263
|
//#endregion
|
|
249
264
|
//#region node_modules/openai/internal/request-options.mjs
|
|
250
|
-
var
|
|
265
|
+
var Se = ({ headers: e, body: t }) => ({
|
|
251
266
|
bodyHeaders: { "content-type": "application/json" },
|
|
252
267
|
body: JSON.stringify(t)
|
|
253
|
-
}),
|
|
268
|
+
}), Ce = "RFC3986", we = (e) => String(e), Te = {
|
|
254
269
|
RFC1738: (e) => String(e).replace(/%20/g, "+"),
|
|
255
|
-
RFC3986:
|
|
256
|
-
},
|
|
270
|
+
RFC3986: we
|
|
271
|
+
}, Ee = (e, t) => (Ee = Object.hasOwn ?? Function.prototype.call.bind(Object.prototype.hasOwnProperty), Ee(e, t)), E = /* @__PURE__ */ (() => {
|
|
257
272
|
let e = [];
|
|
258
273
|
for (let t = 0; t < 256; ++t) e.push("%" + ((t < 16 ? "0" : "") + t.toString(16)).toUpperCase());
|
|
259
274
|
return e;
|
|
260
|
-
})(),
|
|
275
|
+
})(), De = 1024, Oe = (e, t, n, r, i) => {
|
|
261
276
|
if (e.length === 0) return e;
|
|
262
277
|
let a = e;
|
|
263
278
|
if (typeof e == "symbol" ? a = Symbol.prototype.toString.call(e) : typeof e != "string" && (a = String(e)), n === "iso-8859-1") return escape(a).replace(/%u[0-9a-f]{4}/gi, function(e) {
|
|
264
279
|
return "%26%23" + parseInt(e.slice(2), 16) + "%3B";
|
|
265
280
|
});
|
|
266
281
|
let o = "";
|
|
267
|
-
for (let e = 0; e < a.length; e +=
|
|
268
|
-
let t = a.length >=
|
|
282
|
+
for (let e = 0; e < a.length; e += De) {
|
|
283
|
+
let t = a.length >= De ? a.slice(e, e + De) : a, n = [];
|
|
269
284
|
for (let e = 0; e < t.length; ++e) {
|
|
270
285
|
let r = t.charCodeAt(e);
|
|
271
286
|
if (r === 45 || r === 46 || r === 95 || r === 126 || r >= 48 && r <= 57 || r >= 65 && r <= 90 || r >= 97 && r <= 122 || i === "RFC1738" && (r === 40 || r === 41)) {
|
|
@@ -290,11 +305,11 @@ var be = ({ headers: e, body: t }) => ({
|
|
|
290
305
|
}
|
|
291
306
|
return o;
|
|
292
307
|
};
|
|
293
|
-
function
|
|
308
|
+
function ke(e) {
|
|
294
309
|
return !e || typeof e != "object" ? !1 : !!(e.constructor && e.constructor.isBuffer && e.constructor.isBuffer(e));
|
|
295
310
|
}
|
|
296
|
-
function
|
|
297
|
-
if (
|
|
311
|
+
function Ae(e, t) {
|
|
312
|
+
if (w(e)) {
|
|
298
313
|
let n = [];
|
|
299
314
|
for (let r = 0; r < e.length; r += 1) n.push(t(e[r]));
|
|
300
315
|
return n;
|
|
@@ -303,7 +318,7 @@ function Oe(e, t) {
|
|
|
303
318
|
}
|
|
304
319
|
//#endregion
|
|
305
320
|
//#region node_modules/openai/internal/qs/stringify.mjs
|
|
306
|
-
var
|
|
321
|
+
var je = {
|
|
307
322
|
brackets(e) {
|
|
308
323
|
return String(e) + "[]";
|
|
309
324
|
},
|
|
@@ -314,9 +329,9 @@ var ke = {
|
|
|
314
329
|
repeat(e) {
|
|
315
330
|
return String(e);
|
|
316
331
|
}
|
|
317
|
-
},
|
|
318
|
-
Array.prototype.push.apply(e,
|
|
319
|
-
},
|
|
332
|
+
}, Me = function(e, t) {
|
|
333
|
+
Array.prototype.push.apply(e, w(t) ? t : [t]);
|
|
334
|
+
}, Ne, D = {
|
|
320
335
|
addQueryPrefix: !1,
|
|
321
336
|
allowDots: !1,
|
|
322
337
|
allowEmptyArrays: !1,
|
|
@@ -326,80 +341,80 @@ var ke = {
|
|
|
326
341
|
delimiter: "&",
|
|
327
342
|
encode: !0,
|
|
328
343
|
encodeDotInKeys: !1,
|
|
329
|
-
encoder:
|
|
344
|
+
encoder: Oe,
|
|
330
345
|
encodeValuesOnly: !1,
|
|
331
|
-
format:
|
|
332
|
-
formatter:
|
|
346
|
+
format: Ce,
|
|
347
|
+
formatter: we,
|
|
333
348
|
indices: !1,
|
|
334
349
|
serializeDate(e) {
|
|
335
|
-
return (
|
|
350
|
+
return (Ne ??= Function.prototype.call.bind(Date.prototype.toISOString))(e);
|
|
336
351
|
},
|
|
337
352
|
skipNulls: !1,
|
|
338
353
|
strictNullHandling: !1
|
|
339
354
|
};
|
|
340
|
-
function
|
|
355
|
+
function Pe(e) {
|
|
341
356
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "symbol" || typeof e == "bigint";
|
|
342
357
|
}
|
|
343
|
-
var
|
|
344
|
-
function
|
|
345
|
-
let v = e, y = _, b = 0,
|
|
346
|
-
for (; (y = y.get(
|
|
358
|
+
var Fe = {};
|
|
359
|
+
function Ie(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _) {
|
|
360
|
+
let v = e, y = _, b = 0, x = !1;
|
|
361
|
+
for (; (y = y.get(Fe)) !== void 0 && !x;) {
|
|
347
362
|
let t = y.get(e);
|
|
348
363
|
if (b += 1, t !== void 0) {
|
|
349
364
|
if (t === b) throw RangeError("Cyclic object value");
|
|
350
|
-
|
|
365
|
+
x = !0;
|
|
351
366
|
}
|
|
352
|
-
y.get(
|
|
367
|
+
y.get(Fe) === void 0 && (b = 0);
|
|
353
368
|
}
|
|
354
|
-
if (typeof l == "function" ? v = l(t, v) : v instanceof Date ? v = f?.(v) : n === "comma" &&
|
|
369
|
+
if (typeof l == "function" ? v = l(t, v) : v instanceof Date ? v = f?.(v) : n === "comma" && w(v) && (v = Ae(v, function(e) {
|
|
355
370
|
return e instanceof Date ? f?.(e) : e;
|
|
356
371
|
})), v === null) {
|
|
357
372
|
if (a) return c && !h ? c(t, D.encoder, g, "key", p) : t;
|
|
358
373
|
v = "";
|
|
359
374
|
}
|
|
360
|
-
if (
|
|
375
|
+
if (Pe(v) || ke(v)) {
|
|
361
376
|
if (c) {
|
|
362
377
|
let e = h ? t : c(t, D.encoder, g, "key", p);
|
|
363
378
|
return [m?.(e) + "=" + m?.(c(v, D.encoder, g, "value", p))];
|
|
364
379
|
}
|
|
365
380
|
return [m?.(t) + "=" + m?.(String(v))];
|
|
366
381
|
}
|
|
367
|
-
let
|
|
368
|
-
if (v === void 0) return
|
|
382
|
+
let ee = [];
|
|
383
|
+
if (v === void 0) return ee;
|
|
369
384
|
let S;
|
|
370
|
-
if (n === "comma" &&
|
|
371
|
-
else if (
|
|
385
|
+
if (n === "comma" && w(v)) h && c && (v = Ae(v, c)), S = [{ value: v.length > 0 ? v.join(",") || null : void 0 }];
|
|
386
|
+
else if (w(l)) S = l;
|
|
372
387
|
else {
|
|
373
388
|
let e = Object.keys(v);
|
|
374
389
|
S = u ? e.sort(u) : e;
|
|
375
390
|
}
|
|
376
|
-
let C = s ? String(t).replace(/\./g, "%2E") : String(t),
|
|
377
|
-
if (i &&
|
|
391
|
+
let C = s ? String(t).replace(/\./g, "%2E") : String(t), T = r && w(v) && v.length === 1 ? C + "[]" : C;
|
|
392
|
+
if (i && w(v) && v.length === 0) return T + "[]";
|
|
378
393
|
for (let t = 0; t < S.length; ++t) {
|
|
379
|
-
let y = S[t],
|
|
380
|
-
if (o &&
|
|
381
|
-
let C = d && s ? y.replace(/\./g, "%2E") : y,
|
|
394
|
+
let y = S[t], x = typeof y == "object" && y.value !== void 0 ? y.value : v[y];
|
|
395
|
+
if (o && x === null) continue;
|
|
396
|
+
let C = d && s ? y.replace(/\./g, "%2E") : y, te = w(v) ? typeof n == "function" ? n(T, C) : T : T + (d ? "." + C : "[" + C + "]");
|
|
382
397
|
_.set(e, b);
|
|
383
|
-
let
|
|
384
|
-
|
|
398
|
+
let ne = /* @__PURE__ */ new WeakMap();
|
|
399
|
+
ne.set(Fe, _), Me(ee, Ie(x, te, n, r, i, a, o, s, n === "comma" && h && w(v) ? null : c, l, u, d, f, p, m, h, g, ne));
|
|
385
400
|
}
|
|
386
|
-
return
|
|
401
|
+
return ee;
|
|
387
402
|
}
|
|
388
|
-
function
|
|
403
|
+
function Le(e = D) {
|
|
389
404
|
if (e.allowEmptyArrays !== void 0 && typeof e.allowEmptyArrays != "boolean") throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");
|
|
390
405
|
if (e.encodeDotInKeys !== void 0 && typeof e.encodeDotInKeys != "boolean") throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");
|
|
391
406
|
if (e.encoder !== null && e.encoder !== void 0 && typeof e.encoder != "function") throw TypeError("Encoder has to be a function.");
|
|
392
407
|
let t = e.charset || D.charset;
|
|
393
408
|
if (e.charset !== void 0 && e.charset !== "utf-8" && e.charset !== "iso-8859-1") throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
|
|
394
|
-
let n =
|
|
409
|
+
let n = Ce;
|
|
395
410
|
if (e.format !== void 0) {
|
|
396
|
-
if (!
|
|
411
|
+
if (!Ee(Te, e.format)) throw TypeError("Unknown format option provided.");
|
|
397
412
|
n = e.format;
|
|
398
413
|
}
|
|
399
|
-
let r =
|
|
400
|
-
(typeof e.filter == "function" ||
|
|
414
|
+
let r = Te[n], i = D.filter;
|
|
415
|
+
(typeof e.filter == "function" || w(e.filter)) && (i = e.filter);
|
|
401
416
|
let a;
|
|
402
|
-
if (a = e.arrayFormat && e.arrayFormat in
|
|
417
|
+
if (a = e.arrayFormat && e.arrayFormat in je ? e.arrayFormat : "indices" in e ? e.indices ? "indices" : "repeat" : D.arrayFormat, "commaRoundTrip" in e && typeof e.commaRoundTrip != "boolean") throw TypeError("`commaRoundTrip` must be a boolean, or absent");
|
|
403
418
|
let o = e.allowDots === void 0 ? e.encodeDotInKeys ? !0 : D.allowDots : !!e.allowDots;
|
|
404
419
|
return {
|
|
405
420
|
addQueryPrefix: typeof e.addQueryPrefix == "boolean" ? e.addQueryPrefix : D.addQueryPrefix,
|
|
@@ -423,66 +438,66 @@ function Fe(e = D) {
|
|
|
423
438
|
strictNullHandling: typeof e.strictNullHandling == "boolean" ? e.strictNullHandling : D.strictNullHandling
|
|
424
439
|
};
|
|
425
440
|
}
|
|
426
|
-
function
|
|
427
|
-
let n = e, r =
|
|
428
|
-
typeof r.filter == "function" ? (a = r.filter, n = a("", n)) :
|
|
441
|
+
function Re(e, t = {}) {
|
|
442
|
+
let n = e, r = Le(t), i, a;
|
|
443
|
+
typeof r.filter == "function" ? (a = r.filter, n = a("", n)) : w(r.filter) && (a = r.filter, i = a);
|
|
429
444
|
let o = [];
|
|
430
445
|
if (typeof n != "object" || !n) return "";
|
|
431
|
-
let s =
|
|
446
|
+
let s = je[r.arrayFormat], c = s === "comma" && r.commaRoundTrip;
|
|
432
447
|
i ||= Object.keys(n), r.sort && i.sort(r.sort);
|
|
433
448
|
let l = /* @__PURE__ */ new WeakMap();
|
|
434
449
|
for (let e = 0; e < i.length; ++e) {
|
|
435
450
|
let t = i[e];
|
|
436
|
-
r.skipNulls && n[t] === null ||
|
|
451
|
+
r.skipNulls && n[t] === null || Me(o, Ie(n[t], t, s, c, r.allowEmptyArrays, r.strictNullHandling, r.skipNulls, r.encodeDotInKeys, r.encode ? r.encoder : null, r.filter, r.sort, r.allowDots, r.serializeDate, r.format, r.formatter, r.encodeValuesOnly, r.charset, l));
|
|
437
452
|
}
|
|
438
453
|
let u = o.join(r.delimiter), d = r.addQueryPrefix === !0 ? "?" : "";
|
|
439
454
|
return r.charsetSentinel && (r.charset === "iso-8859-1" ? d += "utf8=%26%2310003%3B&" : d += "utf8=%E2%9C%93&"), u.length > 0 ? d + u : "";
|
|
440
455
|
}
|
|
441
456
|
//#endregion
|
|
442
457
|
//#region node_modules/openai/internal/utils/query.mjs
|
|
443
|
-
function
|
|
444
|
-
return
|
|
458
|
+
function ze(e) {
|
|
459
|
+
return Re(e, { arrayFormat: "brackets" });
|
|
445
460
|
}
|
|
446
461
|
//#endregion
|
|
447
462
|
//#region node_modules/openai/internal/utils/bytes.mjs
|
|
448
|
-
function
|
|
463
|
+
function Be(e) {
|
|
449
464
|
let t = 0;
|
|
450
465
|
for (let n of e) t += n.length;
|
|
451
466
|
let n = new Uint8Array(t), r = 0;
|
|
452
467
|
for (let t of e) n.set(t, r), r += t.length;
|
|
453
468
|
return n;
|
|
454
469
|
}
|
|
455
|
-
var ze;
|
|
456
|
-
function Be(e) {
|
|
457
|
-
let t;
|
|
458
|
-
return (ze ??= (t = new globalThis.TextEncoder(), t.encode.bind(t)))(e);
|
|
459
|
-
}
|
|
460
470
|
var Ve;
|
|
461
471
|
function He(e) {
|
|
462
472
|
let t;
|
|
463
|
-
return (Ve ??= (t = new globalThis.
|
|
473
|
+
return (Ve ??= (t = new globalThis.TextEncoder(), t.encode.bind(t)))(e);
|
|
474
|
+
}
|
|
475
|
+
var Ue;
|
|
476
|
+
function We(e) {
|
|
477
|
+
let t;
|
|
478
|
+
return (Ue ??= (t = new globalThis.TextDecoder(), t.decode.bind(t)))(e);
|
|
464
479
|
}
|
|
465
480
|
//#endregion
|
|
466
481
|
//#region node_modules/openai/internal/decoders/line.mjs
|
|
467
|
-
var O, k,
|
|
482
|
+
var O, k, Ge = class {
|
|
468
483
|
constructor() {
|
|
469
484
|
O.set(this, void 0), k.set(this, void 0), e(this, O, new Uint8Array(), "f"), e(this, k, null, "f");
|
|
470
485
|
}
|
|
471
486
|
decode(n) {
|
|
472
487
|
if (n == null) return [];
|
|
473
|
-
let r = n instanceof ArrayBuffer ? new Uint8Array(n) : typeof n == "string" ?
|
|
474
|
-
e(this, O,
|
|
488
|
+
let r = n instanceof ArrayBuffer ? new Uint8Array(n) : typeof n == "string" ? He(n) : n;
|
|
489
|
+
e(this, O, Be([t(this, O, "f"), r]), "f");
|
|
475
490
|
let i = [], a;
|
|
476
|
-
for (; (a =
|
|
491
|
+
for (; (a = Ke(t(this, O, "f"), t(this, k, "f"))) != null;) {
|
|
477
492
|
if (a.carriage && t(this, k, "f") == null) {
|
|
478
493
|
e(this, k, a.index, "f");
|
|
479
494
|
continue;
|
|
480
495
|
}
|
|
481
496
|
if (t(this, k, "f") != null && (a.index !== t(this, k, "f") + 1 || a.carriage)) {
|
|
482
|
-
i.push(
|
|
497
|
+
i.push(We(t(this, O, "f").subarray(0, t(this, k, "f") - 1))), e(this, O, t(this, O, "f").subarray(t(this, k, "f")), "f"), e(this, k, null, "f");
|
|
483
498
|
continue;
|
|
484
499
|
}
|
|
485
|
-
let n = t(this, k, "f") === null ? a.preceding : a.preceding - 1, r =
|
|
500
|
+
let n = t(this, k, "f") === null ? a.preceding : a.preceding - 1, r = We(t(this, O, "f").subarray(0, n));
|
|
486
501
|
i.push(r), e(this, O, t(this, O, "f").subarray(a.index), "f"), e(this, k, null, "f");
|
|
487
502
|
}
|
|
488
503
|
return i;
|
|
@@ -491,8 +506,8 @@ var O, k, Ue = class {
|
|
|
491
506
|
return t(this, O, "f").length ? this.decode("\n") : [];
|
|
492
507
|
}
|
|
493
508
|
};
|
|
494
|
-
O = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(),
|
|
495
|
-
function
|
|
509
|
+
O = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(), Ge.NEWLINE_CHARS = new Set(["\n", "\r"]), Ge.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
510
|
+
function Ke(e, t) {
|
|
496
511
|
for (let n = t ?? 0; n < e.length; n++) {
|
|
497
512
|
if (e[n] === 10) return {
|
|
498
513
|
preceding: n,
|
|
@@ -507,7 +522,7 @@ function We(e, t) {
|
|
|
507
522
|
}
|
|
508
523
|
return null;
|
|
509
524
|
}
|
|
510
|
-
function
|
|
525
|
+
function qe(e) {
|
|
511
526
|
for (let t = 0; t < e.length - 1; t++) {
|
|
512
527
|
if (e[t] === 10 && e[t + 1] === 10 || e[t] === 13 && e[t + 1] === 13) return t + 2;
|
|
513
528
|
if (e[t] === 13 && e[t + 1] === 10 && t + 3 < e.length && e[t + 2] === 13 && e[t + 3] === 10) return t + 4;
|
|
@@ -516,44 +531,44 @@ function Ge(e) {
|
|
|
516
531
|
}
|
|
517
532
|
//#endregion
|
|
518
533
|
//#region node_modules/openai/internal/utils/log.mjs
|
|
519
|
-
var
|
|
534
|
+
var Je = {
|
|
520
535
|
off: 0,
|
|
521
536
|
error: 200,
|
|
522
537
|
warn: 300,
|
|
523
538
|
info: 400,
|
|
524
539
|
debug: 500
|
|
525
|
-
},
|
|
540
|
+
}, Ye = (e, t, n) => {
|
|
526
541
|
if (e) {
|
|
527
|
-
if (
|
|
528
|
-
A(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(
|
|
542
|
+
if (re(Je, e)) return e;
|
|
543
|
+
A(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Je))}`);
|
|
529
544
|
}
|
|
530
545
|
};
|
|
531
|
-
function
|
|
532
|
-
function
|
|
533
|
-
return !t ||
|
|
546
|
+
function Xe() {}
|
|
547
|
+
function Ze(e, t, n) {
|
|
548
|
+
return !t || Je[e] > Je[n] ? Xe : t[e].bind(t);
|
|
534
549
|
}
|
|
535
|
-
var
|
|
536
|
-
error:
|
|
537
|
-
warn:
|
|
538
|
-
info:
|
|
539
|
-
debug:
|
|
540
|
-
},
|
|
550
|
+
var Qe = {
|
|
551
|
+
error: Xe,
|
|
552
|
+
warn: Xe,
|
|
553
|
+
info: Xe,
|
|
554
|
+
debug: Xe
|
|
555
|
+
}, $e = /* @__PURE__ */ new WeakMap();
|
|
541
556
|
function A(e) {
|
|
542
557
|
let t = e.logger, n = e.logLevel ?? "off";
|
|
543
|
-
if (!t) return
|
|
544
|
-
let r =
|
|
558
|
+
if (!t) return Qe;
|
|
559
|
+
let r = $e.get(t);
|
|
545
560
|
if (r && r[0] === n) return r[1];
|
|
546
561
|
let i = {
|
|
547
|
-
error:
|
|
548
|
-
warn:
|
|
549
|
-
info:
|
|
550
|
-
debug:
|
|
562
|
+
error: Ze("error", t, n),
|
|
563
|
+
warn: Ze("warn", t, n),
|
|
564
|
+
info: Ze("info", t, n),
|
|
565
|
+
debug: Ze("debug", t, n)
|
|
551
566
|
};
|
|
552
|
-
return
|
|
567
|
+
return $e.set(t, [n, i]), i;
|
|
553
568
|
}
|
|
554
|
-
var j = (e) => (e.options && (e.options = { ...e.options }, delete e.options.headers), e.headers &&= Object.fromEntries((e.headers instanceof Headers ? [...e.headers] : Object.entries(e.headers)).map(([e, t]) => [e, e.toLowerCase() === "authorization" || e.toLowerCase() === "cookie" || e.toLowerCase() === "set-cookie" ? "***" : t])), "retryOfRequestLogID" in e && (e.retryOfRequestLogID && (e.retryOf = e.retryOfRequestLogID), delete e.retryOfRequestLogID), e),
|
|
569
|
+
var j = (e) => (e.options && (e.options = { ...e.options }, delete e.options.headers), e.headers &&= Object.fromEntries((e.headers instanceof Headers ? [...e.headers] : Object.entries(e.headers)).map(([e, t]) => [e, e.toLowerCase() === "authorization" || e.toLowerCase() === "cookie" || e.toLowerCase() === "set-cookie" ? "***" : t])), "retryOfRequestLogID" in e && (e.retryOfRequestLogID && (e.retryOf = e.retryOfRequestLogID), delete e.retryOfRequestLogID), e), et, tt = class n {
|
|
555
570
|
constructor(t, n, r) {
|
|
556
|
-
this.iterator = t,
|
|
571
|
+
this.iterator = t, et.set(this, void 0), this.controller = n, e(this, et, r, "f");
|
|
557
572
|
}
|
|
558
573
|
static fromSSEResponse(e, t, i, s) {
|
|
559
574
|
let c = !1, l = i ? A(i) : console;
|
|
@@ -562,7 +577,7 @@ var j = (e) => (e.options && (e.options = { ...e.options }, delete e.options.hea
|
|
|
562
577
|
c = !0;
|
|
563
578
|
let n = !1;
|
|
564
579
|
try {
|
|
565
|
-
for await (let r of
|
|
580
|
+
for await (let r of nt(e, t)) if (!n) {
|
|
566
581
|
if (r.data.startsWith("[DONE]")) {
|
|
567
582
|
n = !0;
|
|
568
583
|
continue;
|
|
@@ -606,7 +621,7 @@ var j = (e) => (e.options && (e.options = { ...e.options }, delete e.options.hea
|
|
|
606
621
|
static fromReadableStream(e, t, i) {
|
|
607
622
|
let o = !1;
|
|
608
623
|
async function* s() {
|
|
609
|
-
let t = new
|
|
624
|
+
let t = new Ge(), n = be(e);
|
|
610
625
|
for await (let e of n) for (let n of t.decode(e)) yield n;
|
|
611
626
|
for (let e of t.flush()) yield e;
|
|
612
627
|
}
|
|
@@ -626,7 +641,7 @@ var j = (e) => (e.options && (e.options = { ...e.options }, delete e.options.hea
|
|
|
626
641
|
}
|
|
627
642
|
return new n(c, t, i);
|
|
628
643
|
}
|
|
629
|
-
[(
|
|
644
|
+
[(et = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() {
|
|
630
645
|
return this.iterator();
|
|
631
646
|
}
|
|
632
647
|
tee() {
|
|
@@ -637,11 +652,11 @@ var j = (e) => (e.options && (e.options = { ...e.options }, delete e.options.hea
|
|
|
637
652
|
}
|
|
638
653
|
return t.shift();
|
|
639
654
|
} });
|
|
640
|
-
return [new n(() => a(e), this.controller, t(this,
|
|
655
|
+
return [new n(() => a(e), this.controller, t(this, et, "f")), new n(() => a(r), this.controller, t(this, et, "f"))];
|
|
641
656
|
}
|
|
642
657
|
toReadableStream() {
|
|
643
658
|
let e = this, t;
|
|
644
|
-
return
|
|
659
|
+
return ve({
|
|
645
660
|
async start() {
|
|
646
661
|
t = e[Symbol.asyncIterator]();
|
|
647
662
|
},
|
|
@@ -649,7 +664,7 @@ var j = (e) => (e.options && (e.options = { ...e.options }, delete e.options.hea
|
|
|
649
664
|
try {
|
|
650
665
|
let { value: n, done: r } = await t.next();
|
|
651
666
|
if (r) return e.close();
|
|
652
|
-
let i =
|
|
667
|
+
let i = He(JSON.stringify(n) + "\n");
|
|
653
668
|
e.enqueue(i);
|
|
654
669
|
} catch (t) {
|
|
655
670
|
e.error(t);
|
|
@@ -661,10 +676,10 @@ var j = (e) => (e.options && (e.options = { ...e.options }, delete e.options.hea
|
|
|
661
676
|
});
|
|
662
677
|
}
|
|
663
678
|
};
|
|
664
|
-
async function*
|
|
679
|
+
async function* nt(e, t) {
|
|
665
680
|
if (!e.body) throw t.abort(), globalThis.navigator !== void 0 && globalThis.navigator.product === "ReactNative" ? new a("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api") : new a("Attempted to iterate over a response with no body");
|
|
666
|
-
let n = new
|
|
667
|
-
for await (let e of
|
|
681
|
+
let n = new it(), r = new Ge(), i = be(e.body);
|
|
682
|
+
for await (let e of rt(i)) for (let t of r.decode(e)) {
|
|
668
683
|
let e = n.decode(t);
|
|
669
684
|
e && (yield e);
|
|
670
685
|
}
|
|
@@ -673,18 +688,18 @@ async function* et(e, t) {
|
|
|
673
688
|
t && (yield t);
|
|
674
689
|
}
|
|
675
690
|
}
|
|
676
|
-
async function*
|
|
691
|
+
async function* rt(e) {
|
|
677
692
|
let t = new Uint8Array();
|
|
678
693
|
for await (let n of e) {
|
|
679
694
|
if (n == null) continue;
|
|
680
|
-
let e = n instanceof ArrayBuffer ? new Uint8Array(n) : typeof n == "string" ?
|
|
695
|
+
let e = n instanceof ArrayBuffer ? new Uint8Array(n) : typeof n == "string" ? He(n) : n, r = new Uint8Array(t.length + e.length);
|
|
681
696
|
r.set(t), r.set(e, t.length), t = r;
|
|
682
697
|
let i;
|
|
683
|
-
for (; (i =
|
|
698
|
+
for (; (i = qe(t)) !== -1;) yield t.slice(0, i), t = t.slice(i);
|
|
684
699
|
}
|
|
685
700
|
t.length > 0 && (yield t);
|
|
686
701
|
}
|
|
687
|
-
var
|
|
702
|
+
var it = class {
|
|
688
703
|
constructor() {
|
|
689
704
|
this.event = null, this.data = [], this.chunks = [];
|
|
690
705
|
}
|
|
@@ -699,11 +714,11 @@ var nt = class {
|
|
|
699
714
|
return this.event = null, this.data = [], this.chunks = [], e;
|
|
700
715
|
}
|
|
701
716
|
if (this.chunks.push(e), e.startsWith(":")) return null;
|
|
702
|
-
let [t, n, r] =
|
|
717
|
+
let [t, n, r] = at(e, ":");
|
|
703
718
|
return r.startsWith(" ") && (r = r.substring(1)), t === "event" ? this.event = r : t === "data" && this.data.push(r), null;
|
|
704
719
|
}
|
|
705
720
|
};
|
|
706
|
-
function
|
|
721
|
+
function at(e, t) {
|
|
707
722
|
let n = e.indexOf(t);
|
|
708
723
|
return n === -1 ? [
|
|
709
724
|
e,
|
|
@@ -717,13 +732,13 @@ function rt(e, t) {
|
|
|
717
732
|
}
|
|
718
733
|
//#endregion
|
|
719
734
|
//#region node_modules/openai/internal/parse.mjs
|
|
720
|
-
async function
|
|
735
|
+
async function ot(e, t) {
|
|
721
736
|
let { response: n, requestLogID: r, retryOfRequestLogID: i, startTime: a } = t, o = await (async () => {
|
|
722
|
-
if (t.options.stream) return A(e).debug("response", n.status, n.url, n.headers, n.body), t.options.__streamClass ? t.options.__streamClass.fromSSEResponse(n, t.controller, e, t.options.__synthesizeEventData) :
|
|
737
|
+
if (t.options.stream) return A(e).debug("response", n.status, n.url, n.headers, n.body), t.options.__streamClass ? t.options.__streamClass.fromSSEResponse(n, t.controller, e, t.options.__synthesizeEventData) : tt.fromSSEResponse(n, t.controller, e, t.options.__synthesizeEventData);
|
|
723
738
|
if (n.status === 204) return null;
|
|
724
739
|
if (t.options.__binaryResponse) return n;
|
|
725
740
|
let r = n.headers.get("content-type")?.split(";")[0]?.trim();
|
|
726
|
-
return r?.includes("application/json") || r?.endsWith("+json") ? n.headers.get("content-length") === "0" ? void 0 :
|
|
741
|
+
return r?.includes("application/json") || r?.endsWith("+json") ? n.headers.get("content-length") === "0" ? void 0 : st(await n.json(), n) : await n.text();
|
|
727
742
|
})();
|
|
728
743
|
return A(e).debug(`[${r}] response parsed`, j({
|
|
729
744
|
retryOfRequestLogID: i,
|
|
@@ -733,7 +748,7 @@ async function it(e, t) {
|
|
|
733
748
|
durationMs: Date.now() - a
|
|
734
749
|
})), o;
|
|
735
750
|
}
|
|
736
|
-
function
|
|
751
|
+
function st(e, t) {
|
|
737
752
|
return !e || typeof e != "object" || Array.isArray(e) ? e : Object.defineProperty(e, "_request_id", {
|
|
738
753
|
value: t.headers.get("x-request-id"),
|
|
739
754
|
enumerable: !1
|
|
@@ -741,14 +756,14 @@ function at(e, t) {
|
|
|
741
756
|
}
|
|
742
757
|
//#endregion
|
|
743
758
|
//#region node_modules/openai/core/api-promise.mjs
|
|
744
|
-
var
|
|
745
|
-
constructor(t, n, r =
|
|
759
|
+
var ct, lt = class n extends Promise {
|
|
760
|
+
constructor(t, n, r = ot) {
|
|
746
761
|
super((e) => {
|
|
747
762
|
e(null);
|
|
748
|
-
}), this.responsePromise = n, this.parseResponse = r,
|
|
763
|
+
}), this.responsePromise = n, this.parseResponse = r, ct.set(this, void 0), e(this, ct, t, "f");
|
|
749
764
|
}
|
|
750
765
|
_thenUnwrap(e) {
|
|
751
|
-
return new n(t(this,
|
|
766
|
+
return new n(t(this, ct, "f"), this.responsePromise, async (t, n) => st(e(await this.parseResponse(t, n), n), n.response));
|
|
752
767
|
}
|
|
753
768
|
asResponse() {
|
|
754
769
|
return this.responsePromise.then((e) => e.response);
|
|
@@ -762,7 +777,7 @@ var ot, st = class n extends Promise {
|
|
|
762
777
|
};
|
|
763
778
|
}
|
|
764
779
|
parse() {
|
|
765
|
-
return this.parsedPromise ||= this.responsePromise.then((e) => this.parseResponse(t(this,
|
|
780
|
+
return this.parsedPromise ||= this.responsePromise.then((e) => this.parseResponse(t(this, ct, "f"), e)), this.parsedPromise;
|
|
766
781
|
}
|
|
767
782
|
then(e, t) {
|
|
768
783
|
return this.parse().then(e, t);
|
|
@@ -774,12 +789,12 @@ var ot, st = class n extends Promise {
|
|
|
774
789
|
return this.parse().finally(e);
|
|
775
790
|
}
|
|
776
791
|
};
|
|
777
|
-
|
|
792
|
+
ct = /* @__PURE__ */ new WeakMap();
|
|
778
793
|
//#endregion
|
|
779
794
|
//#region node_modules/openai/core/pagination.mjs
|
|
780
|
-
var
|
|
795
|
+
var ut, dt = class {
|
|
781
796
|
constructor(t, n, r, i) {
|
|
782
|
-
|
|
797
|
+
ut.set(this, void 0), e(this, ut, t, "f"), this.options = i, this.response = n, this.body = r;
|
|
783
798
|
}
|
|
784
799
|
hasNextPage() {
|
|
785
800
|
return this.getPaginatedItems().length ? this.nextPageRequestOptions() != null : !1;
|
|
@@ -787,24 +802,24 @@ var ct, lt = class {
|
|
|
787
802
|
async getNextPage() {
|
|
788
803
|
let e = this.nextPageRequestOptions();
|
|
789
804
|
if (!e) throw new a("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");
|
|
790
|
-
return await t(this,
|
|
805
|
+
return await t(this, ut, "f").requestAPIList(this.constructor, e);
|
|
791
806
|
}
|
|
792
807
|
async *iterPages() {
|
|
793
808
|
let e = this;
|
|
794
809
|
for (yield e; e.hasNextPage();) e = await e.getNextPage(), yield e;
|
|
795
810
|
}
|
|
796
|
-
async *[(
|
|
811
|
+
async *[(ut = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() {
|
|
797
812
|
for await (let e of this.iterPages()) for (let t of e.getPaginatedItems()) yield t;
|
|
798
813
|
}
|
|
799
|
-
},
|
|
814
|
+
}, ft = class extends lt {
|
|
800
815
|
constructor(e, t, n) {
|
|
801
|
-
super(e, t, async (e, t) => new n(e, t.response, await
|
|
816
|
+
super(e, t, async (e, t) => new n(e, t.response, await ot(e, t), t.options));
|
|
802
817
|
}
|
|
803
818
|
async *[Symbol.asyncIterator]() {
|
|
804
819
|
let e = await this;
|
|
805
820
|
for await (let t of e) yield t;
|
|
806
821
|
}
|
|
807
|
-
},
|
|
822
|
+
}, pt = class extends dt {
|
|
808
823
|
constructor(e, t, n, r) {
|
|
809
824
|
super(e, t, n, r), this.data = n.data || [], this.object = n.object;
|
|
810
825
|
}
|
|
@@ -814,7 +829,7 @@ var ct, lt = class {
|
|
|
814
829
|
nextPageRequestOptions() {
|
|
815
830
|
return null;
|
|
816
831
|
}
|
|
817
|
-
}, M = class extends
|
|
832
|
+
}, M = class extends dt {
|
|
818
833
|
constructor(e, t, n, r) {
|
|
819
834
|
super(e, t, n, r), this.data = n.data || [], this.has_more = n.has_more || !1;
|
|
820
835
|
}
|
|
@@ -829,12 +844,12 @@ var ct, lt = class {
|
|
|
829
844
|
return t ? {
|
|
830
845
|
...this.options,
|
|
831
846
|
query: {
|
|
832
|
-
...
|
|
847
|
+
...te(this.options.query),
|
|
833
848
|
after: t
|
|
834
849
|
}
|
|
835
850
|
} : null;
|
|
836
851
|
}
|
|
837
|
-
},
|
|
852
|
+
}, mt = class extends dt {
|
|
838
853
|
constructor(e, t, n, r) {
|
|
839
854
|
super(e, t, n, r), this.data = n.data || [], this.has_more = n.has_more || !1, this.last_id = n.last_id || "";
|
|
840
855
|
}
|
|
@@ -849,32 +864,89 @@ var ct, lt = class {
|
|
|
849
864
|
return e ? {
|
|
850
865
|
...this.options,
|
|
851
866
|
query: {
|
|
852
|
-
...
|
|
867
|
+
...te(this.options.query),
|
|
853
868
|
after: e
|
|
854
869
|
}
|
|
855
870
|
} : null;
|
|
856
871
|
}
|
|
857
|
-
},
|
|
872
|
+
}, ht = {
|
|
873
|
+
jwt: "urn:ietf:params:oauth:token-type:jwt",
|
|
874
|
+
id: "urn:ietf:params:oauth:token-type:id_token"
|
|
875
|
+
}, gt = "urn:ietf:params:oauth:grant-type:token-exchange", _t = class {
|
|
876
|
+
constructor(e, t) {
|
|
877
|
+
this.cachedToken = null, this.refreshPromise = null, this.tokenExchangeUrl = "https://auth.openai.com/oauth/token", this.config = e, this.fetch = t ?? _e();
|
|
878
|
+
}
|
|
879
|
+
async getToken() {
|
|
880
|
+
if (!this.cachedToken || this.isTokenExpired(this.cachedToken)) {
|
|
881
|
+
if (this.refreshPromise) return await this.refreshPromise;
|
|
882
|
+
this.refreshPromise = this.refreshToken();
|
|
883
|
+
try {
|
|
884
|
+
return await this.refreshPromise;
|
|
885
|
+
} finally {
|
|
886
|
+
this.refreshPromise = null;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
return this.needsRefresh(this.cachedToken) && !this.refreshPromise && (this.refreshPromise = this.refreshToken().finally(() => {
|
|
890
|
+
this.refreshPromise = null;
|
|
891
|
+
})), this.cachedToken.token;
|
|
892
|
+
}
|
|
893
|
+
async refreshToken() {
|
|
894
|
+
let e = await this.config.provider.getToken(), t = await this.fetch(this.tokenExchangeUrl, {
|
|
895
|
+
method: "POST",
|
|
896
|
+
headers: { "Content-Type": "application/json" },
|
|
897
|
+
body: JSON.stringify({
|
|
898
|
+
grant_type: gt,
|
|
899
|
+
client_id: this.config.clientId,
|
|
900
|
+
subject_token: e,
|
|
901
|
+
subject_token_type: ht[this.config.provider.tokenType],
|
|
902
|
+
identity_provider_id: this.config.identityProviderId,
|
|
903
|
+
service_account_id: this.config.serviceAccountId
|
|
904
|
+
})
|
|
905
|
+
});
|
|
906
|
+
if (!t.ok) {
|
|
907
|
+
let e = await t.text(), n;
|
|
908
|
+
try {
|
|
909
|
+
n = JSON.parse(e);
|
|
910
|
+
} catch {}
|
|
911
|
+
throw t.status === 400 || t.status === 401 || t.status === 403 ? new x(t.status, n, t.headers) : o.generate(t.status, n, `Token exchange failed with status ${t.status}`, t.headers);
|
|
912
|
+
}
|
|
913
|
+
let n = await t.json(), r = n.expires_in || 3600, i = Date.now() + r * 1e3;
|
|
914
|
+
return this.cachedToken = {
|
|
915
|
+
token: n.access_token,
|
|
916
|
+
expiresAt: i
|
|
917
|
+
}, n.access_token;
|
|
918
|
+
}
|
|
919
|
+
isTokenExpired(e) {
|
|
920
|
+
return Date.now() >= e.expiresAt;
|
|
921
|
+
}
|
|
922
|
+
needsRefresh(e) {
|
|
923
|
+
let t = (this.config.refreshBufferSeconds ?? 1200) * 1e3;
|
|
924
|
+
return Date.now() >= e.expiresAt - t;
|
|
925
|
+
}
|
|
926
|
+
invalidateToken() {
|
|
927
|
+
this.cachedToken = null, this.refreshPromise = null;
|
|
928
|
+
}
|
|
929
|
+
}, vt = () => {
|
|
858
930
|
if (typeof File > "u") {
|
|
859
931
|
let { process: e } = globalThis, t = typeof e?.versions?.node == "string" && parseInt(e.versions.node.split(".")) < 20;
|
|
860
932
|
throw Error("`File` is not defined as a global, which is required for file uploads." + (t ? " Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`." : ""));
|
|
861
933
|
}
|
|
862
934
|
};
|
|
863
|
-
function
|
|
864
|
-
return
|
|
935
|
+
function yt(e, t, n) {
|
|
936
|
+
return vt(), new File(e, t ?? "unknown_file", n);
|
|
865
937
|
}
|
|
866
|
-
function
|
|
938
|
+
function bt(e) {
|
|
867
939
|
return (typeof e == "object" && !!e && ("name" in e && e.name && String(e.name) || "url" in e && e.url && String(e.url) || "filename" in e && e.filename && String(e.filename) || "path" in e && e.path && String(e.path)) || "").split(/[\\/]/).pop() || void 0;
|
|
868
940
|
}
|
|
869
|
-
var
|
|
941
|
+
var xt = (e) => typeof e == "object" && !!e && typeof e[Symbol.asyncIterator] == "function", St = async (e, t) => Ot(e.body) ? {
|
|
870
942
|
...e,
|
|
871
|
-
body: await
|
|
943
|
+
body: await Tt(e.body, t)
|
|
872
944
|
} : e, N = async (e, t) => ({
|
|
873
945
|
...e,
|
|
874
|
-
body: await
|
|
875
|
-
}),
|
|
876
|
-
function
|
|
877
|
-
let t = typeof e == "function" ? e : e.fetch, n =
|
|
946
|
+
body: await Tt(e.body, t)
|
|
947
|
+
}), Ct = /* @__PURE__ */ new WeakMap();
|
|
948
|
+
function wt(e) {
|
|
949
|
+
let t = typeof e == "function" ? e : e.fetch, n = Ct.get(t);
|
|
878
950
|
if (n) return n;
|
|
879
951
|
let r = (async () => {
|
|
880
952
|
try {
|
|
@@ -884,59 +956,59 @@ function yt(e) {
|
|
|
884
956
|
return !0;
|
|
885
957
|
}
|
|
886
958
|
})();
|
|
887
|
-
return
|
|
959
|
+
return Ct.set(t, r), r;
|
|
888
960
|
}
|
|
889
|
-
var
|
|
890
|
-
if (!await
|
|
961
|
+
var Tt = async (e, t) => {
|
|
962
|
+
if (!await wt(t)) throw TypeError("The provided fetch function does not support file uploads with the current global FormData class.");
|
|
891
963
|
let n = new FormData();
|
|
892
|
-
return await Promise.all(Object.entries(e || {}).map(([e, t]) =>
|
|
893
|
-
},
|
|
894
|
-
if (
|
|
895
|
-
if (Array.isArray(e)) return e.some(
|
|
964
|
+
return await Promise.all(Object.entries(e || {}).map(([e, t]) => kt(n, e, t))), n;
|
|
965
|
+
}, Et = (e) => e instanceof Blob && "name" in e, Dt = (e) => typeof e == "object" && !!e && (e instanceof Response || xt(e) || Et(e)), Ot = (e) => {
|
|
966
|
+
if (Dt(e)) return !0;
|
|
967
|
+
if (Array.isArray(e)) return e.some(Ot);
|
|
896
968
|
if (e && typeof e == "object") {
|
|
897
|
-
for (let t in e) if (
|
|
969
|
+
for (let t in e) if (Ot(e[t])) return !0;
|
|
898
970
|
}
|
|
899
971
|
return !1;
|
|
900
|
-
},
|
|
972
|
+
}, kt = async (e, t, n) => {
|
|
901
973
|
if (n !== void 0) {
|
|
902
974
|
if (n == null) throw TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);
|
|
903
975
|
if (typeof n == "string" || typeof n == "number" || typeof n == "boolean") e.append(t, String(n));
|
|
904
|
-
else if (n instanceof Response) e.append(t,
|
|
905
|
-
else if (
|
|
906
|
-
else if (
|
|
907
|
-
else if (Array.isArray(n)) await Promise.all(n.map((n) =>
|
|
908
|
-
else if (typeof n == "object") await Promise.all(Object.entries(n).map(([n, r]) =>
|
|
976
|
+
else if (n instanceof Response) e.append(t, yt([await n.blob()], bt(n)));
|
|
977
|
+
else if (xt(n)) e.append(t, yt([await new Response(ye(n)).blob()], bt(n)));
|
|
978
|
+
else if (Et(n)) e.append(t, n, bt(n));
|
|
979
|
+
else if (Array.isArray(n)) await Promise.all(n.map((n) => kt(e, t + "[]", n)));
|
|
980
|
+
else if (typeof n == "object") await Promise.all(Object.entries(n).map(([n, r]) => kt(e, `${t}[${n}]`, r)));
|
|
909
981
|
else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`);
|
|
910
982
|
}
|
|
911
|
-
},
|
|
912
|
-
async function
|
|
913
|
-
if (
|
|
914
|
-
if (
|
|
983
|
+
}, At = (e) => typeof e == "object" && !!e && typeof e.size == "number" && typeof e.type == "string" && typeof e.text == "function" && typeof e.slice == "function" && typeof e.arrayBuffer == "function", jt = (e) => typeof e == "object" && !!e && typeof e.name == "string" && typeof e.lastModified == "number" && At(e), Mt = (e) => typeof e == "object" && !!e && typeof e.url == "string" && typeof e.blob == "function";
|
|
984
|
+
async function Nt(e, t, n) {
|
|
985
|
+
if (vt(), e = await e, jt(e)) return e instanceof File ? e : yt([await e.arrayBuffer()], e.name);
|
|
986
|
+
if (Mt(e)) {
|
|
915
987
|
let r = await e.blob();
|
|
916
|
-
return t ||= new URL(e.url).pathname.split(/[\\/]/).pop(),
|
|
988
|
+
return t ||= new URL(e.url).pathname.split(/[\\/]/).pop(), yt(await Pt(r), t, n);
|
|
917
989
|
}
|
|
918
|
-
let r = await
|
|
919
|
-
if (t ||=
|
|
990
|
+
let r = await Pt(e);
|
|
991
|
+
if (t ||= bt(e), !n?.type) {
|
|
920
992
|
let e = r.find((e) => typeof e == "object" && "type" in e && e.type);
|
|
921
993
|
typeof e == "string" && (n = {
|
|
922
994
|
...n,
|
|
923
995
|
type: e
|
|
924
996
|
});
|
|
925
997
|
}
|
|
926
|
-
return
|
|
998
|
+
return yt(r, t, n);
|
|
927
999
|
}
|
|
928
|
-
async function
|
|
1000
|
+
async function Pt(e) {
|
|
929
1001
|
let t = [];
|
|
930
1002
|
if (typeof e == "string" || ArrayBuffer.isView(e) || e instanceof ArrayBuffer) t.push(e);
|
|
931
|
-
else if (
|
|
932
|
-
else if (
|
|
1003
|
+
else if (At(e)) t.push(e instanceof Blob ? e : await e.arrayBuffer());
|
|
1004
|
+
else if (xt(e)) for await (let n of e) t.push(...await Pt(n));
|
|
933
1005
|
else {
|
|
934
1006
|
let t = e?.constructor?.name;
|
|
935
|
-
throw Error(`Unexpected data type: ${typeof e}${t ? `; constructor: ${t}` : ""}${
|
|
1007
|
+
throw Error(`Unexpected data type: ${typeof e}${t ? `; constructor: ${t}` : ""}${Ft(e)}`);
|
|
936
1008
|
}
|
|
937
1009
|
return t;
|
|
938
1010
|
}
|
|
939
|
-
function
|
|
1011
|
+
function Ft(e) {
|
|
940
1012
|
return typeof e != "object" || !e ? "" : `; props: [${Object.getOwnPropertyNames(e).map((e) => `"${e}"`).join(", ")}]`;
|
|
941
1013
|
}
|
|
942
1014
|
//#endregion
|
|
@@ -948,15 +1020,15 @@ var P = class {
|
|
|
948
1020
|
};
|
|
949
1021
|
//#endregion
|
|
950
1022
|
//#region node_modules/openai/internal/utils/path.mjs
|
|
951
|
-
function
|
|
1023
|
+
function It(e) {
|
|
952
1024
|
return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
|
|
953
1025
|
}
|
|
954
|
-
var
|
|
1026
|
+
var Lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null)), F = /* @__PURE__ */ ((e = It) => function(t, ...n) {
|
|
955
1027
|
if (t.length === 1) return t[0];
|
|
956
1028
|
let r = !1, i = [], o = t.reduce((t, a, o) => {
|
|
957
1029
|
/[?#]/.test(a) && (r = !0);
|
|
958
1030
|
let s = n[o], c = (r ? encodeURIComponent : e)("" + s);
|
|
959
|
-
return o !== n.length && (s == null || typeof s == "object" && s.toString === Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty ??
|
|
1031
|
+
return o !== n.length && (s == null || typeof s == "object" && s.toString === Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty ?? Lt) ?? Lt)?.toString) && (c = s + "", i.push({
|
|
960
1032
|
start: t.length + a.length,
|
|
961
1033
|
length: c.length,
|
|
962
1034
|
error: `Value of type ${Object.prototype.toString.call(s).slice(8, -1)} is not a valid path parameter`
|
|
@@ -975,7 +1047,7 @@ var Mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null)), F =
|
|
|
975
1047
|
throw new a(`Path parameters result in path with invalid segments:\n${i.map((e) => e.error).join("\n")}\n${o}\n${t}`);
|
|
976
1048
|
}
|
|
977
1049
|
return o;
|
|
978
|
-
})(
|
|
1050
|
+
})(It), Rt = class extends P {
|
|
979
1051
|
list(e, t = {}, n) {
|
|
980
1052
|
return this._client.getAPIList(F`/chat/completions/${e}/messages`, M, {
|
|
981
1053
|
query: t,
|
|
@@ -985,19 +1057,19 @@ var Mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null)), F =
|
|
|
985
1057
|
};
|
|
986
1058
|
//#endregion
|
|
987
1059
|
//#region node_modules/openai/lib/parser.mjs
|
|
988
|
-
function
|
|
1060
|
+
function zt(e) {
|
|
989
1061
|
return e !== void 0 && "function" in e && e.function !== void 0;
|
|
990
1062
|
}
|
|
991
|
-
function
|
|
1063
|
+
function Bt(e) {
|
|
992
1064
|
return e?.$brand === "auto-parseable-response-format";
|
|
993
1065
|
}
|
|
994
|
-
function
|
|
1066
|
+
function Vt(e) {
|
|
995
1067
|
return e?.$brand === "auto-parseable-tool";
|
|
996
1068
|
}
|
|
997
|
-
function
|
|
998
|
-
return !t || !
|
|
1069
|
+
function Ht(e, t) {
|
|
1070
|
+
return !t || !qt(t) ? {
|
|
999
1071
|
...e,
|
|
1000
|
-
choices: e.choices.map((e) => (
|
|
1072
|
+
choices: e.choices.map((e) => (Jt(e.message.tool_calls), {
|
|
1001
1073
|
...e,
|
|
1002
1074
|
message: {
|
|
1003
1075
|
...e.message,
|
|
@@ -1005,18 +1077,18 @@ function Lt(e, t) {
|
|
|
1005
1077
|
...e.message.tool_calls ? { tool_calls: e.message.tool_calls } : void 0
|
|
1006
1078
|
}
|
|
1007
1079
|
}))
|
|
1008
|
-
} :
|
|
1080
|
+
} : Ut(e, t);
|
|
1009
1081
|
}
|
|
1010
|
-
function
|
|
1082
|
+
function Ut(e, t) {
|
|
1011
1083
|
let n = e.choices.map((e) => {
|
|
1012
1084
|
if (e.finish_reason === "length") throw new v();
|
|
1013
1085
|
if (e.finish_reason === "content_filter") throw new y();
|
|
1014
|
-
return
|
|
1086
|
+
return Jt(e.message.tool_calls), {
|
|
1015
1087
|
...e,
|
|
1016
1088
|
message: {
|
|
1017
1089
|
...e.message,
|
|
1018
|
-
...e.message.tool_calls ? { tool_calls: e.message.tool_calls?.map((e) =>
|
|
1019
|
-
parsed: e.message.content && !e.message.refusal ?
|
|
1090
|
+
...e.message.tool_calls ? { tool_calls: e.message.tool_calls?.map((e) => Gt(t, e)) ?? void 0 } : void 0,
|
|
1091
|
+
parsed: e.message.content && !e.message.refusal ? Wt(t, e.message.content) : null
|
|
1020
1092
|
}
|
|
1021
1093
|
};
|
|
1022
1094
|
});
|
|
@@ -1025,31 +1097,31 @@ function Rt(e, t) {
|
|
|
1025
1097
|
choices: n
|
|
1026
1098
|
};
|
|
1027
1099
|
}
|
|
1028
|
-
function
|
|
1100
|
+
function Wt(e, t) {
|
|
1029
1101
|
return e.response_format?.type === "json_schema" && e.response_format?.type === "json_schema" ? "$parseRaw" in e.response_format ? e.response_format.$parseRaw(t) : JSON.parse(t) : null;
|
|
1030
1102
|
}
|
|
1031
|
-
function
|
|
1032
|
-
let n = e.tools?.find((e) =>
|
|
1103
|
+
function Gt(e, t) {
|
|
1104
|
+
let n = e.tools?.find((e) => zt(e) && e.function?.name === t.function.name);
|
|
1033
1105
|
return {
|
|
1034
1106
|
...t,
|
|
1035
1107
|
function: {
|
|
1036
1108
|
...t.function,
|
|
1037
|
-
parsed_arguments:
|
|
1109
|
+
parsed_arguments: Vt(n) ? n.$parseRaw(t.function.arguments) : n?.function.strict ? JSON.parse(t.function.arguments) : null
|
|
1038
1110
|
}
|
|
1039
1111
|
};
|
|
1040
1112
|
}
|
|
1041
|
-
function
|
|
1113
|
+
function Kt(e, t) {
|
|
1042
1114
|
if (!e || !("tools" in e) || !e.tools) return !1;
|
|
1043
|
-
let n = e.tools?.find((e) =>
|
|
1044
|
-
return
|
|
1115
|
+
let n = e.tools?.find((e) => zt(e) && e.function?.name === t.function.name);
|
|
1116
|
+
return zt(n) && (Vt(n) || n?.function.strict || !1);
|
|
1045
1117
|
}
|
|
1046
|
-
function
|
|
1047
|
-
return
|
|
1118
|
+
function qt(e) {
|
|
1119
|
+
return Bt(e.response_format) ? !0 : e.tools?.some((e) => Vt(e) || e.type === "function" && e.function.strict === !0) ?? !1;
|
|
1048
1120
|
}
|
|
1049
|
-
function
|
|
1121
|
+
function Jt(e) {
|
|
1050
1122
|
for (let t of e || []) if (t.type !== "function") throw new a(`Currently only \`function\` tool calls are supported; Received \`${t.type}\``);
|
|
1051
1123
|
}
|
|
1052
|
-
function
|
|
1124
|
+
function Yt(e) {
|
|
1053
1125
|
for (let t of e ?? []) {
|
|
1054
1126
|
if (t.type !== "function") throw new a(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);
|
|
1055
1127
|
if (t.function.strict !== !0) throw new a(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`);
|
|
@@ -1057,32 +1129,32 @@ function Wt(e) {
|
|
|
1057
1129
|
}
|
|
1058
1130
|
//#endregion
|
|
1059
1131
|
//#region node_modules/openai/lib/chatCompletionUtils.mjs
|
|
1060
|
-
var
|
|
1132
|
+
var Xt = (e) => e?.role === "assistant", Zt = (e) => e?.role === "tool", Qt, $t, en, tn, nn, rn, an, I, on, sn, cn, L, ln, un = class {
|
|
1061
1133
|
constructor() {
|
|
1062
|
-
|
|
1063
|
-
e(this,
|
|
1064
|
-
}), "f"), e(this,
|
|
1065
|
-
e(this,
|
|
1066
|
-
}), "f"), t(this,
|
|
1134
|
+
Qt.add(this), this.controller = new AbortController(), $t.set(this, void 0), en.set(this, () => {}), tn.set(this, () => {}), nn.set(this, void 0), rn.set(this, () => {}), an.set(this, () => {}), I.set(this, {}), on.set(this, !1), sn.set(this, !1), cn.set(this, !1), L.set(this, !1), e(this, $t, new Promise((t, n) => {
|
|
1135
|
+
e(this, en, t, "f"), e(this, tn, n, "f");
|
|
1136
|
+
}), "f"), e(this, nn, new Promise((t, n) => {
|
|
1137
|
+
e(this, rn, t, "f"), e(this, an, n, "f");
|
|
1138
|
+
}), "f"), t(this, $t, "f").catch(() => {}), t(this, nn, "f").catch(() => {});
|
|
1067
1139
|
}
|
|
1068
1140
|
_run(e) {
|
|
1069
1141
|
setTimeout(() => {
|
|
1070
1142
|
e().then(() => {
|
|
1071
1143
|
this._emitFinal(), this._emit("end");
|
|
1072
|
-
}, t(this,
|
|
1144
|
+
}, t(this, Qt, "m", ln).bind(this));
|
|
1073
1145
|
}, 0);
|
|
1074
1146
|
}
|
|
1075
1147
|
_connected() {
|
|
1076
|
-
this.ended || (t(this,
|
|
1148
|
+
this.ended || (t(this, en, "f").call(this), this._emit("connect"));
|
|
1077
1149
|
}
|
|
1078
1150
|
get ended() {
|
|
1079
|
-
return t(this,
|
|
1151
|
+
return t(this, on, "f");
|
|
1080
1152
|
}
|
|
1081
1153
|
get errored() {
|
|
1082
|
-
return t(this,
|
|
1154
|
+
return t(this, sn, "f");
|
|
1083
1155
|
}
|
|
1084
1156
|
get aborted() {
|
|
1085
|
-
return t(this,
|
|
1157
|
+
return t(this, cn, "f");
|
|
1086
1158
|
}
|
|
1087
1159
|
abort() {
|
|
1088
1160
|
this.controller.abort();
|
|
@@ -1104,30 +1176,30 @@ var Gt = (e) => e?.role === "assistant", Kt = (e) => e?.role === "tool", qt, Jt,
|
|
|
1104
1176
|
}
|
|
1105
1177
|
emitted(t) {
|
|
1106
1178
|
return new Promise((n, r) => {
|
|
1107
|
-
e(this,
|
|
1179
|
+
e(this, L, !0, "f"), t !== "error" && this.once("error", r), this.once(t, n);
|
|
1108
1180
|
});
|
|
1109
1181
|
}
|
|
1110
1182
|
async done() {
|
|
1111
|
-
e(this,
|
|
1183
|
+
e(this, L, !0, "f"), await t(this, nn, "f");
|
|
1112
1184
|
}
|
|
1113
1185
|
_emit(n, ...r) {
|
|
1114
|
-
if (t(this,
|
|
1115
|
-
n === "end" && (e(this,
|
|
1186
|
+
if (t(this, on, "f")) return;
|
|
1187
|
+
n === "end" && (e(this, on, !0, "f"), t(this, rn, "f").call(this));
|
|
1116
1188
|
let i = t(this, I, "f")[n];
|
|
1117
1189
|
if (i && (t(this, I, "f")[n] = i.filter((e) => !e.once), i.forEach(({ listener: e }) => e(...r))), n === "abort") {
|
|
1118
1190
|
let e = r[0];
|
|
1119
|
-
!t(this,
|
|
1191
|
+
!t(this, L, "f") && !i?.length && Promise.reject(e), t(this, tn, "f").call(this, e), t(this, an, "f").call(this, e), this._emit("end");
|
|
1120
1192
|
return;
|
|
1121
1193
|
}
|
|
1122
1194
|
if (n === "error") {
|
|
1123
1195
|
let e = r[0];
|
|
1124
|
-
!t(this,
|
|
1196
|
+
!t(this, L, "f") && !i?.length && Promise.reject(e), t(this, tn, "f").call(this, e), t(this, an, "f").call(this, e), this._emit("end");
|
|
1125
1197
|
}
|
|
1126
1198
|
}
|
|
1127
1199
|
_emitFinal() {}
|
|
1128
1200
|
};
|
|
1129
|
-
|
|
1130
|
-
if (e(this,
|
|
1201
|
+
$t = /* @__PURE__ */ new WeakMap(), en = /* @__PURE__ */ new WeakMap(), tn = /* @__PURE__ */ new WeakMap(), nn = /* @__PURE__ */ new WeakMap(), rn = /* @__PURE__ */ new WeakMap(), an = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), on = /* @__PURE__ */ new WeakMap(), sn = /* @__PURE__ */ new WeakMap(), cn = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), Qt = /* @__PURE__ */ new WeakSet(), ln = function(t) {
|
|
1202
|
+
if (e(this, sn, !0, "f"), t instanceof Error && t.name === "AbortError" && (t = new s()), t instanceof s) return e(this, cn, !0, "f"), this._emit("abort", t);
|
|
1131
1203
|
if (t instanceof a) return this._emit("error", t);
|
|
1132
1204
|
if (t instanceof Error) {
|
|
1133
1205
|
let e = new a(t.message);
|
|
@@ -1137,14 +1209,14 @@ Jt = /* @__PURE__ */ new WeakMap(), Yt = /* @__PURE__ */ new WeakMap(), Xt = /*
|
|
|
1137
1209
|
};
|
|
1138
1210
|
//#endregion
|
|
1139
1211
|
//#region node_modules/openai/lib/RunnableFunction.mjs
|
|
1140
|
-
function
|
|
1212
|
+
function dn(e) {
|
|
1141
1213
|
return typeof e.parse == "function";
|
|
1142
1214
|
}
|
|
1143
1215
|
//#endregion
|
|
1144
1216
|
//#region node_modules/openai/lib/AbstractChatCompletionRunner.mjs
|
|
1145
|
-
var
|
|
1217
|
+
var R, fn, pn, mn, hn, gn, _n, vn, yn = 10, bn = class extends un {
|
|
1146
1218
|
constructor() {
|
|
1147
|
-
super(...arguments),
|
|
1219
|
+
super(...arguments), R.add(this), this._chatCompletions = [], this.messages = [];
|
|
1148
1220
|
}
|
|
1149
1221
|
_addChatCompletion(e) {
|
|
1150
1222
|
this._chatCompletions.push(e), this._emit("chatCompletion", e);
|
|
@@ -1153,8 +1225,8 @@ var L, cn, ln, un, dn, fn, pn, mn, hn = 10, gn = class extends on {
|
|
|
1153
1225
|
}
|
|
1154
1226
|
_addMessage(e, t = !0) {
|
|
1155
1227
|
if ("content" in e || (e.content = null), this.messages.push(e), t) {
|
|
1156
|
-
if (this._emit("message", e),
|
|
1157
|
-
else if (
|
|
1228
|
+
if (this._emit("message", e), Zt(e) && e.content) this._emit("functionToolCallResult", e.content);
|
|
1229
|
+
else if (Xt(e) && e.tool_calls) for (let t of e.tool_calls) t.type === "function" && this._emit("functionToolCall", t.function);
|
|
1158
1230
|
}
|
|
1159
1231
|
}
|
|
1160
1232
|
async finalChatCompletion() {
|
|
@@ -1164,19 +1236,19 @@ var L, cn, ln, un, dn, fn, pn, mn, hn = 10, gn = class extends on {
|
|
|
1164
1236
|
return e;
|
|
1165
1237
|
}
|
|
1166
1238
|
async finalContent() {
|
|
1167
|
-
return await this.done(), t(this,
|
|
1239
|
+
return await this.done(), t(this, R, "m", fn).call(this);
|
|
1168
1240
|
}
|
|
1169
1241
|
async finalMessage() {
|
|
1170
|
-
return await this.done(), t(this,
|
|
1242
|
+
return await this.done(), t(this, R, "m", pn).call(this);
|
|
1171
1243
|
}
|
|
1172
1244
|
async finalFunctionToolCall() {
|
|
1173
|
-
return await this.done(), t(this,
|
|
1245
|
+
return await this.done(), t(this, R, "m", mn).call(this);
|
|
1174
1246
|
}
|
|
1175
1247
|
async finalFunctionToolCallResult() {
|
|
1176
|
-
return await this.done(), t(this,
|
|
1248
|
+
return await this.done(), t(this, R, "m", hn).call(this);
|
|
1177
1249
|
}
|
|
1178
1250
|
async totalUsage() {
|
|
1179
|
-
return await this.done(), t(this,
|
|
1251
|
+
return await this.done(), t(this, R, "m", gn).call(this);
|
|
1180
1252
|
}
|
|
1181
1253
|
allChatCompletions() {
|
|
1182
1254
|
return [...this._chatCompletions];
|
|
@@ -1184,18 +1256,18 @@ var L, cn, ln, un, dn, fn, pn, mn, hn = 10, gn = class extends on {
|
|
|
1184
1256
|
_emitFinal() {
|
|
1185
1257
|
let e = this._chatCompletions[this._chatCompletions.length - 1];
|
|
1186
1258
|
e && this._emit("finalChatCompletion", e);
|
|
1187
|
-
let n = t(this,
|
|
1259
|
+
let n = t(this, R, "m", pn).call(this);
|
|
1188
1260
|
n && this._emit("finalMessage", n);
|
|
1189
|
-
let r = t(this,
|
|
1261
|
+
let r = t(this, R, "m", fn).call(this);
|
|
1190
1262
|
r && this._emit("finalContent", r);
|
|
1191
|
-
let i = t(this,
|
|
1263
|
+
let i = t(this, R, "m", mn).call(this);
|
|
1192
1264
|
i && this._emit("finalFunctionToolCall", i);
|
|
1193
|
-
let a = t(this,
|
|
1194
|
-
a != null && this._emit("finalFunctionToolCallResult", a), this._chatCompletions.some((e) => e.usage) && this._emit("totalUsage", t(this,
|
|
1265
|
+
let a = t(this, R, "m", hn).call(this);
|
|
1266
|
+
a != null && this._emit("finalFunctionToolCallResult", a), this._chatCompletions.some((e) => e.usage) && this._emit("totalUsage", t(this, R, "m", gn).call(this));
|
|
1195
1267
|
}
|
|
1196
1268
|
async _createChatCompletion(e, n, r) {
|
|
1197
1269
|
let i = r?.signal;
|
|
1198
|
-
i && (i.aborted && this.controller.abort(), i.addEventListener("abort", () => this.controller.abort())), t(this,
|
|
1270
|
+
i && (i.aborted && this.controller.abort(), i.addEventListener("abort", () => this.controller.abort())), t(this, R, "m", _n).call(this, n);
|
|
1199
1271
|
let a = await e.chat.completions.create({
|
|
1200
1272
|
...n,
|
|
1201
1273
|
stream: !1
|
|
@@ -1203,15 +1275,15 @@ var L, cn, ln, un, dn, fn, pn, mn, hn = 10, gn = class extends on {
|
|
|
1203
1275
|
...r,
|
|
1204
1276
|
signal: this.controller.signal
|
|
1205
1277
|
});
|
|
1206
|
-
return this._connected(), this._addChatCompletion(
|
|
1278
|
+
return this._connected(), this._addChatCompletion(Ut(a, n));
|
|
1207
1279
|
}
|
|
1208
1280
|
async _runChatCompletion(e, t, n) {
|
|
1209
1281
|
for (let e of t.messages) this._addMessage(e, !1);
|
|
1210
1282
|
return await this._createChatCompletion(e, t, n);
|
|
1211
1283
|
}
|
|
1212
1284
|
async _runTools(e, n, r) {
|
|
1213
|
-
let i = "tool", { tool_choice: o = "auto", stream: s, ...c } = n, l = typeof o != "string" && o.type === "function" && o?.function?.name, { maxChatCompletions: u =
|
|
1214
|
-
if (
|
|
1285
|
+
let i = "tool", { tool_choice: o = "auto", stream: s, ...c } = n, l = typeof o != "string" && o.type === "function" && o?.function?.name, { maxChatCompletions: u = yn } = r || {}, d = n.tools.map((e) => {
|
|
1286
|
+
if (Vt(e)) {
|
|
1215
1287
|
if (!e.$callback) throw new a("Tool given to `.runTools()` that does not have an associated function");
|
|
1216
1288
|
return {
|
|
1217
1289
|
type: "function",
|
|
@@ -1269,7 +1341,7 @@ var L, cn, ln, un, dn, fn, pn, mn, hn = 10, gn = class extends on {
|
|
|
1269
1341
|
}
|
|
1270
1342
|
let s;
|
|
1271
1343
|
try {
|
|
1272
|
-
s =
|
|
1344
|
+
s = dn(o) ? await o.parse(a) : a;
|
|
1273
1345
|
} catch (e) {
|
|
1274
1346
|
let t = e instanceof Error ? e.message : String(e);
|
|
1275
1347
|
this._addMessage({
|
|
@@ -1279,7 +1351,7 @@ var L, cn, ln, un, dn, fn, pn, mn, hn = 10, gn = class extends on {
|
|
|
1279
1351
|
});
|
|
1280
1352
|
continue;
|
|
1281
1353
|
}
|
|
1282
|
-
let c = await o.function(s, this), u = t(this,
|
|
1354
|
+
let c = await o.function(s, this), u = t(this, R, "m", vn).call(this, c);
|
|
1283
1355
|
if (this._addMessage({
|
|
1284
1356
|
role: i,
|
|
1285
1357
|
tool_call_id: n,
|
|
@@ -1289,30 +1361,30 @@ var L, cn, ln, un, dn, fn, pn, mn, hn = 10, gn = class extends on {
|
|
|
1289
1361
|
}
|
|
1290
1362
|
}
|
|
1291
1363
|
};
|
|
1292
|
-
|
|
1293
|
-
return t(this,
|
|
1294
|
-
},
|
|
1364
|
+
R = /* @__PURE__ */ new WeakSet(), fn = function() {
|
|
1365
|
+
return t(this, R, "m", pn).call(this).content ?? null;
|
|
1366
|
+
}, pn = function() {
|
|
1295
1367
|
let e = this.messages.length;
|
|
1296
1368
|
for (; e-- > 0;) {
|
|
1297
1369
|
let t = this.messages[e];
|
|
1298
|
-
if (
|
|
1370
|
+
if (Xt(t)) return {
|
|
1299
1371
|
...t,
|
|
1300
1372
|
content: t.content ?? null,
|
|
1301
1373
|
refusal: t.refusal ?? null
|
|
1302
1374
|
};
|
|
1303
1375
|
}
|
|
1304
1376
|
throw new a("stream ended without producing a ChatCompletionMessage with role=assistant");
|
|
1305
|
-
},
|
|
1377
|
+
}, mn = function() {
|
|
1306
1378
|
for (let e = this.messages.length - 1; e >= 0; e--) {
|
|
1307
1379
|
let t = this.messages[e];
|
|
1308
|
-
if (
|
|
1380
|
+
if (Xt(t) && t?.tool_calls?.length) return t.tool_calls.filter((e) => e.type === "function").at(-1)?.function;
|
|
1309
1381
|
}
|
|
1310
|
-
},
|
|
1382
|
+
}, hn = function() {
|
|
1311
1383
|
for (let e = this.messages.length - 1; e >= 0; e--) {
|
|
1312
1384
|
let t = this.messages[e];
|
|
1313
|
-
if (
|
|
1385
|
+
if (Zt(t) && t.content != null && typeof t.content == "string" && this.messages.some((e) => e.role === "assistant" && e.tool_calls?.some((e) => e.type === "function" && e.id === t.tool_call_id))) return t.content;
|
|
1314
1386
|
}
|
|
1315
|
-
},
|
|
1387
|
+
}, gn = function() {
|
|
1316
1388
|
let e = {
|
|
1317
1389
|
completion_tokens: 0,
|
|
1318
1390
|
prompt_tokens: 0,
|
|
@@ -1320,14 +1392,14 @@ L = /* @__PURE__ */ new WeakSet(), cn = function() {
|
|
|
1320
1392
|
};
|
|
1321
1393
|
for (let { usage: t } of this._chatCompletions) t && (e.completion_tokens += t.completion_tokens, e.prompt_tokens += t.prompt_tokens, e.total_tokens += t.total_tokens);
|
|
1322
1394
|
return e;
|
|
1323
|
-
},
|
|
1395
|
+
}, _n = function(e) {
|
|
1324
1396
|
if (e.n != null && e.n > 1) throw new a("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.");
|
|
1325
|
-
},
|
|
1397
|
+
}, vn = function(e) {
|
|
1326
1398
|
return typeof e == "string" ? e : e === void 0 ? "undefined" : JSON.stringify(e);
|
|
1327
1399
|
};
|
|
1328
1400
|
//#endregion
|
|
1329
1401
|
//#region node_modules/openai/lib/ChatCompletionRunner.mjs
|
|
1330
|
-
var
|
|
1402
|
+
var xn = class e extends bn {
|
|
1331
1403
|
static runTools(t, n, r) {
|
|
1332
1404
|
let i = new e(), a = {
|
|
1333
1405
|
...r,
|
|
@@ -1339,35 +1411,35 @@ var _n = class e extends gn {
|
|
|
1339
1411
|
return i._run(() => i._runTools(t, n, a)), i;
|
|
1340
1412
|
}
|
|
1341
1413
|
_addMessage(e, t = !0) {
|
|
1342
|
-
super._addMessage(e, t),
|
|
1343
|
-
}
|
|
1344
|
-
},
|
|
1345
|
-
STR:
|
|
1346
|
-
NUM:
|
|
1347
|
-
ARR:
|
|
1348
|
-
OBJ:
|
|
1349
|
-
NULL:
|
|
1350
|
-
BOOL:
|
|
1351
|
-
NAN:
|
|
1352
|
-
INFINITY:
|
|
1353
|
-
MINUS_INFINITY:
|
|
1354
|
-
INF:
|
|
1355
|
-
SPECIAL:
|
|
1356
|
-
ATOM:
|
|
1357
|
-
COLLECTION:
|
|
1358
|
-
ALL:
|
|
1359
|
-
},
|
|
1360
|
-
function
|
|
1414
|
+
super._addMessage(e, t), Xt(e) && e.content && this._emit("content", e.content);
|
|
1415
|
+
}
|
|
1416
|
+
}, Sn = 1, Cn = 2, wn = 4, Tn = 8, En = 16, Dn = 32, On = 64, kn = 128, An = 256, jn = kn | An, Mn = 496, Nn = Cn | 497, Pn = wn | Tn, z = {
|
|
1417
|
+
STR: Sn,
|
|
1418
|
+
NUM: Cn,
|
|
1419
|
+
ARR: wn,
|
|
1420
|
+
OBJ: Tn,
|
|
1421
|
+
NULL: En,
|
|
1422
|
+
BOOL: Dn,
|
|
1423
|
+
NAN: On,
|
|
1424
|
+
INFINITY: kn,
|
|
1425
|
+
MINUS_INFINITY: An,
|
|
1426
|
+
INF: jn,
|
|
1427
|
+
SPECIAL: Mn,
|
|
1428
|
+
ATOM: Nn,
|
|
1429
|
+
COLLECTION: Pn,
|
|
1430
|
+
ALL: Nn | Pn
|
|
1431
|
+
}, Fn = class extends Error {}, In = class extends Error {};
|
|
1432
|
+
function Ln(e, t = z.ALL) {
|
|
1361
1433
|
if (typeof e != "string") throw TypeError(`expecting str, got ${typeof e}`);
|
|
1362
1434
|
if (!e.trim()) throw Error(`${e} is empty`);
|
|
1363
|
-
return
|
|
1435
|
+
return Rn(e.trim(), t);
|
|
1364
1436
|
}
|
|
1365
|
-
var
|
|
1437
|
+
var Rn = (e, t) => {
|
|
1366
1438
|
let n = e.length, r = 0, i = (e) => {
|
|
1367
|
-
throw new
|
|
1439
|
+
throw new Fn(`${e} at position ${r}`);
|
|
1368
1440
|
}, a = (e) => {
|
|
1369
|
-
throw new
|
|
1370
|
-
}, o = () => (d(), r >= n && i("Unexpected end of input"), e[r] === "\"" ? s() : e[r] === "{" ? c() : e[r] === "[" ? l() : e.substring(r, r + 4) === "null" ||
|
|
1441
|
+
throw new In(`${e} at position ${r}`);
|
|
1442
|
+
}, o = () => (d(), r >= n && i("Unexpected end of input"), e[r] === "\"" ? s() : e[r] === "{" ? c() : e[r] === "[" ? l() : e.substring(r, r + 4) === "null" || z.NULL & t && n - r < 4 && "null".startsWith(e.substring(r)) ? (r += 4, null) : e.substring(r, r + 4) === "true" || z.BOOL & t && n - r < 4 && "true".startsWith(e.substring(r)) ? (r += 4, !0) : e.substring(r, r + 5) === "false" || z.BOOL & t && n - r < 5 && "false".startsWith(e.substring(r)) ? (r += 5, !1) : e.substring(r, r + 8) === "Infinity" || z.INFINITY & t && n - r < 8 && "Infinity".startsWith(e.substring(r)) ? (r += 8, Infinity) : e.substring(r, r + 9) === "-Infinity" || z.MINUS_INFINITY & t && 1 < n - r && n - r < 9 && "-Infinity".startsWith(e.substring(r)) ? (r += 9, -Infinity) : e.substring(r, r + 3) === "NaN" || z.NAN & t && n - r < 3 && "NaN".startsWith(e.substring(r)) ? (r += 3, NaN) : u()), s = () => {
|
|
1371
1443
|
let o = r, s = !1;
|
|
1372
1444
|
for (r++; r < n && (e[r] !== "\"" || s && e[r - 1] === "\\");) s = e[r] === "\\" ? !s : !1, r++;
|
|
1373
1445
|
if (e.charAt(r) == "\"") try {
|
|
@@ -1375,7 +1447,7 @@ var Pn = (e, t) => {
|
|
|
1375
1447
|
} catch (e) {
|
|
1376
1448
|
a(String(e));
|
|
1377
1449
|
}
|
|
1378
|
-
else if (
|
|
1450
|
+
else if (z.STR & t) try {
|
|
1379
1451
|
return JSON.parse(e.substring(o, r - Number(s)) + "\"");
|
|
1380
1452
|
} catch {
|
|
1381
1453
|
return JSON.parse(e.substring(o, e.lastIndexOf("\\")) + "\"");
|
|
@@ -1386,7 +1458,7 @@ var Pn = (e, t) => {
|
|
|
1386
1458
|
let a = {};
|
|
1387
1459
|
try {
|
|
1388
1460
|
for (; e[r] !== "}";) {
|
|
1389
|
-
if (d(), r >= n &&
|
|
1461
|
+
if (d(), r >= n && z.OBJ & t) return a;
|
|
1390
1462
|
let i = s();
|
|
1391
1463
|
d(), r++;
|
|
1392
1464
|
try {
|
|
@@ -1398,13 +1470,13 @@ var Pn = (e, t) => {
|
|
|
1398
1470
|
configurable: !0
|
|
1399
1471
|
});
|
|
1400
1472
|
} catch (e) {
|
|
1401
|
-
if (
|
|
1473
|
+
if (z.OBJ & t) return a;
|
|
1402
1474
|
throw e;
|
|
1403
1475
|
}
|
|
1404
1476
|
d(), e[r] === "," && r++;
|
|
1405
1477
|
}
|
|
1406
1478
|
} catch {
|
|
1407
|
-
if (
|
|
1479
|
+
if (z.OBJ & t) return a;
|
|
1408
1480
|
i("Expected '}' at end of object");
|
|
1409
1481
|
}
|
|
1410
1482
|
return r++, a;
|
|
@@ -1414,17 +1486,17 @@ var Pn = (e, t) => {
|
|
|
1414
1486
|
try {
|
|
1415
1487
|
for (; e[r] !== "]";) n.push(o()), d(), e[r] === "," && r++;
|
|
1416
1488
|
} catch {
|
|
1417
|
-
if (
|
|
1489
|
+
if (z.ARR & t) return n;
|
|
1418
1490
|
i("Expected ']' at end of array");
|
|
1419
1491
|
}
|
|
1420
1492
|
return r++, n;
|
|
1421
1493
|
}, u = () => {
|
|
1422
1494
|
if (r === 0) {
|
|
1423
|
-
e === "-" &&
|
|
1495
|
+
e === "-" && z.NUM & t && i("Not sure what '-' is");
|
|
1424
1496
|
try {
|
|
1425
1497
|
return JSON.parse(e);
|
|
1426
1498
|
} catch (n) {
|
|
1427
|
-
if (
|
|
1499
|
+
if (z.NUM & t) try {
|
|
1428
1500
|
return e[e.length - 1] === "." ? JSON.parse(e.substring(0, e.lastIndexOf("."))) : JSON.parse(e.substring(0, e.lastIndexOf("e")));
|
|
1429
1501
|
} catch {}
|
|
1430
1502
|
a(String(n));
|
|
@@ -1432,11 +1504,11 @@ var Pn = (e, t) => {
|
|
|
1432
1504
|
}
|
|
1433
1505
|
let o = r;
|
|
1434
1506
|
for (e[r] === "-" && r++; e[r] && !",]}".includes(e[r]);) r++;
|
|
1435
|
-
r == n && !(
|
|
1507
|
+
r == n && !(z.NUM & t) && i("Unterminated number literal");
|
|
1436
1508
|
try {
|
|
1437
1509
|
return JSON.parse(e.substring(o, r));
|
|
1438
1510
|
} catch {
|
|
1439
|
-
e.substring(o, r) === "-" &&
|
|
1511
|
+
e.substring(o, r) === "-" && z.NUM & t && i("Not sure what '-' is");
|
|
1440
1512
|
try {
|
|
1441
1513
|
return JSON.parse(e.substring(o, e.lastIndexOf("e")));
|
|
1442
1514
|
} catch (e) {
|
|
@@ -1447,12 +1519,12 @@ var Pn = (e, t) => {
|
|
|
1447
1519
|
for (; r < n && " \n\r ".includes(e[r]);) r++;
|
|
1448
1520
|
};
|
|
1449
1521
|
return o();
|
|
1450
|
-
},
|
|
1522
|
+
}, zn = (e) => Ln(e, z.ALL ^ z.NUM), B, V, Bn, H, Vn, Hn, Un, Wn, Gn, Kn, qn, Jn, Yn = class n extends bn {
|
|
1451
1523
|
constructor(t) {
|
|
1452
|
-
super(),
|
|
1524
|
+
super(), B.add(this), V.set(this, void 0), Bn.set(this, void 0), H.set(this, void 0), e(this, V, t, "f"), e(this, Bn, [], "f");
|
|
1453
1525
|
}
|
|
1454
1526
|
get currentChatCompletionSnapshot() {
|
|
1455
|
-
return t(this,
|
|
1527
|
+
return t(this, H, "f");
|
|
1456
1528
|
}
|
|
1457
1529
|
static fromReadableStream(e) {
|
|
1458
1530
|
let t = new n(null);
|
|
@@ -1474,7 +1546,7 @@ var Pn = (e, t) => {
|
|
|
1474
1546
|
async _createChatCompletion(e, n, r) {
|
|
1475
1547
|
super._createChatCompletion;
|
|
1476
1548
|
let i = r?.signal;
|
|
1477
|
-
i && (i.aborted && this.controller.abort(), i.addEventListener("abort", () => this.controller.abort())), t(this,
|
|
1549
|
+
i && (i.aborted && this.controller.abort(), i.addEventListener("abort", () => this.controller.abort())), t(this, B, "m", Vn).call(this);
|
|
1478
1550
|
let a = await e.chat.completions.create({
|
|
1479
1551
|
...n,
|
|
1480
1552
|
stream: !0
|
|
@@ -1483,22 +1555,22 @@ var Pn = (e, t) => {
|
|
|
1483
1555
|
signal: this.controller.signal
|
|
1484
1556
|
});
|
|
1485
1557
|
this._connected();
|
|
1486
|
-
for await (let e of a) t(this,
|
|
1558
|
+
for await (let e of a) t(this, B, "m", Un).call(this, e);
|
|
1487
1559
|
if (a.controller.signal?.aborted) throw new s();
|
|
1488
|
-
return this._addChatCompletion(t(this,
|
|
1560
|
+
return this._addChatCompletion(t(this, B, "m", Kn).call(this));
|
|
1489
1561
|
}
|
|
1490
1562
|
async _fromReadableStream(e, n) {
|
|
1491
1563
|
let r = n?.signal;
|
|
1492
|
-
r && (r.aborted && this.controller.abort(), r.addEventListener("abort", () => this.controller.abort())), t(this,
|
|
1493
|
-
let i =
|
|
1494
|
-
for await (let e of i) a && a !== e.id && this._addChatCompletion(t(this,
|
|
1564
|
+
r && (r.aborted && this.controller.abort(), r.addEventListener("abort", () => this.controller.abort())), t(this, B, "m", Vn).call(this), this._connected();
|
|
1565
|
+
let i = tt.fromReadableStream(e, this.controller), a;
|
|
1566
|
+
for await (let e of i) a && a !== e.id && this._addChatCompletion(t(this, B, "m", Kn).call(this)), t(this, B, "m", Un).call(this, e), a = e.id;
|
|
1495
1567
|
if (i.controller.signal?.aborted) throw new s();
|
|
1496
|
-
return this._addChatCompletion(t(this,
|
|
1568
|
+
return this._addChatCompletion(t(this, B, "m", Kn).call(this));
|
|
1497
1569
|
}
|
|
1498
|
-
[(
|
|
1499
|
-
this.ended || e(this,
|
|
1500
|
-
},
|
|
1501
|
-
let n = t(this,
|
|
1570
|
+
[(V = /* @__PURE__ */ new WeakMap(), Bn = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakSet(), Vn = function() {
|
|
1571
|
+
this.ended || e(this, H, void 0, "f");
|
|
1572
|
+
}, Hn = function(e) {
|
|
1573
|
+
let n = t(this, Bn, "f")[e.index];
|
|
1502
1574
|
return n || (n = {
|
|
1503
1575
|
content_done: !1,
|
|
1504
1576
|
refusal_done: !1,
|
|
@@ -1506,10 +1578,10 @@ var Pn = (e, t) => {
|
|
|
1506
1578
|
logprobs_refusal_done: !1,
|
|
1507
1579
|
done_tool_calls: /* @__PURE__ */ new Set(),
|
|
1508
1580
|
current_tool_call_index: null
|
|
1509
|
-
}, t(this,
|
|
1510
|
-
},
|
|
1581
|
+
}, t(this, Bn, "f")[e.index] = n, n);
|
|
1582
|
+
}, Un = function(e) {
|
|
1511
1583
|
if (this.ended) return;
|
|
1512
|
-
let n = t(this,
|
|
1584
|
+
let n = t(this, B, "m", Jn).call(this, e);
|
|
1513
1585
|
this._emit("chunk", e, n);
|
|
1514
1586
|
for (let r of e.choices) {
|
|
1515
1587
|
let e = n.choices[r.index];
|
|
@@ -1527,9 +1599,9 @@ var Pn = (e, t) => {
|
|
|
1527
1599
|
refusal: r.logprobs?.refusal,
|
|
1528
1600
|
snapshot: e.logprobs?.refusal ?? []
|
|
1529
1601
|
});
|
|
1530
|
-
let i = t(this,
|
|
1531
|
-
e.finish_reason && (t(this,
|
|
1532
|
-
for (let n of r.delta.tool_calls ?? []) i.current_tool_call_index !== n.index && (t(this,
|
|
1602
|
+
let i = t(this, B, "m", Hn).call(this, e);
|
|
1603
|
+
e.finish_reason && (t(this, B, "m", Gn).call(this, e), i.current_tool_call_index != null && t(this, B, "m", Wn).call(this, e, i.current_tool_call_index));
|
|
1604
|
+
for (let n of r.delta.tool_calls ?? []) i.current_tool_call_index !== n.index && (t(this, B, "m", Gn).call(this, e), i.current_tool_call_index != null && t(this, B, "m", Wn).call(this, e, i.current_tool_call_index)), i.current_tool_call_index = n.index;
|
|
1533
1605
|
for (let t of r.delta.tool_calls ?? []) {
|
|
1534
1606
|
let n = e.message.tool_calls?.[t.index];
|
|
1535
1607
|
n?.type && (n?.type === "function" ? this._emit("tool_calls.function.arguments.delta", {
|
|
@@ -1541,43 +1613,43 @@ var Pn = (e, t) => {
|
|
|
1541
1613
|
}) : n?.type);
|
|
1542
1614
|
}
|
|
1543
1615
|
}
|
|
1544
|
-
},
|
|
1545
|
-
if (t(this,
|
|
1616
|
+
}, Wn = function(e, n) {
|
|
1617
|
+
if (t(this, B, "m", Hn).call(this, e).done_tool_calls.has(n)) return;
|
|
1546
1618
|
let r = e.message.tool_calls?.[n];
|
|
1547
1619
|
if (!r) throw Error("no tool call snapshot");
|
|
1548
1620
|
if (!r.type) throw Error("tool call snapshot missing `type`");
|
|
1549
1621
|
if (r.type === "function") {
|
|
1550
|
-
let e = t(this,
|
|
1622
|
+
let e = t(this, V, "f")?.tools?.find((e) => zt(e) && e.function.name === r.function.name);
|
|
1551
1623
|
this._emit("tool_calls.function.arguments.done", {
|
|
1552
1624
|
name: r.function.name,
|
|
1553
1625
|
index: n,
|
|
1554
1626
|
arguments: r.function.arguments,
|
|
1555
|
-
parsed_arguments:
|
|
1627
|
+
parsed_arguments: Vt(e) ? e.$parseRaw(r.function.arguments) : e?.function.strict ? JSON.parse(r.function.arguments) : null
|
|
1556
1628
|
});
|
|
1557
1629
|
} else r.type;
|
|
1558
|
-
},
|
|
1559
|
-
let n = t(this,
|
|
1630
|
+
}, Gn = function(e) {
|
|
1631
|
+
let n = t(this, B, "m", Hn).call(this, e);
|
|
1560
1632
|
if (e.message.content && !n.content_done) {
|
|
1561
1633
|
n.content_done = !0;
|
|
1562
|
-
let r = t(this,
|
|
1634
|
+
let r = t(this, B, "m", qn).call(this);
|
|
1563
1635
|
this._emit("content.done", {
|
|
1564
1636
|
content: e.message.content,
|
|
1565
1637
|
parsed: r ? r.$parseRaw(e.message.content) : null
|
|
1566
1638
|
});
|
|
1567
1639
|
}
|
|
1568
1640
|
e.message.refusal && !n.refusal_done && (n.refusal_done = !0, this._emit("refusal.done", { refusal: e.message.refusal })), e.logprobs?.content && !n.logprobs_content_done && (n.logprobs_content_done = !0, this._emit("logprobs.content.done", { content: e.logprobs.content })), e.logprobs?.refusal && !n.logprobs_refusal_done && (n.logprobs_refusal_done = !0, this._emit("logprobs.refusal.done", { refusal: e.logprobs.refusal }));
|
|
1569
|
-
},
|
|
1641
|
+
}, Kn = function() {
|
|
1570
1642
|
if (this.ended) throw new a("stream has ended, this shouldn't happen");
|
|
1571
|
-
let n = t(this,
|
|
1643
|
+
let n = t(this, H, "f");
|
|
1572
1644
|
if (!n) throw new a("request ended without sending any chunks");
|
|
1573
|
-
return e(this,
|
|
1574
|
-
},
|
|
1575
|
-
let e = t(this,
|
|
1576
|
-
return
|
|
1577
|
-
},
|
|
1645
|
+
return e(this, H, void 0, "f"), e(this, Bn, [], "f"), Xn(n, t(this, V, "f"));
|
|
1646
|
+
}, qn = function() {
|
|
1647
|
+
let e = t(this, V, "f")?.response_format;
|
|
1648
|
+
return Bt(e) ? e : null;
|
|
1649
|
+
}, Jn = function(n) {
|
|
1578
1650
|
var r, i, a, o;
|
|
1579
|
-
let s = t(this,
|
|
1580
|
-
s ? Object.assign(s, l) : s = e(this,
|
|
1651
|
+
let s = t(this, H, "f"), { choices: c, ...l } = n;
|
|
1652
|
+
s ? Object.assign(s, l) : s = e(this, H, {
|
|
1581
1653
|
...l,
|
|
1582
1654
|
choices: []
|
|
1583
1655
|
}, "f");
|
|
@@ -1594,20 +1666,20 @@ var Pn = (e, t) => {
|
|
|
1594
1666
|
let { content: e, refusal: t, ...a } = u;
|
|
1595
1667
|
Object.assign(n.logprobs, a), e && ((r = n.logprobs).content ?? (r.content = []), n.logprobs.content.push(...e)), t && ((i = n.logprobs).refusal ?? (i.refusal = []), n.logprobs.refusal.push(...t));
|
|
1596
1668
|
}
|
|
1597
|
-
if (c && (n.finish_reason = c, t(this,
|
|
1669
|
+
if (c && (n.finish_reason = c, t(this, V, "f") && qt(t(this, V, "f")))) {
|
|
1598
1670
|
if (c === "length") throw new v();
|
|
1599
1671
|
if (c === "content_filter") throw new y();
|
|
1600
1672
|
}
|
|
1601
1673
|
if (Object.assign(n, d), !e) continue;
|
|
1602
1674
|
let { content: f, refusal: p, function_call: m, role: h, tool_calls: g, ..._ } = e;
|
|
1603
|
-
if (Object.assign(n.message, _), p && (n.message.refusal = (n.message.refusal || "") + p), h && (n.message.role = h), m && (n.message.function_call ? (m.name && (n.message.function_call.name = m.name), m.arguments && ((a = n.message.function_call).arguments ?? (a.arguments = ""), n.message.function_call.arguments += m.arguments)) : n.message.function_call = m), f && (n.message.content = (n.message.content || "") + f, !n.message.refusal && t(this,
|
|
1675
|
+
if (Object.assign(n.message, _), p && (n.message.refusal = (n.message.refusal || "") + p), h && (n.message.role = h), m && (n.message.function_call ? (m.name && (n.message.function_call.name = m.name), m.arguments && ((a = n.message.function_call).arguments ?? (a.arguments = ""), n.message.function_call.arguments += m.arguments)) : n.message.function_call = m), f && (n.message.content = (n.message.content || "") + f, !n.message.refusal && t(this, B, "m", qn).call(this) && (n.message.parsed = zn(n.message.content))), g) {
|
|
1604
1676
|
n.message.tool_calls || (n.message.tool_calls = []);
|
|
1605
1677
|
for (let { index: e, id: r, type: i, function: a, ...s } of g) {
|
|
1606
1678
|
let c = (o = n.message.tool_calls)[e] ?? (o[e] = {});
|
|
1607
1679
|
Object.assign(c, s), r && (c.id = r), i && (c.type = i), a && (c.function ??= {
|
|
1608
1680
|
name: a.name ?? "",
|
|
1609
1681
|
arguments: ""
|
|
1610
|
-
}), a?.name && (c.function.name = a.name), a?.arguments && (c.function.arguments += a.arguments,
|
|
1682
|
+
}), a?.name && (c.function.name = a.name), a?.arguments && (c.function.arguments += a.arguments, Kt(t(this, V, "f"), c) && (c.function.parsed_arguments = zn(c.function.arguments)));
|
|
1611
1683
|
}
|
|
1612
1684
|
}
|
|
1613
1685
|
}
|
|
@@ -1653,12 +1725,12 @@ var Pn = (e, t) => {
|
|
|
1653
1725
|
};
|
|
1654
1726
|
}
|
|
1655
1727
|
toReadableStream() {
|
|
1656
|
-
return new
|
|
1728
|
+
return new tt(this[Symbol.asyncIterator].bind(this), this.controller).toReadableStream();
|
|
1657
1729
|
}
|
|
1658
1730
|
};
|
|
1659
|
-
function
|
|
1731
|
+
function Xn(e, t) {
|
|
1660
1732
|
let { id: n, choices: r, created: i, model: o, system_fingerprint: s, ...c } = e;
|
|
1661
|
-
return
|
|
1733
|
+
return Ht({
|
|
1662
1734
|
...c,
|
|
1663
1735
|
id: n,
|
|
1664
1736
|
choices: r.map(({ message: t, finish_reason: n, index: r, logprobs: i, ...o }) => {
|
|
@@ -1697,10 +1769,10 @@ function Kn(e, t) {
|
|
|
1697
1769
|
refusal: t.refusal ?? null,
|
|
1698
1770
|
tool_calls: l.map((t, n) => {
|
|
1699
1771
|
let { function: i, type: o, id: s, ...c } = t, { arguments: l, name: u, ...d } = i || {};
|
|
1700
|
-
if (s == null) throw new a(`missing choices[${r}].tool_calls[${n}].id\n${
|
|
1701
|
-
if (o == null) throw new a(`missing choices[${r}].tool_calls[${n}].type\n${
|
|
1702
|
-
if (u == null) throw new a(`missing choices[${r}].tool_calls[${n}].function.name\n${
|
|
1703
|
-
if (l == null) throw new a(`missing choices[${r}].tool_calls[${n}].function.arguments\n${
|
|
1772
|
+
if (s == null) throw new a(`missing choices[${r}].tool_calls[${n}].id\n${Zn(e)}`);
|
|
1773
|
+
if (o == null) throw new a(`missing choices[${r}].tool_calls[${n}].type\n${Zn(e)}`);
|
|
1774
|
+
if (u == null) throw new a(`missing choices[${r}].tool_calls[${n}].function.name\n${Zn(e)}`);
|
|
1775
|
+
if (l == null) throw new a(`missing choices[${r}].tool_calls[${n}].function.arguments\n${Zn(e)}`);
|
|
1704
1776
|
return {
|
|
1705
1777
|
...c,
|
|
1706
1778
|
id: s,
|
|
@@ -1732,12 +1804,12 @@ function Kn(e, t) {
|
|
|
1732
1804
|
...s ? { system_fingerprint: s } : {}
|
|
1733
1805
|
}, t);
|
|
1734
1806
|
}
|
|
1735
|
-
function
|
|
1807
|
+
function Zn(e) {
|
|
1736
1808
|
return JSON.stringify(e);
|
|
1737
1809
|
}
|
|
1738
1810
|
//#endregion
|
|
1739
1811
|
//#region node_modules/openai/lib/ChatCompletionStreamingRunner.mjs
|
|
1740
|
-
var
|
|
1812
|
+
var Qn = class e extends Yn {
|
|
1741
1813
|
static fromReadableStream(t) {
|
|
1742
1814
|
let n = new e(null);
|
|
1743
1815
|
return n._run(() => n._fromReadableStream(t)), n;
|
|
@@ -1752,9 +1824,9 @@ var Jn = class e extends Gn {
|
|
|
1752
1824
|
};
|
|
1753
1825
|
return i._run(() => i._runTools(t, n, a)), i;
|
|
1754
1826
|
}
|
|
1755
|
-
},
|
|
1827
|
+
}, $n = class extends P {
|
|
1756
1828
|
constructor() {
|
|
1757
|
-
super(...arguments), this.messages = new
|
|
1829
|
+
super(...arguments), this.messages = new Rt(this._client);
|
|
1758
1830
|
}
|
|
1759
1831
|
create(e, t) {
|
|
1760
1832
|
return this._client.post("/chat/completions", {
|
|
@@ -1782,74 +1854,74 @@ var Jn = class e extends Gn {
|
|
|
1782
1854
|
return this._client.delete(F`/chat/completions/${e}`, t);
|
|
1783
1855
|
}
|
|
1784
1856
|
parse(e, t) {
|
|
1785
|
-
return
|
|
1857
|
+
return Yt(e.tools), this._client.chat.completions.create(e, {
|
|
1786
1858
|
...t,
|
|
1787
1859
|
headers: {
|
|
1788
1860
|
...t?.headers,
|
|
1789
1861
|
"X-Stainless-Helper-Method": "chat.completions.parse"
|
|
1790
1862
|
}
|
|
1791
|
-
})._thenUnwrap((t) =>
|
|
1863
|
+
})._thenUnwrap((t) => Ut(t, e));
|
|
1792
1864
|
}
|
|
1793
1865
|
runTools(e, t) {
|
|
1794
|
-
return e.stream ?
|
|
1866
|
+
return e.stream ? Qn.runTools(this._client, e, t) : xn.runTools(this._client, e, t);
|
|
1795
1867
|
}
|
|
1796
1868
|
stream(e, t) {
|
|
1797
|
-
return
|
|
1869
|
+
return Yn.createChatCompletion(this._client, e, t);
|
|
1798
1870
|
}
|
|
1799
1871
|
};
|
|
1800
|
-
|
|
1872
|
+
$n.Messages = Rt;
|
|
1801
1873
|
//#endregion
|
|
1802
1874
|
//#region node_modules/openai/resources/chat/chat.mjs
|
|
1803
|
-
var
|
|
1875
|
+
var er = class extends P {
|
|
1804
1876
|
constructor() {
|
|
1805
|
-
super(...arguments), this.completions = new
|
|
1877
|
+
super(...arguments), this.completions = new $n(this._client);
|
|
1806
1878
|
}
|
|
1807
1879
|
};
|
|
1808
|
-
|
|
1880
|
+
er.Completions = $n;
|
|
1809
1881
|
//#endregion
|
|
1810
1882
|
//#region node_modules/openai/internal/headers.mjs
|
|
1811
|
-
var
|
|
1812
|
-
function*
|
|
1883
|
+
var tr = /* @__PURE__ */ Symbol("brand.privateNullableHeaders");
|
|
1884
|
+
function* nr(e) {
|
|
1813
1885
|
if (!e) return;
|
|
1814
|
-
if (
|
|
1886
|
+
if (tr in e) {
|
|
1815
1887
|
let { values: t, nulls: n } = e;
|
|
1816
1888
|
yield* t.entries();
|
|
1817
1889
|
for (let e of n) yield [e, null];
|
|
1818
1890
|
return;
|
|
1819
1891
|
}
|
|
1820
1892
|
let t = !1, n;
|
|
1821
|
-
e instanceof Headers ? n = e.entries() :
|
|
1893
|
+
e instanceof Headers ? n = e.entries() : T(e) ? n = e : (t = !0, n = Object.entries(e ?? {}));
|
|
1822
1894
|
for (let e of n) {
|
|
1823
1895
|
let n = e[0];
|
|
1824
1896
|
if (typeof n != "string") throw TypeError("expected header name to be a string");
|
|
1825
|
-
let r =
|
|
1897
|
+
let r = T(e[1]) ? e[1] : [e[1]], i = !1;
|
|
1826
1898
|
for (let e of r) e !== void 0 && (t && !i && (i = !0, yield [n, null]), yield [n, e]);
|
|
1827
1899
|
}
|
|
1828
1900
|
}
|
|
1829
|
-
var
|
|
1901
|
+
var U = (e) => {
|
|
1830
1902
|
let t = new Headers(), n = /* @__PURE__ */ new Set();
|
|
1831
1903
|
for (let r of e) {
|
|
1832
1904
|
let e = /* @__PURE__ */ new Set();
|
|
1833
|
-
for (let [i, a] of
|
|
1905
|
+
for (let [i, a] of nr(r)) {
|
|
1834
1906
|
let r = i.toLowerCase();
|
|
1835
1907
|
e.has(r) || (t.delete(i), e.add(r)), a === null ? (t.delete(i), n.add(r)) : (t.append(i, a), n.delete(r));
|
|
1836
1908
|
}
|
|
1837
1909
|
}
|
|
1838
1910
|
return {
|
|
1839
|
-
[
|
|
1911
|
+
[tr]: !0,
|
|
1840
1912
|
values: t,
|
|
1841
1913
|
nulls: n
|
|
1842
1914
|
};
|
|
1843
|
-
},
|
|
1915
|
+
}, rr = class extends P {
|
|
1844
1916
|
create(e, t) {
|
|
1845
1917
|
return this._client.post("/audio/speech", {
|
|
1846
1918
|
body: e,
|
|
1847
1919
|
...t,
|
|
1848
|
-
headers:
|
|
1920
|
+
headers: U([{ Accept: "application/octet-stream" }, t?.headers]),
|
|
1849
1921
|
__binaryResponse: !0
|
|
1850
1922
|
});
|
|
1851
1923
|
}
|
|
1852
|
-
},
|
|
1924
|
+
}, ir = class extends P {
|
|
1853
1925
|
create(e, t) {
|
|
1854
1926
|
return this._client.post("/audio/transcriptions", N({
|
|
1855
1927
|
body: e,
|
|
@@ -1858,7 +1930,7 @@ var H = (e) => {
|
|
|
1858
1930
|
__metadata: { model: e.model }
|
|
1859
1931
|
}, this._client));
|
|
1860
1932
|
}
|
|
1861
|
-
},
|
|
1933
|
+
}, ar = class extends P {
|
|
1862
1934
|
create(e, t) {
|
|
1863
1935
|
return this._client.post("/audio/translations", N({
|
|
1864
1936
|
body: e,
|
|
@@ -1866,15 +1938,15 @@ var H = (e) => {
|
|
|
1866
1938
|
__metadata: { model: e.model }
|
|
1867
1939
|
}, this._client));
|
|
1868
1940
|
}
|
|
1869
|
-
},
|
|
1941
|
+
}, or = class extends P {
|
|
1870
1942
|
constructor() {
|
|
1871
|
-
super(...arguments), this.transcriptions = new
|
|
1943
|
+
super(...arguments), this.transcriptions = new ir(this._client), this.translations = new ar(this._client), this.speech = new rr(this._client);
|
|
1872
1944
|
}
|
|
1873
1945
|
};
|
|
1874
|
-
|
|
1946
|
+
or.Transcriptions = ir, or.Translations = ar, or.Speech = rr;
|
|
1875
1947
|
//#endregion
|
|
1876
1948
|
//#region node_modules/openai/resources/batches.mjs
|
|
1877
|
-
var
|
|
1949
|
+
var sr = class extends P {
|
|
1878
1950
|
create(e, t) {
|
|
1879
1951
|
return this._client.post("/batches", {
|
|
1880
1952
|
body: e,
|
|
@@ -1893,126 +1965,126 @@ var rr = class extends P {
|
|
|
1893
1965
|
cancel(e, t) {
|
|
1894
1966
|
return this._client.post(F`/batches/${e}/cancel`, t);
|
|
1895
1967
|
}
|
|
1896
|
-
},
|
|
1968
|
+
}, cr = class extends P {
|
|
1897
1969
|
create(e, t) {
|
|
1898
1970
|
return this._client.post("/assistants", {
|
|
1899
1971
|
body: e,
|
|
1900
1972
|
...t,
|
|
1901
|
-
headers:
|
|
1973
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
1902
1974
|
});
|
|
1903
1975
|
}
|
|
1904
1976
|
retrieve(e, t) {
|
|
1905
1977
|
return this._client.get(F`/assistants/${e}`, {
|
|
1906
1978
|
...t,
|
|
1907
|
-
headers:
|
|
1979
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
1908
1980
|
});
|
|
1909
1981
|
}
|
|
1910
1982
|
update(e, t, n) {
|
|
1911
1983
|
return this._client.post(F`/assistants/${e}`, {
|
|
1912
1984
|
body: t,
|
|
1913
1985
|
...n,
|
|
1914
|
-
headers:
|
|
1986
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
1915
1987
|
});
|
|
1916
1988
|
}
|
|
1917
1989
|
list(e = {}, t) {
|
|
1918
1990
|
return this._client.getAPIList("/assistants", M, {
|
|
1919
1991
|
query: e,
|
|
1920
1992
|
...t,
|
|
1921
|
-
headers:
|
|
1993
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
1922
1994
|
});
|
|
1923
1995
|
}
|
|
1924
1996
|
delete(e, t) {
|
|
1925
1997
|
return this._client.delete(F`/assistants/${e}`, {
|
|
1926
1998
|
...t,
|
|
1927
|
-
headers:
|
|
1999
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
1928
2000
|
});
|
|
1929
2001
|
}
|
|
1930
|
-
},
|
|
2002
|
+
}, lr = class extends P {
|
|
1931
2003
|
create(e, t) {
|
|
1932
2004
|
return this._client.post("/realtime/sessions", {
|
|
1933
2005
|
body: e,
|
|
1934
2006
|
...t,
|
|
1935
|
-
headers:
|
|
2007
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
1936
2008
|
});
|
|
1937
2009
|
}
|
|
1938
|
-
},
|
|
2010
|
+
}, ur = class extends P {
|
|
1939
2011
|
create(e, t) {
|
|
1940
2012
|
return this._client.post("/realtime/transcription_sessions", {
|
|
1941
2013
|
body: e,
|
|
1942
2014
|
...t,
|
|
1943
|
-
headers:
|
|
2015
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
1944
2016
|
});
|
|
1945
2017
|
}
|
|
1946
|
-
},
|
|
2018
|
+
}, dr = class extends P {
|
|
1947
2019
|
constructor() {
|
|
1948
|
-
super(...arguments), this.sessions = new
|
|
2020
|
+
super(...arguments), this.sessions = new lr(this._client), this.transcriptionSessions = new ur(this._client);
|
|
1949
2021
|
}
|
|
1950
2022
|
};
|
|
1951
|
-
|
|
2023
|
+
dr.Sessions = lr, dr.TranscriptionSessions = ur;
|
|
1952
2024
|
//#endregion
|
|
1953
2025
|
//#region node_modules/openai/resources/beta/chatkit/sessions.mjs
|
|
1954
|
-
var
|
|
2026
|
+
var fr = class extends P {
|
|
1955
2027
|
create(e, t) {
|
|
1956
2028
|
return this._client.post("/chatkit/sessions", {
|
|
1957
2029
|
body: e,
|
|
1958
2030
|
...t,
|
|
1959
|
-
headers:
|
|
2031
|
+
headers: U([{ "OpenAI-Beta": "chatkit_beta=v1" }, t?.headers])
|
|
1960
2032
|
});
|
|
1961
2033
|
}
|
|
1962
2034
|
cancel(e, t) {
|
|
1963
2035
|
return this._client.post(F`/chatkit/sessions/${e}/cancel`, {
|
|
1964
2036
|
...t,
|
|
1965
|
-
headers:
|
|
2037
|
+
headers: U([{ "OpenAI-Beta": "chatkit_beta=v1" }, t?.headers])
|
|
1966
2038
|
});
|
|
1967
2039
|
}
|
|
1968
|
-
},
|
|
2040
|
+
}, pr = class extends P {
|
|
1969
2041
|
retrieve(e, t) {
|
|
1970
2042
|
return this._client.get(F`/chatkit/threads/${e}`, {
|
|
1971
2043
|
...t,
|
|
1972
|
-
headers:
|
|
2044
|
+
headers: U([{ "OpenAI-Beta": "chatkit_beta=v1" }, t?.headers])
|
|
1973
2045
|
});
|
|
1974
2046
|
}
|
|
1975
2047
|
list(e = {}, t) {
|
|
1976
|
-
return this._client.getAPIList("/chatkit/threads",
|
|
2048
|
+
return this._client.getAPIList("/chatkit/threads", mt, {
|
|
1977
2049
|
query: e,
|
|
1978
2050
|
...t,
|
|
1979
|
-
headers:
|
|
2051
|
+
headers: U([{ "OpenAI-Beta": "chatkit_beta=v1" }, t?.headers])
|
|
1980
2052
|
});
|
|
1981
2053
|
}
|
|
1982
2054
|
delete(e, t) {
|
|
1983
2055
|
return this._client.delete(F`/chatkit/threads/${e}`, {
|
|
1984
2056
|
...t,
|
|
1985
|
-
headers:
|
|
2057
|
+
headers: U([{ "OpenAI-Beta": "chatkit_beta=v1" }, t?.headers])
|
|
1986
2058
|
});
|
|
1987
2059
|
}
|
|
1988
2060
|
listItems(e, t = {}, n) {
|
|
1989
|
-
return this._client.getAPIList(F`/chatkit/threads/${e}/items`,
|
|
2061
|
+
return this._client.getAPIList(F`/chatkit/threads/${e}/items`, mt, {
|
|
1990
2062
|
query: t,
|
|
1991
2063
|
...n,
|
|
1992
|
-
headers:
|
|
2064
|
+
headers: U([{ "OpenAI-Beta": "chatkit_beta=v1" }, n?.headers])
|
|
1993
2065
|
});
|
|
1994
2066
|
}
|
|
1995
|
-
},
|
|
2067
|
+
}, mr = class extends P {
|
|
1996
2068
|
constructor() {
|
|
1997
|
-
super(...arguments), this.sessions = new
|
|
2069
|
+
super(...arguments), this.sessions = new fr(this._client), this.threads = new pr(this._client);
|
|
1998
2070
|
}
|
|
1999
2071
|
};
|
|
2000
|
-
|
|
2072
|
+
mr.Sessions = fr, mr.Threads = pr;
|
|
2001
2073
|
//#endregion
|
|
2002
2074
|
//#region node_modules/openai/resources/beta/threads/messages.mjs
|
|
2003
|
-
var
|
|
2075
|
+
var hr = class extends P {
|
|
2004
2076
|
create(e, t, n) {
|
|
2005
2077
|
return this._client.post(F`/threads/${e}/messages`, {
|
|
2006
2078
|
body: t,
|
|
2007
2079
|
...n,
|
|
2008
|
-
headers:
|
|
2080
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2009
2081
|
});
|
|
2010
2082
|
}
|
|
2011
2083
|
retrieve(e, t, n) {
|
|
2012
2084
|
let { thread_id: r } = t;
|
|
2013
2085
|
return this._client.get(F`/threads/${r}/messages/${e}`, {
|
|
2014
2086
|
...n,
|
|
2015
|
-
headers:
|
|
2087
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2016
2088
|
});
|
|
2017
2089
|
}
|
|
2018
2090
|
update(e, t, n) {
|
|
@@ -2020,30 +2092,30 @@ var dr = class extends P {
|
|
|
2020
2092
|
return this._client.post(F`/threads/${r}/messages/${e}`, {
|
|
2021
2093
|
body: i,
|
|
2022
2094
|
...n,
|
|
2023
|
-
headers:
|
|
2095
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2024
2096
|
});
|
|
2025
2097
|
}
|
|
2026
2098
|
list(e, t = {}, n) {
|
|
2027
2099
|
return this._client.getAPIList(F`/threads/${e}/messages`, M, {
|
|
2028
2100
|
query: t,
|
|
2029
2101
|
...n,
|
|
2030
|
-
headers:
|
|
2102
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2031
2103
|
});
|
|
2032
2104
|
}
|
|
2033
2105
|
delete(e, t, n) {
|
|
2034
2106
|
let { thread_id: r } = t;
|
|
2035
2107
|
return this._client.delete(F`/threads/${r}/messages/${e}`, {
|
|
2036
2108
|
...n,
|
|
2037
|
-
headers:
|
|
2109
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2038
2110
|
});
|
|
2039
2111
|
}
|
|
2040
|
-
},
|
|
2112
|
+
}, gr = class extends P {
|
|
2041
2113
|
retrieve(e, t, n) {
|
|
2042
2114
|
let { thread_id: r, run_id: i, ...a } = t;
|
|
2043
2115
|
return this._client.get(F`/threads/${r}/runs/${i}/steps/${e}`, {
|
|
2044
2116
|
query: a,
|
|
2045
2117
|
...n,
|
|
2046
|
-
headers:
|
|
2118
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2047
2119
|
});
|
|
2048
2120
|
}
|
|
2049
2121
|
list(e, t, n) {
|
|
@@ -2051,10 +2123,10 @@ var dr = class extends P {
|
|
|
2051
2123
|
return this._client.getAPIList(F`/threads/${r}/runs/${e}/steps`, M, {
|
|
2052
2124
|
query: i,
|
|
2053
2125
|
...n,
|
|
2054
|
-
headers:
|
|
2126
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2055
2127
|
});
|
|
2056
2128
|
}
|
|
2057
|
-
},
|
|
2129
|
+
}, _r = (e) => {
|
|
2058
2130
|
if (typeof Buffer < "u") {
|
|
2059
2131
|
let t = Buffer.from(e, "base64");
|
|
2060
2132
|
return Array.from(new Float32Array(t.buffer, t.byteOffset, t.length / Float32Array.BYTES_PER_ELEMENT));
|
|
@@ -2063,14 +2135,14 @@ var dr = class extends P {
|
|
|
2063
2135
|
for (let e = 0; e < n; e++) r[e] = t.charCodeAt(e);
|
|
2064
2136
|
return Array.from(new Float32Array(r.buffer));
|
|
2065
2137
|
}
|
|
2066
|
-
},
|
|
2138
|
+
}, W = (e) => {
|
|
2067
2139
|
if (globalThis.process !== void 0) return globalThis.process.env?.[e]?.trim() ?? void 0;
|
|
2068
2140
|
if (globalThis.Deno !== void 0) return globalThis.Deno.env?.get?.(e)?.trim();
|
|
2069
|
-
},
|
|
2141
|
+
}, G, K, vr, q, yr, J, Y, br, X, xr, Z, Sr, Cr, wr, Tr, Er, Dr, Or, kr, Ar, jr, Mr, Nr, Pr = class extends un {
|
|
2070
2142
|
constructor() {
|
|
2071
|
-
super(...arguments),
|
|
2143
|
+
super(...arguments), G.add(this), vr.set(this, []), q.set(this, {}), yr.set(this, {}), J.set(this, void 0), Y.set(this, void 0), br.set(this, void 0), X.set(this, void 0), xr.set(this, void 0), Z.set(this, void 0), Sr.set(this, void 0), Cr.set(this, void 0), wr.set(this, void 0);
|
|
2072
2144
|
}
|
|
2073
|
-
[(
|
|
2145
|
+
[(vr = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), yr = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), br = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap(), xr = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakMap(), Sr = /* @__PURE__ */ new WeakMap(), Cr = /* @__PURE__ */ new WeakMap(), wr = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakSet(), Symbol.asyncIterator)]() {
|
|
2074
2146
|
let e = [], t = [], n = !1;
|
|
2075
2147
|
return this.on("event", (n) => {
|
|
2076
2148
|
let r = t.shift();
|
|
@@ -2111,22 +2183,22 @@ var dr = class extends P {
|
|
|
2111
2183
|
};
|
|
2112
2184
|
}
|
|
2113
2185
|
static fromReadableStream(e) {
|
|
2114
|
-
let t = new
|
|
2186
|
+
let t = new K();
|
|
2115
2187
|
return t._run(() => t._fromReadableStream(e)), t;
|
|
2116
2188
|
}
|
|
2117
2189
|
async _fromReadableStream(e, n) {
|
|
2118
2190
|
let r = n?.signal;
|
|
2119
2191
|
r && (r.aborted && this.controller.abort(), r.addEventListener("abort", () => this.controller.abort())), this._connected();
|
|
2120
|
-
let i =
|
|
2121
|
-
for await (let e of i) t(this,
|
|
2192
|
+
let i = tt.fromReadableStream(e, this.controller);
|
|
2193
|
+
for await (let e of i) t(this, G, "m", Tr).call(this, e);
|
|
2122
2194
|
if (i.controller.signal?.aborted) throw new s();
|
|
2123
|
-
return this._addRun(t(this,
|
|
2195
|
+
return this._addRun(t(this, G, "m", Er).call(this));
|
|
2124
2196
|
}
|
|
2125
2197
|
toReadableStream() {
|
|
2126
|
-
return new
|
|
2198
|
+
return new tt(this[Symbol.asyncIterator].bind(this), this.controller).toReadableStream();
|
|
2127
2199
|
}
|
|
2128
2200
|
static createToolAssistantStream(e, t, n, r) {
|
|
2129
|
-
let i = new
|
|
2201
|
+
let i = new K();
|
|
2130
2202
|
return i._run(() => i._runToolAssistantStream(e, t, n, {
|
|
2131
2203
|
...r,
|
|
2132
2204
|
headers: {
|
|
@@ -2146,12 +2218,12 @@ var dr = class extends P {
|
|
|
2146
2218
|
signal: this.controller.signal
|
|
2147
2219
|
});
|
|
2148
2220
|
this._connected();
|
|
2149
|
-
for await (let e of c) t(this,
|
|
2221
|
+
for await (let e of c) t(this, G, "m", Tr).call(this, e);
|
|
2150
2222
|
if (c.controller.signal?.aborted) throw new s();
|
|
2151
|
-
return this._addRun(t(this,
|
|
2223
|
+
return this._addRun(t(this, G, "m", Er).call(this));
|
|
2152
2224
|
}
|
|
2153
2225
|
static createThreadAssistantStream(e, t, n) {
|
|
2154
|
-
let r = new
|
|
2226
|
+
let r = new K();
|
|
2155
2227
|
return r._run(() => r._threadAssistantStream(e, t, {
|
|
2156
2228
|
...n,
|
|
2157
2229
|
headers: {
|
|
@@ -2161,7 +2233,7 @@ var dr = class extends P {
|
|
|
2161
2233
|
})), r;
|
|
2162
2234
|
}
|
|
2163
2235
|
static createAssistantStream(e, t, n, r) {
|
|
2164
|
-
let i = new
|
|
2236
|
+
let i = new K();
|
|
2165
2237
|
return i._run(() => i._runAssistantStream(e, t, n, {
|
|
2166
2238
|
...r,
|
|
2167
2239
|
headers: {
|
|
@@ -2171,26 +2243,26 @@ var dr = class extends P {
|
|
|
2171
2243
|
})), i;
|
|
2172
2244
|
}
|
|
2173
2245
|
currentEvent() {
|
|
2174
|
-
return t(this,
|
|
2246
|
+
return t(this, Sr, "f");
|
|
2175
2247
|
}
|
|
2176
2248
|
currentRun() {
|
|
2177
|
-
return t(this,
|
|
2249
|
+
return t(this, Cr, "f");
|
|
2178
2250
|
}
|
|
2179
2251
|
currentMessageSnapshot() {
|
|
2180
|
-
return t(this,
|
|
2252
|
+
return t(this, J, "f");
|
|
2181
2253
|
}
|
|
2182
2254
|
currentRunStepSnapshot() {
|
|
2183
|
-
return t(this,
|
|
2255
|
+
return t(this, wr, "f");
|
|
2184
2256
|
}
|
|
2185
2257
|
async finalRunSteps() {
|
|
2186
|
-
return await this.done(), Object.values(t(this,
|
|
2258
|
+
return await this.done(), Object.values(t(this, q, "f"));
|
|
2187
2259
|
}
|
|
2188
2260
|
async finalMessages() {
|
|
2189
|
-
return await this.done(), Object.values(t(this,
|
|
2261
|
+
return await this.done(), Object.values(t(this, yr, "f"));
|
|
2190
2262
|
}
|
|
2191
2263
|
async finalRun() {
|
|
2192
|
-
if (await this.done(), !t(this,
|
|
2193
|
-
return t(this,
|
|
2264
|
+
if (await this.done(), !t(this, Y, "f")) throw Error("Final run was not received.");
|
|
2265
|
+
return t(this, Y, "f");
|
|
2194
2266
|
}
|
|
2195
2267
|
async _createThreadAssistantStream(e, n, r) {
|
|
2196
2268
|
let i = r?.signal;
|
|
@@ -2203,9 +2275,9 @@ var dr = class extends P {
|
|
|
2203
2275
|
signal: this.controller.signal
|
|
2204
2276
|
});
|
|
2205
2277
|
this._connected();
|
|
2206
|
-
for await (let e of o) t(this,
|
|
2278
|
+
for await (let e of o) t(this, G, "m", Tr).call(this, e);
|
|
2207
2279
|
if (o.controller.signal?.aborted) throw new s();
|
|
2208
|
-
return this._addRun(t(this,
|
|
2280
|
+
return this._addRun(t(this, G, "m", Er).call(this));
|
|
2209
2281
|
}
|
|
2210
2282
|
async _createAssistantStream(e, n, r, i) {
|
|
2211
2283
|
let a = i?.signal;
|
|
@@ -2218,9 +2290,9 @@ var dr = class extends P {
|
|
|
2218
2290
|
signal: this.controller.signal
|
|
2219
2291
|
});
|
|
2220
2292
|
this._connected();
|
|
2221
|
-
for await (let e of c) t(this,
|
|
2293
|
+
for await (let e of c) t(this, G, "m", Tr).call(this, e);
|
|
2222
2294
|
if (c.controller.signal?.aborted) throw new s();
|
|
2223
|
-
return this._addRun(t(this,
|
|
2295
|
+
return this._addRun(t(this, G, "m", Er).call(this));
|
|
2224
2296
|
}
|
|
2225
2297
|
static accumulateDelta(e, t) {
|
|
2226
2298
|
for (let [n, r] of Object.entries(t)) {
|
|
@@ -2239,14 +2311,14 @@ var dr = class extends P {
|
|
|
2239
2311
|
}
|
|
2240
2312
|
if (typeof t == "string" && typeof r == "string") t += r;
|
|
2241
2313
|
else if (typeof t == "number" && typeof r == "number") t += r;
|
|
2242
|
-
else if (
|
|
2314
|
+
else if (ie(t) && ie(r)) t = this.accumulateDelta(t, r);
|
|
2243
2315
|
else if (Array.isArray(t) && Array.isArray(r)) {
|
|
2244
2316
|
if (t.every((e) => typeof e == "string" || typeof e == "number")) {
|
|
2245
2317
|
t.push(...r);
|
|
2246
2318
|
continue;
|
|
2247
2319
|
}
|
|
2248
2320
|
for (let e of r) {
|
|
2249
|
-
if (!
|
|
2321
|
+
if (!ie(e)) throw Error(`Expected array delta entry to be an object but got: ${e}`);
|
|
2250
2322
|
let n = e.index;
|
|
2251
2323
|
if (n == null) throw console.error(e), Error("Expected array delta entry to have an `index` property");
|
|
2252
2324
|
if (typeof n != "number") throw Error(`Expected array delta entry \`index\` property to be a number but got ${n}`);
|
|
@@ -2272,8 +2344,8 @@ var dr = class extends P {
|
|
|
2272
2344
|
return await this._createToolAssistantStream(t, e, n, r);
|
|
2273
2345
|
}
|
|
2274
2346
|
};
|
|
2275
|
-
|
|
2276
|
-
if (!this.ended) switch (e(this,
|
|
2347
|
+
K = Pr, Tr = function(n) {
|
|
2348
|
+
if (!this.ended) switch (e(this, Sr, n, "f"), t(this, G, "m", kr).call(this, n), n.event) {
|
|
2277
2349
|
case "thread.created": break;
|
|
2278
2350
|
case "thread.run.created":
|
|
2279
2351
|
case "thread.run.queued":
|
|
@@ -2285,7 +2357,7 @@ G = Ar, xr = function(n) {
|
|
|
2285
2357
|
case "thread.run.cancelling":
|
|
2286
2358
|
case "thread.run.cancelled":
|
|
2287
2359
|
case "thread.run.expired":
|
|
2288
|
-
t(this,
|
|
2360
|
+
t(this, G, "m", Nr).call(this, n);
|
|
2289
2361
|
break;
|
|
2290
2362
|
case "thread.run.step.created":
|
|
2291
2363
|
case "thread.run.step.in_progress":
|
|
@@ -2294,25 +2366,25 @@ G = Ar, xr = function(n) {
|
|
|
2294
2366
|
case "thread.run.step.failed":
|
|
2295
2367
|
case "thread.run.step.cancelled":
|
|
2296
2368
|
case "thread.run.step.expired":
|
|
2297
|
-
t(this,
|
|
2369
|
+
t(this, G, "m", Or).call(this, n);
|
|
2298
2370
|
break;
|
|
2299
2371
|
case "thread.message.created":
|
|
2300
2372
|
case "thread.message.in_progress":
|
|
2301
2373
|
case "thread.message.delta":
|
|
2302
2374
|
case "thread.message.completed":
|
|
2303
2375
|
case "thread.message.incomplete":
|
|
2304
|
-
t(this,
|
|
2376
|
+
t(this, G, "m", Dr).call(this, n);
|
|
2305
2377
|
break;
|
|
2306
2378
|
case "error": throw Error("Encountered an error event in event processing - errors should be processed earlier");
|
|
2307
2379
|
default:
|
|
2308
2380
|
}
|
|
2309
|
-
},
|
|
2381
|
+
}, Er = function() {
|
|
2310
2382
|
if (this.ended) throw new a("stream has ended, this shouldn't happen");
|
|
2311
|
-
if (!t(this,
|
|
2312
|
-
return t(this,
|
|
2313
|
-
},
|
|
2314
|
-
let [r, i] = t(this,
|
|
2315
|
-
e(this,
|
|
2383
|
+
if (!t(this, Y, "f")) throw Error("Final run has not been received");
|
|
2384
|
+
return t(this, Y, "f");
|
|
2385
|
+
}, Dr = function(n) {
|
|
2386
|
+
let [r, i] = t(this, G, "m", jr).call(this, n, t(this, J, "f"));
|
|
2387
|
+
e(this, J, r, "f"), t(this, yr, "f")[r.id] = r;
|
|
2316
2388
|
for (let e of i) {
|
|
2317
2389
|
let t = r.content[e.index];
|
|
2318
2390
|
t?.type == "text" && this._emit("textCreated", t.text);
|
|
@@ -2329,79 +2401,79 @@ G = Ar, xr = function(n) {
|
|
|
2329
2401
|
if (t && t.type == "text") this._emit("textDelta", e, t.text);
|
|
2330
2402
|
else throw Error("The snapshot associated with this text delta is not text or missing");
|
|
2331
2403
|
}
|
|
2332
|
-
if (i.index != t(this,
|
|
2333
|
-
if (t(this,
|
|
2404
|
+
if (i.index != t(this, br, "f")) {
|
|
2405
|
+
if (t(this, X, "f")) switch (t(this, X, "f").type) {
|
|
2334
2406
|
case "text":
|
|
2335
|
-
this._emit("textDone", t(this,
|
|
2407
|
+
this._emit("textDone", t(this, X, "f").text, t(this, J, "f"));
|
|
2336
2408
|
break;
|
|
2337
2409
|
case "image_file":
|
|
2338
|
-
this._emit("imageFileDone", t(this,
|
|
2410
|
+
this._emit("imageFileDone", t(this, X, "f").image_file, t(this, J, "f"));
|
|
2339
2411
|
break;
|
|
2340
2412
|
}
|
|
2341
|
-
e(this,
|
|
2413
|
+
e(this, br, i.index, "f");
|
|
2342
2414
|
}
|
|
2343
|
-
e(this,
|
|
2415
|
+
e(this, X, r.content[i.index], "f");
|
|
2344
2416
|
}
|
|
2345
2417
|
break;
|
|
2346
2418
|
case "thread.message.completed":
|
|
2347
2419
|
case "thread.message.incomplete":
|
|
2348
|
-
if (t(this,
|
|
2349
|
-
let e = n.data.content[t(this,
|
|
2420
|
+
if (t(this, br, "f") !== void 0) {
|
|
2421
|
+
let e = n.data.content[t(this, br, "f")];
|
|
2350
2422
|
if (e) switch (e.type) {
|
|
2351
2423
|
case "image_file":
|
|
2352
|
-
this._emit("imageFileDone", e.image_file, t(this,
|
|
2424
|
+
this._emit("imageFileDone", e.image_file, t(this, J, "f"));
|
|
2353
2425
|
break;
|
|
2354
2426
|
case "text":
|
|
2355
|
-
this._emit("textDone", e.text, t(this,
|
|
2427
|
+
this._emit("textDone", e.text, t(this, J, "f"));
|
|
2356
2428
|
break;
|
|
2357
2429
|
}
|
|
2358
2430
|
}
|
|
2359
|
-
t(this,
|
|
2431
|
+
t(this, J, "f") && this._emit("messageDone", n.data), e(this, J, void 0, "f");
|
|
2360
2432
|
}
|
|
2361
|
-
},
|
|
2362
|
-
let r = t(this,
|
|
2363
|
-
switch (e(this,
|
|
2433
|
+
}, Or = function(n) {
|
|
2434
|
+
let r = t(this, G, "m", Ar).call(this, n);
|
|
2435
|
+
switch (e(this, wr, r, "f"), n.event) {
|
|
2364
2436
|
case "thread.run.step.created":
|
|
2365
2437
|
this._emit("runStepCreated", n.data);
|
|
2366
2438
|
break;
|
|
2367
2439
|
case "thread.run.step.delta":
|
|
2368
2440
|
let i = n.data.delta;
|
|
2369
|
-
if (i.step_details && i.step_details.type == "tool_calls" && i.step_details.tool_calls && r.step_details.type == "tool_calls") for (let n of i.step_details.tool_calls) n.index == t(this,
|
|
2441
|
+
if (i.step_details && i.step_details.type == "tool_calls" && i.step_details.tool_calls && r.step_details.type == "tool_calls") for (let n of i.step_details.tool_calls) n.index == t(this, xr, "f") ? this._emit("toolCallDelta", n, r.step_details.tool_calls[n.index]) : (t(this, Z, "f") && this._emit("toolCallDone", t(this, Z, "f")), e(this, xr, n.index, "f"), e(this, Z, r.step_details.tool_calls[n.index], "f"), t(this, Z, "f") && this._emit("toolCallCreated", t(this, Z, "f")));
|
|
2370
2442
|
this._emit("runStepDelta", n.data.delta, r);
|
|
2371
2443
|
break;
|
|
2372
2444
|
case "thread.run.step.completed":
|
|
2373
2445
|
case "thread.run.step.failed":
|
|
2374
2446
|
case "thread.run.step.cancelled":
|
|
2375
2447
|
case "thread.run.step.expired":
|
|
2376
|
-
e(this,
|
|
2448
|
+
e(this, wr, void 0, "f"), n.data.step_details.type == "tool_calls" && t(this, Z, "f") && (this._emit("toolCallDone", t(this, Z, "f")), e(this, Z, void 0, "f")), this._emit("runStepDone", n.data, r);
|
|
2377
2449
|
break;
|
|
2378
2450
|
case "thread.run.step.in_progress": break;
|
|
2379
2451
|
}
|
|
2380
|
-
},
|
|
2381
|
-
t(this,
|
|
2382
|
-
},
|
|
2452
|
+
}, kr = function(e) {
|
|
2453
|
+
t(this, vr, "f").push(e), this._emit("event", e);
|
|
2454
|
+
}, Ar = function(e) {
|
|
2383
2455
|
switch (e.event) {
|
|
2384
|
-
case "thread.run.step.created": return t(this,
|
|
2456
|
+
case "thread.run.step.created": return t(this, q, "f")[e.data.id] = e.data, e.data;
|
|
2385
2457
|
case "thread.run.step.delta":
|
|
2386
|
-
let n = t(this,
|
|
2458
|
+
let n = t(this, q, "f")[e.data.id];
|
|
2387
2459
|
if (!n) throw Error("Received a RunStepDelta before creation of a snapshot");
|
|
2388
2460
|
let r = e.data;
|
|
2389
2461
|
if (r.delta) {
|
|
2390
|
-
let i =
|
|
2391
|
-
t(this,
|
|
2462
|
+
let i = K.accumulateDelta(n, r.delta);
|
|
2463
|
+
t(this, q, "f")[e.data.id] = i;
|
|
2392
2464
|
}
|
|
2393
|
-
return t(this,
|
|
2465
|
+
return t(this, q, "f")[e.data.id];
|
|
2394
2466
|
case "thread.run.step.completed":
|
|
2395
2467
|
case "thread.run.step.failed":
|
|
2396
2468
|
case "thread.run.step.cancelled":
|
|
2397
2469
|
case "thread.run.step.expired":
|
|
2398
2470
|
case "thread.run.step.in_progress":
|
|
2399
|
-
t(this,
|
|
2471
|
+
t(this, q, "f")[e.data.id] = e.data;
|
|
2400
2472
|
break;
|
|
2401
2473
|
}
|
|
2402
|
-
if (t(this,
|
|
2474
|
+
if (t(this, q, "f")[e.data.id]) return t(this, q, "f")[e.data.id];
|
|
2403
2475
|
throw Error("No snapshot available");
|
|
2404
|
-
},
|
|
2476
|
+
}, jr = function(e, n) {
|
|
2405
2477
|
let r = [];
|
|
2406
2478
|
switch (e.event) {
|
|
2407
2479
|
case "thread.message.created": return [e.data, r];
|
|
@@ -2410,7 +2482,7 @@ G = Ar, xr = function(n) {
|
|
|
2410
2482
|
let i = e.data;
|
|
2411
2483
|
if (i.delta.content) for (let e of i.delta.content) if (e.index in n.content) {
|
|
2412
2484
|
let r = n.content[e.index];
|
|
2413
|
-
n.content[e.index] = t(this,
|
|
2485
|
+
n.content[e.index] = t(this, G, "m", Mr).call(this, e, r);
|
|
2414
2486
|
} else n.content[e.index] = e, r.push(e);
|
|
2415
2487
|
return [n, r];
|
|
2416
2488
|
case "thread.message.in_progress":
|
|
@@ -2420,10 +2492,10 @@ G = Ar, xr = function(n) {
|
|
|
2420
2492
|
throw Error("Received thread message event with no existing snapshot");
|
|
2421
2493
|
}
|
|
2422
2494
|
throw Error("Tried to accumulate a non-message event");
|
|
2423
|
-
},
|
|
2424
|
-
return
|
|
2425
|
-
},
|
|
2426
|
-
switch (e(this,
|
|
2495
|
+
}, Mr = function(e, t) {
|
|
2496
|
+
return K.accumulateDelta(t, e);
|
|
2497
|
+
}, Nr = function(n) {
|
|
2498
|
+
switch (e(this, Cr, n.data, "f"), n.event) {
|
|
2427
2499
|
case "thread.run.created": break;
|
|
2428
2500
|
case "thread.run.queued": break;
|
|
2429
2501
|
case "thread.run.in_progress": break;
|
|
@@ -2433,16 +2505,16 @@ G = Ar, xr = function(n) {
|
|
|
2433
2505
|
case "thread.run.completed":
|
|
2434
2506
|
case "thread.run.expired":
|
|
2435
2507
|
case "thread.run.incomplete":
|
|
2436
|
-
e(this,
|
|
2508
|
+
e(this, Y, n.data, "f"), t(this, Z, "f") && (this._emit("toolCallDone", t(this, Z, "f")), e(this, Z, void 0, "f"));
|
|
2437
2509
|
break;
|
|
2438
2510
|
case "thread.run.cancelling": break;
|
|
2439
2511
|
}
|
|
2440
2512
|
};
|
|
2441
2513
|
//#endregion
|
|
2442
2514
|
//#region node_modules/openai/resources/beta/threads/runs/runs.mjs
|
|
2443
|
-
var
|
|
2515
|
+
var Fr = class extends P {
|
|
2444
2516
|
constructor() {
|
|
2445
|
-
super(...arguments), this.steps = new
|
|
2517
|
+
super(...arguments), this.steps = new gr(this._client);
|
|
2446
2518
|
}
|
|
2447
2519
|
create(e, t, n) {
|
|
2448
2520
|
let { include: r, ...i } = t;
|
|
@@ -2450,7 +2522,7 @@ var jr = class extends P {
|
|
|
2450
2522
|
query: { include: r },
|
|
2451
2523
|
body: i,
|
|
2452
2524
|
...n,
|
|
2453
|
-
headers:
|
|
2525
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers]),
|
|
2454
2526
|
stream: t.stream ?? !1,
|
|
2455
2527
|
__synthesizeEventData: !0
|
|
2456
2528
|
});
|
|
@@ -2459,7 +2531,7 @@ var jr = class extends P {
|
|
|
2459
2531
|
let { thread_id: r } = t;
|
|
2460
2532
|
return this._client.get(F`/threads/${r}/runs/${e}`, {
|
|
2461
2533
|
...n,
|
|
2462
|
-
headers:
|
|
2534
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2463
2535
|
});
|
|
2464
2536
|
}
|
|
2465
2537
|
update(e, t, n) {
|
|
@@ -2467,21 +2539,21 @@ var jr = class extends P {
|
|
|
2467
2539
|
return this._client.post(F`/threads/${r}/runs/${e}`, {
|
|
2468
2540
|
body: i,
|
|
2469
2541
|
...n,
|
|
2470
|
-
headers:
|
|
2542
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2471
2543
|
});
|
|
2472
2544
|
}
|
|
2473
2545
|
list(e, t = {}, n) {
|
|
2474
2546
|
return this._client.getAPIList(F`/threads/${e}/runs`, M, {
|
|
2475
2547
|
query: t,
|
|
2476
2548
|
...n,
|
|
2477
|
-
headers:
|
|
2549
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2478
2550
|
});
|
|
2479
2551
|
}
|
|
2480
2552
|
cancel(e, t, n) {
|
|
2481
2553
|
let { thread_id: r } = t;
|
|
2482
2554
|
return this._client.post(F`/threads/${r}/runs/${e}/cancel`, {
|
|
2483
2555
|
...n,
|
|
2484
|
-
headers:
|
|
2556
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2485
2557
|
});
|
|
2486
2558
|
}
|
|
2487
2559
|
async createAndPoll(e, t, n) {
|
|
@@ -2489,10 +2561,10 @@ var jr = class extends P {
|
|
|
2489
2561
|
return await this.poll(r.id, { thread_id: e }, n);
|
|
2490
2562
|
}
|
|
2491
2563
|
createAndStream(e, t, n) {
|
|
2492
|
-
return
|
|
2564
|
+
return Pr.createAssistantStream(e, this._client.beta.threads.runs, t, n);
|
|
2493
2565
|
}
|
|
2494
2566
|
async poll(e, t, n) {
|
|
2495
|
-
let r =
|
|
2567
|
+
let r = U([n?.headers, {
|
|
2496
2568
|
"X-Stainless-Poll-Helper": "true",
|
|
2497
2569
|
"X-Stainless-Custom-Poll-Interval": n?.pollIntervalMs?.toString() ?? void 0
|
|
2498
2570
|
}]);
|
|
@@ -2517,7 +2589,7 @@ var jr = class extends P {
|
|
|
2517
2589
|
isNaN(n) || (e = n);
|
|
2518
2590
|
}
|
|
2519
2591
|
}
|
|
2520
|
-
await
|
|
2592
|
+
await se(e);
|
|
2521
2593
|
break;
|
|
2522
2594
|
case "requires_action":
|
|
2523
2595
|
case "incomplete":
|
|
@@ -2529,14 +2601,14 @@ var jr = class extends P {
|
|
|
2529
2601
|
}
|
|
2530
2602
|
}
|
|
2531
2603
|
stream(e, t, n) {
|
|
2532
|
-
return
|
|
2604
|
+
return Pr.createAssistantStream(e, this._client.beta.threads.runs, t, n);
|
|
2533
2605
|
}
|
|
2534
2606
|
submitToolOutputs(e, t, n) {
|
|
2535
2607
|
let { thread_id: r, ...i } = t;
|
|
2536
2608
|
return this._client.post(F`/threads/${r}/runs/${e}/submit_tool_outputs`, {
|
|
2537
2609
|
body: i,
|
|
2538
2610
|
...n,
|
|
2539
|
-
headers:
|
|
2611
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers]),
|
|
2540
2612
|
stream: t.stream ?? !1,
|
|
2541
2613
|
__synthesizeEventData: !0
|
|
2542
2614
|
});
|
|
@@ -2546,47 +2618,47 @@ var jr = class extends P {
|
|
|
2546
2618
|
return await this.poll(r.id, t, n);
|
|
2547
2619
|
}
|
|
2548
2620
|
submitToolOutputsStream(e, t, n) {
|
|
2549
|
-
return
|
|
2621
|
+
return Pr.createToolAssistantStream(e, this._client.beta.threads.runs, t, n);
|
|
2550
2622
|
}
|
|
2551
2623
|
};
|
|
2552
|
-
|
|
2624
|
+
Fr.Steps = gr;
|
|
2553
2625
|
//#endregion
|
|
2554
2626
|
//#region node_modules/openai/resources/beta/threads/threads.mjs
|
|
2555
|
-
var
|
|
2627
|
+
var Ir = class extends P {
|
|
2556
2628
|
constructor() {
|
|
2557
|
-
super(...arguments), this.runs = new
|
|
2629
|
+
super(...arguments), this.runs = new Fr(this._client), this.messages = new hr(this._client);
|
|
2558
2630
|
}
|
|
2559
2631
|
create(e = {}, t) {
|
|
2560
2632
|
return this._client.post("/threads", {
|
|
2561
2633
|
body: e,
|
|
2562
2634
|
...t,
|
|
2563
|
-
headers:
|
|
2635
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
2564
2636
|
});
|
|
2565
2637
|
}
|
|
2566
2638
|
retrieve(e, t) {
|
|
2567
2639
|
return this._client.get(F`/threads/${e}`, {
|
|
2568
2640
|
...t,
|
|
2569
|
-
headers:
|
|
2641
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
2570
2642
|
});
|
|
2571
2643
|
}
|
|
2572
2644
|
update(e, t, n) {
|
|
2573
2645
|
return this._client.post(F`/threads/${e}`, {
|
|
2574
2646
|
body: t,
|
|
2575
2647
|
...n,
|
|
2576
|
-
headers:
|
|
2648
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
2577
2649
|
});
|
|
2578
2650
|
}
|
|
2579
2651
|
delete(e, t) {
|
|
2580
2652
|
return this._client.delete(F`/threads/${e}`, {
|
|
2581
2653
|
...t,
|
|
2582
|
-
headers:
|
|
2654
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
2583
2655
|
});
|
|
2584
2656
|
}
|
|
2585
2657
|
createAndRun(e, t) {
|
|
2586
2658
|
return this._client.post("/threads/runs", {
|
|
2587
2659
|
body: e,
|
|
2588
2660
|
...t,
|
|
2589
|
-
headers:
|
|
2661
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, t?.headers]),
|
|
2590
2662
|
stream: e.stream ?? !1,
|
|
2591
2663
|
__synthesizeEventData: !0
|
|
2592
2664
|
});
|
|
@@ -2596,21 +2668,21 @@ var Mr = class extends P {
|
|
|
2596
2668
|
return await this.runs.poll(n.id, { thread_id: n.thread_id }, t);
|
|
2597
2669
|
}
|
|
2598
2670
|
createAndRunStream(e, t) {
|
|
2599
|
-
return
|
|
2671
|
+
return Pr.createThreadAssistantStream(e, this._client.beta.threads, t);
|
|
2600
2672
|
}
|
|
2601
2673
|
};
|
|
2602
|
-
|
|
2674
|
+
Ir.Runs = Fr, Ir.Messages = hr;
|
|
2603
2675
|
//#endregion
|
|
2604
2676
|
//#region node_modules/openai/resources/beta/beta.mjs
|
|
2605
|
-
var
|
|
2677
|
+
var Lr = class extends P {
|
|
2606
2678
|
constructor() {
|
|
2607
|
-
super(...arguments), this.realtime = new
|
|
2679
|
+
super(...arguments), this.realtime = new dr(this._client), this.chatkit = new mr(this._client), this.assistants = new cr(this._client), this.threads = new Ir(this._client);
|
|
2608
2680
|
}
|
|
2609
2681
|
};
|
|
2610
|
-
|
|
2682
|
+
Lr.Realtime = dr, Lr.ChatKit = mr, Lr.Assistants = cr, Lr.Threads = Ir;
|
|
2611
2683
|
//#endregion
|
|
2612
2684
|
//#region node_modules/openai/resources/completions.mjs
|
|
2613
|
-
var
|
|
2685
|
+
var Rr = class extends P {
|
|
2614
2686
|
create(e, t) {
|
|
2615
2687
|
return this._client.post("/completions", {
|
|
2616
2688
|
body: e,
|
|
@@ -2618,21 +2690,21 @@ var Pr = class extends P {
|
|
|
2618
2690
|
stream: e.stream ?? !1
|
|
2619
2691
|
});
|
|
2620
2692
|
}
|
|
2621
|
-
},
|
|
2693
|
+
}, zr = class extends P {
|
|
2622
2694
|
retrieve(e, t, n) {
|
|
2623
2695
|
let { container_id: r } = t;
|
|
2624
2696
|
return this._client.get(F`/containers/${r}/files/${e}/content`, {
|
|
2625
2697
|
...n,
|
|
2626
|
-
headers:
|
|
2698
|
+
headers: U([{ Accept: "application/binary" }, n?.headers]),
|
|
2627
2699
|
__binaryResponse: !0
|
|
2628
2700
|
});
|
|
2629
2701
|
}
|
|
2630
|
-
},
|
|
2702
|
+
}, Br = class extends P {
|
|
2631
2703
|
constructor() {
|
|
2632
|
-
super(...arguments), this.content = new
|
|
2704
|
+
super(...arguments), this.content = new zr(this._client);
|
|
2633
2705
|
}
|
|
2634
2706
|
create(e, t, n) {
|
|
2635
|
-
return this._client.post(F`/containers/${e}/files`,
|
|
2707
|
+
return this._client.post(F`/containers/${e}/files`, St({
|
|
2636
2708
|
body: t,
|
|
2637
2709
|
...n
|
|
2638
2710
|
}, this._client));
|
|
@@ -2651,16 +2723,16 @@ var Pr = class extends P {
|
|
|
2651
2723
|
let { container_id: r } = t;
|
|
2652
2724
|
return this._client.delete(F`/containers/${r}/files/${e}`, {
|
|
2653
2725
|
...n,
|
|
2654
|
-
headers:
|
|
2726
|
+
headers: U([{ Accept: "*/*" }, n?.headers])
|
|
2655
2727
|
});
|
|
2656
2728
|
}
|
|
2657
2729
|
};
|
|
2658
|
-
|
|
2730
|
+
Br.Content = zr;
|
|
2659
2731
|
//#endregion
|
|
2660
2732
|
//#region node_modules/openai/resources/containers/containers.mjs
|
|
2661
|
-
var
|
|
2733
|
+
var Vr = class extends P {
|
|
2662
2734
|
constructor() {
|
|
2663
|
-
super(...arguments), this.files = new
|
|
2735
|
+
super(...arguments), this.files = new Br(this._client);
|
|
2664
2736
|
}
|
|
2665
2737
|
create(e, t) {
|
|
2666
2738
|
return this._client.post("/containers", {
|
|
@@ -2680,14 +2752,14 @@ var Lr = class extends P {
|
|
|
2680
2752
|
delete(e, t) {
|
|
2681
2753
|
return this._client.delete(F`/containers/${e}`, {
|
|
2682
2754
|
...t,
|
|
2683
|
-
headers:
|
|
2755
|
+
headers: U([{ Accept: "*/*" }, t?.headers])
|
|
2684
2756
|
});
|
|
2685
2757
|
}
|
|
2686
2758
|
};
|
|
2687
|
-
|
|
2759
|
+
Vr.Files = Br;
|
|
2688
2760
|
//#endregion
|
|
2689
2761
|
//#region node_modules/openai/resources/conversations/items.mjs
|
|
2690
|
-
var
|
|
2762
|
+
var Hr = class extends P {
|
|
2691
2763
|
create(e, t, n) {
|
|
2692
2764
|
let { include: r, ...i } = t;
|
|
2693
2765
|
return this._client.post(F`/conversations/${e}/items`, {
|
|
@@ -2704,7 +2776,7 @@ var Rr = class extends P {
|
|
|
2704
2776
|
});
|
|
2705
2777
|
}
|
|
2706
2778
|
list(e, t = {}, n) {
|
|
2707
|
-
return this._client.getAPIList(F`/conversations/${e}/items`,
|
|
2779
|
+
return this._client.getAPIList(F`/conversations/${e}/items`, mt, {
|
|
2708
2780
|
query: t,
|
|
2709
2781
|
...n
|
|
2710
2782
|
});
|
|
@@ -2713,9 +2785,9 @@ var Rr = class extends P {
|
|
|
2713
2785
|
let { conversation_id: r } = t;
|
|
2714
2786
|
return this._client.delete(F`/conversations/${r}/items/${e}`, n);
|
|
2715
2787
|
}
|
|
2716
|
-
},
|
|
2788
|
+
}, Ur = class extends P {
|
|
2717
2789
|
constructor() {
|
|
2718
|
-
super(...arguments), this.items = new
|
|
2790
|
+
super(...arguments), this.items = new Hr(this._client);
|
|
2719
2791
|
}
|
|
2720
2792
|
create(e = {}, t) {
|
|
2721
2793
|
return this._client.post("/conversations", {
|
|
@@ -2736,10 +2808,10 @@ var Rr = class extends P {
|
|
|
2736
2808
|
return this._client.delete(F`/conversations/${e}`, t);
|
|
2737
2809
|
}
|
|
2738
2810
|
};
|
|
2739
|
-
|
|
2811
|
+
Ur.Items = Hr;
|
|
2740
2812
|
//#endregion
|
|
2741
2813
|
//#region node_modules/openai/resources/embeddings.mjs
|
|
2742
|
-
var
|
|
2814
|
+
var Wr = class extends P {
|
|
2743
2815
|
create(e, t) {
|
|
2744
2816
|
let n = !!e.encoding_format, r = n ? e.encoding_format : "base64";
|
|
2745
2817
|
n && A(this._client).debug("embeddings/user defined encoding_format:", e.encoding_format);
|
|
@@ -2752,10 +2824,10 @@ var Br = class extends P {
|
|
|
2752
2824
|
});
|
|
2753
2825
|
return n ? i : (A(this._client).debug("embeddings/decoding base64 embeddings from base64"), i._thenUnwrap((e) => (e && e.data && e.data.forEach((e) => {
|
|
2754
2826
|
let t = e.embedding;
|
|
2755
|
-
e.embedding =
|
|
2827
|
+
e.embedding = _r(t);
|
|
2756
2828
|
}), e)));
|
|
2757
2829
|
}
|
|
2758
|
-
},
|
|
2830
|
+
}, Gr = class extends P {
|
|
2759
2831
|
retrieve(e, t, n) {
|
|
2760
2832
|
let { eval_id: r, run_id: i } = t;
|
|
2761
2833
|
return this._client.get(F`/evals/${r}/runs/${i}/output_items/${e}`, n);
|
|
@@ -2767,9 +2839,9 @@ var Br = class extends P {
|
|
|
2767
2839
|
...n
|
|
2768
2840
|
});
|
|
2769
2841
|
}
|
|
2770
|
-
},
|
|
2842
|
+
}, Kr = class extends P {
|
|
2771
2843
|
constructor() {
|
|
2772
|
-
super(...arguments), this.outputItems = new
|
|
2844
|
+
super(...arguments), this.outputItems = new Gr(this._client);
|
|
2773
2845
|
}
|
|
2774
2846
|
create(e, t, n) {
|
|
2775
2847
|
return this._client.post(F`/evals/${e}/runs`, {
|
|
@@ -2796,12 +2868,12 @@ var Br = class extends P {
|
|
|
2796
2868
|
return this._client.post(F`/evals/${r}/runs/${e}`, n);
|
|
2797
2869
|
}
|
|
2798
2870
|
};
|
|
2799
|
-
|
|
2871
|
+
Kr.OutputItems = Gr;
|
|
2800
2872
|
//#endregion
|
|
2801
2873
|
//#region node_modules/openai/resources/evals/evals.mjs
|
|
2802
|
-
var
|
|
2874
|
+
var qr = class extends P {
|
|
2803
2875
|
constructor() {
|
|
2804
|
-
super(...arguments), this.runs = new
|
|
2876
|
+
super(...arguments), this.runs = new Kr(this._client);
|
|
2805
2877
|
}
|
|
2806
2878
|
create(e, t) {
|
|
2807
2879
|
return this._client.post("/evals", {
|
|
@@ -2828,10 +2900,10 @@ var Ur = class extends P {
|
|
|
2828
2900
|
return this._client.delete(F`/evals/${e}`, t);
|
|
2829
2901
|
}
|
|
2830
2902
|
};
|
|
2831
|
-
|
|
2903
|
+
qr.Runs = Kr;
|
|
2832
2904
|
//#endregion
|
|
2833
2905
|
//#region node_modules/openai/resources/files.mjs
|
|
2834
|
-
var
|
|
2906
|
+
var Jr = class extends P {
|
|
2835
2907
|
create(e, t) {
|
|
2836
2908
|
return this._client.post("/files", N({
|
|
2837
2909
|
body: e,
|
|
@@ -2853,7 +2925,7 @@ var Wr = class extends P {
|
|
|
2853
2925
|
content(e, t) {
|
|
2854
2926
|
return this._client.get(F`/files/${e}/content`, {
|
|
2855
2927
|
...t,
|
|
2856
|
-
headers:
|
|
2928
|
+
headers: U([{ Accept: "application/binary" }, t?.headers]),
|
|
2857
2929
|
__binaryResponse: !0
|
|
2858
2930
|
});
|
|
2859
2931
|
}
|
|
@@ -2863,10 +2935,10 @@ var Wr = class extends P {
|
|
|
2863
2935
|
"error",
|
|
2864
2936
|
"deleted"
|
|
2865
2937
|
]), i = Date.now(), a = await this.retrieve(e);
|
|
2866
|
-
for (; !a.status || !r.has(a.status);) if (await
|
|
2938
|
+
for (; !a.status || !r.has(a.status);) if (await se(t), a = await this.retrieve(e), Date.now() - i > n) throw new l({ message: `Giving up on waiting for file ${e} to finish processing after ${n} milliseconds.` });
|
|
2867
2939
|
return a;
|
|
2868
2940
|
}
|
|
2869
|
-
},
|
|
2941
|
+
}, Yr = class extends P {}, Xr = class extends P {
|
|
2870
2942
|
run(e, t) {
|
|
2871
2943
|
return this._client.post("/fine_tuning/alpha/graders/run", {
|
|
2872
2944
|
body: e,
|
|
@@ -2879,17 +2951,17 @@ var Wr = class extends P {
|
|
|
2879
2951
|
...t
|
|
2880
2952
|
});
|
|
2881
2953
|
}
|
|
2882
|
-
},
|
|
2954
|
+
}, Zr = class extends P {
|
|
2883
2955
|
constructor() {
|
|
2884
|
-
super(...arguments), this.graders = new
|
|
2956
|
+
super(...arguments), this.graders = new Xr(this._client);
|
|
2885
2957
|
}
|
|
2886
2958
|
};
|
|
2887
|
-
|
|
2959
|
+
Zr.Graders = Xr;
|
|
2888
2960
|
//#endregion
|
|
2889
2961
|
//#region node_modules/openai/resources/fine-tuning/checkpoints/permissions.mjs
|
|
2890
|
-
var
|
|
2962
|
+
var Qr = class extends P {
|
|
2891
2963
|
create(e, t, n) {
|
|
2892
|
-
return this._client.getAPIList(F`/fine_tuning/checkpoints/${e}/permissions`,
|
|
2964
|
+
return this._client.getAPIList(F`/fine_tuning/checkpoints/${e}/permissions`, pt, {
|
|
2893
2965
|
body: t,
|
|
2894
2966
|
method: "post",
|
|
2895
2967
|
...n
|
|
@@ -2902,7 +2974,7 @@ var Jr = class extends P {
|
|
|
2902
2974
|
});
|
|
2903
2975
|
}
|
|
2904
2976
|
list(e, t = {}, n) {
|
|
2905
|
-
return this._client.getAPIList(F`/fine_tuning/checkpoints/${e}/permissions`,
|
|
2977
|
+
return this._client.getAPIList(F`/fine_tuning/checkpoints/${e}/permissions`, mt, {
|
|
2906
2978
|
query: t,
|
|
2907
2979
|
...n
|
|
2908
2980
|
});
|
|
@@ -2911,24 +2983,24 @@ var Jr = class extends P {
|
|
|
2911
2983
|
let { fine_tuned_model_checkpoint: r } = t;
|
|
2912
2984
|
return this._client.delete(F`/fine_tuning/checkpoints/${r}/permissions/${e}`, n);
|
|
2913
2985
|
}
|
|
2914
|
-
},
|
|
2986
|
+
}, $r = class extends P {
|
|
2915
2987
|
constructor() {
|
|
2916
|
-
super(...arguments), this.permissions = new
|
|
2988
|
+
super(...arguments), this.permissions = new Qr(this._client);
|
|
2917
2989
|
}
|
|
2918
2990
|
};
|
|
2919
|
-
|
|
2991
|
+
$r.Permissions = Qr;
|
|
2920
2992
|
//#endregion
|
|
2921
2993
|
//#region node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs
|
|
2922
|
-
var
|
|
2994
|
+
var ei = class extends P {
|
|
2923
2995
|
list(e, t = {}, n) {
|
|
2924
2996
|
return this._client.getAPIList(F`/fine_tuning/jobs/${e}/checkpoints`, M, {
|
|
2925
2997
|
query: t,
|
|
2926
2998
|
...n
|
|
2927
2999
|
});
|
|
2928
3000
|
}
|
|
2929
|
-
},
|
|
3001
|
+
}, ti = class extends P {
|
|
2930
3002
|
constructor() {
|
|
2931
|
-
super(...arguments), this.checkpoints = new
|
|
3003
|
+
super(...arguments), this.checkpoints = new ei(this._client);
|
|
2932
3004
|
}
|
|
2933
3005
|
create(e, t) {
|
|
2934
3006
|
return this._client.post("/fine_tuning/jobs", {
|
|
@@ -2961,26 +3033,26 @@ var Xr = class extends P {
|
|
|
2961
3033
|
return this._client.post(F`/fine_tuning/jobs/${e}/resume`, t);
|
|
2962
3034
|
}
|
|
2963
3035
|
};
|
|
2964
|
-
|
|
3036
|
+
ti.Checkpoints = ei;
|
|
2965
3037
|
//#endregion
|
|
2966
3038
|
//#region node_modules/openai/resources/fine-tuning/fine-tuning.mjs
|
|
2967
|
-
var
|
|
3039
|
+
var ni = class extends P {
|
|
2968
3040
|
constructor() {
|
|
2969
|
-
super(...arguments), this.methods = new
|
|
3041
|
+
super(...arguments), this.methods = new Yr(this._client), this.jobs = new ti(this._client), this.checkpoints = new $r(this._client), this.alpha = new Zr(this._client);
|
|
2970
3042
|
}
|
|
2971
3043
|
};
|
|
2972
|
-
|
|
3044
|
+
ni.Methods = Yr, ni.Jobs = ti, ni.Checkpoints = $r, ni.Alpha = Zr;
|
|
2973
3045
|
//#endregion
|
|
2974
3046
|
//#region node_modules/openai/resources/graders/grader-models.mjs
|
|
2975
|
-
var
|
|
3047
|
+
var ri = class extends P {}, ii = class extends P {
|
|
2976
3048
|
constructor() {
|
|
2977
|
-
super(...arguments), this.graderModels = new
|
|
3049
|
+
super(...arguments), this.graderModels = new ri(this._client);
|
|
2978
3050
|
}
|
|
2979
3051
|
};
|
|
2980
|
-
|
|
3052
|
+
ii.GraderModels = ri;
|
|
2981
3053
|
//#endregion
|
|
2982
3054
|
//#region node_modules/openai/resources/images.mjs
|
|
2983
|
-
var
|
|
3055
|
+
var ai = class extends P {
|
|
2984
3056
|
createVariation(e, t) {
|
|
2985
3057
|
return this._client.post("/images/variations", N({
|
|
2986
3058
|
body: e,
|
|
@@ -3001,68 +3073,68 @@ var ti = class extends P {
|
|
|
3001
3073
|
stream: e.stream ?? !1
|
|
3002
3074
|
});
|
|
3003
3075
|
}
|
|
3004
|
-
},
|
|
3076
|
+
}, oi = class extends P {
|
|
3005
3077
|
retrieve(e, t) {
|
|
3006
3078
|
return this._client.get(F`/models/${e}`, t);
|
|
3007
3079
|
}
|
|
3008
3080
|
list(e) {
|
|
3009
|
-
return this._client.getAPIList("/models",
|
|
3081
|
+
return this._client.getAPIList("/models", pt, e);
|
|
3010
3082
|
}
|
|
3011
3083
|
delete(e, t) {
|
|
3012
3084
|
return this._client.delete(F`/models/${e}`, t);
|
|
3013
3085
|
}
|
|
3014
|
-
},
|
|
3086
|
+
}, si = class extends P {
|
|
3015
3087
|
create(e, t) {
|
|
3016
3088
|
return this._client.post("/moderations", {
|
|
3017
3089
|
body: e,
|
|
3018
3090
|
...t
|
|
3019
3091
|
});
|
|
3020
3092
|
}
|
|
3021
|
-
},
|
|
3093
|
+
}, ci = class extends P {
|
|
3022
3094
|
accept(e, t, n) {
|
|
3023
3095
|
return this._client.post(F`/realtime/calls/${e}/accept`, {
|
|
3024
3096
|
body: t,
|
|
3025
3097
|
...n,
|
|
3026
|
-
headers:
|
|
3098
|
+
headers: U([{ Accept: "*/*" }, n?.headers])
|
|
3027
3099
|
});
|
|
3028
3100
|
}
|
|
3029
3101
|
hangup(e, t) {
|
|
3030
3102
|
return this._client.post(F`/realtime/calls/${e}/hangup`, {
|
|
3031
3103
|
...t,
|
|
3032
|
-
headers:
|
|
3104
|
+
headers: U([{ Accept: "*/*" }, t?.headers])
|
|
3033
3105
|
});
|
|
3034
3106
|
}
|
|
3035
3107
|
refer(e, t, n) {
|
|
3036
3108
|
return this._client.post(F`/realtime/calls/${e}/refer`, {
|
|
3037
3109
|
body: t,
|
|
3038
3110
|
...n,
|
|
3039
|
-
headers:
|
|
3111
|
+
headers: U([{ Accept: "*/*" }, n?.headers])
|
|
3040
3112
|
});
|
|
3041
3113
|
}
|
|
3042
3114
|
reject(e, t = {}, n) {
|
|
3043
3115
|
return this._client.post(F`/realtime/calls/${e}/reject`, {
|
|
3044
3116
|
body: t,
|
|
3045
3117
|
...n,
|
|
3046
|
-
headers:
|
|
3118
|
+
headers: U([{ Accept: "*/*" }, n?.headers])
|
|
3047
3119
|
});
|
|
3048
3120
|
}
|
|
3049
|
-
},
|
|
3121
|
+
}, li = class extends P {
|
|
3050
3122
|
create(e, t) {
|
|
3051
3123
|
return this._client.post("/realtime/client_secrets", {
|
|
3052
3124
|
body: e,
|
|
3053
3125
|
...t
|
|
3054
3126
|
});
|
|
3055
3127
|
}
|
|
3056
|
-
},
|
|
3128
|
+
}, ui = class extends P {
|
|
3057
3129
|
constructor() {
|
|
3058
|
-
super(...arguments), this.clientSecrets = new
|
|
3130
|
+
super(...arguments), this.clientSecrets = new li(this._client), this.calls = new ci(this._client);
|
|
3059
3131
|
}
|
|
3060
3132
|
};
|
|
3061
|
-
|
|
3133
|
+
ui.ClientSecrets = li, ui.Calls = ci;
|
|
3062
3134
|
//#endregion
|
|
3063
3135
|
//#region node_modules/openai/lib/ResponsesParser.mjs
|
|
3064
|
-
function
|
|
3065
|
-
return !t || !
|
|
3136
|
+
function di(e, t) {
|
|
3137
|
+
return !t || !mi(t) ? {
|
|
3066
3138
|
...e,
|
|
3067
3139
|
output_parsed: null,
|
|
3068
3140
|
output: e.output.map((e) => e.type === "function_call" ? {
|
|
@@ -3075,18 +3147,18 @@ function si(e, t) {
|
|
|
3075
3147
|
parsed: null
|
|
3076
3148
|
}))
|
|
3077
3149
|
} : e)
|
|
3078
|
-
} :
|
|
3150
|
+
} : fi(e, t);
|
|
3079
3151
|
}
|
|
3080
|
-
function
|
|
3152
|
+
function fi(e, t) {
|
|
3081
3153
|
let n = e.output.map((e) => {
|
|
3082
3154
|
if (e.type === "function_call") return {
|
|
3083
3155
|
...e,
|
|
3084
|
-
parsed_arguments:
|
|
3156
|
+
parsed_arguments: _i(t, e)
|
|
3085
3157
|
};
|
|
3086
3158
|
if (e.type === "message") {
|
|
3087
3159
|
let n = e.content.map((e) => e.type === "output_text" ? {
|
|
3088
3160
|
...e,
|
|
3089
|
-
parsed:
|
|
3161
|
+
parsed: pi(t, e.text)
|
|
3090
3162
|
} : e);
|
|
3091
3163
|
return {
|
|
3092
3164
|
...e,
|
|
@@ -3095,7 +3167,7 @@ function ci(e, t) {
|
|
|
3095
3167
|
}
|
|
3096
3168
|
return e;
|
|
3097
3169
|
}), r = Object.assign({}, e, { output: n });
|
|
3098
|
-
return Object.getOwnPropertyDescriptor(e, "output_text") ||
|
|
3170
|
+
return Object.getOwnPropertyDescriptor(e, "output_text") || vi(r), Object.defineProperty(r, "output_parsed", {
|
|
3099
3171
|
enumerable: !0,
|
|
3100
3172
|
get() {
|
|
3101
3173
|
for (let e of r.output) if (e.type === "message") {
|
|
@@ -3105,36 +3177,36 @@ function ci(e, t) {
|
|
|
3105
3177
|
}
|
|
3106
3178
|
}), r;
|
|
3107
3179
|
}
|
|
3108
|
-
function
|
|
3180
|
+
function pi(e, t) {
|
|
3109
3181
|
return e.text?.format?.type === "json_schema" ? "$parseRaw" in e.text?.format ? (e.text?.format).$parseRaw(t) : JSON.parse(t) : null;
|
|
3110
3182
|
}
|
|
3111
|
-
function
|
|
3112
|
-
return !!
|
|
3183
|
+
function mi(e) {
|
|
3184
|
+
return !!Bt(e.text?.format);
|
|
3113
3185
|
}
|
|
3114
|
-
function
|
|
3186
|
+
function hi(e) {
|
|
3115
3187
|
return e?.$brand === "auto-parseable-tool";
|
|
3116
3188
|
}
|
|
3117
|
-
function
|
|
3189
|
+
function gi(e, t) {
|
|
3118
3190
|
return e.find((e) => e.type === "function" && e.name === t);
|
|
3119
3191
|
}
|
|
3120
|
-
function
|
|
3121
|
-
let n =
|
|
3192
|
+
function _i(e, t) {
|
|
3193
|
+
let n = gi(e.tools ?? [], t.name);
|
|
3122
3194
|
return {
|
|
3123
3195
|
...t,
|
|
3124
3196
|
...t,
|
|
3125
|
-
parsed_arguments:
|
|
3197
|
+
parsed_arguments: hi(n) ? n.$parseRaw(t.arguments) : n?.strict ? JSON.parse(t.arguments) : null
|
|
3126
3198
|
};
|
|
3127
3199
|
}
|
|
3128
|
-
function
|
|
3200
|
+
function vi(e) {
|
|
3129
3201
|
let t = [];
|
|
3130
3202
|
for (let n of e.output) if (n.type === "message") for (let e of n.content) e.type === "output_text" && t.push(e.text);
|
|
3131
3203
|
e.output_text = t.join("");
|
|
3132
3204
|
}
|
|
3133
3205
|
//#endregion
|
|
3134
3206
|
//#region node_modules/openai/lib/responses/ResponseStream.mjs
|
|
3135
|
-
var
|
|
3207
|
+
var yi, bi, Q, xi, Si, Ci, wi, Ti, Ei = class n extends un {
|
|
3136
3208
|
constructor(t) {
|
|
3137
|
-
super(),
|
|
3209
|
+
super(), yi.add(this), bi.set(this, void 0), Q.set(this, void 0), xi.set(this, void 0), e(this, bi, t, "f");
|
|
3138
3210
|
}
|
|
3139
3211
|
static createResponse(e, t, r) {
|
|
3140
3212
|
let i = new n(t);
|
|
@@ -3148,7 +3220,7 @@ var hi, gi, Z, _i, vi, yi, bi, xi, Si = class n extends on {
|
|
|
3148
3220
|
}
|
|
3149
3221
|
async _createOrRetrieveResponse(e, n, r) {
|
|
3150
3222
|
let i = r?.signal;
|
|
3151
|
-
i && (i.aborted && this.controller.abort(), i.addEventListener("abort", () => this.controller.abort())), t(this,
|
|
3223
|
+
i && (i.aborted && this.controller.abort(), i.addEventListener("abort", () => this.controller.abort())), t(this, yi, "m", Si).call(this);
|
|
3152
3224
|
let a, o = null;
|
|
3153
3225
|
"response_id" in n ? (a = await e.responses.retrieve(n.response_id, { stream: !0 }, {
|
|
3154
3226
|
...r,
|
|
@@ -3161,17 +3233,17 @@ var hi, gi, Z, _i, vi, yi, bi, xi, Si = class n extends on {
|
|
|
3161
3233
|
...r,
|
|
3162
3234
|
signal: this.controller.signal
|
|
3163
3235
|
}), this._connected();
|
|
3164
|
-
for await (let e of a) t(this,
|
|
3236
|
+
for await (let e of a) t(this, yi, "m", Ci).call(this, e, o);
|
|
3165
3237
|
if (a.controller.signal?.aborted) throw new s();
|
|
3166
|
-
return t(this,
|
|
3238
|
+
return t(this, yi, "m", wi).call(this);
|
|
3167
3239
|
}
|
|
3168
|
-
[(
|
|
3169
|
-
this.ended || e(this,
|
|
3170
|
-
},
|
|
3240
|
+
[(bi = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), xi = /* @__PURE__ */ new WeakMap(), yi = /* @__PURE__ */ new WeakSet(), Si = function() {
|
|
3241
|
+
this.ended || e(this, Q, void 0, "f");
|
|
3242
|
+
}, Ci = function(e, n) {
|
|
3171
3243
|
if (this.ended) return;
|
|
3172
3244
|
let r = (e, t) => {
|
|
3173
3245
|
(n == null || t.sequence_number > n) && this._emit(e, t);
|
|
3174
|
-
}, i = t(this,
|
|
3246
|
+
}, i = t(this, yi, "m", Ti).call(this, e);
|
|
3175
3247
|
switch (r("event", e), e.type) {
|
|
3176
3248
|
case "response.output_text.delta": {
|
|
3177
3249
|
let t = i.output[e.output_index];
|
|
@@ -3200,18 +3272,18 @@ var hi, gi, Z, _i, vi, yi, bi, xi, Si = class n extends on {
|
|
|
3200
3272
|
r(e.type, e);
|
|
3201
3273
|
break;
|
|
3202
3274
|
}
|
|
3203
|
-
},
|
|
3275
|
+
}, wi = function() {
|
|
3204
3276
|
if (this.ended) throw new a("stream has ended, this shouldn't happen");
|
|
3205
|
-
let n = t(this,
|
|
3277
|
+
let n = t(this, Q, "f");
|
|
3206
3278
|
if (!n) throw new a("request ended without sending any events");
|
|
3207
|
-
e(this,
|
|
3208
|
-
let r =
|
|
3209
|
-
return e(this,
|
|
3210
|
-
},
|
|
3211
|
-
let r = t(this,
|
|
3279
|
+
e(this, Q, void 0, "f");
|
|
3280
|
+
let r = Di(n, t(this, bi, "f"));
|
|
3281
|
+
return e(this, xi, r, "f"), r;
|
|
3282
|
+
}, Ti = function(n) {
|
|
3283
|
+
let r = t(this, Q, "f");
|
|
3212
3284
|
if (!r) {
|
|
3213
3285
|
if (n.type !== "response.created") throw new a(`When snapshot hasn't been set yet, expected 'response.created' event, got ${n.type}`);
|
|
3214
|
-
return r = e(this,
|
|
3286
|
+
return r = e(this, Q, n.response, "f"), r;
|
|
3215
3287
|
}
|
|
3216
3288
|
switch (n.type) {
|
|
3217
3289
|
case "response.output_item.added":
|
|
@@ -3253,7 +3325,7 @@ var hi, gi, Z, _i, vi, yi, bi, xi, Si = class n extends on {
|
|
|
3253
3325
|
break;
|
|
3254
3326
|
}
|
|
3255
3327
|
case "response.completed":
|
|
3256
|
-
e(this,
|
|
3328
|
+
e(this, Q, n.response, "f");
|
|
3257
3329
|
break;
|
|
3258
3330
|
}
|
|
3259
3331
|
return r;
|
|
@@ -3299,59 +3371,59 @@ var hi, gi, Z, _i, vi, yi, bi, xi, Si = class n extends on {
|
|
|
3299
3371
|
}
|
|
3300
3372
|
async finalResponse() {
|
|
3301
3373
|
await this.done();
|
|
3302
|
-
let e = t(this,
|
|
3374
|
+
let e = t(this, xi, "f");
|
|
3303
3375
|
if (!e) throw new a("stream ended without producing a ChatCompletion");
|
|
3304
3376
|
return e;
|
|
3305
3377
|
}
|
|
3306
3378
|
};
|
|
3307
|
-
function
|
|
3308
|
-
return
|
|
3379
|
+
function Di(e, t) {
|
|
3380
|
+
return di(e, t);
|
|
3309
3381
|
}
|
|
3310
3382
|
//#endregion
|
|
3311
3383
|
//#region node_modules/openai/resources/responses/input-items.mjs
|
|
3312
|
-
var
|
|
3384
|
+
var Oi = class extends P {
|
|
3313
3385
|
list(e, t = {}, n) {
|
|
3314
3386
|
return this._client.getAPIList(F`/responses/${e}/input_items`, M, {
|
|
3315
3387
|
query: t,
|
|
3316
3388
|
...n
|
|
3317
3389
|
});
|
|
3318
3390
|
}
|
|
3319
|
-
},
|
|
3391
|
+
}, ki = class extends P {
|
|
3320
3392
|
count(e = {}, t) {
|
|
3321
3393
|
return this._client.post("/responses/input_tokens", {
|
|
3322
3394
|
body: e,
|
|
3323
3395
|
...t
|
|
3324
3396
|
});
|
|
3325
3397
|
}
|
|
3326
|
-
},
|
|
3398
|
+
}, Ai = class extends P {
|
|
3327
3399
|
constructor() {
|
|
3328
|
-
super(...arguments), this.inputItems = new
|
|
3400
|
+
super(...arguments), this.inputItems = new Oi(this._client), this.inputTokens = new ki(this._client);
|
|
3329
3401
|
}
|
|
3330
3402
|
create(e, t) {
|
|
3331
3403
|
return this._client.post("/responses", {
|
|
3332
3404
|
body: e,
|
|
3333
3405
|
...t,
|
|
3334
3406
|
stream: e.stream ?? !1
|
|
3335
|
-
})._thenUnwrap((e) => ("object" in e && e.object === "response" &&
|
|
3407
|
+
})._thenUnwrap((e) => ("object" in e && e.object === "response" && vi(e), e));
|
|
3336
3408
|
}
|
|
3337
3409
|
retrieve(e, t = {}, n) {
|
|
3338
3410
|
return this._client.get(F`/responses/${e}`, {
|
|
3339
3411
|
query: t,
|
|
3340
3412
|
...n,
|
|
3341
3413
|
stream: t?.stream ?? !1
|
|
3342
|
-
})._thenUnwrap((e) => ("object" in e && e.object === "response" &&
|
|
3414
|
+
})._thenUnwrap((e) => ("object" in e && e.object === "response" && vi(e), e));
|
|
3343
3415
|
}
|
|
3344
3416
|
delete(e, t) {
|
|
3345
3417
|
return this._client.delete(F`/responses/${e}`, {
|
|
3346
3418
|
...t,
|
|
3347
|
-
headers:
|
|
3419
|
+
headers: U([{ Accept: "*/*" }, t?.headers])
|
|
3348
3420
|
});
|
|
3349
3421
|
}
|
|
3350
3422
|
parse(e, t) {
|
|
3351
|
-
return this._client.responses.create(e, t)._thenUnwrap((t) =>
|
|
3423
|
+
return this._client.responses.create(e, t)._thenUnwrap((t) => fi(t, e));
|
|
3352
3424
|
}
|
|
3353
3425
|
stream(e, t) {
|
|
3354
|
-
return
|
|
3426
|
+
return Ei.createResponse(this._client, e, t);
|
|
3355
3427
|
}
|
|
3356
3428
|
cancel(e, t) {
|
|
3357
3429
|
return this._client.post(F`/responses/${e}/cancel`, t);
|
|
@@ -3363,32 +3435,32 @@ var wi = class extends P {
|
|
|
3363
3435
|
});
|
|
3364
3436
|
}
|
|
3365
3437
|
};
|
|
3366
|
-
|
|
3438
|
+
Ai.InputItems = Oi, Ai.InputTokens = ki;
|
|
3367
3439
|
//#endregion
|
|
3368
3440
|
//#region node_modules/openai/resources/skills/content.mjs
|
|
3369
|
-
var
|
|
3441
|
+
var ji = class extends P {
|
|
3370
3442
|
retrieve(e, t) {
|
|
3371
3443
|
return this._client.get(F`/skills/${e}/content`, {
|
|
3372
3444
|
...t,
|
|
3373
|
-
headers:
|
|
3445
|
+
headers: U([{ Accept: "application/binary" }, t?.headers]),
|
|
3374
3446
|
__binaryResponse: !0
|
|
3375
3447
|
});
|
|
3376
3448
|
}
|
|
3377
|
-
},
|
|
3449
|
+
}, Mi = class extends P {
|
|
3378
3450
|
retrieve(e, t, n) {
|
|
3379
3451
|
let { skill_id: r } = t;
|
|
3380
3452
|
return this._client.get(F`/skills/${r}/versions/${e}/content`, {
|
|
3381
3453
|
...n,
|
|
3382
|
-
headers:
|
|
3454
|
+
headers: U([{ Accept: "application/binary" }, n?.headers]),
|
|
3383
3455
|
__binaryResponse: !0
|
|
3384
3456
|
});
|
|
3385
3457
|
}
|
|
3386
|
-
},
|
|
3458
|
+
}, Ni = class extends P {
|
|
3387
3459
|
constructor() {
|
|
3388
|
-
super(...arguments), this.content = new
|
|
3460
|
+
super(...arguments), this.content = new Mi(this._client);
|
|
3389
3461
|
}
|
|
3390
3462
|
create(e, t = {}, n) {
|
|
3391
|
-
return this._client.post(F`/skills/${e}/versions`,
|
|
3463
|
+
return this._client.post(F`/skills/${e}/versions`, St({
|
|
3392
3464
|
body: t,
|
|
3393
3465
|
...n
|
|
3394
3466
|
}, this._client));
|
|
@@ -3408,15 +3480,15 @@ var Di = class extends P {
|
|
|
3408
3480
|
return this._client.delete(F`/skills/${r}/versions/${e}`, n);
|
|
3409
3481
|
}
|
|
3410
3482
|
};
|
|
3411
|
-
|
|
3483
|
+
Ni.Content = Mi;
|
|
3412
3484
|
//#endregion
|
|
3413
3485
|
//#region node_modules/openai/resources/skills/skills.mjs
|
|
3414
|
-
var
|
|
3486
|
+
var Pi = class extends P {
|
|
3415
3487
|
constructor() {
|
|
3416
|
-
super(...arguments), this.content = new
|
|
3488
|
+
super(...arguments), this.content = new ji(this._client), this.versions = new Ni(this._client);
|
|
3417
3489
|
}
|
|
3418
3490
|
create(e = {}, t) {
|
|
3419
|
-
return this._client.post("/skills",
|
|
3491
|
+
return this._client.post("/skills", St({
|
|
3420
3492
|
body: e,
|
|
3421
3493
|
...t
|
|
3422
3494
|
}, this._client));
|
|
@@ -3440,19 +3512,19 @@ var Ai = class extends P {
|
|
|
3440
3512
|
return this._client.delete(F`/skills/${e}`, t);
|
|
3441
3513
|
}
|
|
3442
3514
|
};
|
|
3443
|
-
|
|
3515
|
+
Pi.Content = ji, Pi.Versions = Ni;
|
|
3444
3516
|
//#endregion
|
|
3445
3517
|
//#region node_modules/openai/resources/uploads/parts.mjs
|
|
3446
|
-
var
|
|
3518
|
+
var Fi = class extends P {
|
|
3447
3519
|
create(e, t, n) {
|
|
3448
3520
|
return this._client.post(F`/uploads/${e}/parts`, N({
|
|
3449
3521
|
body: t,
|
|
3450
3522
|
...n
|
|
3451
3523
|
}, this._client));
|
|
3452
3524
|
}
|
|
3453
|
-
},
|
|
3525
|
+
}, Ii = class extends P {
|
|
3454
3526
|
constructor() {
|
|
3455
|
-
super(...arguments), this.parts = new
|
|
3527
|
+
super(...arguments), this.parts = new Fi(this._client);
|
|
3456
3528
|
}
|
|
3457
3529
|
create(e, t) {
|
|
3458
3530
|
return this._client.post("/uploads", {
|
|
@@ -3470,10 +3542,10 @@ var ji = class extends P {
|
|
|
3470
3542
|
});
|
|
3471
3543
|
}
|
|
3472
3544
|
};
|
|
3473
|
-
|
|
3545
|
+
Ii.Parts = Fi;
|
|
3474
3546
|
//#endregion
|
|
3475
3547
|
//#region node_modules/openai/lib/Util.mjs
|
|
3476
|
-
var
|
|
3548
|
+
var Li = async (e) => {
|
|
3477
3549
|
let t = await Promise.allSettled(e), n = t.filter((e) => e.status === "rejected");
|
|
3478
3550
|
if (n.length) {
|
|
3479
3551
|
for (let e of n) console.error(e.reason);
|
|
@@ -3482,26 +3554,26 @@ var Ni = async (e) => {
|
|
|
3482
3554
|
let r = [];
|
|
3483
3555
|
for (let e of t) e.status === "fulfilled" && r.push(e.value);
|
|
3484
3556
|
return r;
|
|
3485
|
-
},
|
|
3557
|
+
}, Ri = class extends P {
|
|
3486
3558
|
create(e, t, n) {
|
|
3487
3559
|
return this._client.post(F`/vector_stores/${e}/file_batches`, {
|
|
3488
3560
|
body: t,
|
|
3489
3561
|
...n,
|
|
3490
|
-
headers:
|
|
3562
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3491
3563
|
});
|
|
3492
3564
|
}
|
|
3493
3565
|
retrieve(e, t, n) {
|
|
3494
3566
|
let { vector_store_id: r } = t;
|
|
3495
3567
|
return this._client.get(F`/vector_stores/${r}/file_batches/${e}`, {
|
|
3496
3568
|
...n,
|
|
3497
|
-
headers:
|
|
3569
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3498
3570
|
});
|
|
3499
3571
|
}
|
|
3500
3572
|
cancel(e, t, n) {
|
|
3501
3573
|
let { vector_store_id: r } = t;
|
|
3502
3574
|
return this._client.post(F`/vector_stores/${r}/file_batches/${e}/cancel`, {
|
|
3503
3575
|
...n,
|
|
3504
|
-
headers:
|
|
3576
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3505
3577
|
});
|
|
3506
3578
|
}
|
|
3507
3579
|
async createAndPoll(e, t, n) {
|
|
@@ -3513,11 +3585,11 @@ var Ni = async (e) => {
|
|
|
3513
3585
|
return this._client.getAPIList(F`/vector_stores/${r}/file_batches/${e}/files`, M, {
|
|
3514
3586
|
query: i,
|
|
3515
3587
|
...n,
|
|
3516
|
-
headers:
|
|
3588
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3517
3589
|
});
|
|
3518
3590
|
}
|
|
3519
3591
|
async poll(e, t, n) {
|
|
3520
|
-
let r =
|
|
3592
|
+
let r = U([n?.headers, {
|
|
3521
3593
|
"X-Stainless-Poll-Helper": "true",
|
|
3522
3594
|
"X-Stainless-Custom-Poll-Interval": n?.pollIntervalMs?.toString() ?? void 0
|
|
3523
3595
|
}]);
|
|
@@ -3537,7 +3609,7 @@ var Ni = async (e) => {
|
|
|
3537
3609
|
isNaN(n) || (e = n);
|
|
3538
3610
|
}
|
|
3539
3611
|
}
|
|
3540
|
-
await
|
|
3612
|
+
await se(e);
|
|
3541
3613
|
break;
|
|
3542
3614
|
case "failed":
|
|
3543
3615
|
case "cancelled":
|
|
@@ -3557,21 +3629,21 @@ var Ni = async (e) => {
|
|
|
3557
3629
|
c.push(e.id);
|
|
3558
3630
|
}
|
|
3559
3631
|
}
|
|
3560
|
-
return await
|
|
3632
|
+
return await Li(Array(a).fill(s).map(l)), await this.createAndPoll(e, { file_ids: c });
|
|
3561
3633
|
}
|
|
3562
|
-
},
|
|
3634
|
+
}, zi = class extends P {
|
|
3563
3635
|
create(e, t, n) {
|
|
3564
3636
|
return this._client.post(F`/vector_stores/${e}/files`, {
|
|
3565
3637
|
body: t,
|
|
3566
3638
|
...n,
|
|
3567
|
-
headers:
|
|
3639
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3568
3640
|
});
|
|
3569
3641
|
}
|
|
3570
3642
|
retrieve(e, t, n) {
|
|
3571
3643
|
let { vector_store_id: r } = t;
|
|
3572
3644
|
return this._client.get(F`/vector_stores/${r}/files/${e}`, {
|
|
3573
3645
|
...n,
|
|
3574
|
-
headers:
|
|
3646
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3575
3647
|
});
|
|
3576
3648
|
}
|
|
3577
3649
|
update(e, t, n) {
|
|
@@ -3579,21 +3651,21 @@ var Ni = async (e) => {
|
|
|
3579
3651
|
return this._client.post(F`/vector_stores/${r}/files/${e}`, {
|
|
3580
3652
|
body: i,
|
|
3581
3653
|
...n,
|
|
3582
|
-
headers:
|
|
3654
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3583
3655
|
});
|
|
3584
3656
|
}
|
|
3585
3657
|
list(e, t = {}, n) {
|
|
3586
3658
|
return this._client.getAPIList(F`/vector_stores/${e}/files`, M, {
|
|
3587
3659
|
query: t,
|
|
3588
3660
|
...n,
|
|
3589
|
-
headers:
|
|
3661
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3590
3662
|
});
|
|
3591
3663
|
}
|
|
3592
3664
|
delete(e, t, n) {
|
|
3593
3665
|
let { vector_store_id: r } = t;
|
|
3594
3666
|
return this._client.delete(F`/vector_stores/${r}/files/${e}`, {
|
|
3595
3667
|
...n,
|
|
3596
|
-
headers:
|
|
3668
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3597
3669
|
});
|
|
3598
3670
|
}
|
|
3599
3671
|
async createAndPoll(e, t, n) {
|
|
@@ -3601,7 +3673,7 @@ var Ni = async (e) => {
|
|
|
3601
3673
|
return await this.poll(e, r.id, n);
|
|
3602
3674
|
}
|
|
3603
3675
|
async poll(e, t, n) {
|
|
3604
|
-
let r =
|
|
3676
|
+
let r = U([n?.headers, {
|
|
3605
3677
|
"X-Stainless-Poll-Helper": "true",
|
|
3606
3678
|
"X-Stainless-Custom-Poll-Interval": n?.pollIntervalMs?.toString() ?? void 0
|
|
3607
3679
|
}]);
|
|
@@ -3621,7 +3693,7 @@ var Ni = async (e) => {
|
|
|
3621
3693
|
isNaN(n) || (e = n);
|
|
3622
3694
|
}
|
|
3623
3695
|
}
|
|
3624
|
-
await
|
|
3696
|
+
await se(e);
|
|
3625
3697
|
break;
|
|
3626
3698
|
case "failed":
|
|
3627
3699
|
case "completed": return a;
|
|
@@ -3641,61 +3713,61 @@ var Ni = async (e) => {
|
|
|
3641
3713
|
}
|
|
3642
3714
|
content(e, t, n) {
|
|
3643
3715
|
let { vector_store_id: r } = t;
|
|
3644
|
-
return this._client.getAPIList(F`/vector_stores/${r}/files/${e}/content`,
|
|
3716
|
+
return this._client.getAPIList(F`/vector_stores/${r}/files/${e}/content`, pt, {
|
|
3645
3717
|
...n,
|
|
3646
|
-
headers:
|
|
3718
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3647
3719
|
});
|
|
3648
3720
|
}
|
|
3649
|
-
},
|
|
3721
|
+
}, Bi = class extends P {
|
|
3650
3722
|
constructor() {
|
|
3651
|
-
super(...arguments), this.files = new
|
|
3723
|
+
super(...arguments), this.files = new zi(this._client), this.fileBatches = new Ri(this._client);
|
|
3652
3724
|
}
|
|
3653
3725
|
create(e, t) {
|
|
3654
3726
|
return this._client.post("/vector_stores", {
|
|
3655
3727
|
body: e,
|
|
3656
3728
|
...t,
|
|
3657
|
-
headers:
|
|
3729
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
3658
3730
|
});
|
|
3659
3731
|
}
|
|
3660
3732
|
retrieve(e, t) {
|
|
3661
3733
|
return this._client.get(F`/vector_stores/${e}`, {
|
|
3662
3734
|
...t,
|
|
3663
|
-
headers:
|
|
3735
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
3664
3736
|
});
|
|
3665
3737
|
}
|
|
3666
3738
|
update(e, t, n) {
|
|
3667
3739
|
return this._client.post(F`/vector_stores/${e}`, {
|
|
3668
3740
|
body: t,
|
|
3669
3741
|
...n,
|
|
3670
|
-
headers:
|
|
3742
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3671
3743
|
});
|
|
3672
3744
|
}
|
|
3673
3745
|
list(e = {}, t) {
|
|
3674
3746
|
return this._client.getAPIList("/vector_stores", M, {
|
|
3675
3747
|
query: e,
|
|
3676
3748
|
...t,
|
|
3677
|
-
headers:
|
|
3749
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
3678
3750
|
});
|
|
3679
3751
|
}
|
|
3680
3752
|
delete(e, t) {
|
|
3681
3753
|
return this._client.delete(F`/vector_stores/${e}`, {
|
|
3682
3754
|
...t,
|
|
3683
|
-
headers:
|
|
3755
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, t?.headers])
|
|
3684
3756
|
});
|
|
3685
3757
|
}
|
|
3686
3758
|
search(e, t, n) {
|
|
3687
|
-
return this._client.getAPIList(F`/vector_stores/${e}/search`,
|
|
3759
|
+
return this._client.getAPIList(F`/vector_stores/${e}/search`, pt, {
|
|
3688
3760
|
body: t,
|
|
3689
3761
|
method: "post",
|
|
3690
3762
|
...n,
|
|
3691
|
-
headers:
|
|
3763
|
+
headers: U([{ "OpenAI-Beta": "assistants=v2" }, n?.headers])
|
|
3692
3764
|
});
|
|
3693
3765
|
}
|
|
3694
3766
|
};
|
|
3695
|
-
|
|
3767
|
+
Bi.Files = zi, Bi.FileBatches = Ri;
|
|
3696
3768
|
//#endregion
|
|
3697
3769
|
//#region node_modules/openai/resources/videos.mjs
|
|
3698
|
-
var
|
|
3770
|
+
var Vi = class extends P {
|
|
3699
3771
|
create(e, t) {
|
|
3700
3772
|
return this._client.post("/videos", N({
|
|
3701
3773
|
body: e,
|
|
@@ -3706,7 +3778,7 @@ var Li = class extends P {
|
|
|
3706
3778
|
return this._client.get(F`/videos/${e}`, t);
|
|
3707
3779
|
}
|
|
3708
3780
|
list(e = {}, t) {
|
|
3709
|
-
return this._client.getAPIList("/videos",
|
|
3781
|
+
return this._client.getAPIList("/videos", mt, {
|
|
3710
3782
|
query: e,
|
|
3711
3783
|
...t
|
|
3712
3784
|
});
|
|
@@ -3724,7 +3796,7 @@ var Li = class extends P {
|
|
|
3724
3796
|
return this._client.get(F`/videos/${e}/content`, {
|
|
3725
3797
|
query: t,
|
|
3726
3798
|
...n,
|
|
3727
|
-
headers:
|
|
3799
|
+
headers: U([{ Accept: "application/binary" }, n?.headers]),
|
|
3728
3800
|
__binaryResponse: !0
|
|
3729
3801
|
});
|
|
3730
3802
|
}
|
|
@@ -3744,22 +3816,22 @@ var Li = class extends P {
|
|
|
3744
3816
|
return this._client.get(F`/videos/characters/${e}`, t);
|
|
3745
3817
|
}
|
|
3746
3818
|
remix(e, t, n) {
|
|
3747
|
-
return this._client.post(F`/videos/${e}/remix`,
|
|
3819
|
+
return this._client.post(F`/videos/${e}/remix`, St({
|
|
3748
3820
|
body: t,
|
|
3749
3821
|
...n
|
|
3750
3822
|
}, this._client));
|
|
3751
3823
|
}
|
|
3752
|
-
},
|
|
3824
|
+
}, Hi, Ui, Wi, Gi = class extends P {
|
|
3753
3825
|
constructor() {
|
|
3754
|
-
super(...arguments),
|
|
3826
|
+
super(...arguments), Hi.add(this);
|
|
3755
3827
|
}
|
|
3756
3828
|
async unwrap(e, t, n = this._client.webhookSecret, r = 300) {
|
|
3757
3829
|
return await this.verifySignature(e, t, n, r), JSON.parse(e);
|
|
3758
3830
|
}
|
|
3759
3831
|
async verifySignature(e, n, r = this._client.webhookSecret, i = 300) {
|
|
3760
3832
|
if (typeof crypto > "u" || typeof crypto.subtle.importKey != "function" || typeof crypto.subtle.verify != "function") throw Error("Webhook signature verification is only supported when the `crypto` global is defined");
|
|
3761
|
-
t(this,
|
|
3762
|
-
let a =
|
|
3833
|
+
t(this, Hi, "m", Ui).call(this, r);
|
|
3834
|
+
let a = U([n]).values, o = t(this, Hi, "m", Wi).call(this, a, "webhook-signature"), s = t(this, Hi, "m", Wi).call(this, a, "webhook-timestamp"), c = t(this, Hi, "m", Wi).call(this, a, "webhook-id"), l = parseInt(s, 10);
|
|
3763
3835
|
if (isNaN(l)) throw new b("Invalid webhook timestamp format");
|
|
3764
3836
|
let u = Math.floor(Date.now() / 1e3);
|
|
3765
3837
|
if (u - l > i) throw new b("Webhook timestamp is too old");
|
|
@@ -3777,9 +3849,9 @@ var Li = class extends P {
|
|
|
3777
3849
|
throw new b("The given webhook signature does not match the expected signature");
|
|
3778
3850
|
}
|
|
3779
3851
|
};
|
|
3780
|
-
|
|
3852
|
+
Hi = /* @__PURE__ */ new WeakSet(), Ui = function(e) {
|
|
3781
3853
|
if (typeof e != "string" || e.length === 0) throw Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function");
|
|
3782
|
-
},
|
|
3854
|
+
}, Wi = function(e, t) {
|
|
3783
3855
|
if (!e) throw Error("Headers are required");
|
|
3784
3856
|
let n = e.get(t);
|
|
3785
3857
|
if (n == null) throw Error(`Missing required header: ${t}`);
|
|
@@ -3787,21 +3859,25 @@ Q = /* @__PURE__ */ new WeakSet(), Ri = function(e) {
|
|
|
3787
3859
|
};
|
|
3788
3860
|
//#endregion
|
|
3789
3861
|
//#region node_modules/openai/client.mjs
|
|
3790
|
-
var
|
|
3791
|
-
constructor({ baseURL: t =
|
|
3792
|
-
if (
|
|
3793
|
-
|
|
3862
|
+
var Ki, qi, Ji, Yi, Xi = "workload-identity-auth", $ = class {
|
|
3863
|
+
constructor({ baseURL: t = W("OPENAI_BASE_URL"), apiKey: n = W("OPENAI_API_KEY"), organization: r = W("OPENAI_ORG_ID") ?? null, project: i = W("OPENAI_PROJECT_ID") ?? null, webhookSecret: o = W("OPENAI_WEBHOOK_SECRET") ?? null, workloadIdentity: s, ...c } = {}) {
|
|
3864
|
+
if (Ki.add(this), Ji.set(this, void 0), this.completions = new Rr(this), this.chat = new er(this), this.embeddings = new Wr(this), this.files = new Jr(this), this.images = new ai(this), this.audio = new or(this), this.moderations = new si(this), this.models = new oi(this), this.fineTuning = new ni(this), this.graders = new ii(this), this.vectorStores = new Bi(this), this.webhooks = new Gi(this), this.beta = new Lr(this), this.batches = new sr(this), this.uploads = new Ii(this), this.responses = new Ai(this), this.realtime = new ui(this), this.conversations = new Ur(this), this.evals = new qr(this), this.containers = new Vr(this), this.skills = new Pi(this), this.videos = new Vi(this), s) {
|
|
3865
|
+
if (n && n !== Xi) throw new a("The `apiKey` and `workloadIdentity` arguments are mutually exclusive; only one can be passed at a time.");
|
|
3866
|
+
n = Xi;
|
|
3867
|
+
} else if (n === void 0) throw new a("Missing credentials. Please pass an `apiKey`, `workloadIdentity`, or set the `OPENAI_API_KEY` environment variable.");
|
|
3868
|
+
let l = {
|
|
3794
3869
|
apiKey: n,
|
|
3795
3870
|
organization: r,
|
|
3796
3871
|
project: i,
|
|
3797
3872
|
webhookSecret: o,
|
|
3798
|
-
|
|
3873
|
+
workloadIdentity: s,
|
|
3874
|
+
...c,
|
|
3799
3875
|
baseURL: t || "https://api.openai.com/v1"
|
|
3800
3876
|
};
|
|
3801
|
-
if (!
|
|
3802
|
-
this.baseURL =
|
|
3803
|
-
let
|
|
3804
|
-
this.logLevel =
|
|
3877
|
+
if (!l.dangerouslyAllowBrowser && le()) throw new a("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew OpenAI({ apiKey, dangerouslyAllowBrowser: true });\n\nhttps://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety\n");
|
|
3878
|
+
this.baseURL = l.baseURL, this.timeout = l.timeout ?? qi.DEFAULT_TIMEOUT, this.logger = l.logger ?? console;
|
|
3879
|
+
let u = "warn";
|
|
3880
|
+
this.logLevel = u, this.logLevel = Ye(l.logLevel, "ClientOptions.logLevel", this) ?? Ye(W("OPENAI_LOG"), "process.env['OPENAI_LOG']", this) ?? u, this.fetchOptions = l.fetchOptions, this.maxRetries = l.maxRetries ?? 2, this.fetch = l.fetch ?? _e(), e(this, Ji, Se, "f"), this._options = l, s && (this._workloadIdentityAuth = new _t(s, this.fetch)), this.apiKey = typeof n == "string" ? n : "Missing Key", this.organization = r, this.project = i, this.webhookSecret = o;
|
|
3805
3881
|
}
|
|
3806
3882
|
withOptions(e) {
|
|
3807
3883
|
return new this.constructor({
|
|
@@ -3814,6 +3890,7 @@ var Vi, Hi, Ui, Wi, $ = class {
|
|
|
3814
3890
|
fetch: this.fetch,
|
|
3815
3891
|
fetchOptions: this.fetchOptions,
|
|
3816
3892
|
apiKey: this.apiKey,
|
|
3893
|
+
workloadIdentity: this._options.workloadIdentity,
|
|
3817
3894
|
organization: this.organization,
|
|
3818
3895
|
project: this.project,
|
|
3819
3896
|
webhookSecret: this.webhookSecret,
|
|
@@ -3825,13 +3902,13 @@ var Vi, Hi, Ui, Wi, $ = class {
|
|
|
3825
3902
|
}
|
|
3826
3903
|
validateHeaders({ values: e, nulls: t }) {}
|
|
3827
3904
|
async authHeaders(e) {
|
|
3828
|
-
return
|
|
3905
|
+
return U([{ Authorization: `Bearer ${this.apiKey}` }]);
|
|
3829
3906
|
}
|
|
3830
3907
|
stringifyQuery(e) {
|
|
3831
|
-
return
|
|
3908
|
+
return ze(e);
|
|
3832
3909
|
}
|
|
3833
3910
|
getUserAgent() {
|
|
3834
|
-
return `${this.constructor.name}/JS ${
|
|
3911
|
+
return `${this.constructor.name}/JS ${ce}`;
|
|
3835
3912
|
}
|
|
3836
3913
|
defaultIdempotencyKey() {
|
|
3837
3914
|
return `stainless-node-retry-${n()}`;
|
|
@@ -3852,8 +3929,8 @@ var Vi, Hi, Ui, Wi, $ = class {
|
|
|
3852
3929
|
return this.apiKey = t, !0;
|
|
3853
3930
|
}
|
|
3854
3931
|
buildURL(e, n, r) {
|
|
3855
|
-
let i = !t(this,
|
|
3856
|
-
return (!
|
|
3932
|
+
let i = !t(this, Ki, "m", Yi).call(this) && r || this.baseURL, a = C(e) ? new URL(e) : new URL(i + (i.endsWith("/") && e.startsWith("/") ? e.slice(1) : e)), o = this.defaultQuery(), s = Object.fromEntries(a.searchParams);
|
|
3933
|
+
return (!ne(o) || !ne(s)) && (n = {
|
|
3857
3934
|
...s,
|
|
3858
3935
|
...o,
|
|
3859
3936
|
...n
|
|
@@ -3886,7 +3963,7 @@ var Vi, Hi, Ui, Wi, $ = class {
|
|
|
3886
3963
|
})));
|
|
3887
3964
|
}
|
|
3888
3965
|
request(e, t = null) {
|
|
3889
|
-
return new
|
|
3966
|
+
return new lt(this, this.makeRequest(e, t, void 0));
|
|
3890
3967
|
}
|
|
3891
3968
|
async makeRequest(e, t, n) {
|
|
3892
3969
|
let a = await e, o = a.maxRetries ?? this.maxRetries;
|
|
@@ -3904,7 +3981,7 @@ var Vi, Hi, Ui, Wi, $ = class {
|
|
|
3904
3981
|
options: a,
|
|
3905
3982
|
headers: u.headers
|
|
3906
3983
|
})), a.signal?.aborted) throw new s();
|
|
3907
|
-
let g = new AbortController(), _ = await this.
|
|
3984
|
+
let g = new AbortController(), _ = await this.fetchWithAuth(d, u, f, g).catch(i), v = Date.now();
|
|
3908
3985
|
if (_ instanceof globalThis.Error) {
|
|
3909
3986
|
let e = `retrying, ${t} attempts remaining`;
|
|
3910
3987
|
if (a.signal?.aborted) throw new s();
|
|
@@ -3920,14 +3997,21 @@ var Vi, Hi, Ui, Wi, $ = class {
|
|
|
3920
3997
|
url: d,
|
|
3921
3998
|
durationMs: v - h,
|
|
3922
3999
|
message: _.message
|
|
3923
|
-
})), i ? new l() : new c({ cause: _ });
|
|
4000
|
+
})), _ instanceof x || _ instanceof ee ? _ : i ? new l() : new c({ cause: _ });
|
|
3924
4001
|
}
|
|
3925
4002
|
let y = `[${p}${m}${[..._.headers.entries()].filter(([e]) => e === "x-request-id").map(([e, t]) => ", " + e + ": " + JSON.stringify(t)).join("")}] ${u.method} ${d} ${_.ok ? "succeeded" : "failed"} with status ${_.status} in ${v - h}ms`;
|
|
3926
4003
|
if (!_.ok) {
|
|
4004
|
+
if (_.status === 401 && this._workloadIdentityAuth && !a.__metadata?.hasStreamingBody && !a.__metadata?.workloadIdentityTokenRefreshed) return await xe(_.body), this._workloadIdentityAuth.invalidateToken(), this.makeRequest({
|
|
4005
|
+
...a,
|
|
4006
|
+
__metadata: {
|
|
4007
|
+
...a.__metadata,
|
|
4008
|
+
workloadIdentityTokenRefreshed: !0
|
|
4009
|
+
}
|
|
4010
|
+
}, t, n ?? p);
|
|
3927
4011
|
let e = await this.shouldRetry(_);
|
|
3928
4012
|
if (t && e) {
|
|
3929
4013
|
let e = `retrying, ${t} attempts remaining`;
|
|
3930
|
-
return await
|
|
4014
|
+
return await xe(_.body), A(this).info(`${y} - ${e}`), A(this).debug(`[${p}] response error (${e})`, j({
|
|
3931
4015
|
retryOfRequestLogID: n,
|
|
3932
4016
|
url: _.url,
|
|
3933
4017
|
status: _.status,
|
|
@@ -3937,7 +4021,7 @@ var Vi, Hi, Ui, Wi, $ = class {
|
|
|
3937
4021
|
}
|
|
3938
4022
|
let r = e ? "error; no more retries left" : "error; not retryable";
|
|
3939
4023
|
A(this).info(`${y} - ${r}`);
|
|
3940
|
-
let o = await _.text().catch((e) => i(e).message), s =
|
|
4024
|
+
let o = await _.text().catch((e) => i(e).message), s = oe(o), c = s ? void 0 : o;
|
|
3941
4025
|
throw A(this).debug(`[${p}] response error (${r})`, j({
|
|
3942
4026
|
retryOfRequestLogID: n,
|
|
3943
4027
|
url: _.url,
|
|
@@ -3975,7 +4059,17 @@ var Vi, Hi, Ui, Wi, $ = class {
|
|
|
3975
4059
|
}
|
|
3976
4060
|
requestAPIList(e, t) {
|
|
3977
4061
|
let n = this.makeRequest(t, null, void 0);
|
|
3978
|
-
return new
|
|
4062
|
+
return new ft(this, n, e);
|
|
4063
|
+
}
|
|
4064
|
+
async fetchWithAuth(e, t, n, r) {
|
|
4065
|
+
if (this._workloadIdentityAuth) {
|
|
4066
|
+
let e = t.headers, n = e.get("Authorization");
|
|
4067
|
+
if (!n || n === `Bearer ${Xi}`) {
|
|
4068
|
+
let t = await this._workloadIdentityAuth.getToken();
|
|
4069
|
+
e.set("Authorization", `Bearer ${t}`);
|
|
4070
|
+
}
|
|
4071
|
+
}
|
|
4072
|
+
return await this.fetchWithTimeout(e, t, n, r);
|
|
3979
4073
|
}
|
|
3980
4074
|
async fetchWithTimeout(e, t, n, r) {
|
|
3981
4075
|
let { signal: i, method: a, ...o } = t || {}, s = this._makeAbort(r);
|
|
@@ -4012,7 +4106,7 @@ var Vi, Hi, Ui, Wi, $ = class {
|
|
|
4012
4106
|
let n = e.maxRetries ?? this.maxRetries;
|
|
4013
4107
|
i = this.calculateDefaultRetryTimeoutMillis(t, n);
|
|
4014
4108
|
}
|
|
4015
|
-
return await
|
|
4109
|
+
return await se(i), this.makeRequest(e, t - 1, n);
|
|
4016
4110
|
}
|
|
4017
4111
|
calculateDefaultRetryTimeoutMillis(e, t) {
|
|
4018
4112
|
let n = t - e;
|
|
@@ -4020,9 +4114,12 @@ var Vi, Hi, Ui, Wi, $ = class {
|
|
|
4020
4114
|
}
|
|
4021
4115
|
async buildRequest(e, { retryCount: t = 0 } = {}) {
|
|
4022
4116
|
let n = { ...e }, { method: r, path: i, query: a, defaultBaseURL: o } = n, s = this.buildURL(i, a, o);
|
|
4023
|
-
"timeout" in n &&
|
|
4024
|
-
let { bodyHeaders: c, body: l } = this.buildBody({ options: n });
|
|
4025
|
-
return {
|
|
4117
|
+
"timeout" in n && ae("timeout", n.timeout), n.timeout = n.timeout ?? this.timeout;
|
|
4118
|
+
let { bodyHeaders: c, body: l, isStreamingBody: u } = this.buildBody({ options: n });
|
|
4119
|
+
return u && (e.__metadata = {
|
|
4120
|
+
...e.__metadata,
|
|
4121
|
+
hasStreamingBody: !0
|
|
4122
|
+
}), {
|
|
4026
4123
|
req: {
|
|
4027
4124
|
method: r,
|
|
4028
4125
|
headers: await this.buildHeaders({
|
|
@@ -4044,14 +4141,14 @@ var Vi, Hi, Ui, Wi, $ = class {
|
|
|
4044
4141
|
async buildHeaders({ options: e, method: t, bodyHeaders: n, retryCount: r }) {
|
|
4045
4142
|
let i = {};
|
|
4046
4143
|
this.idempotencyHeader && t !== "get" && (e.idempotencyKey ||= this.defaultIdempotencyKey(), i[this.idempotencyHeader] = e.idempotencyKey);
|
|
4047
|
-
let a =
|
|
4144
|
+
let a = U([
|
|
4048
4145
|
i,
|
|
4049
4146
|
{
|
|
4050
4147
|
Accept: "application/json",
|
|
4051
4148
|
"User-Agent": this.getUserAgent(),
|
|
4052
4149
|
"X-Stainless-Retry-Count": String(r),
|
|
4053
4150
|
...e.timeout ? { "X-Stainless-Timeout": String(Math.trunc(e.timeout / 1e3)) } : {},
|
|
4054
|
-
...
|
|
4151
|
+
...ge(),
|
|
4055
4152
|
"OpenAI-Organization": this.organization,
|
|
4056
4153
|
"OpenAI-Project": this.project
|
|
4057
4154
|
},
|
|
@@ -4068,31 +4165,38 @@ var Vi, Hi, Ui, Wi, $ = class {
|
|
|
4068
4165
|
buildBody({ options: { body: e, headers: n } }) {
|
|
4069
4166
|
if (!e) return {
|
|
4070
4167
|
bodyHeaders: void 0,
|
|
4071
|
-
body: void 0
|
|
4168
|
+
body: void 0,
|
|
4169
|
+
isStreamingBody: !1
|
|
4072
4170
|
};
|
|
4073
|
-
let r =
|
|
4074
|
-
return ArrayBuffer.isView(e) || e instanceof ArrayBuffer || e instanceof DataView || typeof e == "string" && r.values.has("content-type") || globalThis.Blob && e instanceof globalThis.Blob || e instanceof FormData || e instanceof URLSearchParams ||
|
|
4171
|
+
let r = U([n]), i = globalThis.ReadableStream !== void 0 && e instanceof globalThis.ReadableStream, a = !i && (typeof e == "string" || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || globalThis.Blob !== void 0 && e instanceof globalThis.Blob || e instanceof URLSearchParams || e instanceof FormData);
|
|
4172
|
+
return ArrayBuffer.isView(e) || e instanceof ArrayBuffer || e instanceof DataView || typeof e == "string" && r.values.has("content-type") || globalThis.Blob && e instanceof globalThis.Blob || e instanceof FormData || e instanceof URLSearchParams || i ? {
|
|
4075
4173
|
bodyHeaders: void 0,
|
|
4076
|
-
body: e
|
|
4174
|
+
body: e,
|
|
4175
|
+
isStreamingBody: !a
|
|
4077
4176
|
} : typeof e == "object" && (Symbol.asyncIterator in e || Symbol.iterator in e && "next" in e && typeof e.next == "function") ? {
|
|
4078
4177
|
bodyHeaders: void 0,
|
|
4079
|
-
body:
|
|
4178
|
+
body: ye(e),
|
|
4179
|
+
isStreamingBody: !0
|
|
4080
4180
|
} : typeof e == "object" && r.values.get("content-type") === "application/x-www-form-urlencoded" ? {
|
|
4081
4181
|
bodyHeaders: { "content-type": "application/x-www-form-urlencoded" },
|
|
4082
|
-
body: this.stringifyQuery(e)
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4182
|
+
body: this.stringifyQuery(e),
|
|
4183
|
+
isStreamingBody: !1
|
|
4184
|
+
} : {
|
|
4185
|
+
...t(this, Ji, "f").call(this, {
|
|
4186
|
+
body: e,
|
|
4187
|
+
headers: r
|
|
4188
|
+
}),
|
|
4189
|
+
isStreamingBody: !1
|
|
4190
|
+
};
|
|
4087
4191
|
}
|
|
4088
4192
|
};
|
|
4089
|
-
|
|
4193
|
+
qi = $, Ji = /* @__PURE__ */ new WeakMap(), Ki = /* @__PURE__ */ new WeakSet(), Yi = function() {
|
|
4090
4194
|
return this.baseURL !== "https://api.openai.com/v1";
|
|
4091
|
-
}, $.OpenAI =
|
|
4195
|
+
}, $.OpenAI = qi, $.DEFAULT_TIMEOUT = 6e5, $.OpenAIError = a, $.APIError = o, $.APIConnectionError = c, $.APIConnectionTimeoutError = l, $.APIUserAbortError = s, $.NotFoundError = p, $.ConflictError = m, $.RateLimitError = g, $.BadRequestError = u, $.AuthenticationError = d, $.InternalServerError = _, $.PermissionDeniedError = f, $.UnprocessableEntityError = h, $.InvalidWebhookSignatureError = b, $.toFile = Nt, $.Completions = Rr, $.Chat = er, $.Embeddings = Wr, $.Files = Jr, $.Images = ai, $.Audio = or, $.Moderations = si, $.Models = oi, $.FineTuning = ni, $.Graders = ii, $.VectorStores = Bi, $.Webhooks = Gi, $.Beta = Lr, $.Batches = sr, $.Uploads = Ii, $.Responses = Ai, $.Realtime = ui, $.Conversations = Ur, $.Evals = qr, $.Containers = Vr, $.Skills = Pi, $.Videos = Vi;
|
|
4092
4196
|
//#endregion
|
|
4093
4197
|
//#region node_modules/openai/azure.mjs
|
|
4094
|
-
var
|
|
4095
|
-
constructor({ baseURL: e =
|
|
4198
|
+
var Zi = class extends $ {
|
|
4199
|
+
constructor({ baseURL: e = W("OPENAI_BASE_URL"), apiKey: t = W("AZURE_OPENAI_API_KEY"), apiVersion: n = W("OPENAI_API_VERSION"), endpoint: r, deployment: i, azureADTokenProvider: o, dangerouslyAllowBrowser: s, ...c } = {}) {
|
|
4096
4200
|
if (!n) throw new a("The OPENAI_API_VERSION environment variable is missing or empty; either provide it, or instantiate the AzureOpenAI client with an apiVersion option, like new AzureOpenAI({ apiVersion: 'My API Version' }).");
|
|
4097
4201
|
if (typeof o == "function" && (s = !0), !o && !t) throw new a("Missing credentials. Please pass one of `apiKey` and `azureADTokenProvider`, or set the `AZURE_OPENAI_API_KEY` environment variable.");
|
|
4098
4202
|
if (o && t) throw new a("The `apiKey` and `azureADTokenProvider` arguments are mutually exclusive; only one can be passed at a time.");
|
|
@@ -4111,17 +4215,17 @@ var Gi = class extends $ {
|
|
|
4111
4215
|
}), this.apiVersion = "", this.apiVersion = n, this.deploymentName = i;
|
|
4112
4216
|
}
|
|
4113
4217
|
async buildRequest(e, t = {}) {
|
|
4114
|
-
if (
|
|
4115
|
-
if (!
|
|
4218
|
+
if (Qi.has(e.path) && e.method === "post" && e.body !== void 0) {
|
|
4219
|
+
if (!ie(e.body)) throw Error("Expected request body to be an object");
|
|
4116
4220
|
let t = this.deploymentName || e.body.model || e.__metadata?.model;
|
|
4117
4221
|
t !== void 0 && !this.baseURL.includes("/deployments") && (e.path = `/deployments/${t}${e.path}`);
|
|
4118
4222
|
}
|
|
4119
4223
|
return super.buildRequest(e, t);
|
|
4120
4224
|
}
|
|
4121
4225
|
async authHeaders(e) {
|
|
4122
|
-
return typeof this._options.apiKey == "string" ?
|
|
4226
|
+
return typeof this._options.apiKey == "string" ? U([{ "api-key": this.apiKey }]) : super.authHeaders(e);
|
|
4123
4227
|
}
|
|
4124
|
-
},
|
|
4228
|
+
}, Qi = new Set([
|
|
4125
4229
|
"/completions",
|
|
4126
4230
|
"/chat/completions",
|
|
4127
4231
|
"/embeddings",
|
|
@@ -4133,4 +4237,4 @@ var Gi = class extends $ {
|
|
|
4133
4237
|
"/images/edits"
|
|
4134
4238
|
]);
|
|
4135
4239
|
//#endregion
|
|
4136
|
-
export { c as APIConnectionError, l as APIConnectionTimeoutError, o as APIError,
|
|
4240
|
+
export { c as APIConnectionError, l as APIConnectionTimeoutError, o as APIError, lt as APIPromise, s as APIUserAbortError, d as AuthenticationError, Zi as AzureOpenAI, u as BadRequestError, m as ConflictError, _ as InternalServerError, b as InvalidWebhookSignatureError, p as NotFoundError, x as OAuthError, $ as OpenAI, $ as default, a as OpenAIError, ft as PagePromise, f as PermissionDeniedError, g as RateLimitError, ee as SubjectTokenProviderError, h as UnprocessableEntityError, Nt as toFile };
|