Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { z } from 'zod';
/**
* Moderation categories schema
* Represents OpenAI's content moderation model's policy compliance report categories
*/
export const ModerationCategories = z.object({
/** Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment. */
hate: z.boolean(),
/** Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. */
'hate/threatening': z.boolean(),
/** Content that expresses, incites, or promotes harassing language towards any target. */
harassment: z.boolean(),
/** Harassment content that also includes violence or serious harm towards any target. */
'harassment/threatening': z.boolean(),
/** Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders. */
'self-harm': z.boolean(),
/** Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide or cutting. */
'self-harm/intent': z.boolean(),
/** Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts. */
'self-harm/instructions': z.boolean(),
/** Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness). */
sexual: z.boolean(),
/** Sexual content that includes an individual who is under 18 years old. */
'sexual/minors': z.boolean(),
/** Content that depicts death, violence, or physical injury. */
violence: z.boolean(),
/** Content that depicts death, violence, or physical injury in graphic detail. */
'violence/graphic': z.boolean(),
/** Content that includes instructions or advice on how to commit wrongdoing (e.g., "how to shoplift"). Available with omni-moderation models. */
illicit: z.boolean().optional(),
/** Content that includes instructions or advice on committing wrongdoing that also involves violence. Available with omni-moderation models. */
'illicit/violent': z.boolean().optional(),
});
export type ModerationCategories = z.infer<typeof ModerationCategories>;
/**
* Moderation category scores schema
* Represents the confidence scores for each moderation category
*/
export const ModerationCategoryScores = z.object({
/** Score for hate content (0.0 to 1.0) */
hate: z.number(),
/** Score for hate/threatening content (0.0 to 1.0) */
'hate/threatening': z.number(),
/** Score for harassment content (0.0 to 1.0) */
harassment: z.number(),
/** Score for harassment/threatening content (0.0 to 1.0) */
'harassment/threatening': z.number(),
/** Score for self-harm content (0.0 to 1.0) */
'self-harm': z.number(),
/** Score for self-harm/intent content (0.0 to 1.0) */
'self-harm/intent': z.number(),
/** Score for self-harm/instructions content (0.0 to 1.0) */
'self-harm/instructions': z.number(),
/** Score for sexual content (0.0 to 1.0) */
sexual: z.number(),
/** Score for sexual/minors content (0.0 to 1.0) */
'sexual/minors': z.number(),
/** Score for violence content (0.0 to 1.0) */
violence: z.number(),
/** Score for violence/graphic content (0.0 to 1.0) */
'violence/graphic': z.number(),
/** Score for illicit content (0.0 to 1.0). Available with omni-moderation models. */
illicit: z.number().optional(),
/** Score for illicit/violent content (0.0 to 1.0). Available with omni-moderation models. */
'illicit/violent': z.number().optional(),
});
export type ModerationCategoryScores = z.infer<typeof ModerationCategoryScores>;
/**
* Category applied input types schema
* Indicates which modalities of data were taken into account for each category
*/
export const ModerationCategoryAppliedInputTypes = z.object({
/** Input types applied for hate category */
hate: z.array(z.enum(['text', 'image'])).optional(),
/** Input types applied for hate/threatening category */
'hate/threatening': z.array(z.enum(['text', 'image'])).optional(),
/** Input types applied for harassment category */
harassment: z.array(z.enum(['text', 'image'])).optional(),
/** Input types applied for harassment/threatening category */
'harassment/threatening': z.array(z.enum(['text', 'image'])).optional(),
/** Input types applied for self-harm category */
'self-harm': z.array(z.enum(['text', 'image'])).optional(),
/** Input types applied for self-harm/intent category */
'self-harm/intent': z.array(z.enum(['text', 'image'])).optional(),
/** Input types applied for self-harm/instructions category */
'self-harm/instructions': z.array(z.enum(['text', 'image'])).optional(),
/** Input types applied for sexual category */
sexual: z.array(z.enum(['text', 'image'])).optional(),
/** Input types applied for sexual/minors category */
'sexual/minors': z.array(z.enum(['text', 'image'])).optional(),
/** Input types applied for violence category */
violence: z.array(z.enum(['text', 'image'])).optional(),
/** Input types applied for violence/graphic category */
'violence/graphic': z.array(z.enum(['text', 'image'])).optional(),
/** Input types applied for illicit category */
illicit: z.array(z.enum(['text', 'image'])).optional(),
/** Input types applied for illicit/violent category */
'illicit/violent': z.array(z.enum(['text', 'image'])).optional(),
});
export type ModerationCategoryAppliedInputTypes = z.infer<
typeof ModerationCategoryAppliedInputTypes
>;
/**
* Moderation result for a single input
*/
export const ModerationResult = z.object({
/** Whether the content violates OpenAI's usage policies */
flagged: z.boolean(),
/** A dictionary of per-category binary content policy violation flags */
categories: ModerationCategories,
/** A dictionary of per-category raw scores output by the model */
category_scores: ModerationCategoryScores,
/**
* Indicates which modalities of data were taken into account for each category.
* Available with omni-moderation models when using multimodal input.
*/
category_applied_input_types: ModerationCategoryAppliedInputTypes.optional(),
});
export type ModerationResult = z.infer<typeof ModerationResult>;
/**
* OpenAI Moderation API Response Schema
* Represents OpenAI's content moderation model's policy compliance report for given input(s)
*/
export const ModerationResponseBody = z.object({
/** The unique identifier for the moderation request */
id: z.string(),
/** The model used to generate the moderation results */
model: z.string(),
/** A list of moderation objects */
results: z.array(ModerationResult),
});
export type ModerationResponseBody = z.infer<typeof ModerationResponseBody>;
|