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
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless.
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Completions = void 0;
|
|
5
|
-
const resource_1 = require(
|
|
5
|
+
const resource_1 = require("openai/resource");
|
|
6
6
|
class Completions extends resource_1.APIResource {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
...options,
|
|
12
|
-
stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
7
|
+
create(body, options) {
|
|
8
|
+
var _a;
|
|
9
|
+
return this.post('/chat/completions', { body, ...options, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false });
|
|
10
|
+
}
|
|
15
11
|
}
|
|
16
12
|
exports.Completions = Completions;
|
|
17
|
-
(function (Completions) {
|
|
18
|
-
|
|
13
|
+
(function (Completions) {
|
|
14
|
+
})(Completions = exports.Completions || (exports.Completions = {}));
|
|
15
|
+
//# sourceMappingURL=completions.js.map
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
import { APIResource } from 'openai/resource';
|
|
3
3
|
export class Completions extends APIResource {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
...options,
|
|
9
|
-
stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false,
|
|
10
|
-
});
|
|
11
|
-
}
|
|
4
|
+
create(body, options) {
|
|
5
|
+
var _a;
|
|
6
|
+
return this.post('/chat/completions', { body, ...options, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false });
|
|
7
|
+
}
|
|
12
8
|
}
|
|
13
|
-
(function (Completions) {
|
|
14
|
-
|
|
9
|
+
(function (Completions) {
|
|
10
|
+
})(Completions || (Completions = {}));
|
|
11
|
+
//# sourceMappingURL=completions.mjs.map
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
export { Chat } from
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
ChatCompletionChunk,
|
|
5
|
-
ChatCompletionMessage,
|
|
6
|
-
ChatCompletionMessageParam,
|
|
7
|
-
ChatCompletionRole,
|
|
8
|
-
CreateChatCompletionRequestMessage,
|
|
9
|
-
ChatCompletionCreateParams,
|
|
10
|
-
CompletionCreateParams,
|
|
11
|
-
ChatCompletionCreateParamsNonStreaming,
|
|
12
|
-
CompletionCreateParamsNonStreaming,
|
|
13
|
-
ChatCompletionCreateParamsStreaming,
|
|
14
|
-
CompletionCreateParamsStreaming,
|
|
15
|
-
Completions,
|
|
16
|
-
} from './completions.js';
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export { Chat } from "./chat.js";
|
|
2
|
+
export { ChatCompletion, ChatCompletionChunk, ChatCompletionMessage, ChatCompletionMessageParam, ChatCompletionRole, CreateChatCompletionRequestMessage, ChatCompletionCreateParams, CompletionCreateParams, ChatCompletionCreateParamsNonStreaming, CompletionCreateParamsNonStreaming, ChatCompletionCreateParamsStreaming, CompletionCreateParamsStreaming, Completions, } from "./completions.js";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
package/resources/chat/index.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless.
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Completions = exports.Chat = void 0;
|
|
5
|
-
var chat_1 = require(
|
|
6
|
-
Object.defineProperty(exports,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
var completions_1 = require('./completions.js');
|
|
13
|
-
Object.defineProperty(exports, 'Completions', {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return completions_1.Completions;
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
5
|
+
var chat_1 = require("./chat.js");
|
|
6
|
+
Object.defineProperty(exports, "Chat", { enumerable: true, get: function () { return chat_1.Chat; } });
|
|
7
|
+
var completions_1 = require("./completions.js");
|
|
8
|
+
Object.defineProperty(exports, "Completions", { enumerable: true, get: function () { return completions_1.Completions; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
package/resources/chat/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
|
-
export { Chat } from
|
|
3
|
-
export { Completions } from
|
|
4
|
-
//# sourceMappingURL=index.mjs.map
|
|
2
|
+
export { Chat } from "./chat.mjs";
|
|
3
|
+
export { Completions, } from "./completions.mjs";
|
|
4
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,264 +1,248 @@
|
|
|
1
1
|
import * as Core from 'openai/core';
|
|
2
2
|
import { APIPromise } from 'openai/core';
|
|
3
3
|
import { APIResource } from 'openai/resource';
|
|
4
|
-
import * as API from
|
|
4
|
+
import * as API from "./index.js";
|
|
5
5
|
import { Stream } from 'openai/streaming';
|
|
6
6
|
export declare class Completions extends APIResource {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
body:
|
|
13
|
-
options?: Core.RequestOptions,
|
|
14
|
-
): APIPromise<Stream<Completion>>;
|
|
15
|
-
create(
|
|
16
|
-
body: CompletionCreateParamsBase,
|
|
17
|
-
options?: Core.RequestOptions,
|
|
18
|
-
): APIPromise<Stream<Completion> | Completion>;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a completion for the provided prompt and parameters.
|
|
9
|
+
*/
|
|
10
|
+
create(body: CompletionCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise<Completion>;
|
|
11
|
+
create(body: CompletionCreateParamsStreaming, options?: Core.RequestOptions): APIPromise<Stream<Completion>>;
|
|
12
|
+
create(body: CompletionCreateParamsBase, options?: Core.RequestOptions): APIPromise<Stream<Completion> | Completion>;
|
|
19
13
|
}
|
|
20
14
|
/**
|
|
21
15
|
* Represents a completion response from the API. Note: both the streamed and
|
|
22
16
|
* non-streamed response objects share the same shape (unlike the chat endpoint).
|
|
23
17
|
*/
|
|
24
18
|
export interface Completion {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
19
|
+
/**
|
|
20
|
+
* A unique identifier for the completion.
|
|
21
|
+
*/
|
|
22
|
+
id: string;
|
|
23
|
+
/**
|
|
24
|
+
* The list of completion choices the model generated for the input prompt.
|
|
25
|
+
*/
|
|
26
|
+
choices: Array<CompletionChoice>;
|
|
27
|
+
/**
|
|
28
|
+
* The Unix timestamp (in seconds) of when the completion was created.
|
|
29
|
+
*/
|
|
30
|
+
created: number;
|
|
31
|
+
/**
|
|
32
|
+
* The model used for completion.
|
|
33
|
+
*/
|
|
34
|
+
model: string;
|
|
35
|
+
/**
|
|
36
|
+
* The object type, which is always "text_completion"
|
|
37
|
+
*/
|
|
38
|
+
object: string;
|
|
39
|
+
/**
|
|
40
|
+
* Usage statistics for the completion request.
|
|
41
|
+
*/
|
|
42
|
+
usage?: CompletionUsage;
|
|
49
43
|
}
|
|
50
44
|
export interface CompletionChoice {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
/**
|
|
46
|
+
* The reason the model stopped generating tokens. This will be `stop` if the model
|
|
47
|
+
* hit a natural stop point or a provided stop sequence, or `length` if the maximum
|
|
48
|
+
* number of tokens specified in the request was reached.
|
|
49
|
+
*/
|
|
50
|
+
finish_reason: 'stop' | 'length';
|
|
51
|
+
index: number;
|
|
52
|
+
logprobs: CompletionChoice.Logprobs | null;
|
|
53
|
+
text: string;
|
|
60
54
|
}
|
|
61
55
|
export declare namespace CompletionChoice {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
interface Logprobs {
|
|
57
|
+
text_offset?: Array<number>;
|
|
58
|
+
token_logprobs?: Array<number>;
|
|
59
|
+
tokens?: Array<string>;
|
|
60
|
+
top_logprobs?: Array<Record<string, number>>;
|
|
61
|
+
}
|
|
68
62
|
}
|
|
69
63
|
/**
|
|
70
64
|
* Usage statistics for the completion request.
|
|
71
65
|
*/
|
|
72
66
|
export interface CompletionUsage {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Number of tokens in the generated completion.
|
|
69
|
+
*/
|
|
70
|
+
completion_tokens: number;
|
|
71
|
+
/**
|
|
72
|
+
* Number of tokens in the prompt.
|
|
73
|
+
*/
|
|
74
|
+
prompt_tokens: number;
|
|
75
|
+
/**
|
|
76
|
+
* Total number of tokens used in the request (prompt + completion).
|
|
77
|
+
*/
|
|
78
|
+
total_tokens: number;
|
|
85
79
|
}
|
|
86
80
|
export type CompletionCreateParams = CompletionCreateParamsNonStreaming | CompletionCreateParamsStreaming;
|
|
87
81
|
export interface CompletionCreateParamsBase {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
*
|
|
220
|
-
* We generally recommend altering this or `temperature` but not both.
|
|
221
|
-
*/
|
|
222
|
-
top_p?: number | null;
|
|
223
|
-
/**
|
|
224
|
-
* A unique identifier representing your end-user, which can help OpenAI to monitor
|
|
225
|
-
* and detect abuse.
|
|
226
|
-
* [Learn more](https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids).
|
|
227
|
-
*/
|
|
228
|
-
user?: string;
|
|
82
|
+
/**
|
|
83
|
+
* ID of the model to use. You can use the
|
|
84
|
+
* [List models](https://platform.openai.com/docs/api-reference/models/list) API to
|
|
85
|
+
* see all of your available models, or see our
|
|
86
|
+
* [Model overview](https://platform.openai.com/docs/models/overview) for
|
|
87
|
+
* descriptions of them.
|
|
88
|
+
*/
|
|
89
|
+
model: (string & {}) | 'babbage-002' | 'davinci-002' | 'text-davinci-003' | 'text-davinci-002' | 'text-davinci-001' | 'code-davinci-002' | 'text-curie-001' | 'text-babbage-001' | 'text-ada-001';
|
|
90
|
+
/**
|
|
91
|
+
* The prompt(s) to generate completions for, encoded as a string, array of
|
|
92
|
+
* strings, array of tokens, or array of token arrays.
|
|
93
|
+
*
|
|
94
|
+
* Note that <|endoftext|> is the document separator that the model sees during
|
|
95
|
+
* training, so if a prompt is not specified the model will generate as if from the
|
|
96
|
+
* beginning of a new document.
|
|
97
|
+
*/
|
|
98
|
+
prompt: string | Array<string> | Array<number> | Array<Array<number>> | null;
|
|
99
|
+
/**
|
|
100
|
+
* Generates `best_of` completions server-side and returns the "best" (the one with
|
|
101
|
+
* the highest log probability per token). Results cannot be streamed.
|
|
102
|
+
*
|
|
103
|
+
* When used with `n`, `best_of` controls the number of candidate completions and
|
|
104
|
+
* `n` specifies how many to return – `best_of` must be greater than `n`.
|
|
105
|
+
*
|
|
106
|
+
* **Note:** Because this parameter generates many completions, it can quickly
|
|
107
|
+
* consume your token quota. Use carefully and ensure that you have reasonable
|
|
108
|
+
* settings for `max_tokens` and `stop`.
|
|
109
|
+
*/
|
|
110
|
+
best_of?: number | null;
|
|
111
|
+
/**
|
|
112
|
+
* Echo back the prompt in addition to the completion
|
|
113
|
+
*/
|
|
114
|
+
echo?: boolean | null;
|
|
115
|
+
/**
|
|
116
|
+
* Number between -2.0 and 2.0. Positive values penalize new tokens based on their
|
|
117
|
+
* existing frequency in the text so far, decreasing the model's likelihood to
|
|
118
|
+
* repeat the same line verbatim.
|
|
119
|
+
*
|
|
120
|
+
* [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details)
|
|
121
|
+
*/
|
|
122
|
+
frequency_penalty?: number | null;
|
|
123
|
+
/**
|
|
124
|
+
* Modify the likelihood of specified tokens appearing in the completion.
|
|
125
|
+
*
|
|
126
|
+
* Accepts a json object that maps tokens (specified by their token ID in the GPT
|
|
127
|
+
* tokenizer) to an associated bias value from -100 to 100. You can use this
|
|
128
|
+
* [tokenizer tool](/tokenizer?view=bpe) (which works for both GPT-2 and GPT-3) to
|
|
129
|
+
* convert text to token IDs. Mathematically, the bias is added to the logits
|
|
130
|
+
* generated by the model prior to sampling. The exact effect will vary per model,
|
|
131
|
+
* but values between -1 and 1 should decrease or increase likelihood of selection;
|
|
132
|
+
* values like -100 or 100 should result in a ban or exclusive selection of the
|
|
133
|
+
* relevant token.
|
|
134
|
+
*
|
|
135
|
+
* As an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token
|
|
136
|
+
* from being generated.
|
|
137
|
+
*/
|
|
138
|
+
logit_bias?: Record<string, number> | null;
|
|
139
|
+
/**
|
|
140
|
+
* Include the log probabilities on the `logprobs` most likely tokens, as well the
|
|
141
|
+
* chosen tokens. For example, if `logprobs` is 5, the API will return a list of
|
|
142
|
+
* the 5 most likely tokens. The API will always return the `logprob` of the
|
|
143
|
+
* sampled token, so there may be up to `logprobs+1` elements in the response.
|
|
144
|
+
*
|
|
145
|
+
* The maximum value for `logprobs` is 5.
|
|
146
|
+
*/
|
|
147
|
+
logprobs?: number | null;
|
|
148
|
+
/**
|
|
149
|
+
* The maximum number of [tokens](/tokenizer) to generate in the completion.
|
|
150
|
+
*
|
|
151
|
+
* The token count of your prompt plus `max_tokens` cannot exceed the model's
|
|
152
|
+
* context length.
|
|
153
|
+
* [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb)
|
|
154
|
+
* for counting tokens.
|
|
155
|
+
*/
|
|
156
|
+
max_tokens?: number | null;
|
|
157
|
+
/**
|
|
158
|
+
* How many completions to generate for each prompt.
|
|
159
|
+
*
|
|
160
|
+
* **Note:** Because this parameter generates many completions, it can quickly
|
|
161
|
+
* consume your token quota. Use carefully and ensure that you have reasonable
|
|
162
|
+
* settings for `max_tokens` and `stop`.
|
|
163
|
+
*/
|
|
164
|
+
n?: number | null;
|
|
165
|
+
/**
|
|
166
|
+
* Number between -2.0 and 2.0. Positive values penalize new tokens based on
|
|
167
|
+
* whether they appear in the text so far, increasing the model's likelihood to
|
|
168
|
+
* talk about new topics.
|
|
169
|
+
*
|
|
170
|
+
* [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details)
|
|
171
|
+
*/
|
|
172
|
+
presence_penalty?: number | null;
|
|
173
|
+
/**
|
|
174
|
+
* Up to 4 sequences where the API will stop generating further tokens. The
|
|
175
|
+
* returned text will not contain the stop sequence.
|
|
176
|
+
*/
|
|
177
|
+
stop?: string | null | Array<string>;
|
|
178
|
+
/**
|
|
179
|
+
* Whether to stream back partial progress. If set, tokens will be sent as
|
|
180
|
+
* data-only
|
|
181
|
+
* [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)
|
|
182
|
+
* as they become available, with the stream terminated by a `data: [DONE]`
|
|
183
|
+
* message.
|
|
184
|
+
* [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_stream_completions.ipynb).
|
|
185
|
+
*/
|
|
186
|
+
stream?: boolean | null;
|
|
187
|
+
/**
|
|
188
|
+
* The suffix that comes after a completion of inserted text.
|
|
189
|
+
*/
|
|
190
|
+
suffix?: string | null;
|
|
191
|
+
/**
|
|
192
|
+
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
|
|
193
|
+
* make the output more random, while lower values like 0.2 will make it more
|
|
194
|
+
* focused and deterministic.
|
|
195
|
+
*
|
|
196
|
+
* We generally recommend altering this or `top_p` but not both.
|
|
197
|
+
*/
|
|
198
|
+
temperature?: number | null;
|
|
199
|
+
/**
|
|
200
|
+
* An alternative to sampling with temperature, called nucleus sampling, where the
|
|
201
|
+
* model considers the results of the tokens with top_p probability mass. So 0.1
|
|
202
|
+
* means only the tokens comprising the top 10% probability mass are considered.
|
|
203
|
+
*
|
|
204
|
+
* We generally recommend altering this or `temperature` but not both.
|
|
205
|
+
*/
|
|
206
|
+
top_p?: number | null;
|
|
207
|
+
/**
|
|
208
|
+
* A unique identifier representing your end-user, which can help OpenAI to monitor
|
|
209
|
+
* and detect abuse.
|
|
210
|
+
* [Learn more](https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids).
|
|
211
|
+
*/
|
|
212
|
+
user?: string;
|
|
229
213
|
}
|
|
230
214
|
export declare namespace CompletionCreateParams {
|
|
231
|
-
|
|
232
|
-
|
|
215
|
+
type CompletionCreateParamsNonStreaming = API.CompletionCreateParamsNonStreaming;
|
|
216
|
+
type CompletionCreateParamsStreaming = API.CompletionCreateParamsStreaming;
|
|
233
217
|
}
|
|
234
218
|
export interface CompletionCreateParamsNonStreaming extends CompletionCreateParamsBase {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
219
|
+
/**
|
|
220
|
+
* Whether to stream back partial progress. If set, tokens will be sent as
|
|
221
|
+
* data-only
|
|
222
|
+
* [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)
|
|
223
|
+
* as they become available, with the stream terminated by a `data: [DONE]`
|
|
224
|
+
* message.
|
|
225
|
+
* [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_stream_completions.ipynb).
|
|
226
|
+
*/
|
|
227
|
+
stream?: false | null;
|
|
244
228
|
}
|
|
245
229
|
export interface CompletionCreateParamsStreaming extends CompletionCreateParamsBase {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
230
|
+
/**
|
|
231
|
+
* Whether to stream back partial progress. If set, tokens will be sent as
|
|
232
|
+
* data-only
|
|
233
|
+
* [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)
|
|
234
|
+
* as they become available, with the stream terminated by a `data: [DONE]`
|
|
235
|
+
* message.
|
|
236
|
+
* [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_stream_completions.ipynb).
|
|
237
|
+
*/
|
|
238
|
+
stream: true;
|
|
255
239
|
}
|
|
256
240
|
export declare namespace Completions {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
241
|
+
export import Completion = API.Completion;
|
|
242
|
+
export import CompletionChoice = API.CompletionChoice;
|
|
243
|
+
export import CompletionUsage = API.CompletionUsage;
|
|
244
|
+
export import CompletionCreateParams = API.CompletionCreateParams;
|
|
245
|
+
export import CompletionCreateParamsNonStreaming = API.CompletionCreateParamsNonStreaming;
|
|
246
|
+
export import CompletionCreateParamsStreaming = API.CompletionCreateParamsStreaming;
|
|
263
247
|
}
|
|
264
|
-
//# sourceMappingURL=completions.d.ts.map
|
|
248
|
+
//# sourceMappingURL=completions.d.ts.map
|
package/resources/completions.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless.
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Completions = void 0;
|
|
5
|
-
const resource_1 = require(
|
|
5
|
+
const resource_1 = require("openai/resource");
|
|
6
6
|
class Completions extends resource_1.APIResource {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
...options,
|
|
12
|
-
stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
7
|
+
create(body, options) {
|
|
8
|
+
var _a;
|
|
9
|
+
return this.post('/completions', { body, ...options, stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false });
|
|
10
|
+
}
|
|
15
11
|
}
|
|
16
12
|
exports.Completions = Completions;
|
|
17
|
-
(function (Completions) {
|
|
18
|
-
|
|
13
|
+
(function (Completions) {
|
|
14
|
+
})(Completions = exports.Completions || (exports.Completions = {}));
|
|
15
|
+
//# sourceMappingURL=completions.js.map
|