openai 4.4.0 → 4.5.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 +23 -0
- package/README.md +6 -2
- package/_shims/{ReadableStream.node.d.ts → ReadableStream-node.d.ts} +1 -1
- package/_shims/ReadableStream-node.d.ts.map +1 -0
- package/_shims/{ReadableStream.node.js → ReadableStream-node.js} +1 -1
- package/_shims/ReadableStream-node.js.map +1 -0
- package/_shims/{ReadableStream.node.mjs → ReadableStream-node.mjs} +1 -1
- package/_shims/ReadableStream-node.mjs.map +1 -0
- package/_shims/{agent.node.d.ts → agent-node.d.ts} +1 -1
- package/_shims/agent-node.d.ts.map +1 -0
- package/_shims/{agent.node.js → agent-node.js} +1 -1
- package/_shims/{agent.node.js.map → agent-node.js.map} +1 -1
- package/_shims/{agent.node.mjs → agent-node.mjs} +1 -1
- package/_shims/{agent.node.mjs.map → agent-node.mjs.map} +1 -1
- package/_shims/agent.d.ts +1 -1
- package/_shims/agent.js +1 -1
- package/_shims/agent.mjs +1 -1
- package/_shims/{fileFromPath.node.d.ts → fileFromPath-node.d.ts} +2 -2
- package/_shims/{fileFromPath.node.d.ts.map → fileFromPath-node.d.ts.map} +1 -1
- package/_shims/{fileFromPath.node.js → fileFromPath-node.js} +1 -1
- package/_shims/{fileFromPath.node.js.map → fileFromPath-node.js.map} +1 -1
- package/_shims/{fileFromPath.node.mjs → fileFromPath-node.mjs} +1 -1
- package/_shims/{fileFromPath.node.mjs.map → fileFromPath-node.mjs.map} +1 -1
- package/_shims/fileFromPath.d.ts +2 -2
- package/_shims/fileFromPath.d.ts.map +1 -1
- package/_shims/fileFromPath.js +1 -1
- package/_shims/fileFromPath.mjs +1 -1
- package/_shims/{getMultipartRequestOptions.node.d.ts → getMultipartRequestOptions-node.d.ts} +2 -2
- package/_shims/getMultipartRequestOptions-node.d.ts.map +1 -0
- package/_shims/{getMultipartRequestOptions.node.js → getMultipartRequestOptions-node.js} +1 -1
- package/_shims/{getMultipartRequestOptions.node.js.map → getMultipartRequestOptions-node.js.map} +1 -1
- package/_shims/{getMultipartRequestOptions.node.mjs → getMultipartRequestOptions-node.mjs} +1 -1
- package/_shims/{getMultipartRequestOptions.node.mjs.map → getMultipartRequestOptions-node.mjs.map} +1 -1
- package/_shims/getMultipartRequestOptions.d.ts +1 -1
- package/_shims/getMultipartRequestOptions.d.ts.map +1 -1
- package/_shims/{node-readable.node.d.ts → node-readable-node.d.ts} +1 -1
- package/_shims/{node-readable.node.d.ts.map → node-readable-node.d.ts.map} +1 -1
- package/_shims/{node-readable.node.js → node-readable-node.js} +1 -1
- package/_shims/node-readable-node.js.map +1 -0
- package/_shims/{node-readable.node.mjs → node-readable-node.mjs} +1 -1
- package/_shims/node-readable-node.mjs.map +1 -0
- package/core.d.ts +2 -1
- package/core.d.ts.map +1 -1
- package/core.js +5 -3
- package/core.js.map +1 -1
- package/core.mjs +3 -3
- package/core.mjs.map +1 -1
- package/error.d.ts +1 -1
- package/error.d.ts.map +1 -1
- package/error.js +2 -2
- package/error.js.map +1 -1
- package/error.mjs +2 -2
- package/error.mjs.map +1 -1
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/index.mjs +3 -3
- package/index.mjs.map +1 -1
- package/package.json +28 -10
- package/resources/audio/audio.js +1 -1
- package/resources/audio/audio.mjs +1 -1
- package/resources/audio/transcriptions.js +2 -2
- package/resources/audio/transcriptions.mjs +2 -2
- package/resources/audio/translations.js +2 -2
- package/resources/audio/translations.mjs +2 -2
- package/resources/chat/chat.js +1 -1
- package/resources/chat/chat.mjs +1 -1
- package/resources/chat/completions.d.ts +5 -5
- package/resources/chat/completions.js +1 -1
- package/resources/chat/completions.mjs +1 -1
- package/resources/completions.d.ts +3 -3
- package/resources/completions.js +1 -1
- package/resources/completions.mjs +1 -1
- package/resources/edits.d.ts +1 -1
- package/resources/edits.js +1 -1
- package/resources/edits.mjs +1 -1
- package/resources/embeddings.js +1 -1
- package/resources/embeddings.mjs +1 -1
- package/resources/files.d.ts +14 -1
- package/resources/files.d.ts.map +1 -1
- package/resources/files.js +24 -4
- package/resources/files.js.map +1 -1
- package/resources/files.mjs +23 -3
- package/resources/files.mjs.map +1 -1
- package/resources/fine-tunes.d.ts +2 -2
- package/resources/fine-tunes.js +2 -2
- package/resources/fine-tunes.mjs +2 -2
- package/resources/fine-tuning/fine-tuning.js +1 -1
- package/resources/fine-tuning/fine-tuning.mjs +1 -1
- package/resources/fine-tuning/jobs.d.ts +3 -3
- package/resources/fine-tuning/jobs.d.ts.map +1 -1
- package/resources/fine-tuning/jobs.js +3 -3
- package/resources/fine-tuning/jobs.mjs +3 -3
- package/resources/images.js +2 -2
- package/resources/images.mjs +2 -2
- package/resources/models.d.ts +3 -2
- package/resources/models.d.ts.map +1 -1
- package/resources/models.js +4 -3
- package/resources/models.js.map +1 -1
- package/resources/models.mjs +4 -3
- package/resources/models.mjs.map +1 -1
- package/resources/moderations.js +1 -1
- package/resources/moderations.mjs +1 -1
- package/src/_shims/ReadableStream.d.ts +5 -5
- package/src/_shims/agent.ts +1 -1
- package/src/_shims/{fetch.node.d.ts → fetch-node.d.ts} +8 -8
- package/src/_shims/fetch.d.ts +10 -10
- package/src/_shims/{fileFromPath.node.ts → fileFromPath-node.ts} +1 -1
- package/src/_shims/fileFromPath.ts +2 -2
- package/src/_shims/{formdata.node.d.ts → form-data-node.d.ts} +4 -4
- package/src/_shims/{formdata.d.ts → form-data.d.ts} +4 -4
- package/src/_shims/{getMultipartRequestOptions.node.ts → getMultipartRequestOptions-node.ts} +3 -3
- package/src/_shims/getMultipartRequestOptions.ts +3 -3
- package/src/core.ts +12 -11
- package/src/error.ts +3 -3
- package/src/index.ts +7 -7
- 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 +11 -11
- package/src/resources/chat/index.ts +2 -2
- package/src/resources/completions.ts +8 -8
- package/src/resources/edits.ts +5 -5
- package/src/resources/embeddings.ts +3 -3
- package/src/resources/files.ts +34 -6
- package/src/resources/fine-tunes.ts +9 -9
- 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 +9 -9
- package/src/resources/images.ts +4 -4
- package/src/resources/index.ts +11 -11
- package/src/resources/models.ts +7 -6
- package/src/resources/moderations.ts +3 -3
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +6 -6
- package/src/version.ts +1 -1
- package/uploads.d.ts +1 -1
- package/uploads.d.ts.map +1 -1
- package/uploads.js +7 -7
- package/uploads.js.map +1 -1
- package/uploads.mjs +4 -4
- package/uploads.mjs.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/_shims/ReadableStream.node.d.ts.map +0 -1
- package/_shims/ReadableStream.node.js.map +0 -1
- package/_shims/ReadableStream.node.mjs.map +0 -1
- package/_shims/agent.node.d.ts.map +0 -1
- package/_shims/getMultipartRequestOptions.node.d.ts.map +0 -1
- package/_shims/node-readable.node.js.map +0 -1
- package/_shims/node-readable.node.mjs.map +0 -1
- package/src/_shims/fetch.deno.ts +0 -23
- package/src/_shims/formdata.deno.ts +0 -16
- /package/_shims/{fetch.node.d.ts → fetch-node.d.ts} +0 -0
- /package/_shims/{fetch.node.js → fetch-node.js} +0 -0
- /package/_shims/{fetch.node.mjs → fetch-node.mjs} +0 -0
- /package/_shims/{formdata.node.d.ts → form-data-node.d.ts} +0 -0
- /package/_shims/{formdata.node.js → form-data-node.js} +0 -0
- /package/_shims/{formdata.node.mjs → form-data-node.mjs} +0 -0
- /package/_shims/{formdata.d.ts → form-data.d.ts} +0 -0
- /package/_shims/{formdata.js → form-data.js} +0 -0
- /package/_shims/{formdata.mjs → form-data.mjs} +0 -0
- /package/src/_shims/{ReadableStream.node.ts → ReadableStream-node.ts} +0 -0
- /package/src/_shims/{agent.node.ts → agent-node.ts} +0 -0
- /package/src/_shims/{fetch.node.js → fetch-node.js} +0 -0
- /package/src/_shims/{fetch.node.mjs → fetch-node.mjs} +0 -0
- /package/src/_shims/{formdata.node.js → form-data-node.js} +0 -0
- /package/src/_shims/{formdata.node.mjs → form-data-node.mjs} +0 -0
- /package/src/_shims/{formdata.js → form-data.js} +0 -0
- /package/src/_shims/{formdata.mjs → form-data.mjs} +0 -0
- /package/src/_shims/{node-readable.node.ts → node-readable-node.ts} +0 -0
package/src/core.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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';
|
|
5
|
-
import { getDefaultAgent, type Agent } from './_shims/agent';
|
|
1
|
+
import { VERSION } from './version.js';
|
|
2
|
+
import { Stream } from './streaming.js';
|
|
3
|
+
import { APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError } from './error.js';
|
|
4
|
+
import type { Readable } from './_shims/node-readable.js';
|
|
5
|
+
import { getDefaultAgent, type Agent } from './_shims/agent.js';
|
|
6
6
|
import {
|
|
7
7
|
fetch,
|
|
8
8
|
isPolyfilled as fetchIsPolyfilled,
|
|
@@ -12,13 +12,13 @@ import {
|
|
|
12
12
|
type HeadersInit,
|
|
13
13
|
} from './_shims/fetch.js';
|
|
14
14
|
export { type Response };
|
|
15
|
-
import { isMultipartBody } from './uploads';
|
|
15
|
+
import { isMultipartBody } from './uploads.js';
|
|
16
16
|
export {
|
|
17
17
|
maybeMultipartFormRequestOptions,
|
|
18
18
|
multipartFormRequestOptions,
|
|
19
19
|
createForm,
|
|
20
20
|
type Uploadable,
|
|
21
|
-
} from './uploads';
|
|
21
|
+
} from './uploads.js';
|
|
22
22
|
|
|
23
23
|
const MAX_RETRIES = 2;
|
|
24
24
|
|
|
@@ -52,7 +52,7 @@ async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
|
|
|
52
52
|
// TODO handle blob, arraybuffer, other content types, etc.
|
|
53
53
|
const text = await response.text();
|
|
54
54
|
debug('response', response.status, response.url, response.headers, text);
|
|
55
|
-
return text as T;
|
|
55
|
+
return text as any as T;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -313,7 +313,8 @@ export abstract class APIClient {
|
|
|
313
313
|
protected parseHeaders(headers: HeadersInit | null | undefined): Record<string, string> {
|
|
314
314
|
return (
|
|
315
315
|
!headers ? {}
|
|
316
|
-
: Symbol.iterator in headers ?
|
|
316
|
+
: Symbol.iterator in headers ?
|
|
317
|
+
Object.fromEntries(Array.from(headers as Iterable<string[]>).map((header) => [...header]))
|
|
317
318
|
: { ...headers }
|
|
318
319
|
);
|
|
319
320
|
}
|
|
@@ -397,7 +398,7 @@ export abstract class APIClient {
|
|
|
397
398
|
return new PagePromise<PageClass, Item>(this, request, Page);
|
|
398
399
|
}
|
|
399
400
|
|
|
400
|
-
buildURL<Req
|
|
401
|
+
buildURL<Req extends Record<string, unknown>>(path: string, query: Req | null | undefined): string {
|
|
401
402
|
const url =
|
|
402
403
|
isAbsoluteURL(path) ?
|
|
403
404
|
new URL(path)
|
|
@@ -900,7 +901,7 @@ const isAbsoluteURL = (url: string): boolean => {
|
|
|
900
901
|
return startsWithSchemeRegexp.test(url);
|
|
901
902
|
};
|
|
902
903
|
|
|
903
|
-
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
904
|
+
export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
904
905
|
|
|
905
906
|
const validatePositiveInteger = (name: string, n: unknown): number => {
|
|
906
907
|
if (typeof n !== 'number' || !Number.isInteger(n)) {
|
package/src/error.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import { castToError, Headers } from './core';
|
|
3
|
+
import { castToError, Headers } from './core.js';
|
|
4
4
|
|
|
5
5
|
export class APIError extends Error {
|
|
6
6
|
readonly status: number | undefined;
|
|
@@ -106,8 +106,8 @@ export class APIConnectionError extends APIError {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
export class APIConnectionTimeoutError extends APIConnectionError {
|
|
109
|
-
constructor() {
|
|
110
|
-
super({ message: 'Request timed out.' });
|
|
109
|
+
constructor({ message }: { message?: string } = {}) {
|
|
110
|
+
super({ message: message ?? 'Request timed out.' });
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
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 { Agent } from './_shims/agent';
|
|
8
|
-
import * as Uploads from './uploads';
|
|
3
|
+
import * as Core from './core.js';
|
|
4
|
+
import * as Pagination from './pagination.js';
|
|
5
|
+
import * as API from './resources/index.js';
|
|
6
|
+
import * as Errors from './error.js';
|
|
7
|
+
import type { Agent } from './_shims/agent.js';
|
|
8
|
+
import * as Uploads from './uploads.js';
|
|
9
9
|
|
|
10
10
|
export interface ClientOptions {
|
|
11
11
|
/**
|
|
@@ -111,8 +111,8 @@ export class OpenAI extends Core.APIClient {
|
|
|
111
111
|
const options: ClientOptions = {
|
|
112
112
|
apiKey,
|
|
113
113
|
organization,
|
|
114
|
-
baseURL: `https://api.openai.com/v1`,
|
|
115
114
|
...opts,
|
|
115
|
+
baseURL: opts.baseURL ?? `https://api.openai.com/v1`,
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
if (!options.dangerouslyAllowBrowser && Core.isRunningInBrowser()) {
|
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.js';
|
|
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 '../../resource';
|
|
4
|
-
import { Transcriptions } from './transcriptions';
|
|
5
|
-
import { Translations } from './translations';
|
|
6
|
-
import * as API from './index';
|
|
3
|
+
import { APIResource } from '../../resource.js';
|
|
4
|
+
import { Transcriptions } from './transcriptions.js';
|
|
5
|
+
import { Translations } from './translations.js';
|
|
6
|
+
import * as API from './index.js';
|
|
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.js';
|
|
4
|
+
export { Transcription, TranscriptionCreateParams, Transcriptions } from './transcriptions.js';
|
|
5
|
+
export { Translation, TranslationCreateParams, Translations } from './translations.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from '../../core';
|
|
4
|
-
import { APIResource } from '../../resource';
|
|
5
|
-
import * as API from './index';
|
|
6
|
-
import { type Uploadable, multipartFormRequestOptions } from '../../core';
|
|
3
|
+
import * as Core from '../../core.js';
|
|
4
|
+
import { APIResource } from '../../resource.js';
|
|
5
|
+
import * as API from './index.js';
|
|
6
|
+
import { type Uploadable, multipartFormRequestOptions } from '../../core.js';
|
|
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 '../../core';
|
|
4
|
-
import { APIResource } from '../../resource';
|
|
5
|
-
import * as API from './index';
|
|
6
|
-
import { type Uploadable, multipartFormRequestOptions } from '../../core';
|
|
3
|
+
import * as Core from '../../core.js';
|
|
4
|
+
import { APIResource } from '../../resource.js';
|
|
5
|
+
import * as API from './index.js';
|
|
6
|
+
import { type Uploadable, multipartFormRequestOptions } from '../../core.js';
|
|
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 '../../resource';
|
|
4
|
-
import { Completions } from './completions';
|
|
5
|
-
import * as API from './index';
|
|
3
|
+
import { APIResource } from '../../resource.js';
|
|
4
|
+
import { Completions } from './completions.js';
|
|
5
|
+
import * as API from './index.js';
|
|
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 '../../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';
|
|
3
|
+
import * as Core from '../../core.js';
|
|
4
|
+
import { APIPromise } from '../../core.js';
|
|
5
|
+
import { APIResource } from '../../resource.js';
|
|
6
|
+
import * as Completions_ from '../completions.js';
|
|
7
|
+
import * as API from './index.js';
|
|
8
|
+
import { Stream } from '../../streaming.js';
|
|
9
9
|
|
|
10
10
|
export class Completions extends APIResource {
|
|
11
11
|
/**
|
|
@@ -50,7 +50,7 @@ export interface ChatCompletion {
|
|
|
50
50
|
choices: Array<ChatCompletion.Choice>;
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* The Unix timestamp (in seconds) of when the chat completion was created.
|
|
54
54
|
*/
|
|
55
55
|
created: number;
|
|
56
56
|
|
|
@@ -109,7 +109,7 @@ export interface ChatCompletionChunk {
|
|
|
109
109
|
choices: Array<ChatCompletionChunk.Choice>;
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
-
*
|
|
112
|
+
* The Unix timestamp (in seconds) of when the chat completion chunk was created.
|
|
113
113
|
*/
|
|
114
114
|
created: number;
|
|
115
115
|
|
|
@@ -321,7 +321,7 @@ export interface ChatCompletionCreateParamsBase {
|
|
|
321
321
|
* existing frequency in the text so far, decreasing the model's likelihood to
|
|
322
322
|
* repeat the same line verbatim.
|
|
323
323
|
*
|
|
324
|
-
* [See more information about frequency and presence penalties.](/docs/
|
|
324
|
+
* [See more information about frequency and presence penalties.](/docs/guides/gpt/parameter-details)
|
|
325
325
|
*/
|
|
326
326
|
frequency_penalty?: number | null;
|
|
327
327
|
|
|
@@ -329,7 +329,7 @@ export interface ChatCompletionCreateParamsBase {
|
|
|
329
329
|
* Controls how the model responds to function calls. "none" means the model does
|
|
330
330
|
* not call a function, and responds to the end-user. "auto" means the model can
|
|
331
331
|
* pick between an end-user or calling a function. Specifying a particular function
|
|
332
|
-
* via `{"name"
|
|
332
|
+
* via `{"name": "my_function"}` forces the model to call that function. "none" is
|
|
333
333
|
* the default when no functions are present. "auto" is the default if functions
|
|
334
334
|
* are present.
|
|
335
335
|
*/
|
|
@@ -372,7 +372,7 @@ export interface ChatCompletionCreateParamsBase {
|
|
|
372
372
|
* whether they appear in the text so far, increasing the model's likelihood to
|
|
373
373
|
* talk about new topics.
|
|
374
374
|
*
|
|
375
|
-
* [See more information about frequency and presence penalties.](/docs/
|
|
375
|
+
* [See more information about frequency and presence penalties.](/docs/guides/gpt/parameter-details)
|
|
376
376
|
*/
|
|
377
377
|
presence_penalty?: number | null;
|
|
378
378
|
|
|
@@ -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.js';
|
|
4
4
|
export {
|
|
5
5
|
ChatCompletion,
|
|
6
6
|
ChatCompletionChunk,
|
|
@@ -14,4 +14,4 @@ export {
|
|
|
14
14
|
ChatCompletionCreateParamsStreaming,
|
|
15
15
|
CompletionCreateParamsStreaming,
|
|
16
16
|
Completions,
|
|
17
|
-
} from './completions';
|
|
17
|
+
} from './completions.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
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';
|
|
3
|
+
import * as Core from '../core.js';
|
|
4
|
+
import { APIPromise } from '../core.js';
|
|
5
|
+
import { APIResource } from '../resource.js';
|
|
6
|
+
import * as API from './index.js';
|
|
7
|
+
import { Stream } from '../streaming.js';
|
|
8
8
|
|
|
9
9
|
export class Completions extends APIResource {
|
|
10
10
|
/**
|
|
@@ -45,7 +45,7 @@ export interface Completion {
|
|
|
45
45
|
choices: Array<CompletionChoice>;
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* The Unix timestamp of when the completion was created.
|
|
48
|
+
* The Unix timestamp (in seconds) of when the completion was created.
|
|
49
49
|
*/
|
|
50
50
|
created: number;
|
|
51
51
|
|
|
@@ -166,7 +166,7 @@ export interface CompletionCreateParamsBase {
|
|
|
166
166
|
* existing frequency in the text so far, decreasing the model's likelihood to
|
|
167
167
|
* repeat the same line verbatim.
|
|
168
168
|
*
|
|
169
|
-
* [See more information about frequency and presence penalties.](/docs/
|
|
169
|
+
* [See more information about frequency and presence penalties.](/docs/guides/gpt/parameter-details)
|
|
170
170
|
*/
|
|
171
171
|
frequency_penalty?: number | null;
|
|
172
172
|
|
|
@@ -221,7 +221,7 @@ export interface CompletionCreateParamsBase {
|
|
|
221
221
|
* whether they appear in the text so far, increasing the model's likelihood to
|
|
222
222
|
* talk about new topics.
|
|
223
223
|
*
|
|
224
|
-
* [See more information about frequency and presence penalties.](/docs/
|
|
224
|
+
* [See more information about frequency and presence penalties.](/docs/guides/gpt/parameter-details)
|
|
225
225
|
*/
|
|
226
226
|
presence_penalty?: number | null;
|
|
227
227
|
|
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 '../core';
|
|
4
|
-
import { APIResource } from '../resource';
|
|
5
|
-
import * as Completions from './completions';
|
|
6
|
-
import * as API from './index';
|
|
3
|
+
import * as Core from '../core.js';
|
|
4
|
+
import { APIResource } from '../resource.js';
|
|
5
|
+
import * as Completions from './completions.js';
|
|
6
|
+
import * as API from './index.js';
|
|
7
7
|
|
|
8
8
|
export class Edits extends APIResource {
|
|
9
9
|
/**
|
|
@@ -25,7 +25,7 @@ export interface Edit {
|
|
|
25
25
|
choices: Array<Edit.Choice>;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* The Unix timestamp (in seconds) of when the edit was created.
|
|
29
29
|
*/
|
|
30
30
|
created: number;
|
|
31
31
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from '../core';
|
|
4
|
-
import { APIResource } from '../resource';
|
|
5
|
-
import * as API from './index';
|
|
3
|
+
import * as Core from '../core.js';
|
|
4
|
+
import { APIResource } from '../resource.js';
|
|
5
|
+
import * as API from './index.js';
|
|
6
6
|
|
|
7
7
|
export class Embeddings extends APIResource {
|
|
8
8
|
/**
|
package/src/resources/files.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from '../core';
|
|
4
|
-
import { APIResource } from '../resource';
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
3
|
+
import * as Core from '../core.js';
|
|
4
|
+
import { APIResource } from '../resource.js';
|
|
5
|
+
import { sleep } from '../core.js';
|
|
6
|
+
import { APIConnectionTimeoutError } from '../error.js';
|
|
7
|
+
import * as API from './index.js';
|
|
8
|
+
import { type Uploadable, multipartFormRequestOptions } from '../core.js';
|
|
9
|
+
import { Page } from '../pagination.js';
|
|
8
10
|
|
|
9
11
|
export class Files extends APIResource {
|
|
10
12
|
/**
|
|
@@ -47,6 +49,32 @@ export class Files extends APIResource {
|
|
|
47
49
|
headers: { Accept: 'application/json', ...options?.headers },
|
|
48
50
|
});
|
|
49
51
|
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Waits for the given file to be processed, default timeout is 30 mins.
|
|
55
|
+
*/
|
|
56
|
+
async waitForProcessing(
|
|
57
|
+
id: string,
|
|
58
|
+
{ pollInterval = 5000, maxWait = 30 * 60 * 1000 }: { pollInterval?: number; maxWait?: number } = {},
|
|
59
|
+
): Promise<FileObject> {
|
|
60
|
+
const TERMINAL_STATES = new Set(['processed', 'error', 'deleted']);
|
|
61
|
+
|
|
62
|
+
const start = Date.now();
|
|
63
|
+
let file = await this.retrieve(id);
|
|
64
|
+
|
|
65
|
+
while (!file.status || !TERMINAL_STATES.has(file.status)) {
|
|
66
|
+
await sleep(pollInterval);
|
|
67
|
+
|
|
68
|
+
file = await this.retrieve(id);
|
|
69
|
+
if (Date.now() - start > maxWait) {
|
|
70
|
+
throw new APIConnectionTimeoutError({
|
|
71
|
+
message: `Giving up on waiting for file ${id} to finish processing after ${maxWait} milliseconds.`,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return file;
|
|
77
|
+
}
|
|
50
78
|
}
|
|
51
79
|
|
|
52
80
|
/**
|
|
@@ -81,7 +109,7 @@ export interface FileObject {
|
|
|
81
109
|
bytes: number;
|
|
82
110
|
|
|
83
111
|
/**
|
|
84
|
-
* The
|
|
112
|
+
* The Unix timestamp (in seconds) for when the file was created.
|
|
85
113
|
*/
|
|
86
114
|
created_at: number;
|
|
87
115
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
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';
|
|
3
|
+
import * as Core from '../core.js';
|
|
4
|
+
import { APIPromise } from '../core.js';
|
|
5
|
+
import { APIResource } from '../resource.js';
|
|
6
|
+
import * as Files from './files.js';
|
|
7
|
+
import * as API from './index.js';
|
|
8
|
+
import { Page } from '../pagination.js';
|
|
9
|
+
import { Stream } from '../streaming.js';
|
|
10
10
|
|
|
11
11
|
export class FineTunes extends APIResource {
|
|
12
12
|
/**
|
|
@@ -94,7 +94,7 @@ export interface FineTune {
|
|
|
94
94
|
id: string;
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
-
* The
|
|
97
|
+
* The Unix timestamp (in seconds) for when the fine-tuning job was created.
|
|
98
98
|
*/
|
|
99
99
|
created_at: number;
|
|
100
100
|
|
|
@@ -142,7 +142,7 @@ export interface FineTune {
|
|
|
142
142
|
training_files: Array<Files.FileObject>;
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
|
-
* The
|
|
145
|
+
* The Unix timestamp (in seconds) for when the fine-tuning job was last updated.
|
|
146
146
|
*/
|
|
147
147
|
updated_at: number;
|
|
148
148
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import { APIResource } from '../../resource';
|
|
4
|
-
import { Jobs } from './jobs';
|
|
5
|
-
import * as API from './index';
|
|
3
|
+
import { APIResource } from '../../resource.js';
|
|
4
|
+
import { Jobs } from './jobs.js';
|
|
5
|
+
import * as API from './index.js';
|
|
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.js';
|
|
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.js';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
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';
|
|
3
|
+
import * as Core from '../../core.js';
|
|
4
|
+
import { APIResource } from '../../resource.js';
|
|
5
|
+
import { isRequestOptions } from '../../core.js';
|
|
6
|
+
import * as Files from '../files.js';
|
|
7
|
+
import * as API from './index.js';
|
|
8
|
+
import { CursorPage, CursorPageParams } from '../../pagination.js';
|
|
9
9
|
|
|
10
10
|
export class Jobs extends APIResource {
|
|
11
11
|
/**
|
|
@@ -100,7 +100,7 @@ export interface FineTuningJob {
|
|
|
100
100
|
id: string;
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
|
-
* The
|
|
103
|
+
* The Unix timestamp (in seconds) for when the fine-tuning job was created.
|
|
104
104
|
*/
|
|
105
105
|
created_at: number;
|
|
106
106
|
|
|
@@ -154,10 +154,10 @@ export interface FineTuningJob {
|
|
|
154
154
|
/**
|
|
155
155
|
* The file ID used for validation.
|
|
156
156
|
*/
|
|
157
|
-
validation_file: string;
|
|
157
|
+
validation_file: string | null;
|
|
158
158
|
|
|
159
159
|
/**
|
|
160
|
-
* The
|
|
160
|
+
* The Unix timestamp (in seconds) for when the fine-tuning job was finished.
|
|
161
161
|
*/
|
|
162
162
|
finished_at?: number;
|
|
163
163
|
}
|
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 '../core';
|
|
4
|
-
import { APIResource } from '../resource';
|
|
5
|
-
import * as API from './index';
|
|
6
|
-
import { type Uploadable, multipartFormRequestOptions } from '../core';
|
|
3
|
+
import * as Core from '../core.js';
|
|
4
|
+
import { APIResource } from '../resource.js';
|
|
5
|
+
import * as API from './index.js';
|
|
6
|
+
import { type Uploadable, multipartFormRequestOptions } from '../core.js';
|
|
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.js';
|
|
4
|
+
export { Chat } from './chat/chat.js';
|
|
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.js';
|
|
14
|
+
export { CreateEmbeddingResponse, Embedding, EmbeddingCreateParams, Embeddings } from './embeddings.js';
|
|
15
|
+
export { Edit, EditCreateParams, Edits } from './edits.js';
|
|
16
|
+
export { FileContent, FileDeleted, FileObject, FileCreateParams, FileObjectsPage, Files } from './files.js';
|
|
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.js';
|
|
28
|
+
export { FineTuning } from './fine-tuning/fine-tuning.js';
|
|
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.js';
|
|
37
|
+
export { Model, ModelDeleted, ModelsPage, Models } from './models.js';
|
|
38
|
+
export { Moderation, ModerationCreateResponse, ModerationCreateParams, Moderations } from './moderations.js';
|
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 '../core';
|
|
4
|
-
import { APIResource } from '../resource';
|
|
5
|
-
import * as API from './index';
|
|
6
|
-
import { Page } from '../pagination';
|
|
3
|
+
import * as Core from '../core.js';
|
|
4
|
+
import { APIResource } from '../resource.js';
|
|
5
|
+
import * as API from './index.js';
|
|
6
|
+
import { Page } from '../pagination.js';
|
|
7
7
|
|
|
8
8
|
export class Models extends APIResource {
|
|
9
9
|
/**
|
|
@@ -23,7 +23,8 @@ export class Models extends APIResource {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Delete a fine-tuned model. You must have the Owner role in your organization
|
|
26
|
+
* Delete a fine-tuned model. You must have the Owner role in your organization to
|
|
27
|
+
* delete a model.
|
|
27
28
|
*/
|
|
28
29
|
del(model: string, options?: Core.RequestOptions): Core.APIPromise<ModelDeleted> {
|
|
29
30
|
return this.delete(`/models/${model}`, options);
|
|
@@ -47,7 +48,7 @@ export interface Model {
|
|
|
47
48
|
id: string;
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
|
-
* The
|
|
51
|
+
* The Unix timestamp (in seconds) when the model was created.
|
|
51
52
|
*/
|
|
52
53
|
created: number;
|
|
53
54
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless.
|
|
2
2
|
|
|
3
|
-
import * as Core from '../core';
|
|
4
|
-
import { APIResource } from '../resource';
|
|
5
|
-
import * as API from './index';
|
|
3
|
+
import * as Core from '../core.js';
|
|
4
|
+
import { APIResource } from '../resource.js';
|
|
5
|
+
import * as API from './index.js';
|
|
6
6
|
|
|
7
7
|
export class Moderations extends APIResource {
|
|
8
8
|
/**
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
// this config is included in the published src directory to prevent TS errors
|
|
3
|
+
// from appearing when users go to source, and VSCode opens the source .ts file
|
|
4
|
+
// via declaration maps
|
|
5
|
+
"include": ["index.ts"],
|
|
6
|
+
"compilerOptions": {
|
|
7
|
+
"target": "es2015",
|
|
8
|
+
"lib": ["DOM"],
|
|
9
|
+
"moduleResolution": "node"
|
|
10
|
+
}
|
|
11
|
+
}
|