openai 4.3.1 → 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.
Files changed (186) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +7 -3
  3. package/_shims/{ReadableStream.node.d.ts → ReadableStream-node.d.ts} +1 -1
  4. package/_shims/ReadableStream-node.d.ts.map +1 -0
  5. package/_shims/{ReadableStream.node.js → ReadableStream-node.js} +1 -1
  6. package/_shims/ReadableStream-node.js.map +1 -0
  7. package/_shims/{ReadableStream.node.mjs → ReadableStream-node.mjs} +1 -1
  8. package/_shims/ReadableStream-node.mjs.map +1 -0
  9. package/_shims/{agent.node.d.ts → agent-node.d.ts} +1 -1
  10. package/_shims/agent-node.d.ts.map +1 -0
  11. package/_shims/{agent.node.js → agent-node.js} +1 -1
  12. package/_shims/{agent.node.js.map → agent-node.js.map} +1 -1
  13. package/_shims/{agent.node.mjs → agent-node.mjs} +1 -1
  14. package/_shims/{agent.node.mjs.map → agent-node.mjs.map} +1 -1
  15. package/_shims/agent.d.ts +1 -1
  16. package/_shims/agent.js +1 -1
  17. package/_shims/agent.mjs +1 -1
  18. package/_shims/{fileFromPath.node.d.ts → fileFromPath-node.d.ts} +2 -2
  19. package/_shims/{fileFromPath.node.d.ts.map → fileFromPath-node.d.ts.map} +1 -1
  20. package/_shims/{fileFromPath.node.js → fileFromPath-node.js} +1 -1
  21. package/_shims/{fileFromPath.node.js.map → fileFromPath-node.js.map} +1 -1
  22. package/_shims/{fileFromPath.node.mjs → fileFromPath-node.mjs} +1 -1
  23. package/_shims/{fileFromPath.node.mjs.map → fileFromPath-node.mjs.map} +1 -1
  24. package/_shims/fileFromPath.d.ts +2 -2
  25. package/_shims/fileFromPath.d.ts.map +1 -1
  26. package/_shims/fileFromPath.js +1 -1
  27. package/_shims/fileFromPath.mjs +1 -1
  28. package/_shims/{getMultipartRequestOptions.node.d.ts → getMultipartRequestOptions-node.d.ts} +2 -2
  29. package/_shims/getMultipartRequestOptions-node.d.ts.map +1 -0
  30. package/_shims/{getMultipartRequestOptions.node.js → getMultipartRequestOptions-node.js} +1 -1
  31. package/_shims/{getMultipartRequestOptions.node.js.map → getMultipartRequestOptions-node.js.map} +1 -1
  32. package/_shims/{getMultipartRequestOptions.node.mjs → getMultipartRequestOptions-node.mjs} +1 -1
  33. package/_shims/{getMultipartRequestOptions.node.mjs.map → getMultipartRequestOptions-node.mjs.map} +1 -1
  34. package/_shims/getMultipartRequestOptions.d.ts +1 -1
  35. package/_shims/getMultipartRequestOptions.d.ts.map +1 -1
  36. package/_shims/{node-readable.node.d.ts → node-readable-node.d.ts} +1 -1
  37. package/_shims/{node-readable.node.d.ts.map → node-readable-node.d.ts.map} +1 -1
  38. package/_shims/{node-readable.node.js → node-readable-node.js} +1 -1
  39. package/_shims/node-readable-node.js.map +1 -0
  40. package/_shims/{node-readable.node.mjs → node-readable-node.mjs} +1 -1
  41. package/_shims/node-readable-node.mjs.map +1 -0
  42. package/core.d.ts +2 -1
  43. package/core.d.ts.map +1 -1
  44. package/core.js +5 -3
  45. package/core.js.map +1 -1
  46. package/core.mjs +3 -3
  47. package/core.mjs.map +1 -1
  48. package/error.d.ts +1 -1
  49. package/error.d.ts.map +1 -1
  50. package/error.js +2 -2
  51. package/error.js.map +1 -1
  52. package/error.mjs +2 -2
  53. package/error.mjs.map +1 -1
  54. package/index.js +3 -3
  55. package/index.js.map +1 -1
  56. package/index.mjs +3 -3
  57. package/index.mjs.map +1 -1
  58. package/package.json +32 -9
  59. package/resources/audio/audio.js +1 -1
  60. package/resources/audio/audio.mjs +1 -1
  61. package/resources/audio/transcriptions.js +2 -2
  62. package/resources/audio/transcriptions.mjs +2 -2
  63. package/resources/audio/translations.js +2 -2
  64. package/resources/audio/translations.mjs +2 -2
  65. package/resources/chat/chat.d.ts +4 -0
  66. package/resources/chat/chat.d.ts.map +1 -1
  67. package/resources/chat/chat.js +1 -1
  68. package/resources/chat/chat.js.map +1 -1
  69. package/resources/chat/chat.mjs +1 -1
  70. package/resources/chat/chat.mjs.map +1 -1
  71. package/resources/chat/completions.d.ts +46 -21
  72. package/resources/chat/completions.d.ts.map +1 -1
  73. package/resources/chat/completions.js +1 -1
  74. package/resources/chat/completions.js.map +1 -1
  75. package/resources/chat/completions.mjs +1 -1
  76. package/resources/chat/completions.mjs.map +1 -1
  77. package/resources/chat/index.d.ts +4 -0
  78. package/resources/chat/index.d.ts.map +1 -1
  79. package/resources/chat/index.js.map +1 -1
  80. package/resources/chat/index.mjs.map +1 -1
  81. package/resources/completions.d.ts +3 -3
  82. package/resources/completions.js +1 -1
  83. package/resources/completions.mjs +1 -1
  84. package/resources/edits.d.ts +1 -1
  85. package/resources/edits.js +1 -1
  86. package/resources/edits.mjs +1 -1
  87. package/resources/embeddings.js +1 -1
  88. package/resources/embeddings.mjs +1 -1
  89. package/resources/files.d.ts +14 -1
  90. package/resources/files.d.ts.map +1 -1
  91. package/resources/files.js +24 -4
  92. package/resources/files.js.map +1 -1
  93. package/resources/files.mjs +23 -3
  94. package/resources/files.mjs.map +1 -1
  95. package/resources/fine-tunes.d.ts +2 -2
  96. package/resources/fine-tunes.js +2 -2
  97. package/resources/fine-tunes.mjs +2 -2
  98. package/resources/fine-tuning/fine-tuning.js +1 -1
  99. package/resources/fine-tuning/fine-tuning.mjs +1 -1
  100. package/resources/fine-tuning/jobs.d.ts +3 -3
  101. package/resources/fine-tuning/jobs.d.ts.map +1 -1
  102. package/resources/fine-tuning/jobs.js +3 -3
  103. package/resources/fine-tuning/jobs.mjs +3 -3
  104. package/resources/images.js +2 -2
  105. package/resources/images.mjs +2 -2
  106. package/resources/models.d.ts +3 -2
  107. package/resources/models.d.ts.map +1 -1
  108. package/resources/models.js +4 -3
  109. package/resources/models.js.map +1 -1
  110. package/resources/models.mjs +4 -3
  111. package/resources/models.mjs.map +1 -1
  112. package/resources/moderations.js +1 -1
  113. package/resources/moderations.mjs +1 -1
  114. package/src/_shims/ReadableStream.d.ts +5 -5
  115. package/src/_shims/agent.ts +1 -1
  116. package/src/_shims/{fetch.node.d.ts → fetch-node.d.ts} +8 -8
  117. package/src/_shims/fetch.d.ts +10 -10
  118. package/src/_shims/{fileFromPath.node.ts → fileFromPath-node.ts} +1 -1
  119. package/src/_shims/fileFromPath.ts +2 -2
  120. package/src/_shims/{formdata.node.d.ts → form-data-node.d.ts} +4 -4
  121. package/src/_shims/{formdata.d.ts → form-data.d.ts} +4 -4
  122. package/src/_shims/{getMultipartRequestOptions.node.ts → getMultipartRequestOptions-node.ts} +3 -3
  123. package/src/_shims/getMultipartRequestOptions.ts +3 -3
  124. package/src/core.ts +12 -11
  125. package/src/error.ts +3 -3
  126. package/src/index.ts +7 -7
  127. package/src/pagination.ts +1 -1
  128. package/src/resource.ts +1 -1
  129. package/src/resources/audio/audio.ts +4 -4
  130. package/src/resources/audio/index.ts +3 -3
  131. package/src/resources/audio/transcriptions.ts +4 -4
  132. package/src/resources/audio/translations.ts +4 -4
  133. package/src/resources/chat/chat.ts +7 -3
  134. package/src/resources/chat/completions.ts +57 -28
  135. package/src/resources/chat/index.ts +6 -2
  136. package/src/resources/completions.ts +8 -8
  137. package/src/resources/edits.ts +5 -5
  138. package/src/resources/embeddings.ts +3 -3
  139. package/src/resources/files.ts +34 -6
  140. package/src/resources/fine-tunes.ts +9 -9
  141. package/src/resources/fine-tuning/fine-tuning.ts +3 -3
  142. package/src/resources/fine-tuning/index.ts +2 -2
  143. package/src/resources/fine-tuning/jobs.ts +9 -9
  144. package/src/resources/images.ts +4 -4
  145. package/src/resources/index.ts +11 -11
  146. package/src/resources/models.ts +7 -6
  147. package/src/resources/moderations.ts +3 -3
  148. package/src/tsconfig.json +11 -0
  149. package/src/uploads.ts +6 -6
  150. package/src/version.ts +1 -1
  151. package/uploads.d.ts +1 -1
  152. package/uploads.d.ts.map +1 -1
  153. package/uploads.js +7 -7
  154. package/uploads.js.map +1 -1
  155. package/uploads.mjs +4 -4
  156. package/uploads.mjs.map +1 -1
  157. package/version.d.ts +1 -1
  158. package/version.js +1 -1
  159. package/version.mjs +1 -1
  160. package/_shims/ReadableStream.node.d.ts.map +0 -1
  161. package/_shims/ReadableStream.node.js.map +0 -1
  162. package/_shims/ReadableStream.node.mjs.map +0 -1
  163. package/_shims/agent.node.d.ts.map +0 -1
  164. package/_shims/getMultipartRequestOptions.node.d.ts.map +0 -1
  165. package/_shims/node-readable.node.js.map +0 -1
  166. package/_shims/node-readable.node.mjs.map +0 -1
  167. package/src/_shims/fetch.deno.ts +0 -23
  168. package/src/_shims/formdata.deno.ts +0 -16
  169. /package/_shims/{fetch.node.d.ts → fetch-node.d.ts} +0 -0
  170. /package/_shims/{fetch.node.js → fetch-node.js} +0 -0
  171. /package/_shims/{fetch.node.mjs → fetch-node.mjs} +0 -0
  172. /package/_shims/{formdata.node.d.ts → form-data-node.d.ts} +0 -0
  173. /package/_shims/{formdata.node.js → form-data-node.js} +0 -0
  174. /package/_shims/{formdata.node.mjs → form-data-node.mjs} +0 -0
  175. /package/_shims/{formdata.d.ts → form-data.d.ts} +0 -0
  176. /package/_shims/{formdata.js → form-data.js} +0 -0
  177. /package/_shims/{formdata.mjs → form-data.mjs} +0 -0
  178. /package/src/_shims/{ReadableStream.node.ts → ReadableStream-node.ts} +0 -0
  179. /package/src/_shims/{agent.node.ts → agent-node.ts} +0 -0
  180. /package/src/_shims/{fetch.node.js → fetch-node.js} +0 -0
  181. /package/src/_shims/{fetch.node.mjs → fetch-node.mjs} +0 -0
  182. /package/src/_shims/{formdata.node.js → form-data-node.js} +0 -0
  183. /package/src/_shims/{formdata.node.mjs → form-data-node.mjs} +0 -0
  184. /package/src/_shims/{formdata.js → form-data.js} +0 -0
  185. /package/src/_shims/{formdata.mjs → form-data.mjs} +0 -0
  186. /package/src/_shims/{node-readable.node.ts → node-readable-node.ts} +0 -0
