moderations.d.ts 10.0 KB

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