/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 97bb61766b7e
 */

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  ModerationLLMAction,
  ModerationLLMAction$inboundSchema,
  ModerationLLMAction$outboundSchema,
} from "./moderationllmaction.js";
import {
  ModerationLlmv2CategoryThresholds,
  ModerationLlmv2CategoryThresholds$inboundSchema,
  ModerationLlmv2CategoryThresholds$Outbound,
  ModerationLlmv2CategoryThresholds$outboundSchema,
} from "./moderationllmv2categorythresholds.js";

export type ModerationLlmv2Config = {
  /**
   * Override model name. Should be omitted in general.
   */
  modelName?: string | undefined;
  customCategoryThresholds?:
    | ModerationLlmv2CategoryThresholds
    | null
    | undefined;
  /**
   * If true, only evaluate categories in custom_category_thresholds; others are ignored.
   */
  ignoreOtherCategories?: boolean | undefined;
  action?: ModerationLLMAction | undefined;
};

/** @internal */
export const ModerationLlmv2Config$inboundSchema: z.ZodType<
  ModerationLlmv2Config,
  unknown
> = z.object({
  model_name: z.string().default("mistral-moderation-2603"),
  custom_category_thresholds: z.nullable(
    ModerationLlmv2CategoryThresholds$inboundSchema,
  ).optional(),
  ignore_other_categories: z.boolean().default(false),
  action: ModerationLLMAction$inboundSchema.optional(),
}).transform((v) => {
  return remap$(v, {
    "model_name": "modelName",
    "custom_category_thresholds": "customCategoryThresholds",
    "ignore_other_categories": "ignoreOtherCategories",
  });
});
/** @internal */
export type ModerationLlmv2Config$Outbound = {
  model_name: string;
  custom_category_thresholds?:
    | ModerationLlmv2CategoryThresholds$Outbound
    | null
    | undefined;
  ignore_other_categories: boolean;
  action?: string | undefined;
};

/** @internal */
export const ModerationLlmv2Config$outboundSchema: z.ZodType<
  ModerationLlmv2Config$Outbound,
  ModerationLlmv2Config
> = z.object({
  modelName: z.string().default("mistral-moderation-2603"),
  customCategoryThresholds: z.nullable(
    ModerationLlmv2CategoryThresholds$outboundSchema,
  ).optional(),
  ignoreOtherCategories: z.boolean().default(false),
  action: ModerationLLMAction$outboundSchema.optional(),
}).transform((v) => {
  return remap$(v, {
    modelName: "model_name",
    customCategoryThresholds: "custom_category_thresholds",
    ignoreOtherCategories: "ignore_other_categories",
  });
});

export function moderationLlmv2ConfigToJSON(
  moderationLlmv2Config: ModerationLlmv2Config,
): string {
  return JSON.stringify(
    ModerationLlmv2Config$outboundSchema.parse(moderationLlmv2Config),
  );
}
export function moderationLlmv2ConfigFromJSON(
  jsonString: string,
): SafeParseResult<ModerationLlmv2Config, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ModerationLlmv2Config$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ModerationLlmv2Config' from JSON`,
  );
}
