/* * 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"; /** * Configuration for prompt injection detection guardrail */ export type PromptInjectionConfig = { /** * Detection threshold (0-1) */ threshold?: number | undefined; /** * The message to return when this guardrail is triggered */ rejectionMessage?: string | undefined; }; /** @internal */ export const PromptInjectionConfig$inboundSchema: z.ZodType< PromptInjectionConfig, z.ZodTypeDef, unknown > = z.object({ threshold: z.number().default(0.7), rejection_message: z.string().default( "I'm sorry, but I can't process this request. Please rephrase your message in a different way.", ), }).transform((v) => { return remap$(v, { "rejection_message": "rejectionMessage", }); }); /** @internal */ export type PromptInjectionConfig$Outbound = { threshold: number; rejection_message: string; }; /** @internal */ export const PromptInjectionConfig$outboundSchema: z.ZodType< PromptInjectionConfig$Outbound, z.ZodTypeDef, PromptInjectionConfig > = z.object({ threshold: z.number().default(0.7), rejectionMessage: z.string().default( "I'm sorry, but I can't process this request. Please rephrase your message in a different way.", ), }).transform((v) => { return remap$(v, { rejectionMessage: "rejection_message", }); }); export function promptInjectionConfigToJSON( promptInjectionConfig: PromptInjectionConfig, ): string { return JSON.stringify( PromptInjectionConfig$outboundSchema.parse(promptInjectionConfig), ); } export function promptInjectionConfigFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PromptInjectionConfig$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PromptInjectionConfig' from JSON`, ); }