openai 4.28.0 → 4.28.5
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/CHANGELOG.md +71 -0
- package/README.md +7 -10
- package/lib/ChatCompletionRunFunctions.test.js +35 -0
- package/lib/ChatCompletionRunFunctions.test.js.map +1 -1
- package/lib/ChatCompletionRunFunctions.test.mjs +35 -0
- package/lib/ChatCompletionRunFunctions.test.mjs.map +1 -1
- package/lib/ChatCompletionStream.d.ts.map +1 -1
- package/lib/ChatCompletionStream.js +21 -3
- package/lib/ChatCompletionStream.js.map +1 -1
- package/lib/ChatCompletionStream.mjs +21 -3
- package/lib/ChatCompletionStream.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/audio/speech.d.ts +3 -2
- package/resources/audio/speech.d.ts.map +1 -1
- package/resources/audio/speech.js.map +1 -1
- package/resources/audio/speech.mjs.map +1 -1
- package/resources/audio/transcriptions.d.ts +14 -4
- package/resources/audio/transcriptions.d.ts.map +1 -1
- package/resources/audio/transcriptions.js.map +1 -1
- package/resources/audio/transcriptions.mjs.map +1 -1
- package/resources/audio/translations.d.ts +2 -1
- package/resources/audio/translations.d.ts.map +1 -1
- package/resources/audio/translations.js.map +1 -1
- package/resources/audio/translations.mjs.map +1 -1
- package/resources/beta/threads/index.d.ts +1 -1
- package/resources/beta/threads/index.d.ts.map +1 -1
- package/resources/beta/threads/index.js.map +1 -1
- package/resources/beta/threads/index.mjs.map +1 -1
- package/resources/beta/threads/runs/index.d.ts +1 -1
- package/resources/beta/threads/runs/index.d.ts.map +1 -1
- package/resources/beta/threads/runs/index.js.map +1 -1
- package/resources/beta/threads/runs/index.mjs.map +1 -1
- package/resources/beta/threads/runs/runs.d.ts +10 -3
- package/resources/beta/threads/runs/runs.d.ts.map +1 -1
- package/resources/beta/threads/runs/runs.js.map +1 -1
- package/resources/beta/threads/runs/runs.mjs.map +1 -1
- package/resources/beta/threads/threads.d.ts +1 -0
- package/resources/beta/threads/threads.d.ts.map +1 -1
- package/resources/beta/threads/threads.js.map +1 -1
- package/resources/beta/threads/threads.mjs.map +1 -1
- package/resources/chat/completions.d.ts +27 -22
- package/resources/chat/completions.d.ts.map +1 -1
- package/resources/chat/completions.js.map +1 -1
- package/resources/chat/completions.mjs.map +1 -1
- package/resources/files.d.ts +4 -4
- package/resources/images.d.ts +6 -3
- package/resources/images.d.ts.map +1 -1
- package/resources/images.js.map +1 -1
- package/resources/images.mjs.map +1 -1
- package/resources/moderations.d.ts +3 -5
- package/resources/moderations.d.ts.map +1 -1
- package/resources/moderations.js +1 -1
- package/resources/moderations.js.map +1 -1
- package/resources/moderations.mjs +1 -1
- package/resources/moderations.mjs.map +1 -1
- package/src/lib/ChatCompletionRunFunctions.test.ts +52 -1
- package/src/lib/ChatCompletionStream.ts +29 -6
- package/src/resources/audio/speech.ts +3 -2
- package/src/resources/audio/transcriptions.ts +14 -4
- package/src/resources/audio/translations.ts +2 -1
- package/src/resources/beta/threads/index.ts +1 -0
- package/src/resources/beta/threads/runs/index.ts +1 -0
- package/src/resources/beta/threads/runs/runs.ts +19 -11
- package/src/resources/beta/threads/threads.ts +1 -0
- package/src/resources/chat/completions.ts +27 -23
- package/src/resources/files.ts +4 -4
- package/src/resources/images.ts +6 -3
- package/src/resources/moderations.ts +3 -5
- package/src/streaming.ts +17 -0
- package/src/version.ts +1 -1
- package/streaming.d.ts +2 -0
- package/streaming.d.ts.map +1 -1
- package/streaming.js +16 -1
- package/streaming.js.map +1 -1
- package/streaming.mjs +14 -0
- package/streaming.mjs.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import OpenAI from 'openai';
|
|
2
|
-
import { OpenAIError } from "../error";
|
|
2
|
+
import { OpenAIError, APIConnectionError } from "../error";
|
|
3
3
|
import { PassThrough } from 'stream';
|
|
4
4
|
import {
|
|
5
5
|
ParsingToolFunction,
|
|
@@ -2207,6 +2207,7 @@ describe('resource completions', () => {
|
|
|
2207
2207
|
await listener.sanityCheck();
|
|
2208
2208
|
});
|
|
2209
2209
|
});
|
|
2210
|
+
|
|
2210
2211
|
describe('stream', () => {
|
|
2211
2212
|
test('successful flow', async () => {
|
|
2212
2213
|
const { fetch, handleRequest } = mockStreamingChatCompletionFetch();
|
|
@@ -2273,5 +2274,55 @@ describe('resource completions', () => {
|
|
|
2273
2274
|
expect(listener.finalMessage).toEqual({ role: 'assistant', content: 'The weather is great today!' });
|
|
2274
2275
|
await listener.sanityCheck();
|
|
2275
2276
|
});
|
|
2277
|
+
test('handles network errors', async () => {
|
|
2278
|
+
const { fetch, handleRequest } = mockFetch();
|
|
2279
|
+
|
|
2280
|
+
const openai = new OpenAI({ apiKey: '...', fetch });
|
|
2281
|
+
|
|
2282
|
+
const stream = openai.beta.chat.completions.stream(
|
|
2283
|
+
{
|
|
2284
|
+
max_tokens: 1024,
|
|
2285
|
+
model: 'gpt-3.5-turbo',
|
|
2286
|
+
messages: [{ role: 'user', content: 'Say hello there!' }],
|
|
2287
|
+
},
|
|
2288
|
+
{ maxRetries: 0 },
|
|
2289
|
+
);
|
|
2290
|
+
|
|
2291
|
+
handleRequest(async () => {
|
|
2292
|
+
throw new Error('mock request error');
|
|
2293
|
+
}).catch(() => {});
|
|
2294
|
+
|
|
2295
|
+
async function runStream() {
|
|
2296
|
+
await stream.done();
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
await expect(runStream).rejects.toThrow(APIConnectionError);
|
|
2300
|
+
});
|
|
2301
|
+
test('handles network errors on async iterator', async () => {
|
|
2302
|
+
const { fetch, handleRequest } = mockFetch();
|
|
2303
|
+
|
|
2304
|
+
const openai = new OpenAI({ apiKey: '...', fetch });
|
|
2305
|
+
|
|
2306
|
+
const stream = openai.beta.chat.completions.stream(
|
|
2307
|
+
{
|
|
2308
|
+
max_tokens: 1024,
|
|
2309
|
+
model: 'gpt-3.5-turbo',
|
|
2310
|
+
messages: [{ role: 'user', content: 'Say hello there!' }],
|
|
2311
|
+
},
|
|
2312
|
+
{ maxRetries: 0 },
|
|
2313
|
+
);
|
|
2314
|
+
|
|
2315
|
+
handleRequest(async () => {
|
|
2316
|
+
throw new Error('mock request error');
|
|
2317
|
+
}).catch(() => {});
|
|
2318
|
+
|
|
2319
|
+
async function runStream() {
|
|
2320
|
+
for await (const _event of stream) {
|
|
2321
|
+
continue;
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
await expect(runStream).rejects.toThrow(APIConnectionError);
|
|
2326
|
+
});
|
|
2276
2327
|
});
|
|
2277
2328
|
});
|
|
@@ -210,13 +210,16 @@ export class ChatCompletionStream
|
|
|
210
210
|
|
|
211
211
|
[Symbol.asyncIterator](): AsyncIterator<ChatCompletionChunk> {
|
|
212
212
|
const pushQueue: ChatCompletionChunk[] = [];
|
|
213
|
-
const readQueue:
|
|
213
|
+
const readQueue: {
|
|
214
|
+
resolve: (chunk: ChatCompletionChunk | undefined) => void;
|
|
215
|
+
reject: (err: unknown) => void;
|
|
216
|
+
}[] = [];
|
|
214
217
|
let done = false;
|
|
215
218
|
|
|
216
219
|
this.on('chunk', (chunk) => {
|
|
217
220
|
const reader = readQueue.shift();
|
|
218
221
|
if (reader) {
|
|
219
|
-
reader(chunk);
|
|
222
|
+
reader.resolve(chunk);
|
|
220
223
|
} else {
|
|
221
224
|
pushQueue.push(chunk);
|
|
222
225
|
}
|
|
@@ -225,7 +228,23 @@ export class ChatCompletionStream
|
|
|
225
228
|
this.on('end', () => {
|
|
226
229
|
done = true;
|
|
227
230
|
for (const reader of readQueue) {
|
|
228
|
-
reader(undefined);
|
|
231
|
+
reader.resolve(undefined);
|
|
232
|
+
}
|
|
233
|
+
readQueue.length = 0;
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
this.on('abort', (err) => {
|
|
237
|
+
done = true;
|
|
238
|
+
for (const reader of readQueue) {
|
|
239
|
+
reader.reject(err);
|
|
240
|
+
}
|
|
241
|
+
readQueue.length = 0;
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
this.on('error', (err) => {
|
|
245
|
+
done = true;
|
|
246
|
+
for (const reader of readQueue) {
|
|
247
|
+
reader.reject(err);
|
|
229
248
|
}
|
|
230
249
|
readQueue.length = 0;
|
|
231
250
|
});
|
|
@@ -236,13 +255,17 @@ export class ChatCompletionStream
|
|
|
236
255
|
if (done) {
|
|
237
256
|
return { value: undefined, done: true };
|
|
238
257
|
}
|
|
239
|
-
return new Promise<ChatCompletionChunk | undefined>((resolve) =>
|
|
240
|
-
(
|
|
241
|
-
);
|
|
258
|
+
return new Promise<ChatCompletionChunk | undefined>((resolve, reject) =>
|
|
259
|
+
readQueue.push({ resolve, reject }),
|
|
260
|
+
).then((chunk) => (chunk ? { value: chunk, done: false } : { value: undefined, done: true }));
|
|
242
261
|
}
|
|
243
262
|
const chunk = pushQueue.shift()!;
|
|
244
263
|
return { value: chunk, done: false };
|
|
245
264
|
},
|
|
265
|
+
return: async () => {
|
|
266
|
+
this.abort();
|
|
267
|
+
return { value: undefined, done: true };
|
|
268
|
+
},
|
|
246
269
|
};
|
|
247
270
|
}
|
|
248
271
|
|
|
@@ -35,9 +35,10 @@ export interface SpeechCreateParams {
|
|
|
35
35
|
voice: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
* The format to audio in. Supported formats are `mp3`, `opus`, `aac`,
|
|
38
|
+
* The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
|
|
39
|
+
* `wav`, and `pcm`.
|
|
39
40
|
*/
|
|
40
|
-
response_format?: 'mp3' | 'opus' | 'aac' | 'flac';
|
|
41
|
+
response_format?: 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm';
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
|
|
@@ -14,7 +14,14 @@ export class Transcriptions extends APIResource {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Represents a transcription response returned by model, based on the provided
|
|
19
|
+
* input.
|
|
20
|
+
*/
|
|
17
21
|
export interface Transcription {
|
|
22
|
+
/**
|
|
23
|
+
* The transcribed text.
|
|
24
|
+
*/
|
|
18
25
|
text: string;
|
|
19
26
|
}
|
|
20
27
|
|
|
@@ -26,7 +33,8 @@ export interface TranscriptionCreateParams {
|
|
|
26
33
|
file: Uploadable;
|
|
27
34
|
|
|
28
35
|
/**
|
|
29
|
-
* ID of the model to use. Only `whisper-1` is
|
|
36
|
+
* ID of the model to use. Only `whisper-1` (which is powered by our open source
|
|
37
|
+
* Whisper V2 model) is currently available.
|
|
30
38
|
*/
|
|
31
39
|
model: (string & {}) | 'whisper-1';
|
|
32
40
|
|
|
@@ -61,9 +69,11 @@ export interface TranscriptionCreateParams {
|
|
|
61
69
|
temperature?: number;
|
|
62
70
|
|
|
63
71
|
/**
|
|
64
|
-
* The timestamp granularities to populate for this transcription.
|
|
65
|
-
*
|
|
66
|
-
*
|
|
72
|
+
* The timestamp granularities to populate for this transcription.
|
|
73
|
+
* `response_format` must be set `verbose_json` to use timestamp granularities.
|
|
74
|
+
* Either or both of these options are supported: `word`, or `segment`. Note: There
|
|
75
|
+
* is no additional latency for segment timestamps, but generating word timestamps
|
|
76
|
+
* incurs additional latency.
|
|
67
77
|
*/
|
|
68
78
|
timestamp_granularities?: Array<'word' | 'segment'>;
|
|
69
79
|
}
|
|
@@ -26,7 +26,8 @@ export interface TranslationCreateParams {
|
|
|
26
26
|
file: Uploadable;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* ID of the model to use. Only `whisper-1` is
|
|
29
|
+
* ID of the model to use. Only `whisper-1` (which is powered by our open source
|
|
30
|
+
* Whisper V2 model) is currently available.
|
|
30
31
|
*/
|
|
31
32
|
model: (string & {}) | 'whisper-1';
|
|
32
33
|
|
|
@@ -242,15 +242,7 @@ export interface Run {
|
|
|
242
242
|
* `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, or
|
|
243
243
|
* `expired`.
|
|
244
244
|
*/
|
|
245
|
-
status:
|
|
246
|
-
| 'queued'
|
|
247
|
-
| 'in_progress'
|
|
248
|
-
| 'requires_action'
|
|
249
|
-
| 'cancelling'
|
|
250
|
-
| 'cancelled'
|
|
251
|
-
| 'failed'
|
|
252
|
-
| 'completed'
|
|
253
|
-
| 'expired';
|
|
245
|
+
status: RunStatus;
|
|
254
246
|
|
|
255
247
|
/**
|
|
256
248
|
* The ID of the [thread](https://platform.openai.com/docs/api-reference/threads)
|
|
@@ -278,9 +270,9 @@ export namespace Run {
|
|
|
278
270
|
*/
|
|
279
271
|
export interface LastError {
|
|
280
272
|
/**
|
|
281
|
-
* One of `server_error` or `
|
|
273
|
+
* One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.
|
|
282
274
|
*/
|
|
283
|
-
code: 'server_error' | 'rate_limit_exceeded';
|
|
275
|
+
code: 'server_error' | 'rate_limit_exceeded' | 'invalid_prompt';
|
|
284
276
|
|
|
285
277
|
/**
|
|
286
278
|
* A human-readable description of the error.
|
|
@@ -361,6 +353,21 @@ export namespace Run {
|
|
|
361
353
|
}
|
|
362
354
|
}
|
|
363
355
|
|
|
356
|
+
/**
|
|
357
|
+
* The status of the run, which can be either `queued`, `in_progress`,
|
|
358
|
+
* `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, or
|
|
359
|
+
* `expired`.
|
|
360
|
+
*/
|
|
361
|
+
export type RunStatus =
|
|
362
|
+
| 'queued'
|
|
363
|
+
| 'in_progress'
|
|
364
|
+
| 'requires_action'
|
|
365
|
+
| 'cancelling'
|
|
366
|
+
| 'cancelled'
|
|
367
|
+
| 'failed'
|
|
368
|
+
| 'completed'
|
|
369
|
+
| 'expired';
|
|
370
|
+
|
|
364
371
|
export interface RunCreateParams {
|
|
365
372
|
/**
|
|
366
373
|
* The ID of the
|
|
@@ -486,6 +493,7 @@ export namespace RunSubmitToolOutputsParams {
|
|
|
486
493
|
export namespace Runs {
|
|
487
494
|
export import RequiredActionFunctionToolCall = RunsAPI.RequiredActionFunctionToolCall;
|
|
488
495
|
export import Run = RunsAPI.Run;
|
|
496
|
+
export import RunStatus = RunsAPI.RunStatus;
|
|
489
497
|
export import RunsPage = RunsAPI.RunsPage;
|
|
490
498
|
export import RunCreateParams = RunsAPI.RunCreateParams;
|
|
491
499
|
export import RunUpdateParams = RunsAPI.RunUpdateParams;
|
|
@@ -298,6 +298,7 @@ export namespace Threads {
|
|
|
298
298
|
export import Runs = RunsAPI.Runs;
|
|
299
299
|
export import RequiredActionFunctionToolCall = RunsAPI.RequiredActionFunctionToolCall;
|
|
300
300
|
export import Run = RunsAPI.Run;
|
|
301
|
+
export import RunStatus = RunsAPI.RunStatus;
|
|
301
302
|
export import RunsPage = RunsAPI.RunsPage;
|
|
302
303
|
export import RunCreateParams = RunsAPI.RunCreateParams;
|
|
303
304
|
export import RunUpdateParams = RunsAPI.RunUpdateParams;
|
|
@@ -133,8 +133,8 @@ export interface ChatCompletionAssistantMessageParam {
|
|
|
133
133
|
content?: string | null;
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
|
-
* Deprecated and replaced by `tool_calls`. The name and arguments of
|
|
137
|
-
* that should be called, as generated by the model.
|
|
136
|
+
* @deprecated: Deprecated and replaced by `tool_calls`. The name and arguments of
|
|
137
|
+
* a function that should be called, as generated by the model.
|
|
138
138
|
*/
|
|
139
139
|
function_call?: ChatCompletionAssistantMessageParam.FunctionCall;
|
|
140
140
|
|
|
@@ -152,8 +152,8 @@ export interface ChatCompletionAssistantMessageParam {
|
|
|
152
152
|
|
|
153
153
|
export namespace ChatCompletionAssistantMessageParam {
|
|
154
154
|
/**
|
|
155
|
-
* Deprecated and replaced by `tool_calls`. The name and arguments of
|
|
156
|
-
* that should be called, as generated by the model.
|
|
155
|
+
* @deprecated: Deprecated and replaced by `tool_calls`. The name and arguments of
|
|
156
|
+
* a function that should be called, as generated by the model.
|
|
157
157
|
*/
|
|
158
158
|
export interface FunctionCall {
|
|
159
159
|
/**
|
|
@@ -250,8 +250,8 @@ export namespace ChatCompletionChunk {
|
|
|
250
250
|
content?: string | null;
|
|
251
251
|
|
|
252
252
|
/**
|
|
253
|
-
* Deprecated and replaced by `tool_calls`. The name and arguments of
|
|
254
|
-
* that should be called, as generated by the model.
|
|
253
|
+
* @deprecated: Deprecated and replaced by `tool_calls`. The name and arguments of
|
|
254
|
+
* a function that should be called, as generated by the model.
|
|
255
255
|
*/
|
|
256
256
|
function_call?: Delta.FunctionCall;
|
|
257
257
|
|
|
@@ -265,8 +265,8 @@ export namespace ChatCompletionChunk {
|
|
|
265
265
|
|
|
266
266
|
export namespace Delta {
|
|
267
267
|
/**
|
|
268
|
-
* Deprecated and replaced by `tool_calls`. The name and arguments of
|
|
269
|
-
* that should be called, as generated by the model.
|
|
268
|
+
* @deprecated: Deprecated and replaced by `tool_calls`. The name and arguments of
|
|
269
|
+
* a function that should be called, as generated by the model.
|
|
270
270
|
*/
|
|
271
271
|
export interface FunctionCall {
|
|
272
272
|
/**
|
|
@@ -378,6 +378,9 @@ export interface ChatCompletionFunctionCallOption {
|
|
|
378
378
|
name: string;
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
+
/**
|
|
382
|
+
* @deprecated
|
|
383
|
+
*/
|
|
381
384
|
export interface ChatCompletionFunctionMessageParam {
|
|
382
385
|
/**
|
|
383
386
|
* The contents of the function message.
|
|
@@ -410,8 +413,8 @@ export interface ChatCompletionMessage {
|
|
|
410
413
|
role: 'assistant';
|
|
411
414
|
|
|
412
415
|
/**
|
|
413
|
-
* Deprecated and replaced by `tool_calls`. The name and arguments of
|
|
414
|
-
* that should be called, as generated by the model.
|
|
416
|
+
* @deprecated: Deprecated and replaced by `tool_calls`. The name and arguments of
|
|
417
|
+
* a function that should be called, as generated by the model.
|
|
415
418
|
*/
|
|
416
419
|
function_call?: ChatCompletionMessage.FunctionCall;
|
|
417
420
|
|
|
@@ -423,8 +426,8 @@ export interface ChatCompletionMessage {
|
|
|
423
426
|
|
|
424
427
|
export namespace ChatCompletionMessage {
|
|
425
428
|
/**
|
|
426
|
-
* Deprecated and replaced by `tool_calls`. The name and arguments of
|
|
427
|
-
* that should be called, as generated by the model.
|
|
429
|
+
* @deprecated: Deprecated and replaced by `tool_calls`. The name and arguments of
|
|
430
|
+
* a function that should be called, as generated by the model.
|
|
428
431
|
*/
|
|
429
432
|
export interface FunctionCall {
|
|
430
433
|
/**
|
|
@@ -546,7 +549,9 @@ export interface ChatCompletionTokenLogprob {
|
|
|
546
549
|
bytes: Array<number> | null;
|
|
547
550
|
|
|
548
551
|
/**
|
|
549
|
-
* The log probability of this token
|
|
552
|
+
* The log probability of this token, if it is within the top 20 most likely
|
|
553
|
+
* tokens. Otherwise, the value `-9999.0` is used to signify that the token is very
|
|
554
|
+
* unlikely.
|
|
550
555
|
*/
|
|
551
556
|
logprob: number;
|
|
552
557
|
|
|
@@ -574,7 +579,9 @@ export namespace ChatCompletionTokenLogprob {
|
|
|
574
579
|
bytes: Array<number> | null;
|
|
575
580
|
|
|
576
581
|
/**
|
|
577
|
-
* The log probability of this token
|
|
582
|
+
* The log probability of this token, if it is within the top 20 most likely
|
|
583
|
+
* tokens. Otherwise, the value `-9999.0` is used to signify that the token is very
|
|
584
|
+
* unlikely.
|
|
578
585
|
*/
|
|
579
586
|
logprob: number;
|
|
580
587
|
}
|
|
@@ -708,12 +715,6 @@ export interface ChatCompletionCreateParamsBase {
|
|
|
708
715
|
*/
|
|
709
716
|
functions?: Array<ChatCompletionCreateParams.Function>;
|
|
710
717
|
|
|
711
|
-
/**
|
|
712
|
-
* An unique identifier to a custom instance to execute the request. The requesting
|
|
713
|
-
* organization is required to have access to the instance.
|
|
714
|
-
*/
|
|
715
|
-
instance_id?: string | null;
|
|
716
|
-
|
|
717
718
|
/**
|
|
718
719
|
* Modify the likelihood of specified tokens appearing in the completion.
|
|
719
720
|
*
|
|
@@ -833,9 +834,9 @@ export interface ChatCompletionCreateParamsBase {
|
|
|
833
834
|
tools?: Array<ChatCompletionTool>;
|
|
834
835
|
|
|
835
836
|
/**
|
|
836
|
-
* An integer between 0 and
|
|
837
|
-
* at each token position, each with an associated log probability.
|
|
838
|
-
* be set to `true` if this parameter is used.
|
|
837
|
+
* An integer between 0 and 20 specifying the number of most likely tokens to
|
|
838
|
+
* return at each token position, each with an associated log probability.
|
|
839
|
+
* `logprobs` must be set to `true` if this parameter is used.
|
|
839
840
|
*/
|
|
840
841
|
top_logprobs?: number | null;
|
|
841
842
|
|
|
@@ -857,6 +858,9 @@ export interface ChatCompletionCreateParamsBase {
|
|
|
857
858
|
}
|
|
858
859
|
|
|
859
860
|
export namespace ChatCompletionCreateParams {
|
|
861
|
+
/**
|
|
862
|
+
* @deprecated
|
|
863
|
+
*/
|
|
860
864
|
export interface Function {
|
|
861
865
|
/**
|
|
862
866
|
* The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
|
package/src/resources/files.ts
CHANGED
|
@@ -154,14 +154,14 @@ export interface FileObject {
|
|
|
154
154
|
purpose: 'fine-tune' | 'fine-tune-results' | 'assistants' | 'assistants_output';
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
|
-
* Deprecated. The current status of the file, which can be either
|
|
158
|
-
* `processed`, or `error`.
|
|
157
|
+
* @deprecated: Deprecated. The current status of the file, which can be either
|
|
158
|
+
* `uploaded`, `processed`, or `error`.
|
|
159
159
|
*/
|
|
160
160
|
status: 'uploaded' | 'processed' | 'error';
|
|
161
161
|
|
|
162
162
|
/**
|
|
163
|
-
* Deprecated. For details on why a fine-tuning training file failed
|
|
164
|
-
* see the `error` field on `fine_tuning.job`.
|
|
163
|
+
* @deprecated: Deprecated. For details on why a fine-tuning training file failed
|
|
164
|
+
* validation, see the `error` field on `fine_tuning.job`.
|
|
165
165
|
*/
|
|
166
166
|
status_details?: string;
|
|
167
167
|
}
|
package/src/resources/images.ts
CHANGED
|
@@ -80,7 +80,8 @@ export interface ImageCreateVariationParams {
|
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* The format in which the generated images are returned. Must be one of `url` or
|
|
83
|
-
* `b64_json`.
|
|
83
|
+
* `b64_json`. URLs are only valid for 60 minutes after the image has been
|
|
84
|
+
* generated.
|
|
84
85
|
*/
|
|
85
86
|
response_format?: 'url' | 'b64_json' | null;
|
|
86
87
|
|
|
@@ -131,7 +132,8 @@ export interface ImageEditParams {
|
|
|
131
132
|
|
|
132
133
|
/**
|
|
133
134
|
* The format in which the generated images are returned. Must be one of `url` or
|
|
134
|
-
* `b64_json`.
|
|
135
|
+
* `b64_json`. URLs are only valid for 60 minutes after the image has been
|
|
136
|
+
* generated.
|
|
135
137
|
*/
|
|
136
138
|
response_format?: 'url' | 'b64_json' | null;
|
|
137
139
|
|
|
@@ -176,7 +178,8 @@ export interface ImageGenerateParams {
|
|
|
176
178
|
|
|
177
179
|
/**
|
|
178
180
|
* The format in which the generated images are returned. Must be one of `url` or
|
|
179
|
-
* `b64_json`.
|
|
181
|
+
* `b64_json`. URLs are only valid for 60 minutes after the image has been
|
|
182
|
+
* generated.
|
|
180
183
|
*/
|
|
181
184
|
response_format?: 'url' | 'b64_json' | null;
|
|
182
185
|
|
|
@@ -6,7 +6,7 @@ import * as ModerationsAPI from "./moderations";
|
|
|
6
6
|
|
|
7
7
|
export class Moderations extends APIResource {
|
|
8
8
|
/**
|
|
9
|
-
* Classifies if text
|
|
9
|
+
* Classifies if text is potentially harmful.
|
|
10
10
|
*/
|
|
11
11
|
create(
|
|
12
12
|
body: ModerationCreateParams,
|
|
@@ -28,8 +28,7 @@ export interface Moderation {
|
|
|
28
28
|
category_scores: Moderation.CategoryScores;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Whether the
|
|
32
|
-
* [OpenAI's usage policies](/policies/usage-policies).
|
|
31
|
+
* Whether any of the below categories are flagged.
|
|
33
32
|
*/
|
|
34
33
|
flagged: boolean;
|
|
35
34
|
}
|
|
@@ -170,8 +169,7 @@ export namespace Moderation {
|
|
|
170
169
|
}
|
|
171
170
|
|
|
172
171
|
/**
|
|
173
|
-
* Represents
|
|
174
|
-
* a given input.
|
|
172
|
+
* Represents if a given text input is potentially harmful.
|
|
175
173
|
*/
|
|
176
174
|
export interface ModerationCreateResponse {
|
|
177
175
|
/**
|
package/src/streaming.ts
CHANGED
|
@@ -300,6 +300,12 @@ class LineDecoder {
|
|
|
300
300
|
const trailingNewline = LineDecoder.NEWLINE_CHARS.has(text[text.length - 1] || '');
|
|
301
301
|
let lines = text.split(LineDecoder.NEWLINE_REGEXP);
|
|
302
302
|
|
|
303
|
+
// if there is a trailing new line then the last entry will be an empty
|
|
304
|
+
// string which we don't care about
|
|
305
|
+
if (trailingNewline) {
|
|
306
|
+
lines.pop();
|
|
307
|
+
}
|
|
308
|
+
|
|
303
309
|
if (lines.length === 1 && !trailingNewline) {
|
|
304
310
|
this.buffer.push(lines[0]!);
|
|
305
311
|
return [];
|
|
@@ -366,6 +372,17 @@ class LineDecoder {
|
|
|
366
372
|
}
|
|
367
373
|
}
|
|
368
374
|
|
|
375
|
+
/** This is an internal helper function that's just used for testing */
|
|
376
|
+
export function _decodeChunks(chunks: string[]): string[] {
|
|
377
|
+
const decoder = new LineDecoder();
|
|
378
|
+
const lines: string[] = [];
|
|
379
|
+
for (const chunk of chunks) {
|
|
380
|
+
lines.push(...decoder.decode(chunk));
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
return lines;
|
|
384
|
+
}
|
|
385
|
+
|
|
369
386
|
function partition(str: string, delimiter: string): [string, string, string] {
|
|
370
387
|
const index = str.indexOf(delimiter);
|
|
371
388
|
if (index !== -1) {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '4.28.
|
|
1
|
+
export const VERSION = '4.28.5'; // x-release-please-version
|
package/streaming.d.ts
CHANGED
|
@@ -28,6 +28,8 @@ export declare class Stream<Item> implements AsyncIterable<Item> {
|
|
|
28
28
|
*/
|
|
29
29
|
toReadableStream(): ReadableStream;
|
|
30
30
|
}
|
|
31
|
+
/** This is an internal helper function that's just used for testing */
|
|
32
|
+
export declare function _decodeChunks(chunks: string[]): string[];
|
|
31
33
|
/**
|
|
32
34
|
* Most browsers don't yet have async iterable support for ReadableStream,
|
|
33
35
|
* and Node has a very different way of reading bytes from its "ReadableStream".
|
package/streaming.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAO/D,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,EAAE,CAAC;CACf,CAAC;AAEF,qBAAa,MAAM,CAAC,IAAI,CAAE,YAAW,aAAa,CAAC,IAAI,CAAC;IAIpD,OAAO,CAAC,QAAQ;IAHlB,UAAU,EAAE,eAAe,CAAC;gBAGlB,QAAQ,EAAE,MAAM,aAAa,CAAC,IAAI,CAAC,EAC3C,UAAU,EAAE,eAAe;IAK7B,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe;IAyE5E;;;OAGG;IACH,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,eAAe;IA2C3F,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC;IAI7C;;;OAGG;IACH,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAwBnC;;;;OAIG;IACH,gBAAgB,IAAI,cAAc;CA0BnC;
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAO/D,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,EAAE,CAAC;CACf,CAAC;AAEF,qBAAa,MAAM,CAAC,IAAI,CAAE,YAAW,aAAa,CAAC,IAAI,CAAC;IAIpD,OAAO,CAAC,QAAQ;IAHlB,UAAU,EAAE,eAAe,CAAC;gBAGlB,QAAQ,EAAE,MAAM,aAAa,CAAC,IAAI,CAAC,EAC3C,UAAU,EAAE,eAAe;IAK7B,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe;IAyE5E;;;OAGG;IACH,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,eAAe;IA2C3F,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC;IAI7C;;;OAGG;IACH,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAwBnC;;;;OAIG;IACH,gBAAgB,IAAI,cAAc;CA0BnC;AAwKD,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAQxD;AAWD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAyBpF"}
|
package/streaming.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readableStreamAsyncIterable = exports.Stream = void 0;
|
|
3
|
+
exports.readableStreamAsyncIterable = exports._decodeChunks = exports.Stream = void 0;
|
|
4
4
|
const index_1 = require("./_shims/index.js");
|
|
5
5
|
const error_1 = require("./error.js");
|
|
6
6
|
const error_2 = require("openai/error");
|
|
@@ -252,6 +252,11 @@ class LineDecoder {
|
|
|
252
252
|
}
|
|
253
253
|
const trailingNewline = LineDecoder.NEWLINE_CHARS.has(text[text.length - 1] || '');
|
|
254
254
|
let lines = text.split(LineDecoder.NEWLINE_REGEXP);
|
|
255
|
+
// if there is a trailing new line then the last entry will be an empty
|
|
256
|
+
// string which we don't care about
|
|
257
|
+
if (trailingNewline) {
|
|
258
|
+
lines.pop();
|
|
259
|
+
}
|
|
255
260
|
if (lines.length === 1 && !trailingNewline) {
|
|
256
261
|
this.buffer.push(lines[0]);
|
|
257
262
|
return [];
|
|
@@ -303,6 +308,16 @@ class LineDecoder {
|
|
|
303
308
|
// prettier-ignore
|
|
304
309
|
LineDecoder.NEWLINE_CHARS = new Set(['\n', '\r', '\x0b', '\x0c', '\x1c', '\x1d', '\x1e', '\x85', '\u2028', '\u2029']);
|
|
305
310
|
LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r\x0b\x0c\x1c\x1d\x1e\x85\u2028\u2029]/g;
|
|
311
|
+
/** This is an internal helper function that's just used for testing */
|
|
312
|
+
function _decodeChunks(chunks) {
|
|
313
|
+
const decoder = new LineDecoder();
|
|
314
|
+
const lines = [];
|
|
315
|
+
for (const chunk of chunks) {
|
|
316
|
+
lines.push(...decoder.decode(chunk));
|
|
317
|
+
}
|
|
318
|
+
return lines;
|
|
319
|
+
}
|
|
320
|
+
exports._decodeChunks = _decodeChunks;
|
|
306
321
|
function partition(str, delimiter) {
|
|
307
322
|
const index = str.indexOf(delimiter);
|
|
308
323
|
if (index !== -1) {
|
package/streaming.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":";;;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S.has(text[text.length - 1] || '');
|
|
250
250
|
let lines = text.split(LineDecoder.NEWLINE_REGEXP);
|
|
251
|
+
// if there is a trailing new line then the last entry will be an empty
|
|
252
|
+
// string which we don't care about
|
|
253
|
+
if (trailingNewline) {
|
|
254
|
+
lines.pop();
|
|
255
|
+
}
|
|
251
256
|
if (lines.length === 1 && !trailingNewline) {
|
|
252
257
|
this.buffer.push(lines[0]);
|
|
253
258
|
return [];
|
|
@@ -299,6 +304,15 @@ class LineDecoder {
|
|
|
299
304
|
// prettier-ignore
|
|
300
305
|
LineDecoder.NEWLINE_CHARS = new Set(['\n', '\r', '\x0b', '\x0c', '\x1c', '\x1d', '\x1e', '\x85', '\u2028', '\u2029']);
|
|
301
306
|
LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r\x0b\x0c\x1c\x1d\x1e\x85\u2028\u2029]/g;
|
|
307
|
+
/** This is an internal helper function that's just used for testing */
|
|
308
|
+
export function _decodeChunks(chunks) {
|
|
309
|
+
const decoder = new LineDecoder();
|
|
310
|
+
const lines = [];
|
|
311
|
+
for (const chunk of chunks) {
|
|
312
|
+
lines.push(...decoder.decode(chunk));
|
|
313
|
+
}
|
|
314
|
+
return lines;
|
|
315
|
+
}
|
|
302
316
|
function partition(str, delimiter) {
|
|
303
317
|
const index = str.indexOf(delimiter);
|
|
304
318
|
if (index !== -1) {
|