moderations.d.ts 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. import { APIResource } from "../resource.js";
  2. import * as Core from "../core.js";
  3. export declare class Moderations extends APIResource {
  4. /**
  5. * Classifies if text and/or image inputs are potentially harmful. Learn more in
  6. * the [moderation guide](https://platform.openai.com/docs/guides/moderation).
  7. */
  8. create(body: ModerationCreateParams, options?: Core.RequestOptions): Core.APIPromise<ModerationCreateResponse>;
  9. }
  10. export interface Moderation {
  11. /**
  12. * A list of the categories, and whether they are flagged or not.
  13. */
  14. categories: Moderation.Categories;
  15. /**
  16. * A list of the categories along with the input type(s) that the score applies to.
  17. */
  18. category_applied_input_types: Moderation.CategoryAppliedInputTypes;
  19. /**
  20. * A list of the categories along with their scores as predicted by model.
  21. */
  22. category_scores: Moderation.CategoryScores;
  23. /**
  24. * Whether any of the below categories are flagged.
  25. */
  26. flagged: boolean;
  27. }
  28. export declare namespace Moderation {
  29. /**
  30. * A list of the categories, and whether they are flagged or not.
  31. */
  32. interface Categories {
  33. /**
  34. * Content that expresses, incites, or promotes harassing language towards any
  35. * target.
  36. */
  37. harassment: boolean;
  38. /**
  39. * Harassment content that also includes violence or serious harm towards any
  40. * target.
  41. */
  42. 'harassment/threatening': boolean;
  43. /**
  44. * Content that expresses, incites, or promotes hate based on race, gender,
  45. * ethnicity, religion, nationality, sexual orientation, disability status, or
  46. * caste. Hateful content aimed at non-protected groups (e.g., chess players) is
  47. * harassment.
  48. */
  49. hate: boolean;
  50. /**
  51. * Hateful content that also includes violence or serious harm towards the targeted
  52. * group based on race, gender, ethnicity, religion, nationality, sexual
  53. * orientation, disability status, or caste.
  54. */
  55. 'hate/threatening': boolean;
  56. /**
  57. * Content that includes instructions or advice that facilitate the planning or
  58. * execution of wrongdoing, or that gives advice or instruction on how to commit
  59. * illicit acts. For example, "how to shoplift" would fit this category.
  60. */
  61. illicit: boolean | null;
  62. /**
  63. * Content that includes instructions or advice that facilitate the planning or
  64. * execution of wrongdoing that also includes violence, or that gives advice or
  65. * instruction on the procurement of any weapon.
  66. */
  67. 'illicit/violent': boolean | null;
  68. /**
  69. * Content that promotes, encourages, or depicts acts of self-harm, such as
  70. * suicide, cutting, and eating disorders.
  71. */
  72. 'self-harm': boolean;
  73. /**
  74. * Content that encourages performing acts of self-harm, such as suicide, cutting,
  75. * and eating disorders, or that gives instructions or advice on how to commit such
  76. * acts.
  77. */
  78. 'self-harm/instructions': boolean;
  79. /**
  80. * Content where the speaker expresses that they are engaging or intend to engage
  81. * in acts of self-harm, such as suicide, cutting, and eating disorders.
  82. */
  83. 'self-harm/intent': boolean;
  84. /**
  85. * Content meant to arouse sexual excitement, such as the description of sexual
  86. * activity, or that promotes sexual services (excluding sex education and
  87. * wellness).
  88. */
  89. sexual: boolean;
  90. /**
  91. * Sexual content that includes an individual who is under 18 years old.
  92. */
  93. 'sexual/minors': boolean;
  94. /**
  95. * Content that depicts death, violence, or physical injury.
  96. */
  97. violence: boolean;
  98. /**
  99. * Content that depicts death, violence, or physical injury in graphic detail.
  100. */
  101. 'violence/graphic': boolean;
  102. }
  103. /**
  104. * A list of the categories along with the input type(s) that the score applies to.
  105. */
  106. interface CategoryAppliedInputTypes {
  107. /**
  108. * The applied input type(s) for the category 'harassment'.
  109. */
  110. harassment: Array<'text'>;
  111. /**
  112. * The applied input type(s) for the category 'harassment/threatening'.
  113. */
  114. 'harassment/threatening': Array<'text'>;
  115. /**
  116. * The applied input type(s) for the category 'hate'.
  117. */
  118. hate: Array<'text'>;
  119. /**
  120. * The applied input type(s) for the category 'hate/threatening'.
  121. */
  122. 'hate/threatening': Array<'text'>;
  123. /**
  124. * The applied input type(s) for the category 'illicit'.
  125. */
  126. illicit: Array<'text'>;
  127. /**
  128. * The applied input type(s) for the category 'illicit/violent'.
  129. */
  130. 'illicit/violent': Array<'text'>;
  131. /**
  132. * The applied input type(s) for the category 'self-harm'.
  133. */
  134. 'self-harm': Array<'text' | 'image'>;
  135. /**
  136. * The applied input type(s) for the category 'self-harm/instructions'.
  137. */
  138. 'self-harm/instructions': Array<'text' | 'image'>;
  139. /**
  140. * The applied input type(s) for the category 'self-harm/intent'.
  141. */
  142. 'self-harm/intent': Array<'text' | 'image'>;
  143. /**
  144. * The applied input type(s) for the category 'sexual'.
  145. */
  146. sexual: Array<'text' | 'image'>;
  147. /**
  148. * The applied input type(s) for the category 'sexual/minors'.
  149. */
  150. 'sexual/minors': Array<'text'>;
  151. /**
  152. * The applied input type(s) for the category 'violence'.
  153. */
  154. violence: Array<'text' | 'image'>;
  155. /**
  156. * The applied input type(s) for the category 'violence/graphic'.
  157. */
  158. 'violence/graphic': Array<'text' | 'image'>;
  159. }
  160. /**
  161. * A list of the categories along with their scores as predicted by model.
  162. */
  163. interface CategoryScores {
  164. /**
  165. * The score for the category 'harassment'.
  166. */
  167. harassment: number;
  168. /**
  169. * The score for the category 'harassment/threatening'.
  170. */
  171. 'harassment/threatening': number;
  172. /**
  173. * The score for the category 'hate'.
  174. */
  175. hate: number;
  176. /**
  177. * The score for the category 'hate/threatening'.
  178. */
  179. 'hate/threatening': number;
  180. /**
  181. * The score for the category 'illicit'.
  182. */
  183. illicit: number;
  184. /**
  185. * The score for the category 'illicit/violent'.
  186. */
  187. 'illicit/violent': number;
  188. /**
  189. * The score for the category 'self-harm'.
  190. */
  191. 'self-harm': number;
  192. /**
  193. * The score for the category 'self-harm/instructions'.
  194. */
  195. 'self-harm/instructions': number;
  196. /**
  197. * The score for the category 'self-harm/intent'.
  198. */
  199. 'self-harm/intent': number;
  200. /**
  201. * The score for the category 'sexual'.
  202. */
  203. sexual: number;
  204. /**
  205. * The score for the category 'sexual/minors'.
  206. */
  207. 'sexual/minors': number;
  208. /**
  209. * The score for the category 'violence'.
  210. */
  211. violence: number;
  212. /**
  213. * The score for the category 'violence/graphic'.
  214. */
  215. 'violence/graphic': number;
  216. }
  217. }
  218. /**
  219. * An object describing an image to classify.
  220. */
  221. export interface ModerationImageURLInput {
  222. /**
  223. * Contains either an image URL or a data URL for a base64 encoded image.
  224. */
  225. image_url: ModerationImageURLInput.ImageURL;
  226. /**
  227. * Always `image_url`.
  228. */
  229. type: 'image_url';
  230. }
  231. export declare namespace ModerationImageURLInput {
  232. /**
  233. * Contains either an image URL or a data URL for a base64 encoded image.
  234. */
  235. interface ImageURL {
  236. /**
  237. * Either a URL of the image or the base64 encoded image data.
  238. */
  239. url: string;
  240. }
  241. }
  242. export type ModerationModel = 'omni-moderation-latest' | 'omni-moderation-2024-09-26' | 'text-moderation-latest' | 'text-moderation-stable';
  243. /**
  244. * An object describing an image to classify.
  245. */
  246. export type ModerationMultiModalInput = ModerationImageURLInput | ModerationTextInput;
  247. /**
  248. * An object describing text to classify.
  249. */
  250. export interface ModerationTextInput {
  251. /**
  252. * A string of text to classify.
  253. */
  254. text: string;
  255. /**
  256. * Always `text`.
  257. */
  258. type: 'text';
  259. }
  260. /**
  261. * Represents if a given text input is potentially harmful.
  262. */
  263. export interface ModerationCreateResponse {
  264. /**
  265. * The unique identifier for the moderation request.
  266. */
  267. id: string;
  268. /**
  269. * The model used to generate the moderation results.
  270. */
  271. model: string;
  272. /**
  273. * A list of moderation objects.
  274. */
  275. results: Array<Moderation>;
  276. }
  277. export interface ModerationCreateParams {
  278. /**
  279. * Input (or inputs) to classify. Can be a single string, an array of strings, or
  280. * an array of multi-modal input objects similar to other models.
  281. */
  282. input: string | Array<string> | Array<ModerationMultiModalInput>;
  283. /**
  284. * The content moderation model you would like to use. Learn more in
  285. * [the moderation guide](https://platform.openai.com/docs/guides/moderation), and
  286. * learn about available models
  287. * [here](https://platform.openai.com/docs/models#moderation).
  288. */
  289. model?: (string & {}) | ModerationModel;
  290. }
  291. export declare namespace Moderations {
  292. export { type Moderation as Moderation, type ModerationImageURLInput as ModerationImageURLInput, type ModerationModel as ModerationModel, type ModerationMultiModalInput as ModerationMultiModalInput, type ModerationTextInput as ModerationTextInput, type ModerationCreateResponse as ModerationCreateResponse, type ModerationCreateParams as ModerationCreateParams, };
  293. }
  294. //# sourceMappingURL=moderations.d.ts.map