/* * 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 { LeakageConfig, LeakageConfig$inboundSchema, LeakageConfig$Outbound, LeakageConfig$outboundSchema, } from "./leakageconfig.js"; /** * Leakage guardrail */ export type LeakageGuardrail = { mode: "leakage"; /** * Whether this guardrail is enabled */ enabled?: boolean | undefined; /** * Also apply this guardrail to model output, not just the request */ checkOutput?: boolean | undefined; /** * Configuration for system prompt leakage detection guardrail */ config?: LeakageConfig | undefined; }; /** @internal */ export const LeakageGuardrail$inboundSchema: z.ZodType< LeakageGuardrail, z.ZodTypeDef, unknown > = z.object({ mode: z.literal("leakage"), enabled: z.boolean().default(true), check_output: z.boolean().optional(), config: LeakageConfig$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "check_output": "checkOutput", }); }); /** @internal */ export type LeakageGuardrail$Outbound = { mode: "leakage"; enabled: boolean; check_output?: boolean | undefined; config?: LeakageConfig$Outbound | undefined; }; /** @internal */ export const LeakageGuardrail$outboundSchema: z.ZodType< LeakageGuardrail$Outbound, z.ZodTypeDef, LeakageGuardrail > = z.object({ mode: z.literal("leakage"), enabled: z.boolean().default(true), checkOutput: z.boolean().optional(), config: LeakageConfig$outboundSchema.optional(), }).transform((v) => { return remap$(v, { checkOutput: "check_output", }); }); export function leakageGuardrailToJSON( leakageGuardrail: LeakageGuardrail, ): string { return JSON.stringify( LeakageGuardrail$outboundSchema.parse(leakageGuardrail), ); } export function leakageGuardrailFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => LeakageGuardrail$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LeakageGuardrail' from JSON`, ); }