openai 4.0.0 → 4.1.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 (78) hide show
  1. package/README.md +1 -1
  2. package/_shims/formdata.js +9 -1
  3. package/_shims/formdata.mjs +10 -1
  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 +2 -0
  9. package/index.d.ts +2 -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 +8 -3
  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 +10 -3
  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 +29 -17
  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 +224 -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/resources/moderations.d.ts +52 -7
  59. package/resources/moderations.d.ts.map +1 -1
  60. package/resources/moderations.js.map +1 -1
  61. package/resources/moderations.mjs.map +1 -1
  62. package/src/_shims/formdata.js +9 -1
  63. package/src/_shims/formdata.mjs +10 -1
  64. package/src/core.ts +1 -1
  65. package/src/index.ts +3 -0
  66. package/src/resources/chat/completions.ts +9 -3
  67. package/src/resources/completions.ts +11 -3
  68. package/src/resources/files.ts +2 -4
  69. package/src/resources/fine-tunes.ts +30 -17
  70. package/src/resources/fine-tuning/fine-tuning.ts +20 -0
  71. package/src/resources/fine-tuning/index.ts +13 -0
  72. package/src/resources/fine-tuning/jobs.ts +291 -0
  73. package/src/resources/index.ts +1 -0
  74. package/src/resources/moderations.ts +60 -7
  75. package/src/version.ts +1 -1
  76. package/version.d.ts +1 -1
  77. package/version.js +1 -1
  78. package/version.mjs +1 -1
