@@ -6,7 +6,8 @@ import * as ModerationsAPI from './moderations';
6
6
7
7
export class Moderations extends APIResource {
8
8
/**
9
- * Classifies if text is potentially harmful.
9
+ * Classifies if text and/or image inputs are potentially harmful. Learn more in
10
+ * the [moderation guide](https://platform.openai.com/docs/guides/moderation).
10
11
*/
11
12
create (
12
13
body : ModerationCreateParams ,
@@ -22,6 +23,11 @@ export interface Moderation {
22
23
*/
23
24
categories : Moderation . Categories ;
24
25
26
+ /**
27
+ * A list of the categories along with the input type(s) that the score applies to.
28
+ */
29
+ category_applied_input_types : Moderation . CategoryAppliedInputTypes ;
30
+
25
31
/**
26
32
* A list of the categories along with their scores as predicted by model.
27
33
*/
@@ -65,6 +71,20 @@ export namespace Moderation {
65
71
*/
66
72
'hate/threatening' : boolean ;
67
73
74
+ /**
75
+ * Content that includes instructions or advice that facilitate the planning or
76
+ * execution of wrongdoing, or that gives advice or instruction on how to commit
77
+ * illicit acts. For example, "how to shoplift" would fit this category.
78
+ */
79
+ illicit : boolean ;
80
+
81
+ /**
82
+ * Content that includes instructions or advice that facilitate the planning or
83
+ * execution of wrongdoing that also includes violence, or that gives advice or
84
+ * instruction on the procurement of any weapon.
85
+ */
86
+ 'illicit/violent' : boolean ;
87
+
68
88
/**
69
89
* Content that promotes, encourages, or depicts acts of self-harm, such as
70
90
* suicide, cutting, and eating disorders.
@@ -107,6 +127,76 @@ export namespace Moderation {
107
127
'violence/graphic' : boolean ;
108
128
}
109
129
130
+ /**
131
+ * A list of the categories along with the input type(s) that the score applies to.
132
+ */
133
+ export interface CategoryAppliedInputTypes {
134
+ /**
135
+ * The applied input type(s) for the category 'harassment'.
136
+ */
137
+ harassment : Array < 'text' > ;
138
+
139
+ /**
140
+ * The applied input type(s) for the category 'harassment/threatening'.
141
+ */
142
+ 'harassment/threatening' : Array < 'text' > ;
143
+
144
+ /**
145
+ * The applied input type(s) for the category 'hate'.
146
+ */
147
+ hate : Array < 'text' > ;
148
+
149
+ /**
150
+ * The applied input type(s) for the category 'hate/threatening'.
151
+ */
152
+ 'hate/threatening' : Array < 'text' > ;
153
+
154
+ /**
155
+ * The applied input type(s) for the category 'illicit'.
156
+ */
157
+ illicit : Array < 'text' > ;
158
+
159
+ /**
160
+ * The applied input type(s) for the category 'illicit/violent'.
161
+ */
162
+ 'illicit/violent' : Array < 'text' > ;
163
+
164
+ /**
165
+ * The applied input type(s) for the category 'self-harm'.
166
+ */
167
+ 'self-harm' : Array < 'text' | 'image' > ;
168
+
169
+ /**
170
+ * The applied input type(s) for the category 'self-harm/instructions'.
171
+ */
172
+ 'self-harm/instructions' : Array < 'text' | 'image' > ;
173
+
174
+ /**
175
+ * The applied input type(s) for the category 'self-harm/intent'.
176
+ */
177
+ 'self-harm/intent' : Array < 'text' | 'image' > ;
178
+
179
+ /**
180
+ * The applied input type(s) for the category 'sexual'.
181
+ */
182
+ sexual : Array < 'text' | 'image' > ;
183
+
184
+ /**
185
+ * The applied input type(s) for the category 'sexual/minors'.
186
+ */
187
+ 'sexual/minors' : Array < 'text' > ;
188
+
189
+ /**
190
+ * The applied input type(s) for the category 'violence'.
191
+ */
192
+ violence : Array < 'text' | 'image' > ;
193
+
194
+ /**
195
+ * The applied input type(s) for the category 'violence/graphic'.
196
+ */
197
+ 'violence/graphic' : Array < 'text' | 'image' > ;
198
+ }
199
+
110
200
/**
111
201
* A list of the categories along with their scores as predicted by model.
112
202
*/
@@ -131,6 +221,16 @@ export namespace Moderation {
131
221
*/
132
222
'hate/threatening' : number ;
133
223
224
+ /**
225
+ * The score for the category 'illicit'.
226
+ */
227
+ illicit : number ;
228
+
229
+ /**
230
+ * The score for the category 'illicit/violent'.
231
+ */
232
+ 'illicit/violent' : number ;
233
+
134
234
/**
135
235
* The score for the category 'self-harm'.
136
236
*/
@@ -168,7 +268,58 @@ export namespace Moderation {
168
268
}
169
269
}
170
270
171
- export type ModerationModel = 'text-moderation-latest' | 'text-moderation-stable' ;
271
+ /**
272
+ * An object describing an image to classify.
273
+ */
274
+ export interface ModerationImageURLInput {
275
+ /**
276
+ * Contains either an image URL or a data URL for a base64 encoded image.
277
+ */
278
+ image_url : ModerationImageURLInput . ImageURL ;
279
+
280
+ /**
281
+ * Always `image_url`.
282
+ */
283
+ type : 'image_url' ;
284
+ }
285
+
286
+ export namespace ModerationImageURLInput {
287
+ /**
288
+ * Contains either an image URL or a data URL for a base64 encoded image.
289
+ */
290
+ export interface ImageURL {
291
+ /**
292
+ * Either a URL of the image or the base64 encoded image data.
293
+ */
294
+ url : string ;
295
+ }
296
+ }
297
+
298
+ export type ModerationModel =
299
+ | 'omni-moderation-latest'
300
+ | 'omni-moderation-2024-09-26'
301
+ | 'text-moderation-latest'
302
+ | 'text-moderation-stable' ;
303
+
304
+ /**
305
+ * An object describing an image to classify.
306
+ */
307
+ export type ModerationMultiModalInput = ModerationImageURLInput | ModerationTextInput ;
308
+
309
+ /**
310
+ * An object describing text to classify.
311
+ */
312
+ export interface ModerationTextInput {
313
+ /**
314
+ * A string of text to classify.
315
+ */
316
+ text : string ;
317
+
318
+ /**
319
+ * Always `text`.
320
+ */
321
+ type : 'text' ;
322
+ }
172
323
173
324
/**
174
325
* Represents if a given text input is potentially harmful.
@@ -192,26 +343,26 @@ export interface ModerationCreateResponse {
192
343
193
344
export interface ModerationCreateParams {
194
345
/**
195
- * The input text to classify
346
+ * Input (or inputs) to classify. Can be a single string, an array of strings, or
347
+ * an array of multi-modal input objects similar to other models.
196
348
*/
197
- input : string | Array < string > ;
349
+ input : string | Array < string > | Array < ModerationMultiModalInput > ;
198
350
199
351
/**
200
- * Two content moderations models are available: `text-moderation-stable` and
201
- * `text-moderation-latest`.
202
- *
203
- * The default is `text-moderation-latest` which will be automatically upgraded
204
- * over time. This ensures you are always using our most accurate model. If you use
205
- * `text-moderation-stable`, we will provide advanced notice before updating the
206
- * model. Accuracy of `text-moderation-stable` may be slightly lower than for
207
- * `text-moderation-latest`.
352
+ * The content moderation model you would like to use. Learn more in
353
+ * [the moderation guide](https://platform.openai.com/docs/guides/moderation), and
354
+ * learn about available models
355
+ * [here](https://platform.openai.com/docs/models/moderation).
208
356
*/
209
357
model ?: ( string & { } ) | ModerationModel ;
210
358
}
211
359
212
360
export namespace Moderations {
213
361
export import Moderation = ModerationsAPI . Moderation ;
362
+ export import ModerationImageURLInput = ModerationsAPI . ModerationImageURLInput ;
214
363
export import ModerationModel = ModerationsAPI . ModerationModel ;
364
+ export import ModerationMultiModalInput = ModerationsAPI . ModerationMultiModalInput ;
365
+ export import ModerationTextInput = ModerationsAPI . ModerationTextInput ;
215
366
export import ModerationCreateResponse = ModerationsAPI . ModerationCreateResponse ;
216
367
export import ModerationCreateParams = ModerationsAPI . ModerationCreateParams ;
217
368
}
0 commit comments