openai 4.8.0 → 4.9.0
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 +8 -0
- package/README.md +4 -0
- package/_shims/MultipartBody.d.ts +9 -0
- package/_shims/MultipartBody.d.ts.map +1 -0
- package/_shims/MultipartBody.js +16 -0
- package/_shims/MultipartBody.js.map +1 -0
- package/_shims/MultipartBody.mjs +12 -0
- package/_shims/MultipartBody.mjs.map +1 -0
- package/_shims/README.md +46 -0
- package/{src/_shims/ReadableStream-node.ts → _shims/auto/runtime-bun.d.ts} +2 -3
- package/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/_shims/auto/runtime-bun.js +21 -0
- package/_shims/auto/runtime-bun.js.map +1 -0
- package/_shims/auto/runtime-bun.mjs +2 -0
- package/_shims/auto/runtime-bun.mjs.map +1 -0
- package/_shims/auto/runtime-node.d.ts +5 -0
- package/_shims/auto/runtime-node.d.ts.map +1 -0
- package/_shims/auto/runtime-node.js +21 -0
- package/_shims/auto/runtime-node.js.map +1 -0
- package/_shims/auto/runtime-node.mjs +2 -0
- package/_shims/auto/runtime-node.mjs.map +1 -0
- package/_shims/auto/runtime.d.ts +5 -0
- package/_shims/auto/runtime.d.ts.map +1 -0
- package/_shims/auto/runtime.js +21 -0
- package/_shims/auto/runtime.js.map +1 -0
- package/_shims/auto/runtime.mjs +2 -0
- package/_shims/auto/runtime.mjs.map +1 -0
- package/_shims/auto/types-node.d.ts +5 -0
- package/_shims/auto/types-node.d.ts.map +1 -0
- package/_shims/auto/types-node.js +21 -0
- package/_shims/auto/types-node.js.map +1 -0
- package/_shims/auto/types-node.mjs +2 -0
- package/_shims/auto/types-node.mjs.map +1 -0
- package/_shims/auto/types.d.ts +99 -0
- package/_shims/{ReadableStream.js → auto/types.js} +0 -2
- package/{src/_shims/ReadableStream.js → _shims/auto/types.mjs} +0 -2
- package/_shims/bun-runtime.d.ts +6 -0
- package/_shims/bun-runtime.d.ts.map +1 -0
- package/_shims/bun-runtime.js +14 -0
- package/_shims/bun-runtime.js.map +1 -0
- package/_shims/bun-runtime.mjs +10 -0
- package/_shims/bun-runtime.mjs.map +1 -0
- package/_shims/index.d.ts +79 -0
- package/_shims/index.js +13 -0
- package/_shims/index.mjs +7 -0
- package/_shims/manual-types.d.ts +12 -0
- package/_shims/manual-types.js +3 -0
- package/_shims/manual-types.mjs +3 -0
- package/_shims/node-runtime.d.ts +3 -0
- package/_shims/node-runtime.d.ts.map +1 -0
- package/_shims/node-runtime.js +87 -0
- package/_shims/node-runtime.js.map +1 -0
- package/_shims/node-runtime.mjs +54 -0
- package/_shims/node-runtime.mjs.map +1 -0
- package/_shims/node-types.d.ts +42 -0
- package/_shims/node-types.js +3 -0
- package/_shims/node-types.mjs +3 -0
- package/_shims/registry.d.ts +35 -0
- package/_shims/registry.d.ts.map +1 -0
- package/_shims/registry.js +39 -0
- package/_shims/registry.js.map +1 -0
- package/_shims/registry.mjs +35 -0
- package/_shims/registry.mjs.map +1 -0
- package/_shims/web-runtime.d.ts +5 -0
- package/_shims/web-runtime.d.ts.map +1 -0
- package/_shims/web-runtime.js +70 -0
- package/_shims/web-runtime.js.map +1 -0
- package/_shims/web-runtime.mjs +63 -0
- package/_shims/web-runtime.mjs.map +1 -0
- package/_shims/web-types.d.ts +82 -0
- package/_shims/web-types.js +3 -0
- package/_shims/web-types.mjs +3 -0
- package/core.d.ts +170 -218
- package/core.d.ts.map +1 -1
- package/core.js +679 -737
- package/core.js.map +1 -1
- package/core.mjs +673 -688
- package/core.mjs.map +1 -1
- package/error.d.ts +32 -34
- package/error.js +95 -109
- package/error.mjs +92 -94
- package/index.d.mts +164 -175
- package/index.d.ts +164 -175
- package/index.d.ts.map +1 -1
- package/index.js +110 -161
- package/index.mjs +88 -109
- package/package.json +31 -58
- package/pagination.d.ts +31 -41
- package/pagination.js +52 -48
- package/pagination.mjs +50 -46
- package/resource.d.ts +10 -10
- package/resource.js +12 -12
- package/resource.mjs +10 -10
- package/resources/audio/audio.d.ts +12 -12
- package/resources/audio/audio.js +33 -50
- package/resources/audio/audio.mjs +11 -11
- package/resources/audio/index.d.ts +4 -4
- package/resources/audio/index.js +9 -24
- package/resources/audio/index.mjs +4 -4
- package/resources/audio/transcriptions.d.ts +44 -44
- package/resources/audio/transcriptions.js +13 -12
- package/resources/audio/transcriptions.mjs +9 -8
- package/resources/audio/translations.d.ts +38 -38
- package/resources/audio/translations.js +13 -12
- package/resources/audio/translations.mjs +9 -8
- package/resources/chat/chat.d.ts +17 -17
- package/resources/chat/chat.js +30 -47
- package/resources/chat/chat.mjs +8 -8
- package/resources/chat/completions.d.ts +330 -353
- package/resources/chat/completions.js +10 -13
- package/resources/chat/completions.mjs +7 -10
- package/resources/chat/index.d.ts +3 -17
- package/resources/chat/index.js +7 -17
- package/resources/chat/index.mjs +3 -3
- package/resources/completions.d.ts +216 -232
- package/resources/completions.js +10 -13
- package/resources/completions.mjs +7 -10
- package/resources/edits.d.ts +73 -73
- package/resources/edits.js +16 -15
- package/resources/edits.mjs +13 -12
- package/resources/embeddings.d.ts +73 -76
- package/resources/embeddings.js +12 -11
- package/resources/embeddings.mjs +9 -8
- package/resources/files.d.ts +91 -96
- package/resources/files.js +64 -65
- package/resources/files.mjs +57 -58
- package/resources/fine-tunes.d.ts +277 -290
- package/resources/fine-tunes.js +49 -50
- package/resources/fine-tunes.mjs +45 -46
- package/resources/fine-tuning/fine-tuning.d.ts +12 -12
- package/resources/fine-tuning/fine-tuning.js +32 -49
- package/resources/fine-tuning/fine-tuning.mjs +10 -10
- package/resources/fine-tuning/index.d.ts +3 -12
- package/resources/fine-tuning/index.js +9 -29
- package/resources/fine-tuning/index.mjs +3 -3
- package/resources/fine-tuning/jobs.d.ts +173 -179
- package/resources/fine-tuning/jobs.js +50 -47
- package/resources/fine-tuning/jobs.mjs +45 -42
- package/resources/images.d.ts +116 -119
- package/resources/images.js +25 -24
- package/resources/images.mjs +21 -20
- package/resources/index.d.ts +12 -37
- package/resources/index.js +29 -113
- package/resources/index.mjs +12 -12
- package/resources/models.d.ts +41 -40
- package/resources/models.js +30 -28
- package/resources/models.mjs +26 -24
- package/resources/moderations.d.ts +153 -156
- package/resources/moderations.js +12 -11
- package/resources/moderations.mjs +9 -8
- package/shims/node.d.ts +29 -0
- package/shims/node.d.ts.map +1 -0
- package/shims/node.js +31 -0
- package/shims/node.js.map +1 -0
- package/shims/node.mjs +5 -0
- package/shims/node.mjs.map +1 -0
- package/shims/web.d.ts +26 -0
- package/shims/web.d.ts.map +1 -0
- package/shims/web.js +31 -0
- package/shims/web.js.map +1 -0
- package/shims/web.mjs +5 -0
- package/shims/web.mjs.map +1 -0
- package/src/_shims/MultipartBody.ts +9 -0
- package/src/_shims/README.md +46 -0
- package/src/_shims/auto/runtime-bun.ts +4 -0
- package/src/_shims/auto/runtime-node.ts +4 -0
- package/src/_shims/auto/runtime.ts +4 -0
- package/src/_shims/auto/types-node.ts +4 -0
- package/src/_shims/auto/types.d.ts +99 -0
- package/src/_shims/auto/types.js +3 -0
- package/src/_shims/auto/types.mjs +3 -0
- package/src/_shims/bun-runtime.ts +14 -0
- package/src/_shims/index.d.ts +79 -0
- package/src/_shims/index.js +13 -0
- package/src/_shims/index.mjs +7 -0
- package/src/_shims/manual-types.d.ts +12 -0
- package/src/_shims/manual-types.js +3 -0
- package/src/_shims/manual-types.mjs +3 -0
- package/src/_shims/node-runtime.ts +79 -0
- package/src/_shims/node-types.d.ts +42 -0
- package/src/_shims/node-types.js +3 -0
- package/src/_shims/node-types.mjs +3 -0
- package/src/_shims/registry.ts +62 -0
- package/src/_shims/web-runtime.ts +91 -0
- package/src/_shims/web-types.d.ts +82 -0
- package/src/_shims/web-types.js +3 -0
- package/src/_shims/web-types.mjs +3 -0
- package/src/core.ts +34 -17
- package/src/error.ts +1 -1
- package/src/index.ts +6 -6
- package/src/pagination.ts +1 -1
- package/src/resource.ts +1 -1
- package/src/resources/audio/audio.ts +4 -4
- package/src/resources/audio/index.ts +3 -3
- package/src/resources/audio/transcriptions.ts +4 -4
- package/src/resources/audio/translations.ts +4 -4
- package/src/resources/chat/chat.ts +3 -3
- package/src/resources/chat/completions.ts +6 -6
- package/src/resources/chat/index.ts +2 -2
- package/src/resources/completions.ts +5 -5
- package/src/resources/edits.ts +4 -4
- package/src/resources/embeddings.ts +3 -3
- package/src/resources/files.ts +7 -7
- package/src/resources/fine-tunes.ts +7 -7
- package/src/resources/fine-tuning/fine-tuning.ts +3 -3
- package/src/resources/fine-tuning/index.ts +2 -2
- package/src/resources/fine-tuning/jobs.ts +6 -6
- package/src/resources/images.ts +4 -4
- package/src/resources/index.ts +11 -11
- package/src/resources/models.ts +4 -4
- package/src/resources/moderations.ts +3 -3
- package/src/shims/node.ts +50 -0
- package/src/shims/web.ts +50 -0
- package/src/streaming.ts +1 -1
- package/src/uploads.ts +12 -16
- package/src/version.ts +1 -1
- package/streaming.d.ts +9 -8
- package/streaming.d.ts.map +1 -1
- package/streaming.js +194 -185
- package/streaming.mjs +192 -183
- package/uploads.d.ts +23 -39
- package/uploads.d.ts.map +1 -1
- package/uploads.js +115 -157
- package/uploads.js.map +1 -1
- package/uploads.mjs +111 -133
- package/uploads.mjs.map +1 -1
- package/version.d.ts +2 -2
- package/version.js +4 -4
- package/version.mjs +2 -2
- package/_shims/ReadableStream-node.d.ts +0 -6
- package/_shims/ReadableStream-node.d.ts.map +0 -1
- package/_shims/ReadableStream-node.js +0 -14
- package/_shims/ReadableStream-node.js.map +0 -1
- package/_shims/ReadableStream-node.mjs +0 -3
- package/_shims/ReadableStream-node.mjs.map +0 -1
- package/_shims/ReadableStream.d.ts +0 -38
- package/_shims/ReadableStream.mjs +0 -7
- package/_shims/agent-node.d.ts +0 -7
- package/_shims/agent-node.d.ts.map +0 -1
- package/_shims/agent-node.js +0 -28
- package/_shims/agent-node.js.map +0 -1
- package/_shims/agent-node.mjs +0 -16
- package/_shims/agent-node.mjs.map +0 -1
- package/_shims/agent.d.ts +0 -9
- package/_shims/agent.d.ts.map +0 -1
- package/_shims/agent.js +0 -14
- package/_shims/agent.js.map +0 -1
- package/_shims/agent.mjs +0 -10
- package/_shims/agent.mjs.map +0 -1
- package/_shims/fetch-node.d.ts +0 -64
- package/_shims/fetch-node.js +0 -12
- package/_shims/fetch-node.mjs +0 -14
- package/_shims/fetch.d.ts +0 -60
- package/_shims/fetch.js +0 -13
- package/_shims/fetch.mjs +0 -15
- package/_shims/fileFromPath-node.d.ts +0 -17
- package/_shims/fileFromPath-node.d.ts.map +0 -1
- package/_shims/fileFromPath-node.js +0 -17
- package/_shims/fileFromPath-node.js.map +0 -1
- package/_shims/fileFromPath-node.mjs +0 -13
- package/_shims/fileFromPath-node.mjs.map +0 -1
- package/_shims/fileFromPath.d.ts +0 -22
- package/_shims/fileFromPath.d.ts.map +0 -1
- package/_shims/fileFromPath.js +0 -16
- package/_shims/fileFromPath.js.map +0 -1
- package/_shims/fileFromPath.mjs +0 -12
- package/_shims/fileFromPath.mjs.map +0 -1
- package/_shims/form-data-node.d.ts +0 -45
- package/_shims/form-data-node.js +0 -11
- package/_shims/form-data-node.mjs +0 -9
- package/_shims/form-data.d.ts +0 -43
- package/_shims/form-data.js +0 -17
- package/_shims/form-data.mjs +0 -20
- package/_shims/getMultipartRequestOptions-node.d.ts +0 -10
- package/_shims/getMultipartRequestOptions-node.d.ts.map +0 -1
- package/_shims/getMultipartRequestOptions-node.js +0 -22
- package/_shims/getMultipartRequestOptions-node.js.map +0 -1
- package/_shims/getMultipartRequestOptions-node.mjs +0 -18
- package/_shims/getMultipartRequestOptions-node.mjs.map +0 -1
- package/_shims/getMultipartRequestOptions.d.ts +0 -10
- package/_shims/getMultipartRequestOptions.d.ts.map +0 -1
- package/_shims/getMultipartRequestOptions.js +0 -12
- package/_shims/getMultipartRequestOptions.js.map +0 -1
- package/_shims/getMultipartRequestOptions.mjs +0 -8
- package/_shims/getMultipartRequestOptions.mjs.map +0 -1
- package/_shims/node-readable-node.d.ts +0 -8
- package/_shims/node-readable-node.d.ts.map +0 -1
- package/_shims/node-readable-node.js +0 -9
- package/_shims/node-readable-node.js.map +0 -1
- package/_shims/node-readable-node.mjs +0 -5
- package/_shims/node-readable-node.mjs.map +0 -1
- package/_shims/node-readable.d.ts +0 -23
- package/_shims/node-readable.d.ts.map +0 -1
- package/_shims/node-readable.js +0 -11
- package/_shims/node-readable.js.map +0 -1
- package/_shims/node-readable.mjs +0 -7
- package/_shims/node-readable.mjs.map +0 -1
- package/src/_shims/ReadableStream.d.ts +0 -38
- package/src/_shims/ReadableStream.mjs +0 -7
- package/src/_shims/agent-node.ts +0 -22
- package/src/_shims/agent.ts +0 -12
- package/src/_shims/fetch-node.d.ts +0 -64
- package/src/_shims/fetch-node.js +0 -12
- package/src/_shims/fetch-node.mjs +0 -14
- package/src/_shims/fetch.d.ts +0 -60
- package/src/_shims/fetch.js +0 -13
- package/src/_shims/fetch.mjs +0 -15
- package/src/_shims/fileFromPath-node.ts +0 -29
- package/src/_shims/fileFromPath.ts +0 -29
- package/src/_shims/form-data-node.d.ts +0 -45
- package/src/_shims/form-data-node.js +0 -11
- package/src/_shims/form-data-node.mjs +0 -9
- package/src/_shims/form-data.d.ts +0 -43
- package/src/_shims/form-data.js +0 -17
- package/src/_shims/form-data.mjs +0 -20
- package/src/_shims/getMultipartRequestOptions-node.ts +0 -25
- package/src/_shims/getMultipartRequestOptions.ts +0 -14
- package/src/_shims/node-readable-node.ts +0 -10
- package/src/_shims/node-readable.ts +0 -30
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
|
+
*/
|
|
4
|
+
import { MultipartBody } from './MultipartBody';
|
|
5
|
+
import { type RequestOptions } from '../core';
|
|
6
|
+
import { type Shims } from './registry';
|
|
7
|
+
|
|
8
|
+
export function getRuntime({ manuallyImported }: { manuallyImported?: boolean } = {}): Shims {
|
|
9
|
+
const recommendation =
|
|
10
|
+
manuallyImported ?
|
|
11
|
+
`You may need to use polyfills`
|
|
12
|
+
: `Add one of these imports before your first \`import … from 'openai'\`:
|
|
13
|
+
- \`import 'openai/shims/node'\` (if you're running on Node)
|
|
14
|
+
- \`import 'openai/shims/web'\` (otherwise)
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
let _fetch, _Request, _Response, _Headers;
|
|
18
|
+
try {
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
_fetch = fetch;
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
_Request = Request;
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
_Response = Response;
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
_Headers = Headers;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`this environment is missing the following Web Fetch API type: ${
|
|
30
|
+
(error as any).message
|
|
31
|
+
}. ${recommendation}`,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
kind: 'web',
|
|
37
|
+
fetch: _fetch,
|
|
38
|
+
Request: _Request,
|
|
39
|
+
Response: _Response,
|
|
40
|
+
Headers: _Headers,
|
|
41
|
+
FormData:
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
typeof FormData !== 'undefined' ? FormData : (
|
|
44
|
+
class FormData {
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
constructor() {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${recommendation}`,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
Blob:
|
|
54
|
+
typeof Blob !== 'undefined' ? Blob : (
|
|
55
|
+
class Blob {
|
|
56
|
+
constructor() {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${recommendation}`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
File:
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
typeof File !== 'undefined' ? File : (
|
|
66
|
+
class File {
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
constructor() {
|
|
69
|
+
throw new Error(
|
|
70
|
+
`file uploads aren't supported in this environment yet as 'File' is undefined. ${recommendation}`,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
getMultipartRequestOptions: async <T extends {} = Record<string, unknown>>(
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
form: FormData,
|
|
78
|
+
opts: RequestOptions<T>,
|
|
79
|
+
): Promise<RequestOptions<T>> => ({
|
|
80
|
+
...opts,
|
|
81
|
+
body: new MultipartBody(form) as any,
|
|
82
|
+
}),
|
|
83
|
+
getDefaultAgent: (url: string) => undefined,
|
|
84
|
+
fileFromPath: () => {
|
|
85
|
+
throw new Error(
|
|
86
|
+
'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/openai/openai-node#file-uploads',
|
|
87
|
+
);
|
|
88
|
+
},
|
|
89
|
+
isFsReadStream: (value: any) => false,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
|
|
3
|
+
*/
|
|
4
|
+
export type Agent = any;
|
|
5
|
+
|
|
6
|
+
declare const _fetch: typeof fetch;
|
|
7
|
+
export { _fetch as fetch };
|
|
8
|
+
|
|
9
|
+
type _Request = Request;
|
|
10
|
+
export { _Request as Request };
|
|
11
|
+
|
|
12
|
+
type _RequestInfo = RequestInfo;
|
|
13
|
+
export { type _RequestInfo as RequestInfo };
|
|
14
|
+
|
|
15
|
+
type _RequestInit = RequestInit;
|
|
16
|
+
export { type _RequestInit as RequestInit };
|
|
17
|
+
|
|
18
|
+
type _Response = Response;
|
|
19
|
+
export { _Response as Response };
|
|
20
|
+
|
|
21
|
+
type _ResponseInit = ResponseInit;
|
|
22
|
+
export { type _ResponseInit as ResponseInit };
|
|
23
|
+
|
|
24
|
+
type _ResponseType = ResponseType;
|
|
25
|
+
export { type _ResponseType as ResponseType };
|
|
26
|
+
|
|
27
|
+
type _BodyInit = BodyInit;
|
|
28
|
+
export { type _BodyInit as BodyInit };
|
|
29
|
+
|
|
30
|
+
type _Headers = Headers;
|
|
31
|
+
export { _Headers as Headers };
|
|
32
|
+
|
|
33
|
+
type _HeadersInit = HeadersInit;
|
|
34
|
+
export { type _HeadersInit as HeadersInit };
|
|
35
|
+
|
|
36
|
+
type EndingType = 'native' | 'transparent';
|
|
37
|
+
|
|
38
|
+
export interface BlobPropertyBag {
|
|
39
|
+
endings?: EndingType;
|
|
40
|
+
type?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface FilePropertyBag extends BlobPropertyBag {
|
|
44
|
+
lastModified?: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type FileFromPathOptions = Omit<FilePropertyBag, 'lastModified'>;
|
|
48
|
+
|
|
49
|
+
type _FormData = FormData;
|
|
50
|
+
declare const _FormData: typeof FormData;
|
|
51
|
+
export { _FormData as FormData };
|
|
52
|
+
|
|
53
|
+
type _File = File;
|
|
54
|
+
declare const _File: typeof File;
|
|
55
|
+
export { _File as File };
|
|
56
|
+
|
|
57
|
+
type _Blob = Blob;
|
|
58
|
+
declare const _Blob: typeof Blob;
|
|
59
|
+
export { _Blob as Blob };
|
|
60
|
+
|
|
61
|
+
export declare class Readable {
|
|
62
|
+
readable: boolean;
|
|
63
|
+
readonly readableEnded: boolean;
|
|
64
|
+
readonly readableFlowing: boolean | null;
|
|
65
|
+
readonly readableHighWaterMark: number;
|
|
66
|
+
readonly readableLength: number;
|
|
67
|
+
readonly readableObjectMode: boolean;
|
|
68
|
+
destroyed: boolean;
|
|
69
|
+
read(size?: number): any;
|
|
70
|
+
pause(): this;
|
|
71
|
+
resume(): this;
|
|
72
|
+
isPaused(): boolean;
|
|
73
|
+
destroy(error?: Error): this;
|
|
74
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<any>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export declare class FsReadStream extends Readable {
|
|
78
|
+
path: {}; // node type is string | Buffer
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
type _ReadableStream<R = any> = ReadableStream<R>;
|
|
82
|
+
export { type _ReadableStream as ReadableStream };
|
package/src/core.ts
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { VERSION } from './version
|
|
2
|
-
import { Stream } from './streaming
|
|
3
|
-
import { APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError } from './error
|
|
4
|
-
import type { Readable } from './_shims/node-readable.js';
|
|
5
|
-
import { getDefaultAgent, type Agent } from './_shims/agent.js';
|
|
1
|
+
import { VERSION } from './version';
|
|
2
|
+
import { Stream } from './streaming';
|
|
3
|
+
import { APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError } from './error';
|
|
6
4
|
import {
|
|
5
|
+
kind as shimsKind,
|
|
6
|
+
type Readable,
|
|
7
|
+
getDefaultAgent,
|
|
8
|
+
type Agent,
|
|
7
9
|
fetch,
|
|
8
|
-
isPolyfilled as fetchIsPolyfilled,
|
|
9
10
|
type RequestInfo,
|
|
10
11
|
type RequestInit,
|
|
11
12
|
type Response,
|
|
12
13
|
type HeadersInit,
|
|
13
|
-
} from './_shims/
|
|
14
|
+
} from './_shims/index';
|
|
14
15
|
export { type Response };
|
|
15
|
-
import { isMultipartBody } from './uploads
|
|
16
|
+
import { isMultipartBody } from './uploads';
|
|
16
17
|
export {
|
|
17
18
|
maybeMultipartFormRequestOptions,
|
|
18
19
|
multipartFormRequestOptions,
|
|
19
20
|
createForm,
|
|
20
21
|
type Uploadable,
|
|
21
|
-
} from './uploads
|
|
22
|
+
} from './uploads';
|
|
22
23
|
|
|
23
24
|
const MAX_RETRIES = 2;
|
|
24
25
|
|
|
@@ -84,6 +85,12 @@ export class APIPromise<T> extends Promise<T> {
|
|
|
84
85
|
*
|
|
85
86
|
* If you want to parse the response body but still get the `Response`
|
|
86
87
|
* instance, you can use {@link withResponse()}.
|
|
88
|
+
*
|
|
89
|
+
* 👋 Getting the wrong TypeScript type for `Response`?
|
|
90
|
+
* Try setting `"moduleResolution": "NodeNext"` if you can,
|
|
91
|
+
* or add one of these imports before your first `import … from 'openai'`:
|
|
92
|
+
* - `import 'openai/shims/node'` (if you're running on Node)
|
|
93
|
+
* - `import 'openai/shims/web'` (otherwise)
|
|
87
94
|
*/
|
|
88
95
|
asResponse(): Promise<Response> {
|
|
89
96
|
return this.responsePromise.then((p) => p.response);
|
|
@@ -93,6 +100,13 @@ export class APIPromise<T> extends Promise<T> {
|
|
|
93
100
|
*
|
|
94
101
|
* If you just want to get the raw `Response` instance without parsing it,
|
|
95
102
|
* you can use {@link asResponse()}.
|
|
103
|
+
*
|
|
104
|
+
*
|
|
105
|
+
* 👋 Getting the wrong TypeScript type for `Response`?
|
|
106
|
+
* Try setting `"moduleResolution": "NodeNext"` if you can,
|
|
107
|
+
* or add one of these imports before your first `import … from 'openai'`:
|
|
108
|
+
* - `import 'openai/shims/node'` (if you're running on Node)
|
|
109
|
+
* - `import 'openai/shims/web'` (otherwise)
|
|
96
110
|
*/
|
|
97
111
|
async withResponse(): Promise<{ data: T; response: Response }> {
|
|
98
112
|
const [data, response] = await Promise.all([this.parse(), this.asResponse()]);
|
|
@@ -277,7 +291,7 @@ export abstract class APIClient {
|
|
|
277
291
|
...headers,
|
|
278
292
|
};
|
|
279
293
|
// let builtin fetch set the Content-Type for multipart bodies
|
|
280
|
-
if (isMultipartBody(options.body) &&
|
|
294
|
+
if (isMultipartBody(options.body) && shimsKind !== 'node') {
|
|
281
295
|
delete reqHeaders['Content-Type'];
|
|
282
296
|
}
|
|
283
297
|
|
|
@@ -444,11 +458,14 @@ export abstract class APIClient {
|
|
|
444
458
|
|
|
445
459
|
const timeout = setTimeout(() => controller.abort(), ms);
|
|
446
460
|
|
|
447
|
-
return
|
|
448
|
-
.
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
461
|
+
return (
|
|
462
|
+
this.getRequestClient()
|
|
463
|
+
// use undefined this binding; fetch errors if bound to something else in browser/cloudflare
|
|
464
|
+
.fetch.call(undefined, url, { signal: controller.signal as any, ...options })
|
|
465
|
+
.finally(() => {
|
|
466
|
+
clearTimeout(timeout);
|
|
467
|
+
})
|
|
468
|
+
);
|
|
452
469
|
}
|
|
453
470
|
|
|
454
471
|
protected getRequestClient(): RequestClient {
|
|
@@ -592,7 +609,7 @@ export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
|
|
|
592
609
|
} else if ('url' in nextInfo) {
|
|
593
610
|
const params = [...Object.entries(nextOptions.query || {}), ...nextInfo.url.searchParams.entries()];
|
|
594
611
|
for (const [key, value] of params) {
|
|
595
|
-
nextInfo.url.searchParams.set(key, value);
|
|
612
|
+
nextInfo.url.searchParams.set(key, value as any);
|
|
596
613
|
}
|
|
597
614
|
nextOptions.query = undefined;
|
|
598
615
|
nextOptions.path = nextInfo.url.toString();
|
|
@@ -718,7 +735,7 @@ const requestOptionsKeys: KeysEnum<RequestOptions> = {
|
|
|
718
735
|
idempotencyKey: true,
|
|
719
736
|
};
|
|
720
737
|
|
|
721
|
-
export const isRequestOptions = (obj: unknown): obj is RequestOptions => {
|
|
738
|
+
export const isRequestOptions = (obj: unknown): obj is RequestOptions<Record<string, unknown> | Readable> => {
|
|
722
739
|
return (
|
|
723
740
|
typeof obj === 'object' &&
|
|
724
741
|
obj !== null &&
|
package/src/error.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from './core
|
|
4
|
-
import * as Pagination from './pagination
|
|
5
|
-
import * as API from './resources/index
|
|
6
|
-
import * as Errors from './error
|
|
7
|
-
import type
|
|
8
|
-
import * as Uploads from './uploads
|
|
3
|
+
import * as Core from './core';
|
|
4
|
+
import * as Pagination from './pagination';
|
|
5
|
+
import * as API from './resources/index';
|
|
6
|
+
import * as Errors from './error';
|
|
7
|
+
import { type Agent } from './_shims/index';
|
|
8
|
+
import * as Uploads from './uploads';
|
|
9
9
|
|
|
10
10
|
export interface ClientOptions {
|
|
11
11
|
/**
|
package/src/pagination.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import { AbstractPage, Response, APIClient, FinalRequestOptions, PageInfo } from './core
|
|
3
|
+
import { AbstractPage, Response, APIClient, FinalRequestOptions, PageInfo } from './core';
|
|
4
4
|
|
|
5
5
|
export interface PageResponse<Item> {
|
|
6
6
|
data: Array<Item>;
|
package/src/resource.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import { APIResource } from
|
|
4
|
-
import { Transcriptions } from './transcriptions
|
|
5
|
-
import { Translations } from './translations
|
|
6
|
-
import * as API from './index
|
|
3
|
+
import { APIResource } from "../../resource";
|
|
4
|
+
import { Transcriptions } from './transcriptions';
|
|
5
|
+
import { Translations } from './translations';
|
|
6
|
+
import * as API from './index';
|
|
7
7
|
|
|
8
8
|
export class Audio extends APIResource {
|
|
9
9
|
transcriptions: Transcriptions = new Transcriptions(this.client);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
export { Audio } from './audio
|
|
4
|
-
export { Transcription, TranscriptionCreateParams, Transcriptions } from './transcriptions
|
|
5
|
-
export { Translation, TranslationCreateParams, Translations } from './translations
|
|
3
|
+
export { Audio } from './audio';
|
|
4
|
+
export { Transcription, TranscriptionCreateParams, Transcriptions } from './transcriptions';
|
|
5
|
+
export { Translation, TranslationCreateParams, Translations } from './translations';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from
|
|
4
|
-
import { APIResource } from
|
|
5
|
-
import * as API from './index
|
|
6
|
-
import { type Uploadable, multipartFormRequestOptions } from
|
|
3
|
+
import * as Core from "../../core";
|
|
4
|
+
import { APIResource } from "../../resource";
|
|
5
|
+
import * as API from './index';
|
|
6
|
+
import { type Uploadable, multipartFormRequestOptions } from "../../core";
|
|
7
7
|
|
|
8
8
|
export class Transcriptions extends APIResource {
|
|
9
9
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from
|
|
4
|
-
import { APIResource } from
|
|
5
|
-
import * as API from './index
|
|
6
|
-
import { type Uploadable, multipartFormRequestOptions } from
|
|
3
|
+
import * as Core from "../../core";
|
|
4
|
+
import { APIResource } from "../../resource";
|
|
5
|
+
import * as API from './index';
|
|
6
|
+
import { type Uploadable, multipartFormRequestOptions } from "../../core";
|
|
7
7
|
|
|
8
8
|
export class Translations extends APIResource {
|
|
9
9
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import { APIResource } from
|
|
4
|
-
import { Completions } from './completions
|
|
5
|
-
import * as API from './index
|
|
3
|
+
import { APIResource } from "../../resource";
|
|
4
|
+
import { Completions } from './completions';
|
|
5
|
+
import * as API from './index';
|
|
6
6
|
|
|
7
7
|
export class Chat extends APIResource {
|
|
8
8
|
completions: Completions = new Completions(this.client);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from
|
|
4
|
-
import { APIPromise } from
|
|
5
|
-
import { APIResource } from
|
|
6
|
-
import * as Completions_ from
|
|
7
|
-
import * as API from './index
|
|
8
|
-
import { Stream } from
|
|
3
|
+
import * as Core from "../../core";
|
|
4
|
+
import { APIPromise } from "../../core";
|
|
5
|
+
import { APIResource } from "../../resource";
|
|
6
|
+
import * as Completions_ from "../completions";
|
|
7
|
+
import * as API from './index';
|
|
8
|
+
import { Stream } from "../../streaming";
|
|
9
9
|
|
|
10
10
|
export class Completions extends APIResource {
|
|
11
11
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
export { Chat } from './chat
|
|
3
|
+
export { Chat } from './chat';
|
|
4
4
|
export {
|
|
5
5
|
ChatCompletion,
|
|
6
6
|
ChatCompletionChunk,
|
|
@@ -15,4 +15,4 @@ export {
|
|
|
15
15
|
ChatCompletionCreateParamsStreaming,
|
|
16
16
|
CompletionCreateParamsStreaming,
|
|
17
17
|
Completions,
|
|
18
|
-
} from './completions
|
|
18
|
+
} from './completions';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from
|
|
4
|
-
import { APIPromise } from
|
|
5
|
-
import { APIResource } from
|
|
6
|
-
import * as API from './index
|
|
7
|
-
import { Stream } from
|
|
3
|
+
import * as Core from "../core";
|
|
4
|
+
import { APIPromise } from "../core";
|
|
5
|
+
import { APIResource } from "../resource";
|
|
6
|
+
import * as API from './index';
|
|
7
|
+
import { Stream } from "../streaming";
|
|
8
8
|
|
|
9
9
|
export class Completions extends APIResource {
|
|
10
10
|
/**
|
package/src/resources/edits.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from
|
|
4
|
-
import { APIResource } from
|
|
5
|
-
import * as Completions from
|
|
6
|
-
import * as API from './index
|
|
3
|
+
import * as Core from "../core";
|
|
4
|
+
import { APIResource } from "../resource";
|
|
5
|
+
import * as Completions from "./completions";
|
|
6
|
+
import * as API from './index';
|
|
7
7
|
|
|
8
8
|
export class Edits extends APIResource {
|
|
9
9
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from
|
|
4
|
-
import { APIResource } from
|
|
5
|
-
import * as API from './index
|
|
3
|
+
import * as Core from "../core";
|
|
4
|
+
import { APIResource } from "../resource";
|
|
5
|
+
import * as API from './index';
|
|
6
6
|
|
|
7
7
|
export class Embeddings extends APIResource {
|
|
8
8
|
/**
|
package/src/resources/files.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from
|
|
4
|
-
import { APIResource } from
|
|
5
|
-
import { sleep } from
|
|
6
|
-
import { APIConnectionTimeoutError } from
|
|
7
|
-
import * as API from './index
|
|
8
|
-
import { type Uploadable, multipartFormRequestOptions } from
|
|
9
|
-
import { Page } from
|
|
3
|
+
import * as Core from "../core";
|
|
4
|
+
import { APIResource } from "../resource";
|
|
5
|
+
import { sleep } from "../core";
|
|
6
|
+
import { APIConnectionTimeoutError } from "../error";
|
|
7
|
+
import * as API from './index';
|
|
8
|
+
import { type Uploadable, multipartFormRequestOptions } from "../core";
|
|
9
|
+
import { Page } from "../pagination";
|
|
10
10
|
|
|
11
11
|
export class Files extends APIResource {
|
|
12
12
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from
|
|
4
|
-
import { APIPromise } from
|
|
5
|
-
import { APIResource } from
|
|
6
|
-
import * as Files from
|
|
7
|
-
import * as API from './index
|
|
8
|
-
import { Page } from
|
|
9
|
-
import { Stream } from
|
|
3
|
+
import * as Core from "../core";
|
|
4
|
+
import { APIPromise } from "../core";
|
|
5
|
+
import { APIResource } from "../resource";
|
|
6
|
+
import * as Files from "./files";
|
|
7
|
+
import * as API from './index';
|
|
8
|
+
import { Page } from "../pagination";
|
|
9
|
+
import { Stream } from "../streaming";
|
|
10
10
|
|
|
11
11
|
export class FineTunes extends APIResource {
|
|
12
12
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import { APIResource } from
|
|
4
|
-
import { Jobs } from './jobs
|
|
5
|
-
import * as API from './index
|
|
3
|
+
import { APIResource } from "../../resource";
|
|
4
|
+
import { Jobs } from './jobs';
|
|
5
|
+
import * as API from './index';
|
|
6
6
|
|
|
7
7
|
export class FineTuning extends APIResource {
|
|
8
8
|
jobs: Jobs = new Jobs(this.client);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
export { FineTuning } from './fine-tuning
|
|
3
|
+
export { FineTuning } from './fine-tuning';
|
|
4
4
|
export {
|
|
5
5
|
FineTuningJob,
|
|
6
6
|
FineTuningJobEvent,
|
|
@@ -10,4 +10,4 @@ export {
|
|
|
10
10
|
FineTuningJobsPage,
|
|
11
11
|
FineTuningJobEventsPage,
|
|
12
12
|
Jobs,
|
|
13
|
-
} from './jobs
|
|
13
|
+
} from './jobs';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from
|
|
4
|
-
import { APIResource } from
|
|
5
|
-
import { isRequestOptions } from
|
|
6
|
-
import * as Files from
|
|
7
|
-
import * as API from './index
|
|
8
|
-
import { CursorPage, CursorPageParams } from
|
|
3
|
+
import * as Core from "../../core";
|
|
4
|
+
import { APIResource } from "../../resource";
|
|
5
|
+
import { isRequestOptions } from "../../core";
|
|
6
|
+
import * as Files from "../files";
|
|
7
|
+
import * as API from './index';
|
|
8
|
+
import { CursorPage, CursorPageParams } from "../../pagination";
|
|
9
9
|
|
|
10
10
|
export class Jobs extends APIResource {
|
|
11
11
|
/**
|
package/src/resources/images.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from
|
|
4
|
-
import { APIResource } from
|
|
5
|
-
import * as API from './index
|
|
6
|
-
import { type Uploadable, multipartFormRequestOptions } from
|
|
3
|
+
import * as Core from "../core";
|
|
4
|
+
import { APIResource } from "../resource";
|
|
5
|
+
import * as API from './index';
|
|
6
|
+
import { type Uploadable, multipartFormRequestOptions } from "../core";
|
|
7
7
|
|
|
8
8
|
export class Images extends APIResource {
|
|
9
9
|
/**
|
package/src/resources/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
export { Audio } from './audio/audio
|
|
4
|
-
export { Chat } from './chat/chat
|
|
3
|
+
export { Audio } from './audio/audio';
|
|
4
|
+
export { Chat } from './chat/chat';
|
|
5
5
|
export {
|
|
6
6
|
Completion,
|
|
7
7
|
CompletionChoice,
|
|
@@ -10,10 +10,10 @@ export {
|
|
|
10
10
|
CompletionCreateParamsNonStreaming,
|
|
11
11
|
CompletionCreateParamsStreaming,
|
|
12
12
|
Completions,
|
|
13
|
-
} from './completions
|
|
14
|
-
export { CreateEmbeddingResponse, Embedding, EmbeddingCreateParams, Embeddings } from './embeddings
|
|
15
|
-
export { Edit, EditCreateParams, Edits } from './edits
|
|
16
|
-
export { FileContent, FileDeleted, FileObject, FileCreateParams, FileObjectsPage, Files } from './files
|
|
13
|
+
} from './completions';
|
|
14
|
+
export { CreateEmbeddingResponse, Embedding, EmbeddingCreateParams, Embeddings } from './embeddings';
|
|
15
|
+
export { Edit, EditCreateParams, Edits } from './edits';
|
|
16
|
+
export { FileContent, FileDeleted, FileObject, FileCreateParams, FileObjectsPage, Files } from './files';
|
|
17
17
|
export {
|
|
18
18
|
FineTune,
|
|
19
19
|
FineTuneEvent,
|
|
@@ -24,8 +24,8 @@ export {
|
|
|
24
24
|
FineTuneListEventsParamsStreaming,
|
|
25
25
|
FineTunesPage,
|
|
26
26
|
FineTunes,
|
|
27
|
-
} from './fine-tunes
|
|
28
|
-
export { FineTuning } from './fine-tuning/fine-tuning
|
|
27
|
+
} from './fine-tunes';
|
|
28
|
+
export { FineTuning } from './fine-tuning/fine-tuning';
|
|
29
29
|
export {
|
|
30
30
|
Image,
|
|
31
31
|
ImagesResponse,
|
|
@@ -33,6 +33,6 @@ export {
|
|
|
33
33
|
ImageEditParams,
|
|
34
34
|
ImageGenerateParams,
|
|
35
35
|
Images,
|
|
36
|
-
} from './images
|
|
37
|
-
export { Model, ModelDeleted, ModelsPage, Models } from './models
|
|
38
|
-
export { Moderation, ModerationCreateResponse, ModerationCreateParams, Moderations } from './moderations
|
|
36
|
+
} from './images';
|
|
37
|
+
export { Model, ModelDeleted, ModelsPage, Models } from './models';
|
|
38
|
+
export { Moderation, ModerationCreateResponse, ModerationCreateParams, Moderations } from './moderations';
|
package/src/resources/models.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from
|
|
4
|
-
import { APIResource } from
|
|
5
|
-
import * as API from './index
|
|
6
|
-
import { Page } from
|
|
3
|
+
import * as Core from "../core";
|
|
4
|
+
import { APIResource } from "../resource";
|
|
5
|
+
import * as API from './index';
|
|
6
|
+
import { Page } from "../pagination";
|
|
7
7
|
|
|
8
8
|
export class Models extends APIResource {
|
|
9
9
|
/**
|