@@ -0,0 +1,13 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+
3
+ export { FineTuning } from './fine-tuning';
4
+ export {
5
+ FineTuningJob,
6
+ FineTuningJobEvent,
7
+ JobCreateParams,
8
+ JobListParams,
9
+ JobListEventsParams,
10
+ FineTuningJobsPage,
11
+ FineTuningJobEventsPage,
12
+ Jobs,
13
+ } from './jobs';
@@ -0,0 +1,291 @@
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
+ created_at: number;
189
+
190
+ level: 'info' | 'warn' | 'error';
191
+
192
+ message: string;
193
+
194
+ object: string;
195
+ }
196
+
197
+ export interface JobCreateParams {
198
+ /**
199
+ * The name of the model to fine-tune. You can select one of the
200
+ * [supported models](/docs/guides/fine-tuning/what-models-can-be-fine-tuned).
201
+ */
202
+ model: (string & {}) | 'babbage-002' | 'davinci-002' | 'gpt-3.5-turbo';
203
+
204
+ /**
205
+ * The ID of an uploaded file that contains training data.
206
+ *
207
+ * See [upload file](/docs/api-reference/files/upload) for how to upload a file.
208
+ *
209
+ * Your dataset must be formatted as a JSONL file. Additionally, you must upload
210
+ * your file with the purpose `fine-tune`.
211
+ *
212
+ * See the [fine-tuning guide](/docs/guides/fine-tuning) for more details.
213
+ */
214
+ training_file: string;
215
+
216
+ /**
217
+ * The hyperparameters used for the fine-tuning job.
218
+ */
219
+ hyperparameters?: JobCreateParams.Hyperparameters;
220
+
221
+ /**
222
+ * A string of up to 40 characters that will be added to your fine-tuned model
223
+ * name.
224
+ *
225
+ * For example, a `suffix` of "custom-model-name" would produce a model name like
226
+ * `ft:gpt-3.5-turbo:openai:custom-model-name:7p4lURel`.
227
+ */
228
+ suffix?: string | null;
229
+
230
+ /**
231
+ * The ID of an uploaded file that contains validation data.
232
+ *
233
+ * If you provide this file, the data is used to generate validation metrics
234
+ * periodically during fine-tuning. These metrics can be viewed in the fine-tuning
235
+ * results file. The same data should not be present in both train and validation
236
+ * files.
237
+ *
238
+ * Your dataset must be formatted as a JSONL file. You must upload your file with
239
+ * the purpose `fine-tune`.
240
+ *
241
+ * See the [fine-tuning guide](/docs/guides/fine-tuning) for more details.
242
+ */
243
+ validation_file?: string | null;
244
+ }
245
+
246
+ export namespace JobCreateParams {
247
+ /**
248
+ * The hyperparameters used for the fine-tuning job.
249
+ */
250
+ export interface Hyperparameters {
251
+ /**
252
+ * The number of epochs to train the model for. An epoch refers to one full cycle
253
+ * through the training dataset.
254
+ */
255
+ n_epochs?: 'auto' | number;
256
+ }
257
+ }
258
+
259
+ export interface JobListParams {
260
+ /**
261
+ * Identifier for the last job from the previous pagination request.
262
+ */
263
+ after?: string;
264
+
265
+ /**
266
+ * Number of fine-tuning jobs to retrieve.
267
+ */
268
+ limit?: number;
269
+ }
270
+
271
+ export interface JobListEventsParams {
272
+ /**
273
+ * Identifier for the last event from the previous pagination request.
274
+ */
275
+ after?: string;
276
+
277
+ /**
278
+ * Number of events to retrieve.
279
+ */
280
+ limit?: number;
281
+ }
282
+
283
+ export namespace Jobs {
284
+ export import FineTuningJob = API.FineTuningJob;
285
+ export import FineTuningJobEvent = API.FineTuningJobEvent;
286
+ export type FineTuningJobsPage = _FineTuningJobsPage;
287
+ export type FineTuningJobEventsPage = _FineTuningJobEventsPage;
288
+ export import JobCreateParams = API.JobCreateParams;
289
+ export import JobListParams = API.JobListParams;
290
+ export import JobListEventsParams = API.JobListEventsParams;
291
+ }
@@ -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,
@@ -40,37 +40,70 @@ export namespace Moderation {
40
40
  */
41
41
  export interface Categories {
42
42
  /**
43
- * Whether the content was flagged as 'hate'.
43
+ * Content that expresses, incites, or promotes harassing language towards any
44
+ * target.
45
+ */
46
+ harassment: boolean;
47
+
48
+ /**
49
+ * Harassment content that also includes violence or serious harm towards any
50
+ * target.
51
+ */
52
+ 'harassment/threatening': boolean;
53
+
54
+ /**
55
+ * Content that expresses, incites, or promotes hate based on race, gender,
56
+ * ethnicity, religion, nationality, sexual orientation, disability status, or
57
+ * caste. Hateful content aimed at non-protected groups (e.g., chess players) is
58
+ * harrassment.
44
59
  */
45
60
  hate: boolean;
46
61
 
47
62
  /**
48
- * Whether the content was flagged as 'hate/threatening'.
63
+ * Hateful content that also includes violence or serious harm towards the targeted
64
+ * group based on race, gender, ethnicity, religion, nationality, sexual
65
+ * orientation, disability status, or caste.
49
66
  */
50
67
  'hate/threatening': boolean;
51
68
 
52
69
  /**
53
- * Whether the content was flagged as 'self-harm'.
70
+ * Content that promotes, encourages, or depicts acts of self-harm, such as
71
+ * suicide, cutting, and eating disorders.
54
72
  */
55
73
  'self-harm': boolean;
56
74
 
57
75
  /**
58
- * Whether the content was flagged as 'sexual'.
76
+ * Content that encourages performing acts of self-harm, such as suicide, cutting,
77
+ * and eating disorders, or that gives instructions or advice on how to commit such
78
+ * acts.
79
+ */
80
+ 'self-harm/instructions': boolean;
81
+
82
+ /**
83
+ * Content where the speaker expresses that they are engaging or intend to engage
84
+ * in acts of self-harm, such as suicide, cutting, and eating disorders.
85
+ */
86
+ 'self-harm/intent': boolean;
87
+
88
+ /**
89
+ * Content meant to arouse sexual excitement, such as the description of sexual
90
+ * activity, or that promotes sexual services (excluding sex education and
91
+ * wellness).
59
92
  */
60
93
  sexual: boolean;
61
94
 
62
95
  /**
63
- * Whether the content was flagged as 'sexual/minors'.
96
+ * Sexual content that includes an individual who is under 18 years old.
64
97
  */
65
98
  'sexual/minors': boolean;
66
99
 
67
100
  /**
68
- * Whether the content was flagged as 'violence'.
101
+ * Content that depicts death, violence, or physical injury.
69
102
  */
70
103
  violence: boolean;
71
104
 
72
105
  /**
73
- * Whether the content was flagged as 'violence/graphic'.
106
+ * Content that depicts death, violence, or physical injury in graphic detail.
74
107
  */
75
108
  'violence/graphic': boolean;
76
109
  }
@@ -79,6 +112,16 @@ export namespace Moderation {
79
112
  * A list of the categories along with their scores as predicted by model.
80
113
  */
81
114
  export interface CategoryScores {
115
+ /**
116
+ * The score for the category 'harassment'.
117
+ */
118
+ harassment: number;
119
+
120
+ /**
121
+ * The score for the category 'harassment/threatening'.
122
+ */
123
+ 'harassment/threatening': number;
124
+
82
125
  /**
83
126
  * The score for the category 'hate'.
84
127
  */
@@ -94,6 +137,16 @@ export namespace Moderation {
94
137
  */
95
138
  'self-harm': number;
96
139
 
140
+ /**
141
+ * The score for the category 'self-harm/instructions'.
142
+ */
143
+ 'self-harm/instructions': number;
144
+
145
+ /**
146
+ * The score for the category 'self-harm/intent'.
147
+ */
148
+ 'self-harm/intent': number;
149
+
97
150
  /**
98
151
  * The score for the category 'sexual'.
99
152
  */
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '4.0.0';
1
+ export const VERSION = '4.1.0';
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = '4.0.0';
1
+ export declare const VERSION = '4.1.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.0';
4
+ exports.VERSION = '4.1.0';
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '4.0.0';
1
+ export const VERSION = '4.1.0';
2
2
  //# sourceMappingURL=version.mjs.map