openai 4.0.1 → 4.2.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 (75) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/_shims/fetch.d.ts +1 -0
  3. package/_shims/fetch.node.d.ts +1 -0
  4. package/core.js +1 -1
  5. package/core.js.map +1 -1
  6. package/core.mjs +1 -1
  7. package/core.mjs.map +1 -1
  8. package/index.d.mts +3 -0
  9. package/index.d.ts +3 -0
  10. package/index.d.ts.map +1 -1
  11. package/index.js +2 -0
  12. package/index.js.map +1 -1
  13. package/index.mjs +2 -0
  14. package/index.mjs.map +1 -1
  15. package/package.json +1 -1
  16. package/resources/chat/completions.d.ts +5 -4
  17. package/resources/chat/completions.d.ts.map +1 -1
  18. package/resources/chat/completions.js.map +1 -1
  19. package/resources/chat/completions.mjs.map +1 -1
  20. package/resources/completions.d.ts +7 -4
  21. package/resources/completions.d.ts.map +1 -1
  22. package/resources/completions.js.map +1 -1
  23. package/resources/completions.mjs.map +1 -1
  24. package/resources/files.d.ts +2 -4
  25. package/resources/files.d.ts.map +1 -1
  26. package/resources/files.js.map +1 -1
  27. package/resources/files.mjs.map +1 -1
  28. package/resources/fine-tunes.d.ts +25 -18
  29. package/resources/fine-tunes.d.ts.map +1 -1
  30. package/resources/fine-tunes.js +2 -2
  31. package/resources/fine-tunes.js.map +1 -1
  32. package/resources/fine-tunes.mjs +2 -2
  33. package/resources/fine-tunes.mjs.map +1 -1
  34. package/resources/fine-tuning/fine-tuning.d.ts +17 -0
  35. package/resources/fine-tuning/fine-tuning.d.ts.map +1 -0
  36. package/resources/fine-tuning/fine-tuning.js +60 -0
  37. package/resources/fine-tuning/fine-tuning.js.map +1 -0
  38. package/resources/fine-tuning/fine-tuning.mjs +16 -0
  39. package/resources/fine-tuning/fine-tuning.mjs.map +1 -0
  40. package/resources/fine-tuning/index.d.ts +12 -0
  41. package/resources/fine-tuning/index.d.ts.map +1 -0
  42. package/resources/fine-tuning/index.js +31 -0
  43. package/resources/fine-tuning/index.js.map +1 -0
  44. package/resources/fine-tuning/index.mjs +4 -0
  45. package/resources/fine-tuning/index.mjs.map +1 -0
  46. package/resources/fine-tuning/jobs.d.ts +225 -0
  47. package/resources/fine-tuning/jobs.d.ts.map +1 -0
  48. package/resources/fine-tuning/jobs.js +62 -0
  49. package/resources/fine-tuning/jobs.js.map +1 -0
  50. package/resources/fine-tuning/jobs.mjs +56 -0
  51. package/resources/fine-tuning/jobs.mjs.map +1 -0
  52. package/resources/index.d.ts +1 -0
  53. package/resources/index.d.ts.map +1 -1
  54. package/resources/index.js +8 -0
  55. package/resources/index.js.map +1 -1
  56. package/resources/index.mjs +1 -0
  57. package/resources/index.mjs.map +1 -1
  58. package/src/_shims/fetch.d.ts +1 -0
  59. package/src/_shims/fetch.node.d.ts +1 -0
  60. package/src/core.ts +1 -1
  61. package/src/index.ts +5 -0
  62. package/src/resources/chat/completions.ts +6 -4
  63. package/src/resources/completions.ts +8 -4
  64. package/src/resources/files.ts +2 -4
  65. package/src/resources/fine-tunes.ts +26 -18
  66. package/src/resources/fine-tuning/fine-tuning.ts +20 -0
  67. package/src/resources/fine-tuning/index.ts +13 -0
  68. package/src/resources/fine-tuning/jobs.ts +293 -0
  69. package/src/resources/index.ts +1 -0
  70. package/src/version.ts +1 -1
  71. package/version.d.ts +1 -1
  72. package/version.js +1 -1
  73. package/version.js.map +1 -1
  74. package/version.mjs +1 -1
  75. package/version.mjs.map +1 -1