@@ -1,27 +1,30 @@
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
  /**
12
12
  * Creates a model response for the given chat conversation.
13
13
  */
14
- create(body: CompletionCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise<ChatCompletion>;
15
14
  create(
16
- body: CompletionCreateParamsStreaming,
15
+ body: ChatCompletionCreateParamsNonStreaming,
16
+ options?: Core.RequestOptions,
17
+ ): APIPromise<ChatCompletion>;
18
+ create(
19
+ body: ChatCompletionCreateParamsStreaming,
17
20
  options?: Core.RequestOptions,
18
21
  ): APIPromise<Stream<ChatCompletionChunk>>;
19
22
  create(
20
- body: CompletionCreateParamsBase,
23
+ body: ChatCompletionCreateParamsBase,
21
24
  options?: Core.RequestOptions,
22
25
  ): APIPromise<Stream<ChatCompletionChunk> | ChatCompletion>;
23
26
  create(
24
- body: CompletionCreateParams,
27
+ body: ChatCompletionCreateParams,
25
28
  options?: Core.RequestOptions,
26
29
  ): APIPromise<ChatCompletion> | APIPromise<Stream<ChatCompletionChunk>> {
27
30
  return this.post('/chat/completions', { body, ...options, stream: body.stream ?? false }) as
@@ -47,7 +50,7 @@ export interface ChatCompletion {
47
50
  choices: Array<ChatCompletion.Choice>;
48
51
 
49
52
  /**
50
- * A unix timestamp of when the chat completion was created.
53
+ * The Unix timestamp (in seconds) of when the chat completion was created.
51
54
  */
52
55
  created: number;
53
56
 
@@ -106,7 +109,7 @@ export interface ChatCompletionChunk {
106
109
  choices: Array<ChatCompletionChunk.Choice>;
107
110
 
108
111
  /**
109
- * A unix timestamp of when the chat completion chunk was created.
112
+ * The Unix timestamp (in seconds) of when the chat completion chunk was created.
110
113
  */
111
114
  created: number;
112
115
 
@@ -229,7 +232,7 @@ export namespace ChatCompletionMessage {
229
232
  }
230
233
  }
231
234
 
232
- export interface CreateChatCompletionRequestMessage {
235
+ export interface ChatCompletionMessageParam {
233
236
  /**
234
237
  * The contents of the message. `content` is required for all messages, and may be
235
238
  * null for assistant messages with function calls.
@@ -246,7 +249,7 @@ export interface CreateChatCompletionRequestMessage {
246
249
  * The name and arguments of a function that should be called, as generated by the
247
250
  * model.
248
251
  */
249
- function_call?: CreateChatCompletionRequestMessage.FunctionCall;
252
+ function_call?: ChatCompletionMessageParam.FunctionCall;
250
253
 
251
254
  /**
252
255
  * The name of the author of this message. `name` is required if role is
@@ -257,7 +260,7 @@ export interface CreateChatCompletionRequestMessage {
257
260
  name?: string;
258
261
  }
259
262
 
260
- export namespace CreateChatCompletionRequestMessage {
263
+ export namespace ChatCompletionMessageParam {
261
264
  /**
262
265
  * The name and arguments of a function that should be called, as generated by the
263
266
  * model.
@@ -278,14 +281,21 @@ export namespace CreateChatCompletionRequestMessage {
278
281
  }
279
282
  }
280
283
 
281
- export type CompletionCreateParams = CompletionCreateParamsNonStreaming | CompletionCreateParamsStreaming;
284
+ /**
285
+ * @deprecated ChatCompletionMessageParam should be used instead
286
+ */
287
+ export type CreateChatCompletionRequestMessage = ChatCompletionMessageParam;
282
288
 
283
- export interface CompletionCreateParamsBase {
289
+ export type ChatCompletionCreateParams =
290
+ | ChatCompletionCreateParamsNonStreaming
291
+ | ChatCompletionCreateParamsStreaming;
292
+
293
+ export interface ChatCompletionCreateParamsBase {
284
294
  /**
285
295
  * A list of messages comprising the conversation so far.
286
296
  * [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb).
287
297
  */
288
- messages: Array<CreateChatCompletionRequestMessage>;
298
+ messages: Array<ChatCompletionMessageParam>;
289
299
 
290
300
  /**
291
301
  * ID of the model to use. See the
@@ -311,7 +321,7 @@ export interface CompletionCreateParamsBase {
311
321
  * existing frequency in the text so far, decreasing the model's likelihood to
312
322
  * repeat the same line verbatim.
313
323
  *
314
- * [See more information about frequency and presence penalties.](/docs/api-reference/parameter-details)
324
+ * [See more information about frequency and presence penalties.](/docs/guides/gpt/parameter-details)
315
325
  */
316
326
  frequency_penalty?: number | null;
317
327
 
@@ -319,16 +329,16 @@ export interface CompletionCreateParamsBase {
319
329
  * Controls how the model responds to function calls. "none" means the model does
320
330
  * not call a function, and responds to the end-user. "auto" means the model can
321
331
  * pick between an end-user or calling a function. Specifying a particular function
322
- * via `{"name":\ "my_function"}` forces the model to call that function. "none" is
332
+ * via `{"name": "my_function"}` forces the model to call that function. "none" is
323
333
  * the default when no functions are present. "auto" is the default if functions
324
334
  * are present.
325
335
  */
326
- function_call?: 'none' | 'auto' | CompletionCreateParams.FunctionCallOption;
336
+ function_call?: 'none' | 'auto' | ChatCompletionCreateParams.FunctionCallOption;
327
337
 
328
338
  /**
329
339
  * A list of functions the model may generate JSON inputs for.
330
340
  */
331
- functions?: Array<CompletionCreateParams.Function>;
341
+ functions?: Array<ChatCompletionCreateParams.Function>;
332
342
 
333
343
  /**
334
344
  * Modify the likelihood of specified tokens appearing in the completion.
@@ -362,7 +372,7 @@ export interface CompletionCreateParamsBase {
362
372
  * whether they appear in the text so far, increasing the model's likelihood to
363
373
  * talk about new topics.
364
374
  *
365
- * [See more information about frequency and presence penalties.](/docs/api-reference/parameter-details)
375
+ * [See more information about frequency and presence penalties.](/docs/guides/gpt/parameter-details)
366
376
  */
367
377
  presence_penalty?: number | null;
368
378
 
@@ -406,7 +416,7 @@ export interface CompletionCreateParamsBase {
406
416
  user?: string;
407
417
  }
408
418
 
409
- export namespace CompletionCreateParams {
419
+ export namespace ChatCompletionCreateParams {
410
420
  export interface FunctionCallOption {
411
421
  /**
412
422
  * The name of the function to call.
@@ -439,11 +449,16 @@ export namespace CompletionCreateParams {
439
449
  description?: string;
440
450
  }
441
451
 
442
- export type CompletionCreateParamsNonStreaming = API.CompletionCreateParamsNonStreaming;
443
- export type CompletionCreateParamsStreaming = API.CompletionCreateParamsStreaming;
452
+ export type ChatCompletionCreateParamsNonStreaming = API.ChatCompletionCreateParamsNonStreaming;
453
+ export type ChatCompletionCreateParamsStreaming = API.ChatCompletionCreateParamsStreaming;
444
454
  }
445
455
 
446
- export interface CompletionCreateParamsNonStreaming extends CompletionCreateParamsBase {
456
+ /**
457
+ * @deprecated Use ChatCompletionCreateParams instead
458
+ */
459
+ export type CompletionCreateParams = ChatCompletionCreateParams;
460
+
461
+ export interface ChatCompletionCreateParamsNonStreaming extends ChatCompletionCreateParamsBase {
447
462
  /**
448
463
  * If set, partial message deltas will be sent, like in ChatGPT. Tokens will be
449
464
  * sent as data-only
@@ -455,7 +470,12 @@ export interface CompletionCreateParamsNonStreaming extends CompletionCreatePara
455
470
  stream?: false | null;
456
471
  }
457
472
 
458
- export interface CompletionCreateParamsStreaming extends CompletionCreateParamsBase {
473
+ /**
474
+ * @deprecated Use ChatCompletionCreateParamsNonStreaming instead
475
+ */
476
+ export type CompletionCreateParamsNonStreaming = ChatCompletionCreateParamsNonStreaming;
477
+
478
+ export interface ChatCompletionCreateParamsStreaming extends ChatCompletionCreateParamsBase {
459
479
  /**
460
480
  * If set, partial message deltas will be sent, like in ChatGPT. Tokens will be
461
481
  * sent as data-only
@@ -467,12 +487,21 @@ export interface CompletionCreateParamsStreaming extends CompletionCreateParamsB
467
487
  stream: true;
468
488
  }
469
489
 
490
+ /**
491
+ * @deprecated Use ChatCompletionCreateParamsStreaming instead
492
+ */
493
+ export type CompletionCreateParamsStreaming = ChatCompletionCreateParamsStreaming;
494
+
470
495
  export namespace Completions {
471
496
  export import ChatCompletion = API.ChatCompletion;
472
497
  export import ChatCompletionChunk = API.ChatCompletionChunk;
473
498
  export import ChatCompletionMessage = API.ChatCompletionMessage;
499
+ export import ChatCompletionMessageParam = API.ChatCompletionMessageParam;
474
500
  export import CreateChatCompletionRequestMessage = API.CreateChatCompletionRequestMessage;
501
+ export import ChatCompletionCreateParams = API.ChatCompletionCreateParams;
475
502
  export import CompletionCreateParams = API.CompletionCreateParams;
503
+ export import ChatCompletionCreateParamsNonStreaming = API.ChatCompletionCreateParamsNonStreaming;
476
504
  export import CompletionCreateParamsNonStreaming = API.CompletionCreateParamsNonStreaming;
505
+ export import ChatCompletionCreateParamsStreaming = API.ChatCompletionCreateParamsStreaming;
477
506
  export import CompletionCreateParamsStreaming = API.CompletionCreateParamsStreaming;
478
507
  }
@@ -1,13 +1,17 @@
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,
7
7
  ChatCompletionMessage,
8
+ ChatCompletionMessageParam,
8
9
  CreateChatCompletionRequestMessage,
10
+ ChatCompletionCreateParams,
9
11
  CompletionCreateParams,
12
+ ChatCompletionCreateParamsNonStreaming,
10
13
  CompletionCreateParamsNonStreaming,
14
+ ChatCompletionCreateParamsStreaming,
11
15
  CompletionCreateParamsStreaming,
12
16
  Completions,
13
- } 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/api-reference/parameter-details)
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/api-reference/parameter-details)
224
+ * [See more information about frequency and presence penalties.](/docs/guides/gpt/parameter-details)
225
225
  */
226
226
  presence_penalty?: number | null;
227
227
 
@@ -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
- * A unix timestamp of when the edit was created.
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
  /**
@@ -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 * as API from './index';
6
- import { type Uploadable, multipartFormRequestOptions } from '../core';
7
- import { Page } from '../pagination';
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 unix timestamp for when the file was created.
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 unix timestamp for when the fine-tuning job was created.
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 unix timestamp for when the fine-tuning job was last updated.
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 unix timestamp for when the fine-tuning job was created.
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 unix timestamp for when the fine-tuning job was finished.
160
+ * The Unix timestamp (in seconds) for when the fine-tuning job was finished.
161
161
  */
162
162
  finished_at?: number;
163
163
  }
@@ -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
  /**
@@ -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';
@@ -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 date and time when the model was created.
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
+ }
package/src/uploads.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { type RequestOptions } from './core';
2
- import { type Readable } from './_shims/node-readable';
1
+ import { type RequestOptions } from './core.js';
2
+ import { type Readable } from './_shims/node-readable.js';
3
3
  import { type BodyInit } from './_shims/fetch.js';
4
- import { FormData, File, type Blob, type FilePropertyBag } from './_shims/formdata.js';
5
- import { getMultipartRequestOptions } from './_shims/getMultipartRequestOptions';
6
- import { fileFromPath } from './_shims/fileFromPath';
7
- import { type FsReadStream, isFsReadStream } from './_shims/node-readable';
4
+ import { FormData, File, type Blob, type FilePropertyBag } from './_shims/form-data.js';
5
+ import { getMultipartRequestOptions } from './_shims/getMultipartRequestOptions.js';
6
+ import { fileFromPath } from './_shims/fileFromPath.js';
7
+ import { type FsReadStream, isFsReadStream } from './_shims/node-readable.js';
8
8
 
9
9
  export { fileFromPath };
10
10
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '4.3.1'; // x-release-please-version
1
+ export const VERSION = '4.5.0'; // x-release-please-version
package/uploads.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type RequestOptions } from './core.js';
2
2
  import { type Readable } from 'openai/_shims/node-readable';
3
3
  import { type BodyInit } from 'openai/_shims/fetch';
4
- import { FormData, type Blob, type FilePropertyBag } from 'openai/_shims/formdata';
4
+ import { FormData, type Blob, type FilePropertyBag } from 'openai/_shims/form-data';
5
5
  import { fileFromPath } from 'openai/_shims/fileFromPath';
6
6
  import { type FsReadStream } from 'openai/_shims/node-readable';
7
7
  export { fileFromPath };
package/uploads.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"uploads.d.ts","sourceRoot":"","sources":["src/uploads.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAQ,KAAK,IAAI,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzF,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,KAAK,YAAY,EAAkB,MAAM,6BAA6B,CAAC;AAEhF,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,KAAK,YAAY,GAAG,MAAM,GAAG,WAAW,GAAG,eAAe,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;AAC9F,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,eAAe,GAAG,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE7F;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,6EAA6E;IAC7E,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,E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