/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; 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 { BanWordsConfig, BanWordsConfig$inboundSchema, BanWordsConfig$Outbound, BanWordsConfig$outboundSchema, } from "./banwordsconfig.js"; /** * Banned words guardrail */ export type BanWordsGuardrail = { mode: "ban_words"; /** * Whether this guardrail is enabled */ enabled?: boolean | undefined; /** * Also apply this guardrail to model output, not just the request */ checkOutput?: boolean | undefined; /** * Configuration for banned words guardrail */ config?: BanWordsConfig | undefined; }; /** @internal */ export const BanWordsGuardrail$inboundSchema: z.ZodType< BanWordsGuardrail, z.ZodTypeDef, unknown > = z.object({ mode: z.literal("ban_words"), enabled: z.boolean().default(true), check_output: z.boolean().optional(), config: BanWordsConfig$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "check_output": "checkOutput", }); }); /** @internal */ export type BanWordsGuardrail$Outbound = { mode: "ban_words"; enabled: boolean; check_output?: boolean | undefined; config?: BanWordsConfig$Outbound | undefined; }; /** @internal */ export const BanWordsGuardrail$outboundSchema: z.ZodType< BanWordsGuardrail$Outbound, z.ZodTypeDef, BanWordsGuardrail > = z.object({ mode: z.literal("ban_words"), enabled: z.boolean().default(true), checkOutput: z.boolean().optional(), config: BanWordsConfig$outboundSchema.optional(), }).transform((v) => { return remap$(v, { checkOutput: "check_output", }); }); export function banWordsGuardrailToJSON( banWordsGuardrail: BanWordsGuardrail, ): string { return JSON.stringify( BanWordsGuardrail$outboundSchema.parse(banWordsGuardrail), ); } export function banWordsGuardrailFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BanWordsGuardrail$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BanWordsGuardrail' from JSON`, ); }