@@ -16,30 +16,29 @@ pub enum ModerationInput {
1616 MultiModal ( Vec < ModerationContentPart > ) ,
1717}
1818
19+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
20+ pub struct ModerationTextInput {
21+ /// A string of text to classify
22+ pub text : String ,
23+ }
24+
25+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
26+ pub struct ModerationImageURLInput {
27+ /// Either a URL of the image or the base64 encoded image data.
28+ pub image_url : String ,
29+ }
30+
1931/// Content part for multi-modal moderation input
2032#[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
2133#[ serde( tag = "type" ) ]
2234pub enum ModerationContentPart {
2335 /// An object describing text to classify
2436 #[ serde( rename = "text" ) ]
25- Text {
26- /// A string of text to classify
27- text : String ,
28- } ,
37+ Text ( ModerationTextInput ) ,
2938
3039 /// An object describing an image to classify
3140 #[ serde( rename = "image_url" ) ]
32- ImageUrl {
33- /// Contains either an image URL or a data URL for a base64 encoded image
34- image_url : ModerationImageUrl ,
35- } ,
36- }
37-
38- /// Image URL configuration for image moderation
39- #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
40- pub struct ModerationImageUrl {
41- /// Either a URL of the image or the base64 encoded image data
42- pub url : String ,
41+ ImageUrl ( ModerationImageURLInput ) ,
4342}
4443
4544#[ derive( Debug , Default , Clone , Serialize , Builder , PartialEq , Deserialize ) ]
@@ -53,15 +52,15 @@ pub struct CreateModerationRequest {
5352 /// an array of multi-modal input objects similar to other models.
5453 pub input : ModerationInput ,
5554
56- /// The content moderation model you would like to use. Learn more in the
57- /// [moderation guide](https://platform.openai.com/docs/guides/moderation), and learn about
58- /// available models [here](https://platform.openai.com/docs/models/ moderation).
55+ /// The content moderation model you would like to use. Learn more in
56+ /// [the moderation guide](https://platform.openai.com/docs/guides/moderation), and learn about
57+ /// available models [here](https://platform.openai.com/docs/models# moderation).
5958 #[ serde( skip_serializing_if = "Option::is_none" ) ]
6059 pub model : Option < String > ,
6160}
6261
6362#[ derive( Debug , Deserialize , Serialize , Clone , PartialEq ) ]
64- pub struct Category {
63+ pub struct Categories {
6564 /// Content that expresses, incites, or promotes hate based on race, gender,
6665 /// ethnicity, religion, nationality, sexual orientation, disability status, or
6766 /// caste. Hateful content aimed at non-protected groups (e.g., chess players)
@@ -147,7 +146,7 @@ pub struct ContentModerationResult {
147146 /// Whether any of the below categories are flagged.
148147 pub flagged : bool ,
149148 /// A list of the categories, and whether they are flagged or not.
150- pub categories : Category ,
149+ pub categories : Categories ,
151150 /// A list of the categories along with their scores as predicted by model.
152151 pub category_scores : CategoryScore ,
153152 /// A list of the categories along with the input type(s) that the score applies to.
0 commit comments