@@ -0,0 +1,293 @@
1
+ // File generated from our OpenAPI spec by Stainless.
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 { Page } from '../../pagination';
9
+
10
+ export class Jobs extends APIResource {
11
+ /**
12
+ * Creates a job that fine-tunes a specified model from a given dataset.
13
+ *
14
+ * Response includes details of the enqueued job including job status and the name
15
+ * of the fine-tuned models once complete.
16
+ *
17
+ * [Learn more about fine-tuning](/docs/guides/fine-tuning)
18
+ */
19
+ create(body: JobCreateParams, options?: Core.RequestOptions): Core.APIPromise<FineTuningJob> {
20
+ return this.post('/fine_tuning/jobs', { body, ...options });
21
+ }
22
+
23
+ /**
24
+ * Get info about a fine-tuning job.
25
+ *
26
+ * [Learn more about fine-tuning](/docs/guides/fine-tuning)
27
+ */
28
+ retrieve(fineTuningJobId: string, options?: Core.RequestOptions): Core.APIPromise<FineTuningJob> {
29
+ return this.get(`/fine_tuning/jobs/${fineTuningJobId}`, options);
30
+ }
31
+
32
+ /**
33
+ * List your organization's fine-tuning jobs
34
+ */
35
+ list(
36
+ query?: JobListParams,
37
+ options?: Core.RequestOptions,
38
+ ): Core.PagePromise<FineTuningJobsPage, FineTuningJob>;
39
+ list(options?: Core.RequestOptions): Core.PagePromise<FineTuningJobsPage, FineTuningJob>;
40
+ list(
41
+ query: JobListParams | Core.RequestOptions = {},
42
+ options?: Core.RequestOptions,
43
+ ): Core.PagePromise<FineTuningJobsPage, FineTuningJob> {
44
+ if (isRequestOptions(query)) {
45
+ return this.list({}, query);
46
+ }
47
+ return this.getAPIList('/fine_tuning/jobs', FineTuningJobsPage, { query, ...options });
48
+ }
49
+
50
+ /**
51
+ * Immediately cancel a fine-tune job.
52
+ */
53
+ cancel(fineTuningJobId: string, options?: Core.RequestOptions): Core.APIPromise<FineTuningJob> {
54
+ return this.post(`/fine_tuning/jobs/${fineTuningJobId}/cancel`, options);
55
+ }
56
+
57
+ /**
58
+ * Get status updates for a fine-tuning job.
59
+ */
60
+ listEvents(
61
+ fineTuningJobId: string,
62
+ query?: JobListEventsParams,
63
+ options?: Core.RequestOptions,
64
+ ): Core.PagePromise<FineTuningJobEventsPage, FineTuningJobEvent>;
65
+ listEvents(
66
+ fineTuningJobId: string,
67
+ options?: Core.RequestOptions,
68
+ ): Core.PagePromise<FineTuningJobEventsPage, FineTuningJobEvent>;
69
+ listEvents(
70
+ fineTuningJobId: string,
71
+ query: JobListEventsParams | Core.RequestOptions = {},
72
+ options?: Core.RequestOptions,
73
+ ): Core.PagePromise<FineTuningJobEventsPage, FineTuningJobEvent> {
74
+ if (isRequestOptions(query)) {
75
+ return this.listEvents(fineTuningJobId, {}, query);
76
+ }
77
+ return this.getAPIList(`/fine_tuning/jobs/${fineTuningJobId}/events`, FineTuningJobEventsPage, {
78
+ query,
79
+ ...options,
80
+ });
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Note: no pagination actually occurs yet, this is for forwards-compatibility.
86
+ */
87
+ export class FineTuningJobsPage extends Page<FineTuningJob> {}
88
+ // alias so we can export it in the namespace
89
+ type _FineTuningJobsPage = FineTuningJobsPage;
90
+
91
+ /**
92
+ * Note: no pagination actually occurs yet, this is for forwards-compatibility.
93
+ */
94
+ export class FineTuningJobEventsPage extends Page<FineTuningJobEvent> {}
95
+ // alias so we can export it in the namespace
96
+ type _FineTuningJobEventsPage = FineTuningJobEventsPage;
97
+
98
+ /**
99
+ * The `fine_tuning.job` object represents a fine-tuning job that has been created
100
+ * through the API.
101
+ */
102
+ export interface FineTuningJob {
103
+ /**
104
+ * The object identifier, which can be referenced in the API endpoints.
105
+ */
106
+ id: string;
107
+
108
+ /**
109
+ * The unix timestamp for when the fine-tuning job was created.
110
+ */
111
+ created_at: number;
112
+
113
+ /**
114
+ * The name of the fine-tuned model that is being created.
115
+ */
116
+ fine_tuned_model: string | null;
117
+
118
+ /**
119
+ * The hyperparameters used for the fine-tuning job. See the
120
+ * [fine-tuning guide](/docs/guides/fine-tuning) for more details.
121
+ */
122
+ hyperparameters: FineTuningJob.Hyperparameters;
123
+
124
+ /**
125
+ * The base model that is being fine-tuned.
126
+ */
127
+ model: string;
128
+
129
+ /**
130
+ * The object type, which is always "fine_tuning.job".
131
+ */
132
+ object: string;
133
+
134
+ /**
135
+ * The organization that owns the fine-tuning job.
136
+ */
137
+ organization_id: string;
138
+
139
+ /**
140
+ * The compiled results files for the fine-tuning job.
141
+ */
142
+ result_files: Array<Files.FileObject>;
143
+
144
+ /**
145
+ * The current status of the fine-tuning job, which can be either `created`,
146
+ * `pending`, `running`, `succeeded`, `failed`, or `cancelled`.
147
+ */
148
+ status: string;
149
+
150
+ /**
151
+ * The total number of billable tokens processed by this fine tuning job.
152
+ */
153
+ trained_tokens: number;
154
+
155
+ /**
156
+ * The file ID used for training.
157
+ */
158
+ training_file: string;
159
+
160
+ /**
161
+ * The file ID used for validation.
162
+ */
163
+ validation_file: string;
164
+
165
+ /**
166
+ * The unix timestamp for when the fine-tuning job was finished.
167
+ */
168
+ finished_at?: number;
169
+ }
170
+
171
+ export namespace FineTuningJob {
172
+ /**
173
+ * The hyperparameters used for the fine-tuning job. See the
174
+ * [fine-tuning guide](/docs/guides/fine-tuning) for more details.
175
+ */
176
+ export interface Hyperparameters {
177
+ /**
178
+ * The number of epochs to train the model for. An epoch refers to one full cycle
179
+ * through the training dataset. "Auto" decides the optimal number of epochs based
180
+ * on the size of the dataset. If setting the number manually, we support any
181
+ * number between 1 and 50 epochs.
182
+ */
183
+ n_epochs?: 'auto' | number;
184
+ }
185
+ }
186
+
187
+ export interface FineTuningJobEvent {
188
+ id: string;
189
+
190
+ created_at: number;
191
+
192
+ level: 'info' | 'warn' | 'error';
193
+
194
+ message: string;
195
+
196
+ object: string;
197
+ }
198
+
199
+ export interface JobCreateParams {
200
+ /**
201
+ * The name of the model to fine-tune. You can select one of the
202
+ * [supported models](/docs/guides/fine-tuning/what-models-can-be-fine-tuned).
203
+ */
204
+ model: (string & {}) | 'babbage-002' | 'davinci-002' | 'gpt-3.5-turbo';
205
+
206
+ /**
207
+ * The ID of an uploaded file that contains training data.
208
+ *
209
+ * See [upload file](/docs/api-reference/files/upload) for how to upload a file.
210
+ *
211
+ * Your dataset must be formatted as a JSONL file. Additionally, you must upload
212
+ * your file with the purpose `fine-tune`.
213
+ *
214
+ * See the [fine-tuning guide](/docs/guides/fine-tuning) for more details.
215
+ */
216
+ training_file: string;
217
+
218
+ /**
219
+ * The hyperparameters used for the fine-tuning job.
220
+ */
221
+ hyperparameters?: JobCreateParams.Hyperparameters;
222
+
223
+ /**
224
+ * A string of up to 40 characters that will be added to your fine-tuned model
225
+ * name.
226
+ *
227
+ * For example, a `suffix` of "custom-model-name" would produce a model name like
228
+ * `ft:gpt-3.5-turbo:openai:custom-model-name:7p4lURel`.
229
+ */
230
+ suffix?: string | null;
231
+
232
+ /**
233
+ * The ID of an uploaded file that contains validation data.
234
+ *
235
+ * If you provide this file, the data is used to generate validation metrics
236
+ * periodically during fine-tuning. These metrics can be viewed in the fine-tuning
237
+ * results file. The same data should not be present in both train and validation
238
+ * files.
239
+ *
240
+ * Your dataset must be formatted as a JSONL file. You must upload your file with
241
+ * the purpose `fine-tune`.
242
+ *
243
+ * See the [fine-tuning guide](/docs/guides/fine-tuning) for more details.
244
+ */
245
+ validation_file?: string | null;
246
+ }
247
+
248
+ export namespace JobCreateParams {
249
+ /**
250
+ * The hyperparameters used for the fine-tuning job.
251
+ */
252
+ export interface Hyperparameters {
253
+ /**
254
+ * The number of epochs to train the model for. An epoch refers to one full cycle
255
+ * through the training dataset.
256
+ */
257
+ n_epochs?: 'auto' | number;
258
+ }
259
+ }
260
+
261
+ export interface JobListParams {
262
+ /**
263
+ * Identifier for the last job from the previous pagination request.
264
+ */
265
+ after?: string;
266
+
267
+ /**
268
+ * Number of fine-tuning jobs to retrieve.
269
+ */
270
+ limit?: number;
271
+ }
272
+
273
+ export interface JobListEventsParams {
274
+ /**
275
+ * Identifier for the last event from the previous pagination request.
276
+ */
277
+ after?: string;
278
+
279
+ /**
280
+ * Number of events to retrieve.
281
+ */
282
+ limit?: number;
283
+ }
284
+
285
+ export namespace Jobs {
286
+ export import FineTuningJob = API.FineTuningJob;
287
+ export import FineTuningJobEvent = API.FineTuningJobEvent;
288
+ export type FineTuningJobsPage = _FineTuningJobsPage;
289
+ export type FineTuningJobEventsPage = _FineTuningJobEventsPage;
290
+ export import JobCreateParams = API.JobCreateParams;
291
+ export import JobListParams = API.JobListParams;
292
+ export import JobListEventsParams = API.JobListEventsParams;
293
+ }
@@ -25,6 +25,7 @@ export {
25
25
  FineTunesPage,
26
26
  FineTunes,
27
27
  } from './fine-tunes';
28
+ export { FineTuning } from './fine-tuning/fine-tuning';
28
29
  export {
29
30
  Image,
30
31
  ImagesResponse,
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '4.0.1';
1
+ export const VERSION = '4.2.0'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = '4.0.1';
1
+ export declare const VERSION = '4.2.0';
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, '__esModule', { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '4.0.1';
4
+ exports.VERSION = '4.2.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC,CAAC,2BAA2B"}
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '4.0.1';
1
+ export const VERSION = '4.2.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map
package/version.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
1
+ {"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,2BAA2B"}