/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { BanWordsGuardrail, BanWordsGuardrail$inboundSchema, BanWordsGuardrail$Outbound, BanWordsGuardrail$outboundSchema, } from "./banwordsguardrail.js"; import { LeakageGuardrail, LeakageGuardrail$inboundSchema, LeakageGuardrail$Outbound, LeakageGuardrail$outboundSchema, } from "./leakageguardrail.js"; import { PromptInjectionGuardrail, PromptInjectionGuardrail$inboundSchema, PromptInjectionGuardrail$Outbound, PromptInjectionGuardrail$outboundSchema, } from "./promptinjectionguardrail.js"; export type GuardrailConfig = | BanWordsGuardrail | PromptInjectionGuardrail | LeakageGuardrail; /** @internal */ export const GuardrailConfig$inboundSchema: z.ZodType< GuardrailConfig, z.ZodTypeDef, unknown > = z.union([ BanWordsGuardrail$inboundSchema, PromptInjectionGuardrail$inboundSchema, LeakageGuardrail$inboundSchema, ]); /** @internal */ export type GuardrailConfig$Outbound = | BanWordsGuardrail$Outbound | PromptInjectionGuardrail$Outbound | LeakageGuardrail$Outbound; /** @internal */ export const GuardrailConfig$outboundSchema: z.ZodType< GuardrailConfig$Outbound, z.ZodTypeDef, GuardrailConfig > = z.union([ BanWordsGuardrail$outboundSchema, PromptInjectionGuardrail$outboundSchema, LeakageGuardrail$outboundSchema, ]); export function guardrailConfigToJSON( guardrailConfig: GuardrailConfig, ): string { return JSON.stringify(GuardrailConfig$outboundSchema.parse(guardrailConfig)); } export function guardrailConfigFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GuardrailConfig$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GuardrailConfig' from JSON`, ); }