/* * 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 { EvalPythonGraderContract, EvalPythonGraderContract$inboundSchema, EvalPythonGraderContract$outboundSchema, } from "./evalpythongradercontract.js"; import { EvalPythonGraderExecution, EvalPythonGraderExecution$inboundSchema, EvalPythonGraderExecution$outboundSchema, } from "./evalpythongraderexecution.js"; import { EvalPythonGraderModelAccess, EvalPythonGraderModelAccess$inboundSchema, EvalPythonGraderModelAccess$outboundSchema, } from "./evalpythongradermodelaccess.js"; export type EvalPythonGrader = { type: "python"; contract?: EvalPythonGraderContract | undefined; execution?: EvalPythonGraderExecution | undefined; modelAccess?: EvalPythonGraderModelAccess | undefined; /** * Default metric key used when grade returns a single float. */ metricId?: string | undefined; /** * Inline Python source that defines a supported eval grading contract. */ source?: string | undefined; /** * File ID for a Python grader uploaded with purpose 'evals'. */ fileId?: string | undefined; timeoutSeconds?: number | undefined; maxModelCalls?: number | undefined; }; /** @internal */ export const EvalPythonGrader$inboundSchema: z.ZodType< EvalPythonGrader, z.ZodTypeDef, unknown > = z.object({ type: z.literal("python"), contract: EvalPythonGraderContract$inboundSchema.optional(), execution: EvalPythonGraderExecution$inboundSchema.optional(), model_access: EvalPythonGraderModelAccess$inboundSchema.optional(), metric_id: z.string().default("score"), source: z.string().optional(), file_id: z.string().optional(), timeout_seconds: z.number().int().default(120), max_model_calls: z.number().int().default(64), }).transform((v) => { return remap$(v, { "model_access": "modelAccess", "metric_id": "metricId", "file_id": "fileId", "timeout_seconds": "timeoutSeconds", "max_model_calls": "maxModelCalls", }); }); /** @internal */ export type EvalPythonGrader$Outbound = { type: "python"; contract?: string | undefined; execution?: string | undefined; model_access?: string | undefined; metric_id: string; source?: string | undefined; file_id?: string | undefined; timeout_seconds: number; max_model_calls: number; }; /** @internal */ export const EvalPythonGrader$outboundSchema: z.ZodType< EvalPythonGrader$Outbound, z.ZodTypeDef, EvalPythonGrader > = z.object({ type: z.literal("python"), contract: EvalPythonGraderContract$outboundSchema.optional(), execution: EvalPythonGraderExecution$outboundSchema.optional(), modelAccess: EvalPythonGraderModelAccess$outboundSchema.optional(), metricId: z.string().default("score"), source: z.string().optional(), fileId: z.string().optional(), timeoutSeconds: z.number().int().default(120), maxModelCalls: z.number().int().default(64), }).transform((v) => { return remap$(v, { modelAccess: "model_access", metricId: "metric_id", fileId: "file_id", timeoutSeconds: "timeout_seconds", maxModelCalls: "max_model_calls", }); }); export function evalPythonGraderToJSON( evalPythonGrader: EvalPythonGrader, ): string { return JSON.stringify( EvalPythonGrader$outboundSchema.parse(evalPythonGrader), ); } export function evalPythonGraderFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EvalPythonGrader$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EvalPythonGrader' from JSON`, ); }