/* * 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 { EvalDataset, EvalDataset$inboundSchema, EvalDataset$Outbound, EvalDataset$outboundSchema, } from "./evaldataset.js"; import { EvalFewshotConfig, EvalFewshotConfig$inboundSchema, EvalFewshotConfig$Outbound, EvalFewshotConfig$outboundSchema, } from "./evalfewshotconfig.js"; import { EvalMetric, EvalMetric$inboundSchema, EvalMetric$Outbound, EvalMetric$outboundSchema, } from "./evalmetric.js"; import { EvalOutputExtraction, EvalOutputExtraction$inboundSchema, EvalOutputExtraction$Outbound, EvalOutputExtraction$outboundSchema, } from "./evaloutputextraction.js"; import { EvalPythonGrader, EvalPythonGrader$inboundSchema, EvalPythonGrader$Outbound, EvalPythonGrader$outboundSchema, } from "./evalpythongrader.js"; import { EvalPythonPreprocessor, EvalPythonPreprocessor$inboundSchema, EvalPythonPreprocessor$Outbound, EvalPythonPreprocessor$outboundSchema, } from "./evalpythonpreprocessor.js"; import { EvalTaskType, EvalTaskType$inboundSchema, EvalTaskType$outboundSchema, } from "./evaltasktype.js"; /** * One declarative eval task. */ export type EvalTask = { id: string; name?: string | undefined; type: EvalTaskType; /** * Dataset backing an eval task. */ dataset: EvalDataset; promptTemplate?: string | undefined; targetTemplate?: string | undefined; choices?: Array | undefined; outputExtraction?: EvalOutputExtraction | undefined; metrics?: Array | undefined; grader: EvalPythonGrader; preprocess?: EvalPythonPreprocessor | undefined; fewshot?: EvalFewshotConfig | undefined; /** * lm-eval style alias for fewshot.count. */ numFewshot?: number | undefined; /** * BCP-47/ISO language hint passed to the transcription model for transcription tasks (e.g. "ur", "uk"). */ language?: string | undefined; metadata?: { [k: string]: any } | undefined; }; /** @internal */ export const EvalTask$inboundSchema: z.ZodType< EvalTask, z.ZodTypeDef, unknown > = z.object({ id: z.string(), name: z.string().optional(), type: EvalTaskType$inboundSchema, dataset: EvalDataset$inboundSchema, prompt_template: z.string().optional(), target_template: z.string().optional(), choices: z.array(z.string()).optional(), output_extraction: EvalOutputExtraction$inboundSchema.optional(), metrics: z.array(EvalMetric$inboundSchema).optional(), grader: EvalPythonGrader$inboundSchema, preprocess: EvalPythonPreprocessor$inboundSchema.optional(), fewshot: EvalFewshotConfig$inboundSchema.optional(), num_fewshot: z.number().int().optional(), language: z.string().optional(), metadata: z.record(z.any()).optional(), }).transform((v) => { return remap$(v, { "prompt_template": "promptTemplate", "target_template": "targetTemplate", "output_extraction": "outputExtraction", "num_fewshot": "numFewshot", }); }); /** @internal */ export type EvalTask$Outbound = { id: string; name?: string | undefined; type: string; dataset: EvalDataset$Outbound; prompt_template?: string | undefined; target_template?: string | undefined; choices?: Array | undefined; output_extraction?: EvalOutputExtraction$Outbound | undefined; metrics?: Array | undefined; grader: EvalPythonGrader$Outbound; preprocess?: EvalPythonPreprocessor$Outbound | undefined; fewshot?: EvalFewshotConfig$Outbound | undefined; num_fewshot?: number | undefined; language?: string | undefined; metadata?: { [k: string]: any } | undefined; }; /** @internal */ export const EvalTask$outboundSchema: z.ZodType< EvalTask$Outbound, z.ZodTypeDef, EvalTask > = z.object({ id: z.string(), name: z.string().optional(), type: EvalTaskType$outboundSchema, dataset: EvalDataset$outboundSchema, promptTemplate: z.string().optional(), targetTemplate: z.string().optional(), choices: z.array(z.string()).optional(), outputExtraction: EvalOutputExtraction$outboundSchema.optional(), metrics: z.array(EvalMetric$outboundSchema).optional(), grader: EvalPythonGrader$outboundSchema, preprocess: EvalPythonPreprocessor$outboundSchema.optional(), fewshot: EvalFewshotConfig$outboundSchema.optional(), numFewshot: z.number().int().optional(), language: z.string().optional(), metadata: z.record(z.any()).optional(), }).transform((v) => { return remap$(v, { promptTemplate: "prompt_template", targetTemplate: "target_template", outputExtraction: "output_extraction", numFewshot: "num_fewshot", }); }); export function evalTaskToJSON(evalTask: EvalTask): string { return JSON.stringify(EvalTask$outboundSchema.parse(evalTask)); } export function evalTaskFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EvalTask$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EvalTask' from JSON`, ); }