/* * 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 { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Run transform(row) per row or transform_batch(rows) once. */ export const Contract = { Row: "row", Batch: "batch", } as const; /** * Run transform(row) per row or transform_batch(rows) once. */ export type Contract = ClosedEnum; export type EvalPythonPreprocessor = { type: "python"; /** * Run transform(row) per row or transform_batch(rows) once. */ contract?: Contract | undefined; /** * Inline Python source that transforms dataset rows before prompt rendering. */ source?: string | undefined; /** * File ID for a Python preprocessor uploaded with purpose 'evals'. */ fileId?: string | undefined; timeoutSeconds?: number | undefined; }; /** @internal */ export const Contract$inboundSchema: z.ZodNativeEnum = z .nativeEnum(Contract); /** @internal */ export const Contract$outboundSchema: z.ZodNativeEnum = Contract$inboundSchema; /** @internal */ export const EvalPythonPreprocessor$inboundSchema: z.ZodType< EvalPythonPreprocessor, z.ZodTypeDef, unknown > = z.object({ type: z.literal("python"), contract: Contract$inboundSchema.default("row"), source: z.string().optional(), file_id: z.string().optional(), timeout_seconds: z.number().int().default(120), }).transform((v) => { return remap$(v, { "file_id": "fileId", "timeout_seconds": "timeoutSeconds", }); }); /** @internal */ export type EvalPythonPreprocessor$Outbound = { type: "python"; contract: string; source?: string | undefined; file_id?: string | undefined; timeout_seconds: number; }; /** @internal */ export const EvalPythonPreprocessor$outboundSchema: z.ZodType< EvalPythonPreprocessor$Outbound, z.ZodTypeDef, EvalPythonPreprocessor > = z.object({ type: z.literal("python"), contract: Contract$outboundSchema.default("row"), source: z.string().optional(), fileId: z.string().optional(), timeoutSeconds: z.number().int().default(120), }).transform((v) => { return remap$(v, { fileId: "file_id", timeoutSeconds: "timeout_seconds", }); }); export function evalPythonPreprocessorToJSON( evalPythonPreprocessor: EvalPythonPreprocessor, ): string { return JSON.stringify( EvalPythonPreprocessor$outboundSchema.parse(evalPythonPreprocessor), ); } export function evalPythonPreprocessorFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EvalPythonPreprocessor$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EvalPythonPreprocessor' from JSON`, ); }