Package org.mockserver.llm
Class OpenAiModerationBodies
java.lang.Object
org.mockserver.llm.OpenAiModerationBodies
Pure, deterministic encoder for the OpenAI Moderations endpoint
(
POST /v1/moderations) response body. Given the set of categories to
flag, produces OpenAI's exact wire shape:
{"id":..,"model":..,"results":[{"flagged":bool,"categories":{..},"category_scores":{..}}]}.
Every canonical moderation category is emitted (so client SDKs that read a
fixed field set never see a missing key); the categories named in the
ModerationResponse are set true with a high score, the rest
false with a low score. The top-level flagged is true
when any category is flagged. Scores are fixed constants (0.95
/ 1.0E-4) so the body is deterministic.
All methods are static and pure (no clocks, no shared state); the only
non-determinism is the random id, which real OpenAI responses also carry.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringEncode the moderations JSON body flagging the given categories.static Stringencode(ModerationResponse moderation) Encode the moderations JSON body for the givenModerationResponse.
-
Method Details
-
encode
Encode the moderations JSON body for the givenModerationResponse. -
encode
Encode the moderations JSON body flagging the given categories. A null/emptyflaggedCategoriesyields a fully not-flagged verdict.
-