@polka-codes/runner 0.7.18 → 0.7.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1040 -481
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -21407,7 +21407,7 @@ var require_cli_width = __commonJS((exports, module2) => {
|
|
|
21407
21407
|
}
|
|
21408
21408
|
});
|
|
21409
21409
|
|
|
21410
|
-
// ../../node_modules/@inquirer/core/node_modules/strip-ansi/node_modules/ansi-regex/index.js
|
|
21410
|
+
// ../../node_modules/@inquirer/core/node_modules/wrap-ansi/node_modules/strip-ansi/node_modules/ansi-regex/index.js
|
|
21411
21411
|
var require_ansi_regex = __commonJS((exports, module2) => {
|
|
21412
21412
|
module2.exports = ({ onlyFirst = false } = {}) => {
|
|
21413
21413
|
const pattern = [
|
|
@@ -21418,13 +21418,13 @@ var require_ansi_regex = __commonJS((exports, module2) => {
|
|
|
21418
21418
|
};
|
|
21419
21419
|
});
|
|
21420
21420
|
|
|
21421
|
-
// ../../node_modules/@inquirer/core/node_modules/strip-ansi/index.js
|
|
21421
|
+
// ../../node_modules/@inquirer/core/node_modules/wrap-ansi/node_modules/strip-ansi/index.js
|
|
21422
21422
|
var require_strip_ansi = __commonJS((exports, module2) => {
|
|
21423
21423
|
var ansiRegex = require_ansi_regex();
|
|
21424
21424
|
module2.exports = (string) => typeof string === "string" ? string.replace(ansiRegex(), "") : string;
|
|
21425
21425
|
});
|
|
21426
21426
|
|
|
21427
|
-
// ../../node_modules
|
|
21427
|
+
// ../../node_modules/is-fullwidth-code-point/index.js
|
|
21428
21428
|
var require_is_fullwidth_code_point = __commonJS((exports, module2) => {
|
|
21429
21429
|
var isFullwidthCodePoint = (codePoint) => {
|
|
21430
21430
|
if (Number.isNaN(codePoint)) {
|
|
@@ -22428,7 +22428,7 @@ var require_color_convert = __commonJS((exports, module2) => {
|
|
|
22428
22428
|
module2.exports = convert;
|
|
22429
22429
|
});
|
|
22430
22430
|
|
|
22431
|
-
// ../../node_modules
|
|
22431
|
+
// ../../node_modules/ansi-styles/index.js
|
|
22432
22432
|
var require_ansi_styles = __commonJS((exports, module2) => {
|
|
22433
22433
|
var wrapAnsi16 = (fn, offset) => (...args2) => {
|
|
22434
22434
|
const code = fn(...args2);
|
|
@@ -22957,7 +22957,7 @@ var {
|
|
|
22957
22957
|
Help
|
|
22958
22958
|
} = import__.default;
|
|
22959
22959
|
// package.json
|
|
22960
|
-
var version = "0.7.
|
|
22960
|
+
var version = "0.7.20";
|
|
22961
22961
|
|
|
22962
22962
|
// ../cli-shared/src/config.ts
|
|
22963
22963
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -26925,7 +26925,7 @@ function stringify(object, opts = {}) {
|
|
|
26925
26925
|
return joined.length > 0 ? prefix + joined : "";
|
|
26926
26926
|
}
|
|
26927
26927
|
// ../../node_modules/openai/version.mjs
|
|
26928
|
-
var VERSION2 = "4.
|
|
26928
|
+
var VERSION2 = "4.89.1";
|
|
26929
26929
|
|
|
26930
26930
|
// ../../node_modules/openai/_shims/registry.mjs
|
|
26931
26931
|
var auto2 = false;
|
|
@@ -27150,39 +27150,57 @@ class ContentFilterFinishReasonError extends OpenAIError {
|
|
|
27150
27150
|
}
|
|
27151
27151
|
|
|
27152
27152
|
// ../../node_modules/openai/internal/decoders/line.mjs
|
|
27153
|
+
var __classPrivateFieldSet9 = function(receiver, state, value, kind3, f2) {
|
|
27154
|
+
if (kind3 === "m")
|
|
27155
|
+
throw new TypeError("Private method is not writable");
|
|
27156
|
+
if (kind3 === "a" && !f2)
|
|
27157
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
27158
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
27159
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
27160
|
+
return kind3 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
27161
|
+
};
|
|
27162
|
+
var __classPrivateFieldGet10 = function(receiver, state, kind3, f2) {
|
|
27163
|
+
if (kind3 === "a" && !f2)
|
|
27164
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
27165
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
27166
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
27167
|
+
return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
27168
|
+
};
|
|
27169
|
+
var _LineDecoder_carriageReturnIndex2;
|
|
27170
|
+
|
|
27153
27171
|
class LineDecoder2 {
|
|
27154
27172
|
constructor() {
|
|
27155
|
-
this
|
|
27156
|
-
this.
|
|
27173
|
+
_LineDecoder_carriageReturnIndex2.set(this, undefined);
|
|
27174
|
+
this.buffer = new Uint8Array;
|
|
27175
|
+
__classPrivateFieldSet9(this, _LineDecoder_carriageReturnIndex2, null, "f");
|
|
27157
27176
|
}
|
|
27158
27177
|
decode(chunk) {
|
|
27159
|
-
|
|
27160
|
-
if (this.trailingCR) {
|
|
27161
|
-
text = "\r" + text;
|
|
27162
|
-
this.trailingCR = false;
|
|
27163
|
-
}
|
|
27164
|
-
if (text.endsWith("\r")) {
|
|
27165
|
-
this.trailingCR = true;
|
|
27166
|
-
text = text.slice(0, -1);
|
|
27167
|
-
}
|
|
27168
|
-
if (!text) {
|
|
27169
|
-
return [];
|
|
27170
|
-
}
|
|
27171
|
-
const trailingNewline = LineDecoder2.NEWLINE_CHARS.has(text[text.length - 1] || "");
|
|
27172
|
-
let lines = text.split(LineDecoder2.NEWLINE_REGEXP);
|
|
27173
|
-
if (trailingNewline) {
|
|
27174
|
-
lines.pop();
|
|
27175
|
-
}
|
|
27176
|
-
if (lines.length === 1 && !trailingNewline) {
|
|
27177
|
-
this.buffer.push(lines[0]);
|
|
27178
|
+
if (chunk == null) {
|
|
27178
27179
|
return [];
|
|
27179
27180
|
}
|
|
27180
|
-
|
|
27181
|
-
|
|
27182
|
-
|
|
27183
|
-
|
|
27184
|
-
|
|
27185
|
-
|
|
27181
|
+
const binaryChunk = chunk instanceof ArrayBuffer ? new Uint8Array(chunk) : typeof chunk === "string" ? new TextEncoder().encode(chunk) : chunk;
|
|
27182
|
+
let newData = new Uint8Array(this.buffer.length + binaryChunk.length);
|
|
27183
|
+
newData.set(this.buffer);
|
|
27184
|
+
newData.set(binaryChunk, this.buffer.length);
|
|
27185
|
+
this.buffer = newData;
|
|
27186
|
+
const lines = [];
|
|
27187
|
+
let patternIndex;
|
|
27188
|
+
while ((patternIndex = findNewlineIndex2(this.buffer, __classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f"))) != null) {
|
|
27189
|
+
if (patternIndex.carriage && __classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f") == null) {
|
|
27190
|
+
__classPrivateFieldSet9(this, _LineDecoder_carriageReturnIndex2, patternIndex.index, "f");
|
|
27191
|
+
continue;
|
|
27192
|
+
}
|
|
27193
|
+
if (__classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f") != null && (patternIndex.index !== __classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f") + 1 || patternIndex.carriage)) {
|
|
27194
|
+
lines.push(this.decodeText(this.buffer.slice(0, __classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f") - 1)));
|
|
27195
|
+
this.buffer = this.buffer.slice(__classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f"));
|
|
27196
|
+
__classPrivateFieldSet9(this, _LineDecoder_carriageReturnIndex2, null, "f");
|
|
27197
|
+
continue;
|
|
27198
|
+
}
|
|
27199
|
+
const endIndex = __classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f") !== null ? patternIndex.preceding - 1 : patternIndex.preceding;
|
|
27200
|
+
const line = this.decodeText(this.buffer.slice(0, endIndex));
|
|
27201
|
+
lines.push(line);
|
|
27202
|
+
this.buffer = this.buffer.slice(patternIndex.index);
|
|
27203
|
+
__classPrivateFieldSet9(this, _LineDecoder_carriageReturnIndex2, null, "f");
|
|
27186
27204
|
}
|
|
27187
27205
|
return lines;
|
|
27188
27206
|
}
|
|
@@ -27210,18 +27228,46 @@ class LineDecoder2 {
|
|
|
27210
27228
|
throw new OpenAIError(`Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.`);
|
|
27211
27229
|
}
|
|
27212
27230
|
flush() {
|
|
27213
|
-
if (!this.buffer.length
|
|
27231
|
+
if (!this.buffer.length) {
|
|
27214
27232
|
return [];
|
|
27215
27233
|
}
|
|
27216
|
-
|
|
27217
|
-
|
|
27218
|
-
this.trailingCR = false;
|
|
27219
|
-
return lines;
|
|
27234
|
+
return this.decode(`
|
|
27235
|
+
`);
|
|
27220
27236
|
}
|
|
27221
27237
|
}
|
|
27238
|
+
_LineDecoder_carriageReturnIndex2 = new WeakMap;
|
|
27222
27239
|
LineDecoder2.NEWLINE_CHARS = new Set([`
|
|
27223
27240
|
`, "\r"]);
|
|
27224
27241
|
LineDecoder2.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
27242
|
+
function findNewlineIndex2(buffer, startIndex) {
|
|
27243
|
+
const newline = 10;
|
|
27244
|
+
const carriage = 13;
|
|
27245
|
+
for (let i3 = startIndex ?? 0;i3 < buffer.length; i3++) {
|
|
27246
|
+
if (buffer[i3] === newline) {
|
|
27247
|
+
return { preceding: i3, index: i3 + 1, carriage: false };
|
|
27248
|
+
}
|
|
27249
|
+
if (buffer[i3] === carriage) {
|
|
27250
|
+
return { preceding: i3, index: i3 + 1, carriage: true };
|
|
27251
|
+
}
|
|
27252
|
+
}
|
|
27253
|
+
return null;
|
|
27254
|
+
}
|
|
27255
|
+
function findDoubleNewlineIndex2(buffer) {
|
|
27256
|
+
const newline = 10;
|
|
27257
|
+
const carriage = 13;
|
|
27258
|
+
for (let i3 = 0;i3 < buffer.length - 1; i3++) {
|
|
27259
|
+
if (buffer[i3] === newline && buffer[i3 + 1] === newline) {
|
|
27260
|
+
return i3 + 2;
|
|
27261
|
+
}
|
|
27262
|
+
if (buffer[i3] === carriage && buffer[i3 + 1] === carriage) {
|
|
27263
|
+
return i3 + 2;
|
|
27264
|
+
}
|
|
27265
|
+
if (buffer[i3] === carriage && buffer[i3 + 1] === newline && i3 + 3 < buffer.length && buffer[i3 + 2] === carriage && buffer[i3 + 3] === newline) {
|
|
27266
|
+
return i3 + 4;
|
|
27267
|
+
}
|
|
27268
|
+
}
|
|
27269
|
+
return -1;
|
|
27270
|
+
}
|
|
27225
27271
|
|
|
27226
27272
|
// ../../node_modules/openai/internal/stream-utils.mjs
|
|
27227
27273
|
function ReadableStreamToAsyncIterable2(stream) {
|
|
@@ -27274,7 +27320,7 @@ class Stream2 {
|
|
|
27274
27320
|
done = true;
|
|
27275
27321
|
continue;
|
|
27276
27322
|
}
|
|
27277
|
-
if (sse.event === null) {
|
|
27323
|
+
if (sse.event === null || sse.event.startsWith("response.")) {
|
|
27278
27324
|
let data;
|
|
27279
27325
|
try {
|
|
27280
27326
|
data = JSON.parse(sse.data);
|
|
@@ -27445,22 +27491,6 @@ async function* iterSSEChunks2(iterator) {
|
|
|
27445
27491
|
yield data;
|
|
27446
27492
|
}
|
|
27447
27493
|
}
|
|
27448
|
-
function findDoubleNewlineIndex2(buffer) {
|
|
27449
|
-
const newline = 10;
|
|
27450
|
-
const carriage = 13;
|
|
27451
|
-
for (let i3 = 0;i3 < buffer.length - 2; i3++) {
|
|
27452
|
-
if (buffer[i3] === newline && buffer[i3 + 1] === newline) {
|
|
27453
|
-
return i3 + 2;
|
|
27454
|
-
}
|
|
27455
|
-
if (buffer[i3] === carriage && buffer[i3 + 1] === carriage) {
|
|
27456
|
-
return i3 + 2;
|
|
27457
|
-
}
|
|
27458
|
-
if (buffer[i3] === carriage && buffer[i3 + 1] === newline && i3 + 3 < buffer.length && buffer[i3 + 2] === carriage && buffer[i3 + 3] === newline) {
|
|
27459
|
-
return i3 + 4;
|
|
27460
|
-
}
|
|
27461
|
-
}
|
|
27462
|
-
return -1;
|
|
27463
|
-
}
|
|
27464
27494
|
|
|
27465
27495
|
class SSEDecoder2 {
|
|
27466
27496
|
constructor() {
|
|
@@ -27599,7 +27629,7 @@ var addFormValue = async (form, key, value) => {
|
|
|
27599
27629
|
};
|
|
27600
27630
|
|
|
27601
27631
|
// ../../node_modules/openai/core.mjs
|
|
27602
|
-
var
|
|
27632
|
+
var __classPrivateFieldSet10 = function(receiver, state, value, kind3, f2) {
|
|
27603
27633
|
if (kind3 === "m")
|
|
27604
27634
|
throw new TypeError("Private method is not writable");
|
|
27605
27635
|
if (kind3 === "a" && !f2)
|
|
@@ -27608,7 +27638,7 @@ var __classPrivateFieldSet9 = function(receiver, state, value, kind3, f2) {
|
|
|
27608
27638
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
27609
27639
|
return kind3 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
27610
27640
|
};
|
|
27611
|
-
var
|
|
27641
|
+
var __classPrivateFieldGet11 = function(receiver, state, kind3, f2) {
|
|
27612
27642
|
if (kind3 === "a" && !f2)
|
|
27613
27643
|
throw new TypeError("Private accessor was defined without a getter");
|
|
27614
27644
|
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
@@ -27632,7 +27662,8 @@ async function defaultParseResponse2(props) {
|
|
|
27632
27662
|
return response;
|
|
27633
27663
|
}
|
|
27634
27664
|
const contentType = response.headers.get("content-type");
|
|
27635
|
-
const
|
|
27665
|
+
const mediaType = contentType?.split(";")[0]?.trim();
|
|
27666
|
+
const isJSON = mediaType?.includes("application/json") || mediaType?.endsWith("+json");
|
|
27636
27667
|
if (isJSON) {
|
|
27637
27668
|
const json = await response.json();
|
|
27638
27669
|
debug2("response", response.status, response.url, response.headers, json);
|
|
@@ -27757,15 +27788,16 @@ class APIClient2 {
|
|
|
27757
27788
|
return null;
|
|
27758
27789
|
}
|
|
27759
27790
|
buildRequest(options, { retryCount = 0 } = {}) {
|
|
27791
|
+
options = { ...options };
|
|
27760
27792
|
const { method, path, query, headers = {} } = options;
|
|
27761
27793
|
const body2 = ArrayBuffer.isView(options.body) || options.__binaryRequest && typeof options.body === "string" ? options.body : isMultipartBody2(options.body) ? options.body.body : options.body ? JSON.stringify(options.body, null, 2) : null;
|
|
27762
27794
|
const contentLength = this.calculateContentLength(body2);
|
|
27763
27795
|
const url = this.buildURL(path, query);
|
|
27764
27796
|
if ("timeout" in options)
|
|
27765
27797
|
validatePositiveInteger2("timeout", options.timeout);
|
|
27766
|
-
|
|
27798
|
+
options.timeout = options.timeout ?? this.timeout;
|
|
27767
27799
|
const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent2(url);
|
|
27768
|
-
const minAgentTimeout = timeout + 1000;
|
|
27800
|
+
const minAgentTimeout = options.timeout + 1000;
|
|
27769
27801
|
if (typeof httpAgent?.options?.timeout === "number" && minAgentTimeout > (httpAgent.options.timeout ?? 0)) {
|
|
27770
27802
|
httpAgent.options.timeout = minAgentTimeout;
|
|
27771
27803
|
}
|
|
@@ -27782,7 +27814,7 @@ class APIClient2 {
|
|
|
27782
27814
|
...httpAgent && { agent: httpAgent },
|
|
27783
27815
|
signal: options.signal ?? null
|
|
27784
27816
|
};
|
|
27785
|
-
return { req, url, timeout };
|
|
27817
|
+
return { req, url, timeout: options.timeout };
|
|
27786
27818
|
}
|
|
27787
27819
|
buildHeaders({ options, headers, contentLength, retryCount }) {
|
|
27788
27820
|
const reqHeaders = {};
|
|
@@ -27798,6 +27830,9 @@ class APIClient2 {
|
|
|
27798
27830
|
if (getHeader2(defaultHeaders, "x-stainless-retry-count") === undefined && getHeader2(headers, "x-stainless-retry-count") === undefined) {
|
|
27799
27831
|
reqHeaders["x-stainless-retry-count"] = String(retryCount);
|
|
27800
27832
|
}
|
|
27833
|
+
if (getHeader2(defaultHeaders, "x-stainless-timeout") === undefined && getHeader2(headers, "x-stainless-timeout") === undefined && options.timeout) {
|
|
27834
|
+
reqHeaders["x-stainless-timeout"] = String(options.timeout);
|
|
27835
|
+
}
|
|
27801
27836
|
this.validateHeaders(reqHeaders, headers);
|
|
27802
27837
|
return reqHeaders;
|
|
27803
27838
|
}
|
|
@@ -27955,7 +27990,7 @@ class APIClient2 {
|
|
|
27955
27990
|
class AbstractPage2 {
|
|
27956
27991
|
constructor(client, response, body2, options) {
|
|
27957
27992
|
_AbstractPage_client2.set(this, undefined);
|
|
27958
|
-
|
|
27993
|
+
__classPrivateFieldSet10(this, _AbstractPage_client2, client, "f");
|
|
27959
27994
|
this.options = options;
|
|
27960
27995
|
this.response = response;
|
|
27961
27996
|
this.body = body2;
|
|
@@ -27982,7 +28017,7 @@ class AbstractPage2 {
|
|
|
27982
28017
|
nextOptions.query = undefined;
|
|
27983
28018
|
nextOptions.path = nextInfo.url.toString();
|
|
27984
28019
|
}
|
|
27985
|
-
return await
|
|
28020
|
+
return await __classPrivateFieldGet11(this, _AbstractPage_client2, "f").requestAPIList(this.constructor, nextOptions);
|
|
27986
28021
|
}
|
|
27987
28022
|
async* iterPages() {
|
|
27988
28023
|
let page = this;
|
|
@@ -28032,6 +28067,7 @@ var requestOptionsKeys2 = {
|
|
|
28032
28067
|
httpAgent: true,
|
|
28033
28068
|
signal: true,
|
|
28034
28069
|
idempotencyKey: true,
|
|
28070
|
+
__metadata: true,
|
|
28035
28071
|
__binaryRequest: true,
|
|
28036
28072
|
__binaryResponse: true,
|
|
28037
28073
|
__streamClass: true
|
|
@@ -28306,10 +28342,17 @@ class CursorPage extends AbstractPage2 {
|
|
|
28306
28342
|
constructor(client, response, body2, options) {
|
|
28307
28343
|
super(client, response, body2, options);
|
|
28308
28344
|
this.data = body2.data || [];
|
|
28345
|
+
this.has_more = body2.has_more || false;
|
|
28309
28346
|
}
|
|
28310
28347
|
getPaginatedItems() {
|
|
28311
28348
|
return this.data ?? [];
|
|
28312
28349
|
}
|
|
28350
|
+
hasNextPage() {
|
|
28351
|
+
if (this.has_more === false) {
|
|
28352
|
+
return false;
|
|
28353
|
+
}
|
|
28354
|
+
return super.hasNextPage();
|
|
28355
|
+
}
|
|
28313
28356
|
nextPageParams() {
|
|
28314
28357
|
const info2 = this.nextPageInfo();
|
|
28315
28358
|
if (!info2)
|
|
@@ -28341,13 +28384,50 @@ class APIResource2 {
|
|
|
28341
28384
|
}
|
|
28342
28385
|
}
|
|
28343
28386
|
|
|
28344
|
-
// ../../node_modules/openai/resources/chat/completions.mjs
|
|
28387
|
+
// ../../node_modules/openai/resources/chat/completions/messages.mjs
|
|
28388
|
+
class Messages3 extends APIResource2 {
|
|
28389
|
+
list(completionId, query = {}, options) {
|
|
28390
|
+
if (isRequestOptions2(query)) {
|
|
28391
|
+
return this.list(completionId, {}, query);
|
|
28392
|
+
}
|
|
28393
|
+
return this._client.getAPIList(`/chat/completions/${completionId}/messages`, ChatCompletionStoreMessagesPage, { query, ...options });
|
|
28394
|
+
}
|
|
28395
|
+
}
|
|
28396
|
+
|
|
28397
|
+
// ../../node_modules/openai/resources/chat/completions/completions.mjs
|
|
28345
28398
|
class Completions2 extends APIResource2 {
|
|
28399
|
+
constructor() {
|
|
28400
|
+
super(...arguments);
|
|
28401
|
+
this.messages = new Messages3(this._client);
|
|
28402
|
+
}
|
|
28346
28403
|
create(body2, options) {
|
|
28347
28404
|
return this._client.post("/chat/completions", { body: body2, ...options, stream: body2.stream ?? false });
|
|
28348
28405
|
}
|
|
28406
|
+
retrieve(completionId, options) {
|
|
28407
|
+
return this._client.get(`/chat/completions/${completionId}`, options);
|
|
28408
|
+
}
|
|
28409
|
+
update(completionId, body2, options) {
|
|
28410
|
+
return this._client.post(`/chat/completions/${completionId}`, { body: body2, ...options });
|
|
28411
|
+
}
|
|
28412
|
+
list(query = {}, options) {
|
|
28413
|
+
if (isRequestOptions2(query)) {
|
|
28414
|
+
return this.list({}, query);
|
|
28415
|
+
}
|
|
28416
|
+
return this._client.getAPIList("/chat/completions", ChatCompletionsPage, { query, ...options });
|
|
28417
|
+
}
|
|
28418
|
+
del(completionId, options) {
|
|
28419
|
+
return this._client.delete(`/chat/completions/${completionId}`, options);
|
|
28420
|
+
}
|
|
28421
|
+
}
|
|
28422
|
+
|
|
28423
|
+
class ChatCompletionsPage extends CursorPage {
|
|
28349
28424
|
}
|
|
28350
28425
|
|
|
28426
|
+
class ChatCompletionStoreMessagesPage extends CursorPage {
|
|
28427
|
+
}
|
|
28428
|
+
Completions2.ChatCompletionsPage = ChatCompletionsPage;
|
|
28429
|
+
Completions2.Messages = Messages3;
|
|
28430
|
+
|
|
28351
28431
|
// ../../node_modules/openai/resources/chat/chat.mjs
|
|
28352
28432
|
class Chat extends APIResource2 {
|
|
28353
28433
|
constructor() {
|
|
@@ -28356,6 +28436,7 @@ class Chat extends APIResource2 {
|
|
|
28356
28436
|
}
|
|
28357
28437
|
}
|
|
28358
28438
|
Chat.Completions = Completions2;
|
|
28439
|
+
Chat.ChatCompletionsPage = ChatCompletionsPage;
|
|
28359
28440
|
// ../../node_modules/openai/resources/audio/speech.mjs
|
|
28360
28441
|
class Speech extends APIResource2 {
|
|
28361
28442
|
create(body2, options) {
|
|
@@ -28371,14 +28452,14 @@ class Speech extends APIResource2 {
|
|
|
28371
28452
|
// ../../node_modules/openai/resources/audio/transcriptions.mjs
|
|
28372
28453
|
class Transcriptions extends APIResource2 {
|
|
28373
28454
|
create(body2, options) {
|
|
28374
|
-
return this._client.post("/audio/transcriptions", multipartFormRequestOptions({ body: body2, ...options }));
|
|
28455
|
+
return this._client.post("/audio/transcriptions", multipartFormRequestOptions({ body: body2, ...options, __metadata: { model: body2.model } }));
|
|
28375
28456
|
}
|
|
28376
28457
|
}
|
|
28377
28458
|
|
|
28378
28459
|
// ../../node_modules/openai/resources/audio/translations.mjs
|
|
28379
28460
|
class Translations extends APIResource2 {
|
|
28380
28461
|
create(body2, options) {
|
|
28381
|
-
return this._client.post("/audio/translations", multipartFormRequestOptions({ body: body2, ...options }));
|
|
28462
|
+
return this._client.post("/audio/translations", multipartFormRequestOptions({ body: body2, ...options, __metadata: { model: body2.model } }));
|
|
28382
28463
|
}
|
|
28383
28464
|
}
|
|
28384
28465
|
|
|
@@ -28477,7 +28558,7 @@ var isToolMessage = (message) => {
|
|
|
28477
28558
|
};
|
|
28478
28559
|
|
|
28479
28560
|
// ../../node_modules/openai/lib/EventStream.mjs
|
|
28480
|
-
var
|
|
28561
|
+
var __classPrivateFieldSet11 = function(receiver, state, value, kind3, f2) {
|
|
28481
28562
|
if (kind3 === "m")
|
|
28482
28563
|
throw new TypeError("Private method is not writable");
|
|
28483
28564
|
if (kind3 === "a" && !f2)
|
|
@@ -28486,7 +28567,7 @@ var __classPrivateFieldSet10 = function(receiver, state, value, kind3, f2) {
|
|
|
28486
28567
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
28487
28568
|
return kind3 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
28488
28569
|
};
|
|
28489
|
-
var
|
|
28570
|
+
var __classPrivateFieldGet12 = function(receiver, state, kind3, f2) {
|
|
28490
28571
|
if (kind3 === "a" && !f2)
|
|
28491
28572
|
throw new TypeError("Private accessor was defined without a getter");
|
|
28492
28573
|
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
@@ -28522,50 +28603,50 @@ class EventStream {
|
|
|
28522
28603
|
_EventStream_errored.set(this, false);
|
|
28523
28604
|
_EventStream_aborted.set(this, false);
|
|
28524
28605
|
_EventStream_catchingPromiseCreated.set(this, false);
|
|
28525
|
-
|
|
28526
|
-
|
|
28527
|
-
|
|
28606
|
+
__classPrivateFieldSet11(this, _EventStream_connectedPromise, new Promise((resolve, reject) => {
|
|
28607
|
+
__classPrivateFieldSet11(this, _EventStream_resolveConnectedPromise, resolve, "f");
|
|
28608
|
+
__classPrivateFieldSet11(this, _EventStream_rejectConnectedPromise, reject, "f");
|
|
28528
28609
|
}), "f");
|
|
28529
|
-
|
|
28530
|
-
|
|
28531
|
-
|
|
28610
|
+
__classPrivateFieldSet11(this, _EventStream_endPromise, new Promise((resolve, reject) => {
|
|
28611
|
+
__classPrivateFieldSet11(this, _EventStream_resolveEndPromise, resolve, "f");
|
|
28612
|
+
__classPrivateFieldSet11(this, _EventStream_rejectEndPromise, reject, "f");
|
|
28532
28613
|
}), "f");
|
|
28533
|
-
|
|
28534
|
-
|
|
28614
|
+
__classPrivateFieldGet12(this, _EventStream_connectedPromise, "f").catch(() => {});
|
|
28615
|
+
__classPrivateFieldGet12(this, _EventStream_endPromise, "f").catch(() => {});
|
|
28535
28616
|
}
|
|
28536
28617
|
_run(executor) {
|
|
28537
28618
|
setTimeout(() => {
|
|
28538
28619
|
executor().then(() => {
|
|
28539
28620
|
this._emitFinal();
|
|
28540
28621
|
this._emit("end");
|
|
28541
|
-
},
|
|
28622
|
+
}, __classPrivateFieldGet12(this, _EventStream_instances, "m", _EventStream_handleError).bind(this));
|
|
28542
28623
|
}, 0);
|
|
28543
28624
|
}
|
|
28544
28625
|
_connected() {
|
|
28545
28626
|
if (this.ended)
|
|
28546
28627
|
return;
|
|
28547
|
-
|
|
28628
|
+
__classPrivateFieldGet12(this, _EventStream_resolveConnectedPromise, "f").call(this);
|
|
28548
28629
|
this._emit("connect");
|
|
28549
28630
|
}
|
|
28550
28631
|
get ended() {
|
|
28551
|
-
return
|
|
28632
|
+
return __classPrivateFieldGet12(this, _EventStream_ended, "f");
|
|
28552
28633
|
}
|
|
28553
28634
|
get errored() {
|
|
28554
|
-
return
|
|
28635
|
+
return __classPrivateFieldGet12(this, _EventStream_errored, "f");
|
|
28555
28636
|
}
|
|
28556
28637
|
get aborted() {
|
|
28557
|
-
return
|
|
28638
|
+
return __classPrivateFieldGet12(this, _EventStream_aborted, "f");
|
|
28558
28639
|
}
|
|
28559
28640
|
abort() {
|
|
28560
28641
|
this.controller.abort();
|
|
28561
28642
|
}
|
|
28562
28643
|
on(event, listener) {
|
|
28563
|
-
const listeners =
|
|
28644
|
+
const listeners = __classPrivateFieldGet12(this, _EventStream_listeners, "f")[event] || (__classPrivateFieldGet12(this, _EventStream_listeners, "f")[event] = []);
|
|
28564
28645
|
listeners.push({ listener });
|
|
28565
28646
|
return this;
|
|
28566
28647
|
}
|
|
28567
28648
|
off(event, listener) {
|
|
28568
|
-
const listeners =
|
|
28649
|
+
const listeners = __classPrivateFieldGet12(this, _EventStream_listeners, "f")[event];
|
|
28569
28650
|
if (!listeners)
|
|
28570
28651
|
return this;
|
|
28571
28652
|
const index = listeners.findIndex((l2) => l2.listener === listener);
|
|
@@ -28574,64 +28655,64 @@ class EventStream {
|
|
|
28574
28655
|
return this;
|
|
28575
28656
|
}
|
|
28576
28657
|
once(event, listener) {
|
|
28577
|
-
const listeners =
|
|
28658
|
+
const listeners = __classPrivateFieldGet12(this, _EventStream_listeners, "f")[event] || (__classPrivateFieldGet12(this, _EventStream_listeners, "f")[event] = []);
|
|
28578
28659
|
listeners.push({ listener, once: true });
|
|
28579
28660
|
return this;
|
|
28580
28661
|
}
|
|
28581
28662
|
emitted(event) {
|
|
28582
28663
|
return new Promise((resolve, reject) => {
|
|
28583
|
-
|
|
28664
|
+
__classPrivateFieldSet11(this, _EventStream_catchingPromiseCreated, true, "f");
|
|
28584
28665
|
if (event !== "error")
|
|
28585
28666
|
this.once("error", reject);
|
|
28586
28667
|
this.once(event, resolve);
|
|
28587
28668
|
});
|
|
28588
28669
|
}
|
|
28589
28670
|
async done() {
|
|
28590
|
-
|
|
28591
|
-
await
|
|
28671
|
+
__classPrivateFieldSet11(this, _EventStream_catchingPromiseCreated, true, "f");
|
|
28672
|
+
await __classPrivateFieldGet12(this, _EventStream_endPromise, "f");
|
|
28592
28673
|
}
|
|
28593
28674
|
_emit(event, ...args2) {
|
|
28594
|
-
if (
|
|
28675
|
+
if (__classPrivateFieldGet12(this, _EventStream_ended, "f")) {
|
|
28595
28676
|
return;
|
|
28596
28677
|
}
|
|
28597
28678
|
if (event === "end") {
|
|
28598
|
-
|
|
28599
|
-
|
|
28679
|
+
__classPrivateFieldSet11(this, _EventStream_ended, true, "f");
|
|
28680
|
+
__classPrivateFieldGet12(this, _EventStream_resolveEndPromise, "f").call(this);
|
|
28600
28681
|
}
|
|
28601
|
-
const listeners =
|
|
28682
|
+
const listeners = __classPrivateFieldGet12(this, _EventStream_listeners, "f")[event];
|
|
28602
28683
|
if (listeners) {
|
|
28603
|
-
|
|
28684
|
+
__classPrivateFieldGet12(this, _EventStream_listeners, "f")[event] = listeners.filter((l2) => !l2.once);
|
|
28604
28685
|
listeners.forEach(({ listener }) => listener(...args2));
|
|
28605
28686
|
}
|
|
28606
28687
|
if (event === "abort") {
|
|
28607
28688
|
const error = args2[0];
|
|
28608
|
-
if (!
|
|
28689
|
+
if (!__classPrivateFieldGet12(this, _EventStream_catchingPromiseCreated, "f") && !listeners?.length) {
|
|
28609
28690
|
Promise.reject(error);
|
|
28610
28691
|
}
|
|
28611
|
-
|
|
28612
|
-
|
|
28692
|
+
__classPrivateFieldGet12(this, _EventStream_rejectConnectedPromise, "f").call(this, error);
|
|
28693
|
+
__classPrivateFieldGet12(this, _EventStream_rejectEndPromise, "f").call(this, error);
|
|
28613
28694
|
this._emit("end");
|
|
28614
28695
|
return;
|
|
28615
28696
|
}
|
|
28616
28697
|
if (event === "error") {
|
|
28617
28698
|
const error = args2[0];
|
|
28618
|
-
if (!
|
|
28699
|
+
if (!__classPrivateFieldGet12(this, _EventStream_catchingPromiseCreated, "f") && !listeners?.length) {
|
|
28619
28700
|
Promise.reject(error);
|
|
28620
28701
|
}
|
|
28621
|
-
|
|
28622
|
-
|
|
28702
|
+
__classPrivateFieldGet12(this, _EventStream_rejectConnectedPromise, "f").call(this, error);
|
|
28703
|
+
__classPrivateFieldGet12(this, _EventStream_rejectEndPromise, "f").call(this, error);
|
|
28623
28704
|
this._emit("end");
|
|
28624
28705
|
}
|
|
28625
28706
|
}
|
|
28626
28707
|
_emitFinal() {}
|
|
28627
28708
|
}
|
|
28628
28709
|
_EventStream_connectedPromise = new WeakMap, _EventStream_resolveConnectedPromise = new WeakMap, _EventStream_rejectConnectedPromise = new WeakMap, _EventStream_endPromise = new WeakMap, _EventStream_resolveEndPromise = new WeakMap, _EventStream_rejectEndPromise = new WeakMap, _EventStream_listeners = new WeakMap, _EventStream_ended = new WeakMap, _EventStream_errored = new WeakMap, _EventStream_aborted = new WeakMap, _EventStream_catchingPromiseCreated = new WeakMap, _EventStream_instances = new WeakSet, _EventStream_handleError = function _EventStream_handleError2(error) {
|
|
28629
|
-
|
|
28710
|
+
__classPrivateFieldSet11(this, _EventStream_errored, true, "f");
|
|
28630
28711
|
if (error instanceof Error && error.name === "AbortError") {
|
|
28631
28712
|
error = new APIUserAbortError2;
|
|
28632
28713
|
}
|
|
28633
28714
|
if (error instanceof APIUserAbortError2) {
|
|
28634
|
-
|
|
28715
|
+
__classPrivateFieldSet11(this, _EventStream_aborted, true, "f");
|
|
28635
28716
|
return this._emit("abort", error);
|
|
28636
28717
|
}
|
|
28637
28718
|
if (error instanceof OpenAIError) {
|
|
@@ -28658,7 +28739,13 @@ function maybeParseChatCompletion(completion, params) {
|
|
|
28658
28739
|
...completion,
|
|
28659
28740
|
choices: completion.choices.map((choice) => ({
|
|
28660
28741
|
...choice,
|
|
28661
|
-
message: {
|
|
28742
|
+
message: {
|
|
28743
|
+
...choice.message,
|
|
28744
|
+
parsed: null,
|
|
28745
|
+
...choice.message.tool_calls ? {
|
|
28746
|
+
tool_calls: choice.message.tool_calls
|
|
28747
|
+
} : undefined
|
|
28748
|
+
}
|
|
28662
28749
|
}))
|
|
28663
28750
|
};
|
|
28664
28751
|
}
|
|
@@ -28676,7 +28763,9 @@ function parseChatCompletion(completion, params) {
|
|
|
28676
28763
|
...choice,
|
|
28677
28764
|
message: {
|
|
28678
28765
|
...choice.message,
|
|
28679
|
-
|
|
28766
|
+
...choice.message.tool_calls ? {
|
|
28767
|
+
tool_calls: choice.message.tool_calls?.map((toolCall) => parseToolCall(params, toolCall)) ?? undefined
|
|
28768
|
+
} : undefined,
|
|
28680
28769
|
parsed: choice.message.content && !choice.message.refusal ? parseResponseFormat(params, choice.message.content) : null
|
|
28681
28770
|
}
|
|
28682
28771
|
};
|
|
@@ -28731,7 +28820,7 @@ function validateInputTools(tools) {
|
|
|
28731
28820
|
}
|
|
28732
28821
|
|
|
28733
28822
|
// ../../node_modules/openai/lib/AbstractChatCompletionRunner.mjs
|
|
28734
|
-
var
|
|
28823
|
+
var __classPrivateFieldGet13 = function(receiver, state, kind3, f2) {
|
|
28735
28824
|
if (kind3 === "a" && !f2)
|
|
28736
28825
|
throw new TypeError("Private accessor was defined without a getter");
|
|
28737
28826
|
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
@@ -28791,23 +28880,23 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
28791
28880
|
}
|
|
28792
28881
|
async finalContent() {
|
|
28793
28882
|
await this.done();
|
|
28794
|
-
return
|
|
28883
|
+
return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalContent).call(this);
|
|
28795
28884
|
}
|
|
28796
28885
|
async finalMessage() {
|
|
28797
28886
|
await this.done();
|
|
28798
|
-
return
|
|
28887
|
+
return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this);
|
|
28799
28888
|
}
|
|
28800
28889
|
async finalFunctionCall() {
|
|
28801
28890
|
await this.done();
|
|
28802
|
-
return
|
|
28891
|
+
return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCall).call(this);
|
|
28803
28892
|
}
|
|
28804
28893
|
async finalFunctionCallResult() {
|
|
28805
28894
|
await this.done();
|
|
28806
|
-
return
|
|
28895
|
+
return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCallResult).call(this);
|
|
28807
28896
|
}
|
|
28808
28897
|
async totalUsage() {
|
|
28809
28898
|
await this.done();
|
|
28810
|
-
return
|
|
28899
|
+
return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_calculateTotalUsage).call(this);
|
|
28811
28900
|
}
|
|
28812
28901
|
allChatCompletions() {
|
|
28813
28902
|
return [...this._chatCompletions];
|
|
@@ -28816,20 +28905,20 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
28816
28905
|
const completion = this._chatCompletions[this._chatCompletions.length - 1];
|
|
28817
28906
|
if (completion)
|
|
28818
28907
|
this._emit("finalChatCompletion", completion);
|
|
28819
|
-
const finalMessage =
|
|
28908
|
+
const finalMessage = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this);
|
|
28820
28909
|
if (finalMessage)
|
|
28821
28910
|
this._emit("finalMessage", finalMessage);
|
|
28822
|
-
const finalContent =
|
|
28911
|
+
const finalContent = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalContent).call(this);
|
|
28823
28912
|
if (finalContent)
|
|
28824
28913
|
this._emit("finalContent", finalContent);
|
|
28825
|
-
const finalFunctionCall =
|
|
28914
|
+
const finalFunctionCall = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCall).call(this);
|
|
28826
28915
|
if (finalFunctionCall)
|
|
28827
28916
|
this._emit("finalFunctionCall", finalFunctionCall);
|
|
28828
|
-
const finalFunctionCallResult =
|
|
28917
|
+
const finalFunctionCallResult = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCallResult).call(this);
|
|
28829
28918
|
if (finalFunctionCallResult != null)
|
|
28830
28919
|
this._emit("finalFunctionCallResult", finalFunctionCallResult);
|
|
28831
28920
|
if (this._chatCompletions.some((c2) => c2.usage)) {
|
|
28832
|
-
this._emit("totalUsage",
|
|
28921
|
+
this._emit("totalUsage", __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_calculateTotalUsage).call(this));
|
|
28833
28922
|
}
|
|
28834
28923
|
}
|
|
28835
28924
|
async _createChatCompletion(client, params, options) {
|
|
@@ -28839,7 +28928,7 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
28839
28928
|
this.controller.abort();
|
|
28840
28929
|
signal.addEventListener("abort", () => this.controller.abort());
|
|
28841
28930
|
}
|
|
28842
|
-
|
|
28931
|
+
__classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_validateParams).call(this, params);
|
|
28843
28932
|
const chatCompletion = await client.chat.completions.create({ ...params, stream: false }, { ...options, signal: this.controller.signal });
|
|
28844
28933
|
this._connected();
|
|
28845
28934
|
return this._addChatCompletion(parseChatCompletion(chatCompletion, params));
|
|
@@ -28903,7 +28992,7 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
28903
28992
|
continue;
|
|
28904
28993
|
}
|
|
28905
28994
|
const rawContent = await fn.function(parsed, this);
|
|
28906
|
-
const content =
|
|
28995
|
+
const content = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_stringifyFunctionCallResult).call(this, rawContent);
|
|
28907
28996
|
this._addMessage({ role, name: name2, content });
|
|
28908
28997
|
if (singleFunctionToCall)
|
|
28909
28998
|
return;
|
|
@@ -28989,7 +29078,7 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
28989
29078
|
continue;
|
|
28990
29079
|
}
|
|
28991
29080
|
const rawContent = await fn.function(parsed, this);
|
|
28992
|
-
const content =
|
|
29081
|
+
const content = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_stringifyFunctionCallResult).call(this, rawContent);
|
|
28993
29082
|
this._addMessage({ role, tool_call_id, content });
|
|
28994
29083
|
if (singleFunctionToCall) {
|
|
28995
29084
|
return;
|
|
@@ -29000,7 +29089,7 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
29000
29089
|
}
|
|
29001
29090
|
}
|
|
29002
29091
|
_AbstractChatCompletionRunner_instances = new WeakSet, _AbstractChatCompletionRunner_getFinalContent = function _AbstractChatCompletionRunner_getFinalContent2() {
|
|
29003
|
-
return
|
|
29092
|
+
return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this).content ?? null;
|
|
29004
29093
|
}, _AbstractChatCompletionRunner_getFinalMessage = function _AbstractChatCompletionRunner_getFinalMessage2() {
|
|
29005
29094
|
let i3 = this.messages.length;
|
|
29006
29095
|
while (i3-- > 0) {
|
|
@@ -29306,7 +29395,7 @@ var _parseJSON = (jsonString, allow) => {
|
|
|
29306
29395
|
var partialParse2 = (input) => parseJSON(input, Allow.ALL ^ Allow.NUM);
|
|
29307
29396
|
|
|
29308
29397
|
// ../../node_modules/openai/lib/ChatCompletionStream.mjs
|
|
29309
|
-
var
|
|
29398
|
+
var __classPrivateFieldSet12 = function(receiver, state, value, kind3, f2) {
|
|
29310
29399
|
if (kind3 === "m")
|
|
29311
29400
|
throw new TypeError("Private method is not writable");
|
|
29312
29401
|
if (kind3 === "a" && !f2)
|
|
@@ -29315,7 +29404,7 @@ var __classPrivateFieldSet11 = function(receiver, state, value, kind3, f2) {
|
|
|
29315
29404
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
29316
29405
|
return kind3 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
29317
29406
|
};
|
|
29318
|
-
var
|
|
29407
|
+
var __classPrivateFieldGet14 = function(receiver, state, kind3, f2) {
|
|
29319
29408
|
if (kind3 === "a" && !f2)
|
|
29320
29409
|
throw new TypeError("Private accessor was defined without a getter");
|
|
29321
29410
|
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
@@ -29342,11 +29431,11 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
29342
29431
|
_ChatCompletionStream_params.set(this, undefined);
|
|
29343
29432
|
_ChatCompletionStream_choiceEventStates.set(this, undefined);
|
|
29344
29433
|
_ChatCompletionStream_currentChatCompletionSnapshot.set(this, undefined);
|
|
29345
|
-
|
|
29346
|
-
|
|
29434
|
+
__classPrivateFieldSet12(this, _ChatCompletionStream_params, params, "f");
|
|
29435
|
+
__classPrivateFieldSet12(this, _ChatCompletionStream_choiceEventStates, [], "f");
|
|
29347
29436
|
}
|
|
29348
29437
|
get currentChatCompletionSnapshot() {
|
|
29349
|
-
return
|
|
29438
|
+
return __classPrivateFieldGet14(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
|
|
29350
29439
|
}
|
|
29351
29440
|
static fromReadableStream(stream) {
|
|
29352
29441
|
const runner = new ChatCompletionStream(null);
|
|
@@ -29366,16 +29455,16 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
29366
29455
|
this.controller.abort();
|
|
29367
29456
|
signal.addEventListener("abort", () => this.controller.abort());
|
|
29368
29457
|
}
|
|
29369
|
-
|
|
29458
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_beginRequest).call(this);
|
|
29370
29459
|
const stream = await client.chat.completions.create({ ...params, stream: true }, { ...options, signal: this.controller.signal });
|
|
29371
29460
|
this._connected();
|
|
29372
29461
|
for await (const chunk of stream) {
|
|
29373
|
-
|
|
29462
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_addChunk).call(this, chunk);
|
|
29374
29463
|
}
|
|
29375
29464
|
if (stream.controller.signal?.aborted) {
|
|
29376
29465
|
throw new APIUserAbortError2;
|
|
29377
29466
|
}
|
|
29378
|
-
return this._addChatCompletion(
|
|
29467
|
+
return this._addChatCompletion(__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
29379
29468
|
}
|
|
29380
29469
|
async _fromReadableStream(readableStream, options) {
|
|
29381
29470
|
const signal = options?.signal;
|
|
@@ -29384,28 +29473,28 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
29384
29473
|
this.controller.abort();
|
|
29385
29474
|
signal.addEventListener("abort", () => this.controller.abort());
|
|
29386
29475
|
}
|
|
29387
|
-
|
|
29476
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_beginRequest).call(this);
|
|
29388
29477
|
this._connected();
|
|
29389
29478
|
const stream = Stream2.fromReadableStream(readableStream, this.controller);
|
|
29390
29479
|
let chatId;
|
|
29391
29480
|
for await (const chunk of stream) {
|
|
29392
29481
|
if (chatId && chatId !== chunk.id) {
|
|
29393
|
-
this._addChatCompletion(
|
|
29482
|
+
this._addChatCompletion(__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
29394
29483
|
}
|
|
29395
|
-
|
|
29484
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_addChunk).call(this, chunk);
|
|
29396
29485
|
chatId = chunk.id;
|
|
29397
29486
|
}
|
|
29398
29487
|
if (stream.controller.signal?.aborted) {
|
|
29399
29488
|
throw new APIUserAbortError2;
|
|
29400
29489
|
}
|
|
29401
|
-
return this._addChatCompletion(
|
|
29490
|
+
return this._addChatCompletion(__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
29402
29491
|
}
|
|
29403
29492
|
[(_ChatCompletionStream_params = new WeakMap, _ChatCompletionStream_choiceEventStates = new WeakMap, _ChatCompletionStream_currentChatCompletionSnapshot = new WeakMap, _ChatCompletionStream_instances = new WeakSet, _ChatCompletionStream_beginRequest = function _ChatCompletionStream_beginRequest() {
|
|
29404
29493
|
if (this.ended)
|
|
29405
29494
|
return;
|
|
29406
|
-
|
|
29495
|
+
__classPrivateFieldSet12(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
|
|
29407
29496
|
}, _ChatCompletionStream_getChoiceEventState = function _ChatCompletionStream_getChoiceEventState(choice) {
|
|
29408
|
-
let state =
|
|
29497
|
+
let state = __classPrivateFieldGet14(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index];
|
|
29409
29498
|
if (state) {
|
|
29410
29499
|
return state;
|
|
29411
29500
|
}
|
|
@@ -29417,12 +29506,12 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
29417
29506
|
done_tool_calls: new Set,
|
|
29418
29507
|
current_tool_call_index: null
|
|
29419
29508
|
};
|
|
29420
|
-
|
|
29509
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index] = state;
|
|
29421
29510
|
return state;
|
|
29422
29511
|
}, _ChatCompletionStream_addChunk = function _ChatCompletionStream_addChunk(chunk) {
|
|
29423
29512
|
if (this.ended)
|
|
29424
29513
|
return;
|
|
29425
|
-
const completion =
|
|
29514
|
+
const completion = __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_accumulateChatCompletion).call(this, chunk);
|
|
29426
29515
|
this._emit("chunk", chunk, completion);
|
|
29427
29516
|
for (const choice of chunk.choices) {
|
|
29428
29517
|
const choiceSnapshot = completion.choices[choice.index];
|
|
@@ -29452,18 +29541,18 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
29452
29541
|
snapshot: choiceSnapshot.logprobs?.refusal ?? []
|
|
29453
29542
|
});
|
|
29454
29543
|
}
|
|
29455
|
-
const state =
|
|
29544
|
+
const state = __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
29456
29545
|
if (choiceSnapshot.finish_reason) {
|
|
29457
|
-
|
|
29546
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);
|
|
29458
29547
|
if (state.current_tool_call_index != null) {
|
|
29459
|
-
|
|
29548
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state.current_tool_call_index);
|
|
29460
29549
|
}
|
|
29461
29550
|
}
|
|
29462
29551
|
for (const toolCall of choice.delta.tool_calls ?? []) {
|
|
29463
29552
|
if (state.current_tool_call_index !== toolCall.index) {
|
|
29464
|
-
|
|
29553
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);
|
|
29465
29554
|
if (state.current_tool_call_index != null) {
|
|
29466
|
-
|
|
29555
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state.current_tool_call_index);
|
|
29467
29556
|
}
|
|
29468
29557
|
}
|
|
29469
29558
|
state.current_tool_call_index = toolCall.index;
|
|
@@ -29487,7 +29576,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
29487
29576
|
}
|
|
29488
29577
|
}
|
|
29489
29578
|
}, _ChatCompletionStream_emitToolCallDoneEvent = function _ChatCompletionStream_emitToolCallDoneEvent(choiceSnapshot, toolCallIndex) {
|
|
29490
|
-
const state =
|
|
29579
|
+
const state = __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
29491
29580
|
if (state.done_tool_calls.has(toolCallIndex)) {
|
|
29492
29581
|
return;
|
|
29493
29582
|
}
|
|
@@ -29499,7 +29588,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
29499
29588
|
throw new Error("tool call snapshot missing `type`");
|
|
29500
29589
|
}
|
|
29501
29590
|
if (toolCallSnapshot.type === "function") {
|
|
29502
|
-
const inputTool =
|
|
29591
|
+
const inputTool = __classPrivateFieldGet14(this, _ChatCompletionStream_params, "f")?.tools?.find((tool) => tool.type === "function" && tool.function.name === toolCallSnapshot.function.name);
|
|
29503
29592
|
this._emit("tool_calls.function.arguments.done", {
|
|
29504
29593
|
name: toolCallSnapshot.function.name,
|
|
29505
29594
|
index: toolCallIndex,
|
|
@@ -29510,10 +29599,10 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
29510
29599
|
assertNever(toolCallSnapshot.type);
|
|
29511
29600
|
}
|
|
29512
29601
|
}, _ChatCompletionStream_emitContentDoneEvents = function _ChatCompletionStream_emitContentDoneEvents(choiceSnapshot) {
|
|
29513
|
-
const state =
|
|
29602
|
+
const state = __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
29514
29603
|
if (choiceSnapshot.message.content && !state.content_done) {
|
|
29515
29604
|
state.content_done = true;
|
|
29516
|
-
const responseFormat =
|
|
29605
|
+
const responseFormat = __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getAutoParseableResponseFormat).call(this);
|
|
29517
29606
|
this._emit("content.done", {
|
|
29518
29607
|
content: choiceSnapshot.message.content,
|
|
29519
29608
|
parsed: responseFormat ? responseFormat.$parseRaw(choiceSnapshot.message.content) : null
|
|
@@ -29535,25 +29624,25 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
29535
29624
|
if (this.ended) {
|
|
29536
29625
|
throw new OpenAIError(`stream has ended, this shouldn't happen`);
|
|
29537
29626
|
}
|
|
29538
|
-
const snapshot =
|
|
29627
|
+
const snapshot = __classPrivateFieldGet14(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
|
|
29539
29628
|
if (!snapshot) {
|
|
29540
29629
|
throw new OpenAIError(`request ended without sending any chunks`);
|
|
29541
29630
|
}
|
|
29542
|
-
|
|
29543
|
-
|
|
29544
|
-
return finalizeChatCompletion(snapshot,
|
|
29631
|
+
__classPrivateFieldSet12(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
|
|
29632
|
+
__classPrivateFieldSet12(this, _ChatCompletionStream_choiceEventStates, [], "f");
|
|
29633
|
+
return finalizeChatCompletion(snapshot, __classPrivateFieldGet14(this, _ChatCompletionStream_params, "f"));
|
|
29545
29634
|
}, _ChatCompletionStream_getAutoParseableResponseFormat = function _ChatCompletionStream_getAutoParseableResponseFormat() {
|
|
29546
|
-
const responseFormat =
|
|
29635
|
+
const responseFormat = __classPrivateFieldGet14(this, _ChatCompletionStream_params, "f")?.response_format;
|
|
29547
29636
|
if (isAutoParsableResponseFormat(responseFormat)) {
|
|
29548
29637
|
return responseFormat;
|
|
29549
29638
|
}
|
|
29550
29639
|
return null;
|
|
29551
29640
|
}, _ChatCompletionStream_accumulateChatCompletion = function _ChatCompletionStream_accumulateChatCompletion(chunk) {
|
|
29552
29641
|
var _a2, _b, _c, _d;
|
|
29553
|
-
let snapshot =
|
|
29642
|
+
let snapshot = __classPrivateFieldGet14(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
|
|
29554
29643
|
const { choices, ...rest } = chunk;
|
|
29555
29644
|
if (!snapshot) {
|
|
29556
|
-
snapshot =
|
|
29645
|
+
snapshot = __classPrivateFieldSet12(this, _ChatCompletionStream_currentChatCompletionSnapshot, {
|
|
29557
29646
|
...rest,
|
|
29558
29647
|
choices: []
|
|
29559
29648
|
}, "f");
|
|
@@ -29584,7 +29673,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
29584
29673
|
}
|
|
29585
29674
|
if (finish_reason) {
|
|
29586
29675
|
choice.finish_reason = finish_reason;
|
|
29587
|
-
if (
|
|
29676
|
+
if (__classPrivateFieldGet14(this, _ChatCompletionStream_params, "f") && hasAutoParseableInput(__classPrivateFieldGet14(this, _ChatCompletionStream_params, "f"))) {
|
|
29588
29677
|
if (finish_reason === "length") {
|
|
29589
29678
|
throw new LengthFinishReasonError;
|
|
29590
29679
|
}
|
|
@@ -29618,7 +29707,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
29618
29707
|
}
|
|
29619
29708
|
if (content) {
|
|
29620
29709
|
choice.message.content = (choice.message.content || "") + content;
|
|
29621
|
-
if (!choice.message.refusal &&
|
|
29710
|
+
if (!choice.message.refusal && __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getAutoParseableResponseFormat).call(this)) {
|
|
29622
29711
|
choice.message.parsed = partialParse2(choice.message.content);
|
|
29623
29712
|
}
|
|
29624
29713
|
}
|
|
@@ -29638,7 +29727,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
29638
29727
|
tool_call.function.name = fn.name;
|
|
29639
29728
|
if (fn?.arguments) {
|
|
29640
29729
|
tool_call.function.arguments += fn.arguments;
|
|
29641
|
-
if (shouldParseToolCall(
|
|
29730
|
+
if (shouldParseToolCall(__classPrivateFieldGet14(this, _ChatCompletionStream_params, "f"), tool_call)) {
|
|
29642
29731
|
tool_call.function.parsed_arguments = partialParse2(tool_call.function.arguments);
|
|
29643
29732
|
}
|
|
29644
29733
|
}
|
|
@@ -29872,24 +29961,37 @@ class Sessions extends APIResource2 {
|
|
|
29872
29961
|
}
|
|
29873
29962
|
}
|
|
29874
29963
|
|
|
29964
|
+
// ../../node_modules/openai/resources/beta/realtime/transcription-sessions.mjs
|
|
29965
|
+
class TranscriptionSessions extends APIResource2 {
|
|
29966
|
+
create(body2, options) {
|
|
29967
|
+
return this._client.post("/realtime/transcription_sessions", {
|
|
29968
|
+
body: body2,
|
|
29969
|
+
...options,
|
|
29970
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
29971
|
+
});
|
|
29972
|
+
}
|
|
29973
|
+
}
|
|
29974
|
+
|
|
29875
29975
|
// ../../node_modules/openai/resources/beta/realtime/realtime.mjs
|
|
29876
29976
|
class Realtime extends APIResource2 {
|
|
29877
29977
|
constructor() {
|
|
29878
29978
|
super(...arguments);
|
|
29879
29979
|
this.sessions = new Sessions(this._client);
|
|
29980
|
+
this.transcriptionSessions = new TranscriptionSessions(this._client);
|
|
29880
29981
|
}
|
|
29881
29982
|
}
|
|
29882
29983
|
Realtime.Sessions = Sessions;
|
|
29984
|
+
Realtime.TranscriptionSessions = TranscriptionSessions;
|
|
29883
29985
|
|
|
29884
29986
|
// ../../node_modules/openai/lib/AssistantStream.mjs
|
|
29885
|
-
var
|
|
29987
|
+
var __classPrivateFieldGet15 = function(receiver, state, kind3, f2) {
|
|
29886
29988
|
if (kind3 === "a" && !f2)
|
|
29887
29989
|
throw new TypeError("Private accessor was defined without a getter");
|
|
29888
29990
|
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
29889
29991
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
29890
29992
|
return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
29891
29993
|
};
|
|
29892
|
-
var
|
|
29994
|
+
var __classPrivateFieldSet13 = function(receiver, state, value, kind3, f2) {
|
|
29893
29995
|
if (kind3 === "m")
|
|
29894
29996
|
throw new TypeError("Private method is not writable");
|
|
29895
29997
|
if (kind3 === "a" && !f2)
|
|
@@ -30003,12 +30105,12 @@ class AssistantStream extends EventStream {
|
|
|
30003
30105
|
this._connected();
|
|
30004
30106
|
const stream = Stream2.fromReadableStream(readableStream, this.controller);
|
|
30005
30107
|
for await (const event of stream) {
|
|
30006
|
-
|
|
30108
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
|
|
30007
30109
|
}
|
|
30008
30110
|
if (stream.controller.signal?.aborted) {
|
|
30009
30111
|
throw new APIUserAbortError2;
|
|
30010
30112
|
}
|
|
30011
|
-
return this._addRun(
|
|
30113
|
+
return this._addRun(__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
|
|
30012
30114
|
}
|
|
30013
30115
|
toReadableStream() {
|
|
30014
30116
|
const stream = new Stream2(this[Symbol.asyncIterator].bind(this), this.controller);
|
|
@@ -30036,12 +30138,12 @@ class AssistantStream extends EventStream {
|
|
|
30036
30138
|
});
|
|
30037
30139
|
this._connected();
|
|
30038
30140
|
for await (const event of stream) {
|
|
30039
|
-
|
|
30141
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
|
|
30040
30142
|
}
|
|
30041
30143
|
if (stream.controller.signal?.aborted) {
|
|
30042
30144
|
throw new APIUserAbortError2;
|
|
30043
30145
|
}
|
|
30044
|
-
return this._addRun(
|
|
30146
|
+
return this._addRun(__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
|
|
30045
30147
|
}
|
|
30046
30148
|
static createThreadAssistantStream(params, thread, options) {
|
|
30047
30149
|
const runner = new AssistantStream;
|
|
@@ -30060,30 +30162,30 @@ class AssistantStream extends EventStream {
|
|
|
30060
30162
|
return runner;
|
|
30061
30163
|
}
|
|
30062
30164
|
currentEvent() {
|
|
30063
|
-
return
|
|
30165
|
+
return __classPrivateFieldGet15(this, _AssistantStream_currentEvent, "f");
|
|
30064
30166
|
}
|
|
30065
30167
|
currentRun() {
|
|
30066
|
-
return
|
|
30168
|
+
return __classPrivateFieldGet15(this, _AssistantStream_currentRunSnapshot, "f");
|
|
30067
30169
|
}
|
|
30068
30170
|
currentMessageSnapshot() {
|
|
30069
|
-
return
|
|
30171
|
+
return __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f");
|
|
30070
30172
|
}
|
|
30071
30173
|
currentRunStepSnapshot() {
|
|
30072
|
-
return
|
|
30174
|
+
return __classPrivateFieldGet15(this, _AssistantStream_currentRunStepSnapshot, "f");
|
|
30073
30175
|
}
|
|
30074
30176
|
async finalRunSteps() {
|
|
30075
30177
|
await this.done();
|
|
30076
|
-
return Object.values(
|
|
30178
|
+
return Object.values(__classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f"));
|
|
30077
30179
|
}
|
|
30078
30180
|
async finalMessages() {
|
|
30079
30181
|
await this.done();
|
|
30080
|
-
return Object.values(
|
|
30182
|
+
return Object.values(__classPrivateFieldGet15(this, _AssistantStream_messageSnapshots, "f"));
|
|
30081
30183
|
}
|
|
30082
30184
|
async finalRun() {
|
|
30083
30185
|
await this.done();
|
|
30084
|
-
if (!
|
|
30186
|
+
if (!__classPrivateFieldGet15(this, _AssistantStream_finalRun, "f"))
|
|
30085
30187
|
throw Error("Final run was not received.");
|
|
30086
|
-
return
|
|
30188
|
+
return __classPrivateFieldGet15(this, _AssistantStream_finalRun, "f");
|
|
30087
30189
|
}
|
|
30088
30190
|
async _createThreadAssistantStream(thread, params, options) {
|
|
30089
30191
|
const signal = options?.signal;
|
|
@@ -30096,12 +30198,12 @@ class AssistantStream extends EventStream {
|
|
|
30096
30198
|
const stream = await thread.createAndRun(body2, { ...options, signal: this.controller.signal });
|
|
30097
30199
|
this._connected();
|
|
30098
30200
|
for await (const event of stream) {
|
|
30099
|
-
|
|
30201
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
|
|
30100
30202
|
}
|
|
30101
30203
|
if (stream.controller.signal?.aborted) {
|
|
30102
30204
|
throw new APIUserAbortError2;
|
|
30103
30205
|
}
|
|
30104
|
-
return this._addRun(
|
|
30206
|
+
return this._addRun(__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
|
|
30105
30207
|
}
|
|
30106
30208
|
async _createAssistantStream(run2, threadId, params, options) {
|
|
30107
30209
|
const signal = options?.signal;
|
|
@@ -30114,12 +30216,12 @@ class AssistantStream extends EventStream {
|
|
|
30114
30216
|
const stream = await run2.create(threadId, body2, { ...options, signal: this.controller.signal });
|
|
30115
30217
|
this._connected();
|
|
30116
30218
|
for await (const event of stream) {
|
|
30117
|
-
|
|
30219
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
|
|
30118
30220
|
}
|
|
30119
30221
|
if (stream.controller.signal?.aborted) {
|
|
30120
30222
|
throw new APIUserAbortError2;
|
|
30121
30223
|
}
|
|
30122
|
-
return this._addRun(
|
|
30224
|
+
return this._addRun(__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
|
|
30123
30225
|
}
|
|
30124
30226
|
static accumulateDelta(acc, delta) {
|
|
30125
30227
|
for (const [key, deltaValue] of Object.entries(delta)) {
|
|
@@ -30190,8 +30292,8 @@ class AssistantStream extends EventStream {
|
|
|
30190
30292
|
_AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
30191
30293
|
if (this.ended)
|
|
30192
30294
|
return;
|
|
30193
|
-
|
|
30194
|
-
|
|
30295
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentEvent, event, "f");
|
|
30296
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_handleEvent).call(this, event);
|
|
30195
30297
|
switch (event.event) {
|
|
30196
30298
|
case "thread.created":
|
|
30197
30299
|
break;
|
|
@@ -30200,11 +30302,12 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
30200
30302
|
case "thread.run.in_progress":
|
|
30201
30303
|
case "thread.run.requires_action":
|
|
30202
30304
|
case "thread.run.completed":
|
|
30305
|
+
case "thread.run.incomplete":
|
|
30203
30306
|
case "thread.run.failed":
|
|
30204
30307
|
case "thread.run.cancelling":
|
|
30205
30308
|
case "thread.run.cancelled":
|
|
30206
30309
|
case "thread.run.expired":
|
|
30207
|
-
|
|
30310
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_handleRun).call(this, event);
|
|
30208
30311
|
break;
|
|
30209
30312
|
case "thread.run.step.created":
|
|
30210
30313
|
case "thread.run.step.in_progress":
|
|
@@ -30213,29 +30316,31 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
30213
30316
|
case "thread.run.step.failed":
|
|
30214
30317
|
case "thread.run.step.cancelled":
|
|
30215
30318
|
case "thread.run.step.expired":
|
|
30216
|
-
|
|
30319
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_handleRunStep).call(this, event);
|
|
30217
30320
|
break;
|
|
30218
30321
|
case "thread.message.created":
|
|
30219
30322
|
case "thread.message.in_progress":
|
|
30220
30323
|
case "thread.message.delta":
|
|
30221
30324
|
case "thread.message.completed":
|
|
30222
30325
|
case "thread.message.incomplete":
|
|
30223
|
-
|
|
30326
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_handleMessage).call(this, event);
|
|
30224
30327
|
break;
|
|
30225
30328
|
case "error":
|
|
30226
30329
|
throw new Error("Encountered an error event in event processing - errors should be processed earlier");
|
|
30330
|
+
default:
|
|
30331
|
+
assertNever2(event);
|
|
30227
30332
|
}
|
|
30228
30333
|
}, _AssistantStream_endRequest = function _AssistantStream_endRequest2() {
|
|
30229
30334
|
if (this.ended) {
|
|
30230
30335
|
throw new OpenAIError(`stream has ended, this shouldn't happen`);
|
|
30231
30336
|
}
|
|
30232
|
-
if (!
|
|
30337
|
+
if (!__classPrivateFieldGet15(this, _AssistantStream_finalRun, "f"))
|
|
30233
30338
|
throw Error("Final run has not been received");
|
|
30234
|
-
return
|
|
30339
|
+
return __classPrivateFieldGet15(this, _AssistantStream_finalRun, "f");
|
|
30235
30340
|
}, _AssistantStream_handleMessage = function _AssistantStream_handleMessage2(event) {
|
|
30236
|
-
const [accumulatedMessage, newContent] =
|
|
30237
|
-
|
|
30238
|
-
|
|
30341
|
+
const [accumulatedMessage, newContent] = __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_accumulateMessage).call(this, event, __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f"));
|
|
30342
|
+
__classPrivateFieldSet13(this, _AssistantStream_messageSnapshot, accumulatedMessage, "f");
|
|
30343
|
+
__classPrivateFieldGet15(this, _AssistantStream_messageSnapshots, "f")[accumulatedMessage.id] = accumulatedMessage;
|
|
30239
30344
|
for (const content of newContent) {
|
|
30240
30345
|
const snapshotContent = accumulatedMessage.content[content.index];
|
|
30241
30346
|
if (snapshotContent?.type == "text") {
|
|
@@ -30261,46 +30366,46 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
30261
30366
|
throw Error("The snapshot associated with this text delta is not text or missing");
|
|
30262
30367
|
}
|
|
30263
30368
|
}
|
|
30264
|
-
if (content.index !=
|
|
30265
|
-
if (
|
|
30266
|
-
switch (
|
|
30369
|
+
if (content.index != __classPrivateFieldGet15(this, _AssistantStream_currentContentIndex, "f")) {
|
|
30370
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_currentContent, "f")) {
|
|
30371
|
+
switch (__classPrivateFieldGet15(this, _AssistantStream_currentContent, "f").type) {
|
|
30267
30372
|
case "text":
|
|
30268
|
-
this._emit("textDone",
|
|
30373
|
+
this._emit("textDone", __classPrivateFieldGet15(this, _AssistantStream_currentContent, "f").text, __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f"));
|
|
30269
30374
|
break;
|
|
30270
30375
|
case "image_file":
|
|
30271
|
-
this._emit("imageFileDone",
|
|
30376
|
+
this._emit("imageFileDone", __classPrivateFieldGet15(this, _AssistantStream_currentContent, "f").image_file, __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f"));
|
|
30272
30377
|
break;
|
|
30273
30378
|
}
|
|
30274
30379
|
}
|
|
30275
|
-
|
|
30380
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentContentIndex, content.index, "f");
|
|
30276
30381
|
}
|
|
30277
|
-
|
|
30382
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentContent, accumulatedMessage.content[content.index], "f");
|
|
30278
30383
|
}
|
|
30279
30384
|
}
|
|
30280
30385
|
break;
|
|
30281
30386
|
case "thread.message.completed":
|
|
30282
30387
|
case "thread.message.incomplete":
|
|
30283
|
-
if (
|
|
30284
|
-
const currentContent = event.data.content[
|
|
30388
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_currentContentIndex, "f") !== undefined) {
|
|
30389
|
+
const currentContent = event.data.content[__classPrivateFieldGet15(this, _AssistantStream_currentContentIndex, "f")];
|
|
30285
30390
|
if (currentContent) {
|
|
30286
30391
|
switch (currentContent.type) {
|
|
30287
30392
|
case "image_file":
|
|
30288
|
-
this._emit("imageFileDone", currentContent.image_file,
|
|
30393
|
+
this._emit("imageFileDone", currentContent.image_file, __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f"));
|
|
30289
30394
|
break;
|
|
30290
30395
|
case "text":
|
|
30291
|
-
this._emit("textDone", currentContent.text,
|
|
30396
|
+
this._emit("textDone", currentContent.text, __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f"));
|
|
30292
30397
|
break;
|
|
30293
30398
|
}
|
|
30294
30399
|
}
|
|
30295
30400
|
}
|
|
30296
|
-
if (
|
|
30401
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f")) {
|
|
30297
30402
|
this._emit("messageDone", event.data);
|
|
30298
30403
|
}
|
|
30299
|
-
|
|
30404
|
+
__classPrivateFieldSet13(this, _AssistantStream_messageSnapshot, undefined, "f");
|
|
30300
30405
|
}
|
|
30301
30406
|
}, _AssistantStream_handleRunStep = function _AssistantStream_handleRunStep2(event) {
|
|
30302
|
-
const accumulatedRunStep =
|
|
30303
|
-
|
|
30407
|
+
const accumulatedRunStep = __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_accumulateRunStep).call(this, event);
|
|
30408
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentRunStepSnapshot, accumulatedRunStep, "f");
|
|
30304
30409
|
switch (event.event) {
|
|
30305
30410
|
case "thread.run.step.created":
|
|
30306
30411
|
this._emit("runStepCreated", event.data);
|
|
@@ -30309,16 +30414,16 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
30309
30414
|
const delta = event.data.delta;
|
|
30310
30415
|
if (delta.step_details && delta.step_details.type == "tool_calls" && delta.step_details.tool_calls && accumulatedRunStep.step_details.type == "tool_calls") {
|
|
30311
30416
|
for (const toolCall of delta.step_details.tool_calls) {
|
|
30312
|
-
if (toolCall.index ==
|
|
30417
|
+
if (toolCall.index == __classPrivateFieldGet15(this, _AssistantStream_currentToolCallIndex, "f")) {
|
|
30313
30418
|
this._emit("toolCallDelta", toolCall, accumulatedRunStep.step_details.tool_calls[toolCall.index]);
|
|
30314
30419
|
} else {
|
|
30315
|
-
if (
|
|
30316
|
-
this._emit("toolCallDone",
|
|
30420
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f")) {
|
|
30421
|
+
this._emit("toolCallDone", __classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f"));
|
|
30317
30422
|
}
|
|
30318
|
-
|
|
30319
|
-
|
|
30320
|
-
if (
|
|
30321
|
-
this._emit("toolCallCreated",
|
|
30423
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentToolCallIndex, toolCall.index, "f");
|
|
30424
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentToolCall, accumulatedRunStep.step_details.tool_calls[toolCall.index], "f");
|
|
30425
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f"))
|
|
30426
|
+
this._emit("toolCallCreated", __classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f"));
|
|
30322
30427
|
}
|
|
30323
30428
|
}
|
|
30324
30429
|
}
|
|
@@ -30328,12 +30433,12 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
30328
30433
|
case "thread.run.step.failed":
|
|
30329
30434
|
case "thread.run.step.cancelled":
|
|
30330
30435
|
case "thread.run.step.expired":
|
|
30331
|
-
|
|
30436
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentRunStepSnapshot, undefined, "f");
|
|
30332
30437
|
const details = event.data.step_details;
|
|
30333
30438
|
if (details.type == "tool_calls") {
|
|
30334
|
-
if (
|
|
30335
|
-
this._emit("toolCallDone",
|
|
30336
|
-
|
|
30439
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f")) {
|
|
30440
|
+
this._emit("toolCallDone", __classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f"));
|
|
30441
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentToolCall, undefined, "f");
|
|
30337
30442
|
}
|
|
30338
30443
|
}
|
|
30339
30444
|
this._emit("runStepDone", event.data, accumulatedRunStep);
|
|
@@ -30342,34 +30447,34 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
30342
30447
|
break;
|
|
30343
30448
|
}
|
|
30344
30449
|
}, _AssistantStream_handleEvent = function _AssistantStream_handleEvent2(event) {
|
|
30345
|
-
|
|
30450
|
+
__classPrivateFieldGet15(this, _AssistantStream_events, "f").push(event);
|
|
30346
30451
|
this._emit("event", event);
|
|
30347
30452
|
}, _AssistantStream_accumulateRunStep = function _AssistantStream_accumulateRunStep2(event) {
|
|
30348
30453
|
switch (event.event) {
|
|
30349
30454
|
case "thread.run.step.created":
|
|
30350
|
-
|
|
30455
|
+
__classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id] = event.data;
|
|
30351
30456
|
return event.data;
|
|
30352
30457
|
case "thread.run.step.delta":
|
|
30353
|
-
let snapshot =
|
|
30458
|
+
let snapshot = __classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id];
|
|
30354
30459
|
if (!snapshot) {
|
|
30355
30460
|
throw Error("Received a RunStepDelta before creation of a snapshot");
|
|
30356
30461
|
}
|
|
30357
30462
|
let data = event.data;
|
|
30358
30463
|
if (data.delta) {
|
|
30359
30464
|
const accumulated = AssistantStream.accumulateDelta(snapshot, data.delta);
|
|
30360
|
-
|
|
30465
|
+
__classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id] = accumulated;
|
|
30361
30466
|
}
|
|
30362
|
-
return
|
|
30467
|
+
return __classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id];
|
|
30363
30468
|
case "thread.run.step.completed":
|
|
30364
30469
|
case "thread.run.step.failed":
|
|
30365
30470
|
case "thread.run.step.cancelled":
|
|
30366
30471
|
case "thread.run.step.expired":
|
|
30367
30472
|
case "thread.run.step.in_progress":
|
|
30368
|
-
|
|
30473
|
+
__classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id] = event.data;
|
|
30369
30474
|
break;
|
|
30370
30475
|
}
|
|
30371
|
-
if (
|
|
30372
|
-
return
|
|
30476
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id])
|
|
30477
|
+
return __classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id];
|
|
30373
30478
|
throw new Error("No snapshot available");
|
|
30374
30479
|
}, _AssistantStream_accumulateMessage = function _AssistantStream_accumulateMessage2(event, snapshot) {
|
|
30375
30480
|
let newContent = [];
|
|
@@ -30385,7 +30490,7 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
30385
30490
|
for (const contentElement of data.delta.content) {
|
|
30386
30491
|
if (contentElement.index in snapshot.content) {
|
|
30387
30492
|
let currentContent = snapshot.content[contentElement.index];
|
|
30388
|
-
snapshot.content[contentElement.index] =
|
|
30493
|
+
snapshot.content[contentElement.index] = __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_accumulateContent).call(this, contentElement, currentContent);
|
|
30389
30494
|
} else {
|
|
30390
30495
|
snapshot.content[contentElement.index] = contentElement;
|
|
30391
30496
|
newContent.push(contentElement);
|
|
@@ -30406,7 +30511,7 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
30406
30511
|
}, _AssistantStream_accumulateContent = function _AssistantStream_accumulateContent2(contentElement, currentContent) {
|
|
30407
30512
|
return AssistantStream.accumulateDelta(currentContent, contentElement);
|
|
30408
30513
|
}, _AssistantStream_handleRun = function _AssistantStream_handleRun2(event) {
|
|
30409
|
-
|
|
30514
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentRunSnapshot, event.data, "f");
|
|
30410
30515
|
switch (event.event) {
|
|
30411
30516
|
case "thread.run.created":
|
|
30412
30517
|
break;
|
|
@@ -30419,19 +30524,20 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
30419
30524
|
case "thread.run.failed":
|
|
30420
30525
|
case "thread.run.completed":
|
|
30421
30526
|
case "thread.run.expired":
|
|
30422
|
-
|
|
30423
|
-
if (
|
|
30424
|
-
this._emit("toolCallDone",
|
|
30425
|
-
|
|
30527
|
+
__classPrivateFieldSet13(this, _AssistantStream_finalRun, event.data, "f");
|
|
30528
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f")) {
|
|
30529
|
+
this._emit("toolCallDone", __classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f"));
|
|
30530
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentToolCall, undefined, "f");
|
|
30426
30531
|
}
|
|
30427
30532
|
break;
|
|
30428
30533
|
case "thread.run.cancelling":
|
|
30429
30534
|
break;
|
|
30430
30535
|
}
|
|
30431
30536
|
};
|
|
30537
|
+
function assertNever2(_x) {}
|
|
30432
30538
|
|
|
30433
30539
|
// ../../node_modules/openai/resources/beta/threads/messages.mjs
|
|
30434
|
-
class
|
|
30540
|
+
class Messages4 extends APIResource2 {
|
|
30435
30541
|
create(threadId, body2, options) {
|
|
30436
30542
|
return this._client.post(`/threads/${threadId}/messages`, {
|
|
30437
30543
|
body: body2,
|
|
@@ -30472,7 +30578,7 @@ class Messages3 extends APIResource2 {
|
|
|
30472
30578
|
|
|
30473
30579
|
class MessagesPage extends CursorPage {
|
|
30474
30580
|
}
|
|
30475
|
-
|
|
30581
|
+
Messages4.MessagesPage = MessagesPage;
|
|
30476
30582
|
|
|
30477
30583
|
// ../../node_modules/openai/resources/beta/threads/runs/steps.mjs
|
|
30478
30584
|
class Steps extends APIResource2 {
|
|
@@ -30623,7 +30729,7 @@ class Threads extends APIResource2 {
|
|
|
30623
30729
|
constructor() {
|
|
30624
30730
|
super(...arguments);
|
|
30625
30731
|
this.runs = new Runs(this._client);
|
|
30626
|
-
this.messages = new
|
|
30732
|
+
this.messages = new Messages4(this._client);
|
|
30627
30733
|
}
|
|
30628
30734
|
create(body2 = {}, options) {
|
|
30629
30735
|
if (isRequestOptions2(body2)) {
|
|
@@ -30662,19 +30768,626 @@ class Threads extends APIResource2 {
|
|
|
30662
30768
|
stream: body2.stream ?? false
|
|
30663
30769
|
});
|
|
30664
30770
|
}
|
|
30665
|
-
async createAndRunPoll(body2, options) {
|
|
30666
|
-
const run2 = await this.createAndRun(body2, options);
|
|
30667
|
-
return await this.runs.poll(run2.thread_id, run2.id, options);
|
|
30771
|
+
async createAndRunPoll(body2, options) {
|
|
30772
|
+
const run2 = await this.createAndRun(body2, options);
|
|
30773
|
+
return await this.runs.poll(run2.thread_id, run2.id, options);
|
|
30774
|
+
}
|
|
30775
|
+
createAndRunStream(body2, options) {
|
|
30776
|
+
return AssistantStream.createThreadAssistantStream(body2, this._client.beta.threads, options);
|
|
30777
|
+
}
|
|
30778
|
+
}
|
|
30779
|
+
Threads.Runs = Runs;
|
|
30780
|
+
Threads.RunsPage = RunsPage;
|
|
30781
|
+
Threads.Messages = Messages4;
|
|
30782
|
+
Threads.MessagesPage = MessagesPage;
|
|
30783
|
+
|
|
30784
|
+
// ../../node_modules/openai/resources/beta/beta.mjs
|
|
30785
|
+
class Beta2 extends APIResource2 {
|
|
30786
|
+
constructor() {
|
|
30787
|
+
super(...arguments);
|
|
30788
|
+
this.realtime = new Realtime(this._client);
|
|
30789
|
+
this.chat = new Chat2(this._client);
|
|
30790
|
+
this.assistants = new Assistants(this._client);
|
|
30791
|
+
this.threads = new Threads(this._client);
|
|
30792
|
+
}
|
|
30793
|
+
}
|
|
30794
|
+
Beta2.Realtime = Realtime;
|
|
30795
|
+
Beta2.Assistants = Assistants;
|
|
30796
|
+
Beta2.AssistantsPage = AssistantsPage;
|
|
30797
|
+
Beta2.Threads = Threads;
|
|
30798
|
+
// ../../node_modules/openai/resources/completions.mjs
|
|
30799
|
+
class Completions4 extends APIResource2 {
|
|
30800
|
+
create(body2, options) {
|
|
30801
|
+
return this._client.post("/completions", { body: body2, ...options, stream: body2.stream ?? false });
|
|
30802
|
+
}
|
|
30803
|
+
}
|
|
30804
|
+
// ../../node_modules/openai/resources/embeddings.mjs
|
|
30805
|
+
class Embeddings extends APIResource2 {
|
|
30806
|
+
create(body2, options) {
|
|
30807
|
+
return this._client.post("/embeddings", { body: body2, ...options });
|
|
30808
|
+
}
|
|
30809
|
+
}
|
|
30810
|
+
// ../../node_modules/openai/resources/files.mjs
|
|
30811
|
+
class Files extends APIResource2 {
|
|
30812
|
+
create(body2, options) {
|
|
30813
|
+
return this._client.post("/files", multipartFormRequestOptions({ body: body2, ...options }));
|
|
30814
|
+
}
|
|
30815
|
+
retrieve(fileId, options) {
|
|
30816
|
+
return this._client.get(`/files/${fileId}`, options);
|
|
30817
|
+
}
|
|
30818
|
+
list(query = {}, options) {
|
|
30819
|
+
if (isRequestOptions2(query)) {
|
|
30820
|
+
return this.list({}, query);
|
|
30821
|
+
}
|
|
30822
|
+
return this._client.getAPIList("/files", FileObjectsPage, { query, ...options });
|
|
30823
|
+
}
|
|
30824
|
+
del(fileId, options) {
|
|
30825
|
+
return this._client.delete(`/files/${fileId}`, options);
|
|
30826
|
+
}
|
|
30827
|
+
content(fileId, options) {
|
|
30828
|
+
return this._client.get(`/files/${fileId}/content`, {
|
|
30829
|
+
...options,
|
|
30830
|
+
headers: { Accept: "application/binary", ...options?.headers },
|
|
30831
|
+
__binaryResponse: true
|
|
30832
|
+
});
|
|
30833
|
+
}
|
|
30834
|
+
retrieveContent(fileId, options) {
|
|
30835
|
+
return this._client.get(`/files/${fileId}/content`, options);
|
|
30836
|
+
}
|
|
30837
|
+
async waitForProcessing(id, { pollInterval = 5000, maxWait = 30 * 60 * 1000 } = {}) {
|
|
30838
|
+
const TERMINAL_STATES = new Set(["processed", "error", "deleted"]);
|
|
30839
|
+
const start2 = Date.now();
|
|
30840
|
+
let file = await this.retrieve(id);
|
|
30841
|
+
while (!file.status || !TERMINAL_STATES.has(file.status)) {
|
|
30842
|
+
await sleep2(pollInterval);
|
|
30843
|
+
file = await this.retrieve(id);
|
|
30844
|
+
if (Date.now() - start2 > maxWait) {
|
|
30845
|
+
throw new APIConnectionTimeoutError2({
|
|
30846
|
+
message: `Giving up on waiting for file ${id} to finish processing after ${maxWait} milliseconds.`
|
|
30847
|
+
});
|
|
30848
|
+
}
|
|
30849
|
+
}
|
|
30850
|
+
return file;
|
|
30851
|
+
}
|
|
30852
|
+
}
|
|
30853
|
+
|
|
30854
|
+
class FileObjectsPage extends CursorPage {
|
|
30855
|
+
}
|
|
30856
|
+
Files.FileObjectsPage = FileObjectsPage;
|
|
30857
|
+
// ../../node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs
|
|
30858
|
+
class Checkpoints extends APIResource2 {
|
|
30859
|
+
list(fineTuningJobId, query = {}, options) {
|
|
30860
|
+
if (isRequestOptions2(query)) {
|
|
30861
|
+
return this.list(fineTuningJobId, {}, query);
|
|
30862
|
+
}
|
|
30863
|
+
return this._client.getAPIList(`/fine_tuning/jobs/${fineTuningJobId}/checkpoints`, FineTuningJobCheckpointsPage, { query, ...options });
|
|
30864
|
+
}
|
|
30865
|
+
}
|
|
30866
|
+
|
|
30867
|
+
class FineTuningJobCheckpointsPage extends CursorPage {
|
|
30868
|
+
}
|
|
30869
|
+
Checkpoints.FineTuningJobCheckpointsPage = FineTuningJobCheckpointsPage;
|
|
30870
|
+
|
|
30871
|
+
// ../../node_modules/openai/resources/fine-tuning/jobs/jobs.mjs
|
|
30872
|
+
class Jobs extends APIResource2 {
|
|
30873
|
+
constructor() {
|
|
30874
|
+
super(...arguments);
|
|
30875
|
+
this.checkpoints = new Checkpoints(this._client);
|
|
30876
|
+
}
|
|
30877
|
+
create(body2, options) {
|
|
30878
|
+
return this._client.post("/fine_tuning/jobs", { body: body2, ...options });
|
|
30879
|
+
}
|
|
30880
|
+
retrieve(fineTuningJobId, options) {
|
|
30881
|
+
return this._client.get(`/fine_tuning/jobs/${fineTuningJobId}`, options);
|
|
30882
|
+
}
|
|
30883
|
+
list(query = {}, options) {
|
|
30884
|
+
if (isRequestOptions2(query)) {
|
|
30885
|
+
return this.list({}, query);
|
|
30886
|
+
}
|
|
30887
|
+
return this._client.getAPIList("/fine_tuning/jobs", FineTuningJobsPage, { query, ...options });
|
|
30888
|
+
}
|
|
30889
|
+
cancel(fineTuningJobId, options) {
|
|
30890
|
+
return this._client.post(`/fine_tuning/jobs/${fineTuningJobId}/cancel`, options);
|
|
30891
|
+
}
|
|
30892
|
+
listEvents(fineTuningJobId, query = {}, options) {
|
|
30893
|
+
if (isRequestOptions2(query)) {
|
|
30894
|
+
return this.listEvents(fineTuningJobId, {}, query);
|
|
30895
|
+
}
|
|
30896
|
+
return this._client.getAPIList(`/fine_tuning/jobs/${fineTuningJobId}/events`, FineTuningJobEventsPage, {
|
|
30897
|
+
query,
|
|
30898
|
+
...options
|
|
30899
|
+
});
|
|
30900
|
+
}
|
|
30901
|
+
}
|
|
30902
|
+
|
|
30903
|
+
class FineTuningJobsPage extends CursorPage {
|
|
30904
|
+
}
|
|
30905
|
+
|
|
30906
|
+
class FineTuningJobEventsPage extends CursorPage {
|
|
30907
|
+
}
|
|
30908
|
+
Jobs.FineTuningJobsPage = FineTuningJobsPage;
|
|
30909
|
+
Jobs.FineTuningJobEventsPage = FineTuningJobEventsPage;
|
|
30910
|
+
Jobs.Checkpoints = Checkpoints;
|
|
30911
|
+
Jobs.FineTuningJobCheckpointsPage = FineTuningJobCheckpointsPage;
|
|
30912
|
+
|
|
30913
|
+
// ../../node_modules/openai/resources/fine-tuning/fine-tuning.mjs
|
|
30914
|
+
class FineTuning extends APIResource2 {
|
|
30915
|
+
constructor() {
|
|
30916
|
+
super(...arguments);
|
|
30917
|
+
this.jobs = new Jobs(this._client);
|
|
30918
|
+
}
|
|
30919
|
+
}
|
|
30920
|
+
FineTuning.Jobs = Jobs;
|
|
30921
|
+
FineTuning.FineTuningJobsPage = FineTuningJobsPage;
|
|
30922
|
+
FineTuning.FineTuningJobEventsPage = FineTuningJobEventsPage;
|
|
30923
|
+
// ../../node_modules/openai/resources/images.mjs
|
|
30924
|
+
class Images extends APIResource2 {
|
|
30925
|
+
createVariation(body2, options) {
|
|
30926
|
+
return this._client.post("/images/variations", multipartFormRequestOptions({ body: body2, ...options }));
|
|
30927
|
+
}
|
|
30928
|
+
edit(body2, options) {
|
|
30929
|
+
return this._client.post("/images/edits", multipartFormRequestOptions({ body: body2, ...options }));
|
|
30930
|
+
}
|
|
30931
|
+
generate(body2, options) {
|
|
30932
|
+
return this._client.post("/images/generations", { body: body2, ...options });
|
|
30933
|
+
}
|
|
30934
|
+
}
|
|
30935
|
+
// ../../node_modules/openai/resources/models.mjs
|
|
30936
|
+
class Models3 extends APIResource2 {
|
|
30937
|
+
retrieve(model, options) {
|
|
30938
|
+
return this._client.get(`/models/${model}`, options);
|
|
30939
|
+
}
|
|
30940
|
+
list(options) {
|
|
30941
|
+
return this._client.getAPIList("/models", ModelsPage, options);
|
|
30942
|
+
}
|
|
30943
|
+
del(model, options) {
|
|
30944
|
+
return this._client.delete(`/models/${model}`, options);
|
|
30945
|
+
}
|
|
30946
|
+
}
|
|
30947
|
+
|
|
30948
|
+
class ModelsPage extends Page2 {
|
|
30949
|
+
}
|
|
30950
|
+
Models3.ModelsPage = ModelsPage;
|
|
30951
|
+
// ../../node_modules/openai/resources/moderations.mjs
|
|
30952
|
+
class Moderations extends APIResource2 {
|
|
30953
|
+
create(body2, options) {
|
|
30954
|
+
return this._client.post("/moderations", { body: body2, ...options });
|
|
30955
|
+
}
|
|
30956
|
+
}
|
|
30957
|
+
// ../../node_modules/openai/lib/ResponsesParser.mjs
|
|
30958
|
+
function maybeParseResponse(response, params) {
|
|
30959
|
+
if (!params || !hasAutoParseableInput2(params)) {
|
|
30960
|
+
return {
|
|
30961
|
+
...response,
|
|
30962
|
+
output_parsed: null,
|
|
30963
|
+
output: response.output.map((item) => {
|
|
30964
|
+
if (item.type === "function_call") {
|
|
30965
|
+
return {
|
|
30966
|
+
...item,
|
|
30967
|
+
parsed_arguments: null
|
|
30968
|
+
};
|
|
30969
|
+
}
|
|
30970
|
+
if (item.type === "message") {
|
|
30971
|
+
return {
|
|
30972
|
+
...item,
|
|
30973
|
+
content: item.content.map((content) => ({
|
|
30974
|
+
...content,
|
|
30975
|
+
parsed: null
|
|
30976
|
+
}))
|
|
30977
|
+
};
|
|
30978
|
+
} else {
|
|
30979
|
+
return item;
|
|
30980
|
+
}
|
|
30981
|
+
})
|
|
30982
|
+
};
|
|
30983
|
+
}
|
|
30984
|
+
return parseResponse(response, params);
|
|
30985
|
+
}
|
|
30986
|
+
function parseResponse(response, params) {
|
|
30987
|
+
const output = response.output.map((item) => {
|
|
30988
|
+
if (item.type === "function_call") {
|
|
30989
|
+
return {
|
|
30990
|
+
...item,
|
|
30991
|
+
parsed_arguments: parseToolCall2(params, item)
|
|
30992
|
+
};
|
|
30993
|
+
}
|
|
30994
|
+
if (item.type === "message") {
|
|
30995
|
+
const content = item.content.map((content2) => {
|
|
30996
|
+
if (content2.type === "output_text") {
|
|
30997
|
+
return {
|
|
30998
|
+
...content2,
|
|
30999
|
+
parsed: parseTextFormat(params, content2.text)
|
|
31000
|
+
};
|
|
31001
|
+
}
|
|
31002
|
+
return content2;
|
|
31003
|
+
});
|
|
31004
|
+
return {
|
|
31005
|
+
...item,
|
|
31006
|
+
content
|
|
31007
|
+
};
|
|
31008
|
+
}
|
|
31009
|
+
return item;
|
|
31010
|
+
});
|
|
31011
|
+
const parsed = Object.assign({}, response, { output });
|
|
31012
|
+
if (!Object.getOwnPropertyDescriptor(response, "output_text")) {
|
|
31013
|
+
addOutputText(parsed);
|
|
31014
|
+
}
|
|
31015
|
+
Object.defineProperty(parsed, "output_parsed", {
|
|
31016
|
+
enumerable: true,
|
|
31017
|
+
get() {
|
|
31018
|
+
for (const output2 of parsed.output) {
|
|
31019
|
+
if (output2.type !== "message") {
|
|
31020
|
+
continue;
|
|
31021
|
+
}
|
|
31022
|
+
for (const content of output2.content) {
|
|
31023
|
+
if (content.type === "output_text" && content.parsed !== null) {
|
|
31024
|
+
return content.parsed;
|
|
31025
|
+
}
|
|
31026
|
+
}
|
|
31027
|
+
}
|
|
31028
|
+
return null;
|
|
31029
|
+
}
|
|
31030
|
+
});
|
|
31031
|
+
return parsed;
|
|
31032
|
+
}
|
|
31033
|
+
function parseTextFormat(params, content) {
|
|
31034
|
+
if (params.text?.format?.type !== "json_schema") {
|
|
31035
|
+
return null;
|
|
31036
|
+
}
|
|
31037
|
+
if ("$parseRaw" in params.text?.format) {
|
|
31038
|
+
const text_format = params.text?.format;
|
|
31039
|
+
return text_format.$parseRaw(content);
|
|
31040
|
+
}
|
|
31041
|
+
return JSON.parse(content);
|
|
31042
|
+
}
|
|
31043
|
+
function hasAutoParseableInput2(params) {
|
|
31044
|
+
if (isAutoParsableResponseFormat(params.text?.format)) {
|
|
31045
|
+
return true;
|
|
31046
|
+
}
|
|
31047
|
+
return false;
|
|
31048
|
+
}
|
|
31049
|
+
function isAutoParsableTool2(tool) {
|
|
31050
|
+
return tool?.["$brand"] === "auto-parseable-tool";
|
|
31051
|
+
}
|
|
31052
|
+
function getInputToolByName(input_tools, name2) {
|
|
31053
|
+
return input_tools.find((tool) => tool.type === "function" && tool.name === name2);
|
|
31054
|
+
}
|
|
31055
|
+
function parseToolCall2(params, toolCall) {
|
|
31056
|
+
const inputTool = getInputToolByName(params.tools ?? [], toolCall.name);
|
|
31057
|
+
return {
|
|
31058
|
+
...toolCall,
|
|
31059
|
+
...toolCall,
|
|
31060
|
+
parsed_arguments: isAutoParsableTool2(inputTool) ? inputTool.$parseRaw(toolCall.arguments) : inputTool?.strict ? JSON.parse(toolCall.arguments) : null
|
|
31061
|
+
};
|
|
31062
|
+
}
|
|
31063
|
+
function addOutputText(rsp) {
|
|
31064
|
+
const texts = [];
|
|
31065
|
+
for (const output of rsp.output) {
|
|
31066
|
+
if (output.type !== "message") {
|
|
31067
|
+
continue;
|
|
31068
|
+
}
|
|
31069
|
+
for (const content of output.content) {
|
|
31070
|
+
if (content.type === "output_text") {
|
|
31071
|
+
texts.push(content.text);
|
|
31072
|
+
}
|
|
31073
|
+
}
|
|
31074
|
+
}
|
|
31075
|
+
rsp.output_text = texts.join("");
|
|
31076
|
+
}
|
|
31077
|
+
|
|
31078
|
+
// ../../node_modules/openai/resources/responses/input-items.mjs
|
|
31079
|
+
class InputItems extends APIResource2 {
|
|
31080
|
+
list(responseId, query = {}, options) {
|
|
31081
|
+
if (isRequestOptions2(query)) {
|
|
31082
|
+
return this.list(responseId, {}, query);
|
|
31083
|
+
}
|
|
31084
|
+
return this._client.getAPIList(`/responses/${responseId}/input_items`, ResponseItemsPage, {
|
|
31085
|
+
query,
|
|
31086
|
+
...options
|
|
31087
|
+
});
|
|
31088
|
+
}
|
|
31089
|
+
}
|
|
31090
|
+
|
|
31091
|
+
// ../../node_modules/openai/lib/responses/ResponseStream.mjs
|
|
31092
|
+
var __classPrivateFieldSet14 = function(receiver, state, value, kind3, f2) {
|
|
31093
|
+
if (kind3 === "m")
|
|
31094
|
+
throw new TypeError("Private method is not writable");
|
|
31095
|
+
if (kind3 === "a" && !f2)
|
|
31096
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
31097
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
31098
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
31099
|
+
return kind3 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
31100
|
+
};
|
|
31101
|
+
var __classPrivateFieldGet16 = function(receiver, state, kind3, f2) {
|
|
31102
|
+
if (kind3 === "a" && !f2)
|
|
31103
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
31104
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
31105
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
31106
|
+
return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
31107
|
+
};
|
|
31108
|
+
var _ResponseStream_instances;
|
|
31109
|
+
var _ResponseStream_params;
|
|
31110
|
+
var _ResponseStream_currentResponseSnapshot;
|
|
31111
|
+
var _ResponseStream_finalResponse;
|
|
31112
|
+
var _ResponseStream_beginRequest;
|
|
31113
|
+
var _ResponseStream_addEvent;
|
|
31114
|
+
var _ResponseStream_endRequest;
|
|
31115
|
+
var _ResponseStream_accumulateResponse;
|
|
31116
|
+
|
|
31117
|
+
class ResponseStream extends EventStream {
|
|
31118
|
+
constructor(params) {
|
|
31119
|
+
super();
|
|
31120
|
+
_ResponseStream_instances.add(this);
|
|
31121
|
+
_ResponseStream_params.set(this, undefined);
|
|
31122
|
+
_ResponseStream_currentResponseSnapshot.set(this, undefined);
|
|
31123
|
+
_ResponseStream_finalResponse.set(this, undefined);
|
|
31124
|
+
__classPrivateFieldSet14(this, _ResponseStream_params, params, "f");
|
|
31125
|
+
}
|
|
31126
|
+
static createResponse(client, params, options) {
|
|
31127
|
+
const runner = new ResponseStream(params);
|
|
31128
|
+
runner._run(() => runner._createResponse(client, params, {
|
|
31129
|
+
...options,
|
|
31130
|
+
headers: { ...options?.headers, "X-Stainless-Helper-Method": "stream" }
|
|
31131
|
+
}));
|
|
31132
|
+
return runner;
|
|
31133
|
+
}
|
|
31134
|
+
async _createResponse(client, params, options) {
|
|
31135
|
+
const signal = options?.signal;
|
|
31136
|
+
if (signal) {
|
|
31137
|
+
if (signal.aborted)
|
|
31138
|
+
this.controller.abort();
|
|
31139
|
+
signal.addEventListener("abort", () => this.controller.abort());
|
|
31140
|
+
}
|
|
31141
|
+
__classPrivateFieldGet16(this, _ResponseStream_instances, "m", _ResponseStream_beginRequest).call(this);
|
|
31142
|
+
const stream = await client.responses.create({ ...params, stream: true }, { ...options, signal: this.controller.signal });
|
|
31143
|
+
this._connected();
|
|
31144
|
+
for await (const event of stream) {
|
|
31145
|
+
__classPrivateFieldGet16(this, _ResponseStream_instances, "m", _ResponseStream_addEvent).call(this, event);
|
|
31146
|
+
}
|
|
31147
|
+
if (stream.controller.signal?.aborted) {
|
|
31148
|
+
throw new APIUserAbortError2;
|
|
31149
|
+
}
|
|
31150
|
+
return __classPrivateFieldGet16(this, _ResponseStream_instances, "m", _ResponseStream_endRequest).call(this);
|
|
31151
|
+
}
|
|
31152
|
+
[(_ResponseStream_params = new WeakMap, _ResponseStream_currentResponseSnapshot = new WeakMap, _ResponseStream_finalResponse = new WeakMap, _ResponseStream_instances = new WeakSet, _ResponseStream_beginRequest = function _ResponseStream_beginRequest() {
|
|
31153
|
+
if (this.ended)
|
|
31154
|
+
return;
|
|
31155
|
+
__classPrivateFieldSet14(this, _ResponseStream_currentResponseSnapshot, undefined, "f");
|
|
31156
|
+
}, _ResponseStream_addEvent = function _ResponseStream_addEvent(event) {
|
|
31157
|
+
if (this.ended)
|
|
31158
|
+
return;
|
|
31159
|
+
const response = __classPrivateFieldGet16(this, _ResponseStream_instances, "m", _ResponseStream_accumulateResponse).call(this, event);
|
|
31160
|
+
this._emit("event", event);
|
|
31161
|
+
switch (event.type) {
|
|
31162
|
+
case "response.output_text.delta": {
|
|
31163
|
+
const output = response.output[event.output_index];
|
|
31164
|
+
if (!output) {
|
|
31165
|
+
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
31166
|
+
}
|
|
31167
|
+
if (output.type === "message") {
|
|
31168
|
+
const content = output.content[event.content_index];
|
|
31169
|
+
if (!content) {
|
|
31170
|
+
throw new OpenAIError(`missing content at index ${event.content_index}`);
|
|
31171
|
+
}
|
|
31172
|
+
if (content.type !== "output_text") {
|
|
31173
|
+
throw new OpenAIError(`expected content to be 'output_text', got ${content.type}`);
|
|
31174
|
+
}
|
|
31175
|
+
this._emit("response.output_text.delta", {
|
|
31176
|
+
...event,
|
|
31177
|
+
snapshot: content.text
|
|
31178
|
+
});
|
|
31179
|
+
}
|
|
31180
|
+
break;
|
|
31181
|
+
}
|
|
31182
|
+
case "response.function_call_arguments.delta": {
|
|
31183
|
+
const output = response.output[event.output_index];
|
|
31184
|
+
if (!output) {
|
|
31185
|
+
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
31186
|
+
}
|
|
31187
|
+
if (output.type === "function_call") {
|
|
31188
|
+
this._emit("response.function_call_arguments.delta", {
|
|
31189
|
+
...event,
|
|
31190
|
+
snapshot: output.arguments
|
|
31191
|
+
});
|
|
31192
|
+
}
|
|
31193
|
+
break;
|
|
31194
|
+
}
|
|
31195
|
+
default:
|
|
31196
|
+
this._emit(event.type, event);
|
|
31197
|
+
break;
|
|
31198
|
+
}
|
|
31199
|
+
}, _ResponseStream_endRequest = function _ResponseStream_endRequest() {
|
|
31200
|
+
if (this.ended) {
|
|
31201
|
+
throw new OpenAIError(`stream has ended, this shouldn't happen`);
|
|
31202
|
+
}
|
|
31203
|
+
const snapshot = __classPrivateFieldGet16(this, _ResponseStream_currentResponseSnapshot, "f");
|
|
31204
|
+
if (!snapshot) {
|
|
31205
|
+
throw new OpenAIError(`request ended without sending any events`);
|
|
31206
|
+
}
|
|
31207
|
+
__classPrivateFieldSet14(this, _ResponseStream_currentResponseSnapshot, undefined, "f");
|
|
31208
|
+
const parsedResponse = finalizeResponse(snapshot, __classPrivateFieldGet16(this, _ResponseStream_params, "f"));
|
|
31209
|
+
__classPrivateFieldSet14(this, _ResponseStream_finalResponse, parsedResponse, "f");
|
|
31210
|
+
return parsedResponse;
|
|
31211
|
+
}, _ResponseStream_accumulateResponse = function _ResponseStream_accumulateResponse(event) {
|
|
31212
|
+
let snapshot = __classPrivateFieldGet16(this, _ResponseStream_currentResponseSnapshot, "f");
|
|
31213
|
+
if (!snapshot) {
|
|
31214
|
+
if (event.type !== "response.created") {
|
|
31215
|
+
throw new OpenAIError(`When snapshot hasn't been set yet, expected 'response.created' event, got ${event.type}`);
|
|
31216
|
+
}
|
|
31217
|
+
snapshot = __classPrivateFieldSet14(this, _ResponseStream_currentResponseSnapshot, event.response, "f");
|
|
31218
|
+
return snapshot;
|
|
31219
|
+
}
|
|
31220
|
+
switch (event.type) {
|
|
31221
|
+
case "response.output_item.added": {
|
|
31222
|
+
snapshot.output.push(event.item);
|
|
31223
|
+
break;
|
|
31224
|
+
}
|
|
31225
|
+
case "response.content_part.added": {
|
|
31226
|
+
const output = snapshot.output[event.output_index];
|
|
31227
|
+
if (!output) {
|
|
31228
|
+
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
31229
|
+
}
|
|
31230
|
+
if (output.type === "message") {
|
|
31231
|
+
output.content.push(event.part);
|
|
31232
|
+
}
|
|
31233
|
+
break;
|
|
31234
|
+
}
|
|
31235
|
+
case "response.output_text.delta": {
|
|
31236
|
+
const output = snapshot.output[event.output_index];
|
|
31237
|
+
if (!output) {
|
|
31238
|
+
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
31239
|
+
}
|
|
31240
|
+
if (output.type === "message") {
|
|
31241
|
+
const content = output.content[event.content_index];
|
|
31242
|
+
if (!content) {
|
|
31243
|
+
throw new OpenAIError(`missing content at index ${event.content_index}`);
|
|
31244
|
+
}
|
|
31245
|
+
if (content.type !== "output_text") {
|
|
31246
|
+
throw new OpenAIError(`expected content to be 'output_text', got ${content.type}`);
|
|
31247
|
+
}
|
|
31248
|
+
content.text += event.delta;
|
|
31249
|
+
}
|
|
31250
|
+
break;
|
|
31251
|
+
}
|
|
31252
|
+
case "response.function_call_arguments.delta": {
|
|
31253
|
+
const output = snapshot.output[event.output_index];
|
|
31254
|
+
if (!output) {
|
|
31255
|
+
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
31256
|
+
}
|
|
31257
|
+
if (output.type === "function_call") {
|
|
31258
|
+
output.arguments += event.delta;
|
|
31259
|
+
}
|
|
31260
|
+
break;
|
|
31261
|
+
}
|
|
31262
|
+
case "response.completed": {
|
|
31263
|
+
__classPrivateFieldSet14(this, _ResponseStream_currentResponseSnapshot, event.response, "f");
|
|
31264
|
+
break;
|
|
31265
|
+
}
|
|
31266
|
+
}
|
|
31267
|
+
return snapshot;
|
|
31268
|
+
}, Symbol.asyncIterator)]() {
|
|
31269
|
+
const pushQueue = [];
|
|
31270
|
+
const readQueue = [];
|
|
31271
|
+
let done = false;
|
|
31272
|
+
this.on("event", (event) => {
|
|
31273
|
+
const reader = readQueue.shift();
|
|
31274
|
+
if (reader) {
|
|
31275
|
+
reader.resolve(event);
|
|
31276
|
+
} else {
|
|
31277
|
+
pushQueue.push(event);
|
|
31278
|
+
}
|
|
31279
|
+
});
|
|
31280
|
+
this.on("end", () => {
|
|
31281
|
+
done = true;
|
|
31282
|
+
for (const reader of readQueue) {
|
|
31283
|
+
reader.resolve(undefined);
|
|
31284
|
+
}
|
|
31285
|
+
readQueue.length = 0;
|
|
31286
|
+
});
|
|
31287
|
+
this.on("abort", (err2) => {
|
|
31288
|
+
done = true;
|
|
31289
|
+
for (const reader of readQueue) {
|
|
31290
|
+
reader.reject(err2);
|
|
31291
|
+
}
|
|
31292
|
+
readQueue.length = 0;
|
|
31293
|
+
});
|
|
31294
|
+
this.on("error", (err2) => {
|
|
31295
|
+
done = true;
|
|
31296
|
+
for (const reader of readQueue) {
|
|
31297
|
+
reader.reject(err2);
|
|
31298
|
+
}
|
|
31299
|
+
readQueue.length = 0;
|
|
31300
|
+
});
|
|
31301
|
+
return {
|
|
31302
|
+
next: async () => {
|
|
31303
|
+
if (!pushQueue.length) {
|
|
31304
|
+
if (done) {
|
|
31305
|
+
return { value: undefined, done: true };
|
|
31306
|
+
}
|
|
31307
|
+
return new Promise((resolve, reject) => readQueue.push({ resolve, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: undefined, done: true });
|
|
31308
|
+
}
|
|
31309
|
+
const event = pushQueue.shift();
|
|
31310
|
+
return { value: event, done: false };
|
|
31311
|
+
},
|
|
31312
|
+
return: async () => {
|
|
31313
|
+
this.abort();
|
|
31314
|
+
return { value: undefined, done: true };
|
|
31315
|
+
}
|
|
31316
|
+
};
|
|
31317
|
+
}
|
|
31318
|
+
async finalResponse() {
|
|
31319
|
+
await this.done();
|
|
31320
|
+
const response = __classPrivateFieldGet16(this, _ResponseStream_finalResponse, "f");
|
|
31321
|
+
if (!response)
|
|
31322
|
+
throw new OpenAIError("stream ended without producing a ChatCompletion");
|
|
31323
|
+
return response;
|
|
31324
|
+
}
|
|
31325
|
+
}
|
|
31326
|
+
function finalizeResponse(snapshot, params) {
|
|
31327
|
+
return maybeParseResponse(snapshot, params);
|
|
31328
|
+
}
|
|
31329
|
+
|
|
31330
|
+
// ../../node_modules/openai/resources/responses/responses.mjs
|
|
31331
|
+
class Responses extends APIResource2 {
|
|
31332
|
+
constructor() {
|
|
31333
|
+
super(...arguments);
|
|
31334
|
+
this.inputItems = new InputItems(this._client);
|
|
31335
|
+
}
|
|
31336
|
+
create(body2, options) {
|
|
31337
|
+
return this._client.post("/responses", { body: body2, ...options, stream: body2.stream ?? false })._thenUnwrap((rsp) => {
|
|
31338
|
+
if ("object" in rsp && rsp.object === "response") {
|
|
31339
|
+
addOutputText(rsp);
|
|
31340
|
+
}
|
|
31341
|
+
return rsp;
|
|
31342
|
+
});
|
|
31343
|
+
}
|
|
31344
|
+
retrieve(responseId, query = {}, options) {
|
|
31345
|
+
if (isRequestOptions2(query)) {
|
|
31346
|
+
return this.retrieve(responseId, {}, query);
|
|
31347
|
+
}
|
|
31348
|
+
return this._client.get(`/responses/${responseId}`, { query, ...options });
|
|
31349
|
+
}
|
|
31350
|
+
del(responseId, options) {
|
|
31351
|
+
return this._client.delete(`/responses/${responseId}`, {
|
|
31352
|
+
...options,
|
|
31353
|
+
headers: { Accept: "*/*", ...options?.headers }
|
|
31354
|
+
});
|
|
31355
|
+
}
|
|
31356
|
+
parse(body2, options) {
|
|
31357
|
+
return this._client.responses.create(body2, options)._thenUnwrap((response) => parseResponse(response, body2));
|
|
31358
|
+
}
|
|
31359
|
+
stream(body2, options) {
|
|
31360
|
+
return ResponseStream.createResponse(this._client, body2, options);
|
|
30668
31361
|
}
|
|
30669
|
-
|
|
30670
|
-
|
|
31362
|
+
}
|
|
31363
|
+
|
|
31364
|
+
class ResponseItemsPage extends CursorPage {
|
|
31365
|
+
}
|
|
31366
|
+
Responses.InputItems = InputItems;
|
|
31367
|
+
// ../../node_modules/openai/resources/uploads/parts.mjs
|
|
31368
|
+
class Parts extends APIResource2 {
|
|
31369
|
+
create(uploadId, body2, options) {
|
|
31370
|
+
return this._client.post(`/uploads/${uploadId}/parts`, multipartFormRequestOptions({ body: body2, ...options }));
|
|
30671
31371
|
}
|
|
30672
31372
|
}
|
|
30673
|
-
Threads.Runs = Runs;
|
|
30674
|
-
Threads.RunsPage = RunsPage;
|
|
30675
|
-
Threads.Messages = Messages3;
|
|
30676
|
-
Threads.MessagesPage = MessagesPage;
|
|
30677
31373
|
|
|
31374
|
+
// ../../node_modules/openai/resources/uploads/uploads.mjs
|
|
31375
|
+
class Uploads extends APIResource2 {
|
|
31376
|
+
constructor() {
|
|
31377
|
+
super(...arguments);
|
|
31378
|
+
this.parts = new Parts(this._client);
|
|
31379
|
+
}
|
|
31380
|
+
create(body2, options) {
|
|
31381
|
+
return this._client.post("/uploads", { body: body2, ...options });
|
|
31382
|
+
}
|
|
31383
|
+
cancel(uploadId, options) {
|
|
31384
|
+
return this._client.post(`/uploads/${uploadId}/cancel`, options);
|
|
31385
|
+
}
|
|
31386
|
+
complete(uploadId, body2, options) {
|
|
31387
|
+
return this._client.post(`/uploads/${uploadId}/complete`, { body: body2, ...options });
|
|
31388
|
+
}
|
|
31389
|
+
}
|
|
31390
|
+
Uploads.Parts = Parts;
|
|
30678
31391
|
// ../../node_modules/openai/lib/Util.mjs
|
|
30679
31392
|
var allSettledWithThrow = async (promises) => {
|
|
30680
31393
|
const results = await Promise.allSettled(promises);
|
|
@@ -30694,8 +31407,8 @@ var allSettledWithThrow = async (promises) => {
|
|
|
30694
31407
|
return values;
|
|
30695
31408
|
};
|
|
30696
31409
|
|
|
30697
|
-
// ../../node_modules/openai/resources/
|
|
30698
|
-
class
|
|
31410
|
+
// ../../node_modules/openai/resources/vector-stores/files.mjs
|
|
31411
|
+
class Files2 extends APIResource2 {
|
|
30699
31412
|
create(vectorStoreId, body2, options) {
|
|
30700
31413
|
return this._client.post(`/vector_stores/${vectorStoreId}/files`, {
|
|
30701
31414
|
body: body2,
|
|
@@ -30709,6 +31422,13 @@ class Files extends APIResource2 {
|
|
|
30709
31422
|
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
30710
31423
|
});
|
|
30711
31424
|
}
|
|
31425
|
+
update(vectorStoreId, fileId, body2, options) {
|
|
31426
|
+
return this._client.post(`/vector_stores/${vectorStoreId}/files/${fileId}`, {
|
|
31427
|
+
body: body2,
|
|
31428
|
+
...options,
|
|
31429
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
31430
|
+
});
|
|
31431
|
+
}
|
|
30712
31432
|
list(vectorStoreId, query = {}, options) {
|
|
30713
31433
|
if (isRequestOptions2(query)) {
|
|
30714
31434
|
return this.list(vectorStoreId, {}, query);
|
|
@@ -30770,13 +31490,20 @@ class Files extends APIResource2 {
|
|
|
30770
31490
|
const fileInfo = await this.upload(vectorStoreId, file, options);
|
|
30771
31491
|
return await this.poll(vectorStoreId, fileInfo.id, options);
|
|
30772
31492
|
}
|
|
31493
|
+
content(vectorStoreId, fileId, options) {
|
|
31494
|
+
return this._client.getAPIList(`/vector_stores/${vectorStoreId}/files/${fileId}/content`, FileContentResponsesPage, { ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers } });
|
|
31495
|
+
}
|
|
30773
31496
|
}
|
|
30774
31497
|
|
|
30775
31498
|
class VectorStoreFilesPage extends CursorPage {
|
|
30776
31499
|
}
|
|
30777
|
-
Files.VectorStoreFilesPage = VectorStoreFilesPage;
|
|
30778
31500
|
|
|
30779
|
-
|
|
31501
|
+
class FileContentResponsesPage extends Page2 {
|
|
31502
|
+
}
|
|
31503
|
+
Files2.VectorStoreFilesPage = VectorStoreFilesPage;
|
|
31504
|
+
Files2.FileContentResponsesPage = FileContentResponsesPage;
|
|
31505
|
+
|
|
31506
|
+
// ../../node_modules/openai/resources/vector-stores/file-batches.mjs
|
|
30780
31507
|
class FileBatches extends APIResource2 {
|
|
30781
31508
|
create(vectorStoreId, body2, options) {
|
|
30782
31509
|
return this._client.post(`/vector_stores/${vectorStoreId}/file_batches`, {
|
|
@@ -30863,11 +31590,11 @@ class FileBatches extends APIResource2 {
|
|
|
30863
31590
|
}
|
|
30864
31591
|
}
|
|
30865
31592
|
|
|
30866
|
-
// ../../node_modules/openai/resources/
|
|
31593
|
+
// ../../node_modules/openai/resources/vector-stores/vector-stores.mjs
|
|
30867
31594
|
class VectorStores extends APIResource2 {
|
|
30868
31595
|
constructor() {
|
|
30869
31596
|
super(...arguments);
|
|
30870
|
-
this.files = new
|
|
31597
|
+
this.files = new Files2(this._client);
|
|
30871
31598
|
this.fileBatches = new FileBatches(this._client);
|
|
30872
31599
|
}
|
|
30873
31600
|
create(body2, options) {
|
|
@@ -30906,215 +31633,27 @@ class VectorStores extends APIResource2 {
|
|
|
30906
31633
|
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
30907
31634
|
});
|
|
30908
31635
|
}
|
|
30909
|
-
|
|
30910
|
-
|
|
30911
|
-
|
|
30912
|
-
|
|
30913
|
-
VectorStores.VectorStoresPage = VectorStoresPage;
|
|
30914
|
-
VectorStores.Files = Files;
|
|
30915
|
-
VectorStores.VectorStoreFilesPage = VectorStoreFilesPage;
|
|
30916
|
-
VectorStores.FileBatches = FileBatches;
|
|
30917
|
-
|
|
30918
|
-
// ../../node_modules/openai/resources/beta/beta.mjs
|
|
30919
|
-
class Beta2 extends APIResource2 {
|
|
30920
|
-
constructor() {
|
|
30921
|
-
super(...arguments);
|
|
30922
|
-
this.realtime = new Realtime(this._client);
|
|
30923
|
-
this.vectorStores = new VectorStores(this._client);
|
|
30924
|
-
this.chat = new Chat2(this._client);
|
|
30925
|
-
this.assistants = new Assistants(this._client);
|
|
30926
|
-
this.threads = new Threads(this._client);
|
|
30927
|
-
}
|
|
30928
|
-
}
|
|
30929
|
-
Beta2.Realtime = Realtime;
|
|
30930
|
-
Beta2.VectorStores = VectorStores;
|
|
30931
|
-
Beta2.VectorStoresPage = VectorStoresPage;
|
|
30932
|
-
Beta2.Assistants = Assistants;
|
|
30933
|
-
Beta2.AssistantsPage = AssistantsPage;
|
|
30934
|
-
Beta2.Threads = Threads;
|
|
30935
|
-
// ../../node_modules/openai/resources/completions.mjs
|
|
30936
|
-
class Completions4 extends APIResource2 {
|
|
30937
|
-
create(body2, options) {
|
|
30938
|
-
return this._client.post("/completions", { body: body2, ...options, stream: body2.stream ?? false });
|
|
30939
|
-
}
|
|
30940
|
-
}
|
|
30941
|
-
// ../../node_modules/openai/resources/embeddings.mjs
|
|
30942
|
-
class Embeddings extends APIResource2 {
|
|
30943
|
-
create(body2, options) {
|
|
30944
|
-
return this._client.post("/embeddings", { body: body2, ...options });
|
|
30945
|
-
}
|
|
30946
|
-
}
|
|
30947
|
-
// ../../node_modules/openai/resources/files.mjs
|
|
30948
|
-
class Files2 extends APIResource2 {
|
|
30949
|
-
create(body2, options) {
|
|
30950
|
-
return this._client.post("/files", multipartFormRequestOptions({ body: body2, ...options }));
|
|
30951
|
-
}
|
|
30952
|
-
retrieve(fileId, options) {
|
|
30953
|
-
return this._client.get(`/files/${fileId}`, options);
|
|
30954
|
-
}
|
|
30955
|
-
list(query = {}, options) {
|
|
30956
|
-
if (isRequestOptions2(query)) {
|
|
30957
|
-
return this.list({}, query);
|
|
30958
|
-
}
|
|
30959
|
-
return this._client.getAPIList("/files", FileObjectsPage, { query, ...options });
|
|
30960
|
-
}
|
|
30961
|
-
del(fileId, options) {
|
|
30962
|
-
return this._client.delete(`/files/${fileId}`, options);
|
|
30963
|
-
}
|
|
30964
|
-
content(fileId, options) {
|
|
30965
|
-
return this._client.get(`/files/${fileId}/content`, {
|
|
31636
|
+
search(vectorStoreId, body2, options) {
|
|
31637
|
+
return this._client.getAPIList(`/vector_stores/${vectorStoreId}/search`, VectorStoreSearchResponsesPage, {
|
|
31638
|
+
body: body2,
|
|
31639
|
+
method: "post",
|
|
30966
31640
|
...options,
|
|
30967
|
-
headers: {
|
|
30968
|
-
__binaryResponse: true
|
|
30969
|
-
});
|
|
30970
|
-
}
|
|
30971
|
-
retrieveContent(fileId, options) {
|
|
30972
|
-
return this._client.get(`/files/${fileId}/content`, options);
|
|
30973
|
-
}
|
|
30974
|
-
async waitForProcessing(id, { pollInterval = 5000, maxWait = 30 * 60 * 1000 } = {}) {
|
|
30975
|
-
const TERMINAL_STATES = new Set(["processed", "error", "deleted"]);
|
|
30976
|
-
const start2 = Date.now();
|
|
30977
|
-
let file = await this.retrieve(id);
|
|
30978
|
-
while (!file.status || !TERMINAL_STATES.has(file.status)) {
|
|
30979
|
-
await sleep2(pollInterval);
|
|
30980
|
-
file = await this.retrieve(id);
|
|
30981
|
-
if (Date.now() - start2 > maxWait) {
|
|
30982
|
-
throw new APIConnectionTimeoutError2({
|
|
30983
|
-
message: `Giving up on waiting for file ${id} to finish processing after ${maxWait} milliseconds.`
|
|
30984
|
-
});
|
|
30985
|
-
}
|
|
30986
|
-
}
|
|
30987
|
-
return file;
|
|
30988
|
-
}
|
|
30989
|
-
}
|
|
30990
|
-
|
|
30991
|
-
class FileObjectsPage extends CursorPage {
|
|
30992
|
-
}
|
|
30993
|
-
Files2.FileObjectsPage = FileObjectsPage;
|
|
30994
|
-
// ../../node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs
|
|
30995
|
-
class Checkpoints extends APIResource2 {
|
|
30996
|
-
list(fineTuningJobId, query = {}, options) {
|
|
30997
|
-
if (isRequestOptions2(query)) {
|
|
30998
|
-
return this.list(fineTuningJobId, {}, query);
|
|
30999
|
-
}
|
|
31000
|
-
return this._client.getAPIList(`/fine_tuning/jobs/${fineTuningJobId}/checkpoints`, FineTuningJobCheckpointsPage, { query, ...options });
|
|
31001
|
-
}
|
|
31002
|
-
}
|
|
31003
|
-
|
|
31004
|
-
class FineTuningJobCheckpointsPage extends CursorPage {
|
|
31005
|
-
}
|
|
31006
|
-
Checkpoints.FineTuningJobCheckpointsPage = FineTuningJobCheckpointsPage;
|
|
31007
|
-
|
|
31008
|
-
// ../../node_modules/openai/resources/fine-tuning/jobs/jobs.mjs
|
|
31009
|
-
class Jobs extends APIResource2 {
|
|
31010
|
-
constructor() {
|
|
31011
|
-
super(...arguments);
|
|
31012
|
-
this.checkpoints = new Checkpoints(this._client);
|
|
31013
|
-
}
|
|
31014
|
-
create(body2, options) {
|
|
31015
|
-
return this._client.post("/fine_tuning/jobs", { body: body2, ...options });
|
|
31016
|
-
}
|
|
31017
|
-
retrieve(fineTuningJobId, options) {
|
|
31018
|
-
return this._client.get(`/fine_tuning/jobs/${fineTuningJobId}`, options);
|
|
31019
|
-
}
|
|
31020
|
-
list(query = {}, options) {
|
|
31021
|
-
if (isRequestOptions2(query)) {
|
|
31022
|
-
return this.list({}, query);
|
|
31023
|
-
}
|
|
31024
|
-
return this._client.getAPIList("/fine_tuning/jobs", FineTuningJobsPage, { query, ...options });
|
|
31025
|
-
}
|
|
31026
|
-
cancel(fineTuningJobId, options) {
|
|
31027
|
-
return this._client.post(`/fine_tuning/jobs/${fineTuningJobId}/cancel`, options);
|
|
31028
|
-
}
|
|
31029
|
-
listEvents(fineTuningJobId, query = {}, options) {
|
|
31030
|
-
if (isRequestOptions2(query)) {
|
|
31031
|
-
return this.listEvents(fineTuningJobId, {}, query);
|
|
31032
|
-
}
|
|
31033
|
-
return this._client.getAPIList(`/fine_tuning/jobs/${fineTuningJobId}/events`, FineTuningJobEventsPage, {
|
|
31034
|
-
query,
|
|
31035
|
-
...options
|
|
31641
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
31036
31642
|
});
|
|
31037
31643
|
}
|
|
31038
31644
|
}
|
|
31039
31645
|
|
|
31040
|
-
class
|
|
31041
|
-
}
|
|
31042
|
-
|
|
31043
|
-
class FineTuningJobEventsPage extends CursorPage {
|
|
31044
|
-
}
|
|
31045
|
-
Jobs.FineTuningJobsPage = FineTuningJobsPage;
|
|
31046
|
-
Jobs.FineTuningJobEventsPage = FineTuningJobEventsPage;
|
|
31047
|
-
Jobs.Checkpoints = Checkpoints;
|
|
31048
|
-
Jobs.FineTuningJobCheckpointsPage = FineTuningJobCheckpointsPage;
|
|
31049
|
-
|
|
31050
|
-
// ../../node_modules/openai/resources/fine-tuning/fine-tuning.mjs
|
|
31051
|
-
class FineTuning extends APIResource2 {
|
|
31052
|
-
constructor() {
|
|
31053
|
-
super(...arguments);
|
|
31054
|
-
this.jobs = new Jobs(this._client);
|
|
31055
|
-
}
|
|
31056
|
-
}
|
|
31057
|
-
FineTuning.Jobs = Jobs;
|
|
31058
|
-
FineTuning.FineTuningJobsPage = FineTuningJobsPage;
|
|
31059
|
-
FineTuning.FineTuningJobEventsPage = FineTuningJobEventsPage;
|
|
31060
|
-
// ../../node_modules/openai/resources/images.mjs
|
|
31061
|
-
class Images extends APIResource2 {
|
|
31062
|
-
createVariation(body2, options) {
|
|
31063
|
-
return this._client.post("/images/variations", multipartFormRequestOptions({ body: body2, ...options }));
|
|
31064
|
-
}
|
|
31065
|
-
edit(body2, options) {
|
|
31066
|
-
return this._client.post("/images/edits", multipartFormRequestOptions({ body: body2, ...options }));
|
|
31067
|
-
}
|
|
31068
|
-
generate(body2, options) {
|
|
31069
|
-
return this._client.post("/images/generations", { body: body2, ...options });
|
|
31070
|
-
}
|
|
31071
|
-
}
|
|
31072
|
-
// ../../node_modules/openai/resources/models.mjs
|
|
31073
|
-
class Models3 extends APIResource2 {
|
|
31074
|
-
retrieve(model, options) {
|
|
31075
|
-
return this._client.get(`/models/${model}`, options);
|
|
31076
|
-
}
|
|
31077
|
-
list(options) {
|
|
31078
|
-
return this._client.getAPIList("/models", ModelsPage, options);
|
|
31079
|
-
}
|
|
31080
|
-
del(model, options) {
|
|
31081
|
-
return this._client.delete(`/models/${model}`, options);
|
|
31082
|
-
}
|
|
31083
|
-
}
|
|
31084
|
-
|
|
31085
|
-
class ModelsPage extends Page2 {
|
|
31086
|
-
}
|
|
31087
|
-
Models3.ModelsPage = ModelsPage;
|
|
31088
|
-
// ../../node_modules/openai/resources/moderations.mjs
|
|
31089
|
-
class Moderations extends APIResource2 {
|
|
31090
|
-
create(body2, options) {
|
|
31091
|
-
return this._client.post("/moderations", { body: body2, ...options });
|
|
31092
|
-
}
|
|
31093
|
-
}
|
|
31094
|
-
// ../../node_modules/openai/resources/uploads/parts.mjs
|
|
31095
|
-
class Parts extends APIResource2 {
|
|
31096
|
-
create(uploadId, body2, options) {
|
|
31097
|
-
return this._client.post(`/uploads/${uploadId}/parts`, multipartFormRequestOptions({ body: body2, ...options }));
|
|
31098
|
-
}
|
|
31646
|
+
class VectorStoresPage extends CursorPage {
|
|
31099
31647
|
}
|
|
31100
31648
|
|
|
31101
|
-
|
|
31102
|
-
class Uploads extends APIResource2 {
|
|
31103
|
-
constructor() {
|
|
31104
|
-
super(...arguments);
|
|
31105
|
-
this.parts = new Parts(this._client);
|
|
31106
|
-
}
|
|
31107
|
-
create(body2, options) {
|
|
31108
|
-
return this._client.post("/uploads", { body: body2, ...options });
|
|
31109
|
-
}
|
|
31110
|
-
cancel(uploadId, options) {
|
|
31111
|
-
return this._client.post(`/uploads/${uploadId}/cancel`, options);
|
|
31112
|
-
}
|
|
31113
|
-
complete(uploadId, body2, options) {
|
|
31114
|
-
return this._client.post(`/uploads/${uploadId}/complete`, { body: body2, ...options });
|
|
31115
|
-
}
|
|
31649
|
+
class VectorStoreSearchResponsesPage extends Page2 {
|
|
31116
31650
|
}
|
|
31117
|
-
|
|
31651
|
+
VectorStores.VectorStoresPage = VectorStoresPage;
|
|
31652
|
+
VectorStores.VectorStoreSearchResponsesPage = VectorStoreSearchResponsesPage;
|
|
31653
|
+
VectorStores.Files = Files2;
|
|
31654
|
+
VectorStores.VectorStoreFilesPage = VectorStoreFilesPage;
|
|
31655
|
+
VectorStores.FileContentResponsesPage = FileContentResponsesPage;
|
|
31656
|
+
VectorStores.FileBatches = FileBatches;
|
|
31118
31657
|
// ../../node_modules/openai/index.mjs
|
|
31119
31658
|
var _a2;
|
|
31120
31659
|
|
|
@@ -31152,15 +31691,17 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
|
31152
31691
|
this.completions = new Completions4(this);
|
|
31153
31692
|
this.chat = new Chat(this);
|
|
31154
31693
|
this.embeddings = new Embeddings(this);
|
|
31155
|
-
this.files = new
|
|
31694
|
+
this.files = new Files(this);
|
|
31156
31695
|
this.images = new Images(this);
|
|
31157
31696
|
this.audio = new Audio(this);
|
|
31158
31697
|
this.moderations = new Moderations(this);
|
|
31159
31698
|
this.models = new Models3(this);
|
|
31160
31699
|
this.fineTuning = new FineTuning(this);
|
|
31700
|
+
this.vectorStores = new VectorStores(this);
|
|
31161
31701
|
this.beta = new Beta2(this);
|
|
31162
31702
|
this.batches = new Batches3(this);
|
|
31163
31703
|
this.uploads = new Uploads(this);
|
|
31704
|
+
this.responses = new Responses(this);
|
|
31164
31705
|
this._options = options;
|
|
31165
31706
|
this.apiKey = apiKey;
|
|
31166
31707
|
this.organization = organization;
|
|
@@ -31204,8 +31745,9 @@ OpenAI.toFile = toFile2;
|
|
|
31204
31745
|
OpenAI.fileFromPath = fileFromPath4;
|
|
31205
31746
|
OpenAI.Completions = Completions4;
|
|
31206
31747
|
OpenAI.Chat = Chat;
|
|
31748
|
+
OpenAI.ChatCompletionsPage = ChatCompletionsPage;
|
|
31207
31749
|
OpenAI.Embeddings = Embeddings;
|
|
31208
|
-
OpenAI.Files =
|
|
31750
|
+
OpenAI.Files = Files;
|
|
31209
31751
|
OpenAI.FileObjectsPage = FileObjectsPage;
|
|
31210
31752
|
OpenAI.Images = Images;
|
|
31211
31753
|
OpenAI.Audio = Audio;
|
|
@@ -31213,10 +31755,14 @@ OpenAI.Moderations = Moderations;
|
|
|
31213
31755
|
OpenAI.Models = Models3;
|
|
31214
31756
|
OpenAI.ModelsPage = ModelsPage;
|
|
31215
31757
|
OpenAI.FineTuning = FineTuning;
|
|
31758
|
+
OpenAI.VectorStores = VectorStores;
|
|
31759
|
+
OpenAI.VectorStoresPage = VectorStoresPage;
|
|
31760
|
+
OpenAI.VectorStoreSearchResponsesPage = VectorStoreSearchResponsesPage;
|
|
31216
31761
|
OpenAI.Beta = Beta2;
|
|
31217
31762
|
OpenAI.Batches = Batches3;
|
|
31218
31763
|
OpenAI.BatchesPage = BatchesPage;
|
|
31219
31764
|
OpenAI.Uploads = Uploads;
|
|
31765
|
+
OpenAI.Responses = Responses;
|
|
31220
31766
|
var _deployments_endpoints = new Set([
|
|
31221
31767
|
"/completions",
|
|
31222
31768
|
"/chat/completions",
|
|
@@ -33088,6 +33634,7 @@ ${agents}`;
|
|
|
33088
33634
|
}
|
|
33089
33635
|
async#handleResponse(response) {
|
|
33090
33636
|
const toolReponses = [];
|
|
33637
|
+
let hasPause = false;
|
|
33091
33638
|
outer:
|
|
33092
33639
|
for (const content of response) {
|
|
33093
33640
|
switch (content.type) {
|
|
@@ -33099,7 +33646,7 @@ ${agents}`;
|
|
|
33099
33646
|
switch (toolResp.type) {
|
|
33100
33647
|
case "Reply" /* Reply */:
|
|
33101
33648
|
await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name });
|
|
33102
|
-
toolReponses.push({ tool: content.name, response: toolResp.message });
|
|
33649
|
+
toolReponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
33103
33650
|
break;
|
|
33104
33651
|
case "Exit" /* Exit */:
|
|
33105
33652
|
if (toolReponses.length > 0) {
|
|
@@ -33108,11 +33655,11 @@ ${agents}`;
|
|
|
33108
33655
|
return { type: "exit", reason: toolResp };
|
|
33109
33656
|
case "Invalid" /* Invalid */:
|
|
33110
33657
|
await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
|
|
33111
|
-
toolReponses.push({ tool: content.name, response: toolResp.message });
|
|
33658
|
+
toolReponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
33112
33659
|
break outer;
|
|
33113
33660
|
case "Error" /* Error */:
|
|
33114
33661
|
await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name });
|
|
33115
|
-
toolReponses.push({ tool: content.name, response: toolResp.message });
|
|
33662
|
+
toolReponses.push({ type: "response", tool: content.name, response: toolResp.message });
|
|
33116
33663
|
break outer;
|
|
33117
33664
|
case "Interrupted" /* Interrupted */:
|
|
33118
33665
|
await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
|
|
@@ -33157,15 +33704,23 @@ ${agents}`;
|
|
|
33157
33704
|
});
|
|
33158
33705
|
return { type: "exit", reason: delegateResp };
|
|
33159
33706
|
}
|
|
33707
|
+
case "Pause" /* Pause */: {
|
|
33708
|
+
await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
|
|
33709
|
+
toolReponses.push({ type: "pause", tool: content.name, object: toolResp.object });
|
|
33710
|
+
hasPause = true;
|
|
33711
|
+
}
|
|
33160
33712
|
}
|
|
33161
33713
|
break;
|
|
33162
33714
|
}
|
|
33163
33715
|
}
|
|
33164
33716
|
}
|
|
33717
|
+
if (hasPause) {
|
|
33718
|
+
return { type: "exit", reason: { type: "Pause", responses: toolReponses } };
|
|
33719
|
+
}
|
|
33165
33720
|
if (toolReponses.length === 0) {
|
|
33166
33721
|
return { type: "reply", message: responsePrompts.requireUseTool };
|
|
33167
33722
|
}
|
|
33168
|
-
const finalResp = toolReponses.map(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2)).join(`
|
|
33723
|
+
const finalResp = toolReponses.filter((resp) => resp.type === "response").map(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2)).join(`
|
|
33169
33724
|
|
|
33170
33725
|
`);
|
|
33171
33726
|
return { type: "reply", message: finalResp };
|
|
@@ -33804,10 +34359,10 @@ var util;
|
|
|
33804
34359
|
util2.assertEqual = (val) => val;
|
|
33805
34360
|
function assertIs(_arg) {}
|
|
33806
34361
|
util2.assertIs = assertIs;
|
|
33807
|
-
function
|
|
34362
|
+
function assertNever3(_x) {
|
|
33808
34363
|
throw new Error;
|
|
33809
34364
|
}
|
|
33810
|
-
util2.assertNever =
|
|
34365
|
+
util2.assertNever = assertNever3;
|
|
33811
34366
|
util2.arrayToEnum = (items) => {
|
|
33812
34367
|
const obj = {};
|
|
33813
34368
|
for (const item of items) {
|
|
@@ -34254,14 +34809,14 @@ var isAborted = (x2) => x2.status === "aborted";
|
|
|
34254
34809
|
var isDirty = (x2) => x2.status === "dirty";
|
|
34255
34810
|
var isValid = (x2) => x2.status === "valid";
|
|
34256
34811
|
var isAsync = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise;
|
|
34257
|
-
function
|
|
34812
|
+
function __classPrivateFieldGet17(receiver, state, kind3, f2) {
|
|
34258
34813
|
if (kind3 === "a" && !f2)
|
|
34259
34814
|
throw new TypeError("Private accessor was defined without a getter");
|
|
34260
34815
|
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
34261
34816
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
34262
34817
|
return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
34263
34818
|
}
|
|
34264
|
-
function
|
|
34819
|
+
function __classPrivateFieldSet15(receiver, state, value, kind3, f2) {
|
|
34265
34820
|
if (kind3 === "m")
|
|
34266
34821
|
throw new TypeError("Private method is not writable");
|
|
34267
34822
|
if (kind3 === "a" && !f2)
|
|
@@ -37061,10 +37616,10 @@ class ZodEnum extends ZodType {
|
|
|
37061
37616
|
});
|
|
37062
37617
|
return INVALID;
|
|
37063
37618
|
}
|
|
37064
|
-
if (!
|
|
37065
|
-
|
|
37619
|
+
if (!__classPrivateFieldGet17(this, _ZodEnum_cache, "f")) {
|
|
37620
|
+
__classPrivateFieldSet15(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
|
37066
37621
|
}
|
|
37067
|
-
if (!
|
|
37622
|
+
if (!__classPrivateFieldGet17(this, _ZodEnum_cache, "f").has(input.data)) {
|
|
37068
37623
|
const ctx = this._getOrReturnCtx(input);
|
|
37069
37624
|
const expectedValues = this._def.values;
|
|
37070
37625
|
addIssueToContext(ctx, {
|
|
@@ -37133,10 +37688,10 @@ class ZodNativeEnum extends ZodType {
|
|
|
37133
37688
|
});
|
|
37134
37689
|
return INVALID;
|
|
37135
37690
|
}
|
|
37136
|
-
if (!
|
|
37137
|
-
|
|
37691
|
+
if (!__classPrivateFieldGet17(this, _ZodNativeEnum_cache, "f")) {
|
|
37692
|
+
__classPrivateFieldSet15(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
|
|
37138
37693
|
}
|
|
37139
|
-
if (!
|
|
37694
|
+
if (!__classPrivateFieldGet17(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
|
37140
37695
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
37141
37696
|
addIssueToContext(ctx, {
|
|
37142
37697
|
received: ctx.data,
|
|
@@ -37899,10 +38454,10 @@ var util2;
|
|
|
37899
38454
|
util3.assertEqual = (val) => val;
|
|
37900
38455
|
function assertIs(_arg) {}
|
|
37901
38456
|
util3.assertIs = assertIs;
|
|
37902
|
-
function
|
|
38457
|
+
function assertNever3(_x) {
|
|
37903
38458
|
throw new Error;
|
|
37904
38459
|
}
|
|
37905
|
-
util3.assertNever =
|
|
38460
|
+
util3.assertNever = assertNever3;
|
|
37906
38461
|
util3.arrayToEnum = (items) => {
|
|
37907
38462
|
const obj = {};
|
|
37908
38463
|
for (const item of items) {
|
|
@@ -38340,14 +38895,14 @@ var isAborted2 = (x2) => x2.status === "aborted";
|
|
|
38340
38895
|
var isDirty2 = (x2) => x2.status === "dirty";
|
|
38341
38896
|
var isValid2 = (x2) => x2.status === "valid";
|
|
38342
38897
|
var isAsync2 = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise;
|
|
38343
|
-
function
|
|
38898
|
+
function __classPrivateFieldGet18(receiver, state, kind3, f2) {
|
|
38344
38899
|
if (kind3 === "a" && !f2)
|
|
38345
38900
|
throw new TypeError("Private accessor was defined without a getter");
|
|
38346
38901
|
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
38347
38902
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
38348
38903
|
return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
38349
38904
|
}
|
|
38350
|
-
function
|
|
38905
|
+
function __classPrivateFieldSet16(receiver, state, value, kind3, f2) {
|
|
38351
38906
|
if (kind3 === "m")
|
|
38352
38907
|
throw new TypeError("Private method is not writable");
|
|
38353
38908
|
if (kind3 === "a" && !f2)
|
|
@@ -41147,10 +41702,10 @@ class ZodEnum2 extends ZodType2 {
|
|
|
41147
41702
|
});
|
|
41148
41703
|
return INVALID2;
|
|
41149
41704
|
}
|
|
41150
|
-
if (!
|
|
41151
|
-
|
|
41705
|
+
if (!__classPrivateFieldGet18(this, _ZodEnum_cache2, "f")) {
|
|
41706
|
+
__classPrivateFieldSet16(this, _ZodEnum_cache2, new Set(this._def.values), "f");
|
|
41152
41707
|
}
|
|
41153
|
-
if (!
|
|
41708
|
+
if (!__classPrivateFieldGet18(this, _ZodEnum_cache2, "f").has(input.data)) {
|
|
41154
41709
|
const ctx = this._getOrReturnCtx(input);
|
|
41155
41710
|
const expectedValues = this._def.values;
|
|
41156
41711
|
addIssueToContext2(ctx, {
|
|
@@ -41219,10 +41774,10 @@ class ZodNativeEnum2 extends ZodType2 {
|
|
|
41219
41774
|
});
|
|
41220
41775
|
return INVALID2;
|
|
41221
41776
|
}
|
|
41222
|
-
if (!
|
|
41223
|
-
|
|
41777
|
+
if (!__classPrivateFieldGet18(this, _ZodNativeEnum_cache2, "f")) {
|
|
41778
|
+
__classPrivateFieldSet16(this, _ZodNativeEnum_cache2, new Set(util2.getValidEnumValues(this._def.values)), "f");
|
|
41224
41779
|
}
|
|
41225
|
-
if (!
|
|
41780
|
+
if (!__classPrivateFieldGet18(this, _ZodNativeEnum_cache2, "f").has(input.data)) {
|
|
41226
41781
|
const expectedValues = util2.objectValues(nativeEnumValues);
|
|
41227
41782
|
addIssueToContext2(ctx, {
|
|
41228
41783
|
received: ctx.data,
|
|
@@ -41818,7 +42373,7 @@ import { dirname } from "node:path";
|
|
|
41818
42373
|
var isUpKey = (key) => key.name === "up" || key.name === "k" || key.ctrl && key.name === "p";
|
|
41819
42374
|
var isDownKey = (key) => key.name === "down" || key.name === "j" || key.ctrl && key.name === "n";
|
|
41820
42375
|
var isBackspaceKey = (key) => key.name === "backspace";
|
|
41821
|
-
var isNumberKey = (key) => "
|
|
42376
|
+
var isNumberKey = (key) => "1234567890".includes(key.name);
|
|
41822
42377
|
var isEnterKey = (key) => key.name === "enter" || key.name === "return";
|
|
41823
42378
|
// ../../node_modules/@inquirer/core/dist/esm/lib/errors.js
|
|
41824
42379
|
class AbortPromptError extends Error {
|
|
@@ -42702,8 +43257,8 @@ var {
|
|
|
42702
43257
|
} = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback);
|
|
42703
43258
|
|
|
42704
43259
|
// ../../node_modules/@inquirer/core/dist/esm/lib/screen-manager.js
|
|
42705
|
-
var import_strip_ansi = __toESM(require_strip_ansi(), 1);
|
|
42706
43260
|
var import_ansi_escapes = __toESM(require_ansi_escapes(), 1);
|
|
43261
|
+
import { stripVTControlCharacters } from "node:util";
|
|
42707
43262
|
var height = (content) => content.split(`
|
|
42708
43263
|
`).length;
|
|
42709
43264
|
var lastLine = (content) => content.split(`
|
|
@@ -42713,12 +43268,11 @@ function cursorDown(n2) {
|
|
|
42713
43268
|
}
|
|
42714
43269
|
|
|
42715
43270
|
class ScreenManager {
|
|
42716
|
-
rl;
|
|
42717
43271
|
height = 0;
|
|
42718
43272
|
extraLinesUnderPrompt = 0;
|
|
42719
43273
|
cursorPos;
|
|
43274
|
+
rl;
|
|
42720
43275
|
constructor(rl) {
|
|
42721
|
-
this.rl = rl;
|
|
42722
43276
|
this.rl = rl;
|
|
42723
43277
|
this.cursorPos = rl.getCursorPos();
|
|
42724
43278
|
}
|
|
@@ -42729,7 +43283,7 @@ class ScreenManager {
|
|
|
42729
43283
|
}
|
|
42730
43284
|
render(content, bottomContent = "") {
|
|
42731
43285
|
const promptLine = lastLine(content);
|
|
42732
|
-
const rawPromptLine =
|
|
43286
|
+
const rawPromptLine = stripVTControlCharacters(promptLine);
|
|
42733
43287
|
let prompt5 = rawPromptLine;
|
|
42734
43288
|
if (this.rl.line.length > 0) {
|
|
42735
43289
|
prompt5 = prompt5.slice(0, -this.rl.line.length);
|
|
@@ -42788,22 +43342,22 @@ class PromisePolyfill extends Promise {
|
|
|
42788
43342
|
// ../../node_modules/@inquirer/core/dist/esm/lib/create-prompt.js
|
|
42789
43343
|
function getCallSites() {
|
|
42790
43344
|
const _prepareStackTrace = Error.prepareStackTrace;
|
|
43345
|
+
let result = [];
|
|
42791
43346
|
try {
|
|
42792
|
-
let result = [];
|
|
42793
43347
|
Error.prepareStackTrace = (_2, callSites) => {
|
|
42794
43348
|
const callSitesWithoutCurrent = callSites.slice(1);
|
|
42795
43349
|
result = callSitesWithoutCurrent;
|
|
42796
43350
|
return callSitesWithoutCurrent;
|
|
42797
43351
|
};
|
|
42798
43352
|
new Error().stack;
|
|
43353
|
+
} catch {
|
|
42799
43354
|
return result;
|
|
42800
|
-
} finally {
|
|
42801
|
-
Error.prepareStackTrace = _prepareStackTrace;
|
|
42802
43355
|
}
|
|
43356
|
+
Error.prepareStackTrace = _prepareStackTrace;
|
|
43357
|
+
return result;
|
|
42803
43358
|
}
|
|
42804
43359
|
function createPrompt(view) {
|
|
42805
43360
|
const callSites = getCallSites();
|
|
42806
|
-
const callerFilename = callSites[1]?.getFileName?.();
|
|
42807
43361
|
const prompt5 = (config2, context = {}) => {
|
|
42808
43362
|
const { input = process.stdin, signal } = context;
|
|
42809
43363
|
const cleanups = new Set;
|
|
@@ -42842,6 +43396,7 @@ function createPrompt(view) {
|
|
|
42842
43396
|
setImmediate(() => resolve(value));
|
|
42843
43397
|
});
|
|
42844
43398
|
if (nextView === undefined) {
|
|
43399
|
+
const callerFilename = callSites[1]?.getFileName?.();
|
|
42845
43400
|
throw new Error(`Prompt functions must return a string.
|
|
42846
43401
|
at ${callerFilename}`);
|
|
42847
43402
|
}
|
|
@@ -42955,7 +43510,8 @@ var selectTheme = {
|
|
|
42955
43510
|
disabled: (text) => import_yoctocolors_cjs3.default.dim(`- ${text}`),
|
|
42956
43511
|
description: (text) => import_yoctocolors_cjs3.default.cyan(text)
|
|
42957
43512
|
},
|
|
42958
|
-
helpMode: "auto"
|
|
43513
|
+
helpMode: "auto",
|
|
43514
|
+
indexMode: "hidden"
|
|
42959
43515
|
};
|
|
42960
43516
|
function isSelectable(item) {
|
|
42961
43517
|
return !Separator.isSeparator(item) && !item.disabled;
|
|
@@ -43020,13 +43576,15 @@ var esm_default3 = createPrompt((config2, done) => {
|
|
|
43020
43576
|
} while (!isSelectable(items[next]));
|
|
43021
43577
|
setActive(next);
|
|
43022
43578
|
}
|
|
43023
|
-
} else if (isNumberKey(key2)) {
|
|
43024
|
-
rl.
|
|
43025
|
-
const position = Number(key2.name) - 1;
|
|
43579
|
+
} else if (isNumberKey(key2) && !Number.isNaN(Number(rl.line))) {
|
|
43580
|
+
const position = Number(rl.line) - 1;
|
|
43026
43581
|
const item = items[position];
|
|
43027
43582
|
if (item != null && isSelectable(item)) {
|
|
43028
43583
|
setActive(position);
|
|
43029
43584
|
}
|
|
43585
|
+
searchTimeoutRef.current = setTimeout(() => {
|
|
43586
|
+
rl.clearLine(0);
|
|
43587
|
+
}, 700);
|
|
43030
43588
|
} else if (isBackspaceKey(key2)) {
|
|
43031
43589
|
rl.clearLine(0);
|
|
43032
43590
|
} else {
|
|
@@ -43062,17 +43620,18 @@ ${theme.style.help("(Use arrow keys to reveal more choices)")}`;
|
|
|
43062
43620
|
const page = usePagination({
|
|
43063
43621
|
items,
|
|
43064
43622
|
active,
|
|
43065
|
-
renderItem({ item, isActive }) {
|
|
43623
|
+
renderItem({ item, isActive, index }) {
|
|
43066
43624
|
if (Separator.isSeparator(item)) {
|
|
43067
43625
|
return ` ${item.separator}`;
|
|
43068
43626
|
}
|
|
43627
|
+
const indexLabel = theme.indexMode === "number" ? `${index + 1}. ` : "";
|
|
43069
43628
|
if (item.disabled) {
|
|
43070
43629
|
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
|
|
43071
|
-
return theme.style.disabled(`${item.name} ${disabledLabel}`);
|
|
43630
|
+
return theme.style.disabled(`${indexLabel}${item.name} ${disabledLabel}`);
|
|
43072
43631
|
}
|
|
43073
43632
|
const color = isActive ? theme.style.highlight : (x2) => x2;
|
|
43074
43633
|
const cursor = isActive ? theme.icon.cursor : ` `;
|
|
43075
|
-
return color(`${cursor} ${item.name}`);
|
|
43634
|
+
return color(`${cursor} ${indexLabel}${item.name}`);
|
|
43076
43635
|
},
|
|
43077
43636
|
pageSize,
|
|
43078
43637
|
loop
|