/* * 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"; import { DpoHyperparameters, DpoHyperparameters$inboundSchema, DpoHyperparameters$Outbound, DpoHyperparameters$outboundSchema, } from "./dpohyperparameters.js"; import { ReinforcementHyperparameters, ReinforcementHyperparameters$inboundSchema, ReinforcementHyperparameters$Outbound, ReinforcementHyperparameters$outboundSchema, } from "./reinforcementhyperparameters.js"; import { SupervisedHyperparameters, SupervisedHyperparameters$inboundSchema, SupervisedHyperparameters$Outbound, SupervisedHyperparameters$outboundSchema, } from "./supervisedhyperparameters.js"; export const Type = { Supervised: "supervised", Dpo: "dpo", Reinforcement: "reinforcement", } as const; export type Type = ClosedEnum; export type Supervised = { hyperparameters?: SupervisedHyperparameters | null | undefined; }; export type Dpo = { hyperparameters?: DpoHyperparameters | null | undefined; }; export type MethodGradersInput = { role: string; content: string; }; export type Graders5 = { type: "label_model"; name: string; model: string; input: Array; labels: Array; passingLabels: Array; }; export type GradersInput = { role: string; content: string; }; export const MethodSamplingParamsReasoningEffort = { Low: "low", Medium: "medium", High: "high", } as const; export type MethodSamplingParamsReasoningEffort = ClosedEnum< typeof MethodSamplingParamsReasoningEffort >; export type GradersSamplingParams = { maxCompletionsTokens?: number | null | undefined; reasoningEffort?: MethodSamplingParamsReasoningEffort | null | undefined; seed?: number | null | undefined; temperature?: number | null | undefined; topP?: number | null | undefined; }; export type Graders4 = { type: "score_model"; name: string; model: string; input: Array; range?: Array | null | undefined; samplingParams?: GradersSamplingParams | null | undefined; }; export type Graders3 = { type: "python"; name: string; source: string; imageTag?: string | null | undefined; }; export const GradersEvaluationMetric = { Cosine: "cosine", FuzzyMatch: "fuzzy_match", Bleu: "bleu", Gleu: "gleu", Meteor: "meteor", Rouge1: "rouge_1", Rouge2: "rouge_2", Rouge3: "rouge_3", Rouge4: "rouge_4", Rouge5: "rouge_5", RougeL: "rouge_l", } as const; export type GradersEvaluationMetric = ClosedEnum< typeof GradersEvaluationMetric >; export type Graders2 = { type: "text_similarity"; name: string; input: string; reference: string; evaluationMetric: GradersEvaluationMetric; }; export const GradersOperation = { Eq: "eq", Ne: "ne", Like: "like", Ilike: "ilike", } as const; export type GradersOperation = ClosedEnum; export type Graders1 = { type: "string_check"; name: string; input: string; reference: string; operation: GradersOperation; }; export type Graders = Graders1 | Graders2 | Graders3 | Graders4 | Graders5; export type Grader2 = { type: "multi"; name: string; graders: { [k: string]: Graders1 | Graders2 | Graders3 | Graders4 | Graders5; }; calculateOutput: string; }; export type Method1Input = { role: string; content: string; }; export type One5 = { type: "label_model"; name: string; model: string; input: Array; labels: Array; passingLabels: Array; }; export type OneInput = { role: string; content: string; }; export const SamplingParamsReasoningEffort = { Low: "low", Medium: "medium", High: "high", } as const; export type SamplingParamsReasoningEffort = ClosedEnum< typeof SamplingParamsReasoningEffort >; export type SamplingParams = { maxCompletionsTokens?: number | null | undefined; reasoningEffort?: SamplingParamsReasoningEffort | null | undefined; seed?: number | null | undefined; temperature?: number | null | undefined; topP?: number | null | undefined; }; export type One4 = { type: "score_model"; name: string; model: string; input: Array; range?: Array | null | undefined; samplingParams?: SamplingParams | null | undefined; }; export type One3 = { type: "python"; name: string; source: string; imageTag?: string | null | undefined; }; export const EvaluationMetric = { Cosine: "cosine", FuzzyMatch: "fuzzy_match", Bleu: "bleu", Gleu: "gleu", Meteor: "meteor", Rouge1: "rouge_1", Rouge2: "rouge_2", Rouge3: "rouge_3", Rouge4: "rouge_4", Rouge5: "rouge_5", RougeL: "rouge_l", } as const; export type EvaluationMetric = ClosedEnum; export type One2 = { type: "text_similarity"; name: string; input: string; reference: string; evaluationMetric: EvaluationMetric; }; export const Operation = { Eq: "eq", Ne: "ne", Like: "like", Ilike: "ilike", } as const; export type Operation = ClosedEnum; export type One1 = { type: "string_check"; name: string; input: string; reference: string; operation: Operation; }; export type Grader1 = One1 | One2 | One3 | One4 | One5; export type Grader = Grader2 | One1 | One2 | One3 | One4 | One5; export type Reinforcement = { grader: Grader2 | One1 | One2 | One3 | One4 | One5; hyperparameters?: ReinforcementHyperparameters | null | undefined; }; export type Method = { type: Type; supervised?: Supervised | null | undefined; dpo?: Dpo | null | undefined; reinforcement?: Reinforcement | null | undefined; }; /** @internal */ export const Type$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Type, ); /** @internal */ export const Type$outboundSchema: z.ZodNativeEnum = Type$inboundSchema; /** @internal */ export const Supervised$inboundSchema: z.ZodType< Supervised, z.ZodTypeDef, unknown > = z.object({ hyperparameters: z.nullable(SupervisedHyperparameters$inboundSchema) .optional(), }); /** @internal */ export type Supervised$Outbound = { hyperparameters?: SupervisedHyperparameters$Outbound | null | undefined; }; /** @internal */ export const Supervised$outboundSchema: z.ZodType< Supervised$Outbound, z.ZodTypeDef, Supervised > = z.object({ hyperparameters: z.nullable(SupervisedHyperparameters$outboundSchema) .optional(), }); export function supervisedToJSON(supervised: Supervised): string { return JSON.stringify(Supervised$outboundSchema.parse(supervised)); } export function supervisedFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Supervised$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Supervised' from JSON`, ); } /** @internal */ export const Dpo$inboundSchema: z.ZodType = z .object({ hyperparameters: z.nullable(DpoHyperparameters$inboundSchema).optional(), }); /** @internal */ export type Dpo$Outbound = { hyperparameters?: DpoHyperparameters$Outbound | null | undefined; }; /** @internal */ export const Dpo$outboundSchema: z.ZodType = z .object({ hyperparameters: z.nullable(DpoHyperparameters$outboundSchema).optional(), }); export function dpoToJSON(dpo: Dpo): string { return JSON.stringify(Dpo$outboundSchema.parse(dpo)); } export function dpoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Dpo$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Dpo' from JSON`, ); } /** @internal */ export const MethodGradersInput$inboundSchema: z.ZodType< MethodGradersInput, z.ZodTypeDef, unknown > = z.object({ role: z.string(), content: z.string(), }); /** @internal */ export type MethodGradersInput$Outbound = { role: string; content: string; }; /** @internal */ export const MethodGradersInput$outboundSchema: z.ZodType< MethodGradersInput$Outbound, z.ZodTypeDef, MethodGradersInput > = z.object({ role: z.string(), content: z.string(), }); export function methodGradersInputToJSON( methodGradersInput: MethodGradersInput, ): string { return JSON.stringify( MethodGradersInput$outboundSchema.parse(methodGradersInput), ); } export function methodGradersInputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => MethodGradersInput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'MethodGradersInput' from JSON`, ); } /** @internal */ export const Graders5$inboundSchema: z.ZodType< Graders5, z.ZodTypeDef, unknown > = z.object({ type: z.literal("label_model"), name: z.string(), model: z.string(), input: z.array(z.lazy(() => MethodGradersInput$inboundSchema)), labels: z.array(z.string()), passing_labels: z.array(z.string()), }).transform((v) => { return remap$(v, { "passing_labels": "passingLabels", }); }); /** @internal */ export type Graders5$Outbound = { type: "label_model"; name: string; model: string; input: Array; labels: Array; passing_labels: Array; }; /** @internal */ export const Graders5$outboundSchema: z.ZodType< Graders5$Outbound, z.ZodTypeDef, Graders5 > = z.object({ type: z.literal("label_model"), name: z.string(), model: z.string(), input: z.array(z.lazy(() => MethodGradersInput$outboundSchema)), labels: z.array(z.string()), passingLabels: z.array(z.string()), }).transform((v) => { return remap$(v, { passingLabels: "passing_labels", }); }); export function graders5ToJSON(graders5: Graders5): string { return JSON.stringify(Graders5$outboundSchema.parse(graders5)); } export function graders5FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Graders5$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Graders5' from JSON`, ); } /** @internal */ export const GradersInput$inboundSchema: z.ZodType< GradersInput, z.ZodTypeDef, unknown > = z.object({ role: z.string(), content: z.string(), }); /** @internal */ export type GradersInput$Outbound = { role: string; content: string; }; /** @internal */ export const GradersInput$outboundSchema: z.ZodType< GradersInput$Outbound, z.ZodTypeDef, GradersInput > = z.object({ role: z.string(), content: z.string(), }); export function gradersInputToJSON(gradersInput: GradersInput): string { return JSON.stringify(GradersInput$outboundSchema.parse(gradersInput)); } export function gradersInputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GradersInput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GradersInput' from JSON`, ); } /** @internal */ export const MethodSamplingParamsReasoningEffort$inboundSchema: z.ZodNativeEnum< typeof MethodSamplingParamsReasoningEffort > = z.nativeEnum(MethodSamplingParamsReasoningEffort); /** @internal */ export const MethodSamplingParamsReasoningEffort$outboundSchema: z.ZodNativeEnum = MethodSamplingParamsReasoningEffort$inboundSchema; /** @internal */ export const GradersSamplingParams$inboundSchema: z.ZodType< GradersSamplingParams, z.ZodTypeDef, unknown > = z.object({ max_completions_tokens: z.nullable(z.number().int()).optional(), reasoning_effort: z.nullable( MethodSamplingParamsReasoningEffort$inboundSchema, ).optional(), seed: z.nullable(z.number().int()).optional(), temperature: z.nullable(z.number()).optional(), top_p: z.nullable(z.number()).optional(), }).transform((v) => { return remap$(v, { "max_completions_tokens": "maxCompletionsTokens", "reasoning_effort": "reasoningEffort", "top_p": "topP", }); }); /** @internal */ export type GradersSamplingParams$Outbound = { max_completions_tokens?: number | null | undefined; reasoning_effort?: string | null | undefined; seed?: number | null | undefined; temperature?: number | null | undefined; top_p?: number | null | undefined; }; /** @internal */ export const GradersSamplingParams$outboundSchema: z.ZodType< GradersSamplingParams$Outbound, z.ZodTypeDef, GradersSamplingParams > = z.object({ maxCompletionsTokens: z.nullable(z.number().int()).optional(), reasoningEffort: z.nullable( MethodSamplingParamsReasoningEffort$outboundSchema, ).optional(), seed: z.nullable(z.number().int()).optional(), temperature: z.nullable(z.number()).optional(), topP: z.nullable(z.number()).optional(), }).transform((v) => { return remap$(v, { maxCompletionsTokens: "max_completions_tokens", reasoningEffort: "reasoning_effort", topP: "top_p", }); }); export function gradersSamplingParamsToJSON( gradersSamplingParams: GradersSamplingParams, ): string { return JSON.stringify( GradersSamplingParams$outboundSchema.parse(gradersSamplingParams), ); } export function gradersSamplingParamsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GradersSamplingParams$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GradersSamplingParams' from JSON`, ); } /** @internal */ export const Graders4$inboundSchema: z.ZodType< Graders4, z.ZodTypeDef, unknown > = z.object({ type: z.literal("score_model"), name: z.string(), model: z.string(), input: z.array(z.lazy(() => GradersInput$inboundSchema)), range: z.nullable(z.array(z.number())).optional(), sampling_params: z.nullable(z.lazy(() => GradersSamplingParams$inboundSchema)) .optional(), }).transform((v) => { return remap$(v, { "sampling_params": "samplingParams", }); }); /** @internal */ export type Graders4$Outbound = { type: "score_model"; name: string; model: string; input: Array; range?: Array | null | undefined; sampling_params?: GradersSamplingParams$Outbound | null | undefined; }; /** @internal */ export const Graders4$outboundSchema: z.ZodType< Graders4$Outbound, z.ZodTypeDef, Graders4 > = z.object({ type: z.literal("score_model"), name: z.string(), model: z.string(), input: z.array(z.lazy(() => GradersInput$outboundSchema)), range: z.nullable(z.array(z.number())).optional(), samplingParams: z.nullable(z.lazy(() => GradersSamplingParams$outboundSchema)) .optional(), }).transform((v) => { return remap$(v, { samplingParams: "sampling_params", }); }); export function graders4ToJSON(graders4: Graders4): string { return JSON.stringify(Graders4$outboundSchema.parse(graders4)); } export function graders4FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Graders4$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Graders4' from JSON`, ); } /** @internal */ export const Graders3$inboundSchema: z.ZodType< Graders3, z.ZodTypeDef, unknown > = z.object({ type: z.literal("python"), name: z.string(), source: z.string(), image_tag: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "image_tag": "imageTag", }); }); /** @internal */ export type Graders3$Outbound = { type: "python"; name: string; source: string; image_tag?: string | null | undefined; }; /** @internal */ export const Graders3$outboundSchema: z.ZodType< Graders3$Outbound, z.ZodTypeDef, Graders3 > = z.object({ type: z.literal("python"), name: z.string(), source: z.string(), imageTag: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { imageTag: "image_tag", }); }); export function graders3ToJSON(graders3: Graders3): string { return JSON.stringify(Graders3$outboundSchema.parse(graders3)); } export function graders3FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Graders3$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Graders3' from JSON`, ); } /** @internal */ export const GradersEvaluationMetric$inboundSchema: z.ZodNativeEnum< typeof GradersEvaluationMetric > = z.nativeEnum(GradersEvaluationMetric); /** @internal */ export const GradersEvaluationMetric$outboundSchema: z.ZodNativeEnum< typeof GradersEvaluationMetric > = GradersEvaluationMetric$inboundSchema; /** @internal */ export const Graders2$inboundSchema: z.ZodType< Graders2, z.ZodTypeDef, unknown > = z.object({ type: z.literal("text_similarity"), name: z.string(), input: z.string(), reference: z.string(), evaluation_metric: GradersEvaluationMetric$inboundSchema, }).transform((v) => { return remap$(v, { "evaluation_metric": "evaluationMetric", }); }); /** @internal */ export type Graders2$Outbound = { type: "text_similarity"; name: string; input: string; reference: string; evaluation_metric: string; }; /** @internal */ export const Graders2$outboundSchema: z.ZodType< Graders2$Outbound, z.ZodTypeDef, Graders2 > = z.object({ type: z.literal("text_similarity"), name: z.string(), input: z.string(), reference: z.string(), evaluationMetric: GradersEvaluationMetric$outboundSchema, }).transform((v) => { return remap$(v, { evaluationMetric: "evaluation_metric", }); }); export function graders2ToJSON(graders2: Graders2): string { return JSON.stringify(Graders2$outboundSchema.parse(graders2)); } export function graders2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Graders2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Graders2' from JSON`, ); } /** @internal */ export const GradersOperation$inboundSchema: z.ZodNativeEnum< typeof GradersOperation > = z.nativeEnum(GradersOperation); /** @internal */ export const GradersOperation$outboundSchema: z.ZodNativeEnum< typeof GradersOperation > = GradersOperation$inboundSchema; /** @internal */ export const Graders1$inboundSchema: z.ZodType< Graders1, z.ZodTypeDef, unknown > = z.object({ type: z.literal("string_check"), name: z.string(), input: z.string(), reference: z.string(), operation: GradersOperation$inboundSchema, }); /** @internal */ export type Graders1$Outbound = { type: "string_check"; name: string; input: string; reference: string; operation: string; }; /** @internal */ export const Graders1$outboundSchema: z.ZodType< Graders1$Outbound, z.ZodTypeDef, Graders1 > = z.object({ type: z.literal("string_check"), name: z.string(), input: z.string(), reference: z.string(), operation: GradersOperation$outboundSchema, }); export function graders1ToJSON(graders1: Graders1): string { return JSON.stringify(Graders1$outboundSchema.parse(graders1)); } export function graders1FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Graders1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Graders1' from JSON`, ); } /** @internal */ export const Graders$inboundSchema: z.ZodType = z.union([ z.lazy(() => Graders1$inboundSchema), z.lazy(() => Graders2$inboundSchema), z.lazy(() => Graders3$inboundSchema), z.lazy(() => Graders4$inboundSchema), z.lazy(() => Graders5$inboundSchema), ]); /** @internal */ export type Graders$Outbound = | Graders1$Outbound | Graders2$Outbound | Graders3$Outbound | Graders4$Outbound | Graders5$Outbound; /** @internal */ export const Graders$outboundSchema: z.ZodType< Graders$Outbound, z.ZodTypeDef, Graders > = z.union([ z.lazy(() => Graders1$outboundSchema), z.lazy(() => Graders2$outboundSchema), z.lazy(() => Graders3$outboundSchema), z.lazy(() => Graders4$outboundSchema), z.lazy(() => Graders5$outboundSchema), ]); export function gradersToJSON(graders: Graders): string { return JSON.stringify(Graders$outboundSchema.parse(graders)); } export function gradersFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Graders$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Graders' from JSON`, ); } /** @internal */ export const Grader2$inboundSchema: z.ZodType = z.object({ type: z.literal("multi"), name: z.string(), graders: z.record( z.union([ z.lazy(() => Graders1$inboundSchema), z.lazy(() => Graders2$inboundSchema), z.lazy(() => Graders3$inboundSchema), z.lazy(() => Graders4$inboundSchema), z.lazy(() => Graders5$inboundSchema), ]), ), calculate_output: z.string(), }).transform((v) => { return remap$(v, { "calculate_output": "calculateOutput", }); }); /** @internal */ export type Grader2$Outbound = { type: "multi"; name: string; graders: { [k: string]: | Graders1$Outbound | Graders2$Outbound | Graders3$Outbound | Graders4$Outbound | Graders5$Outbound; }; calculate_output: string; }; /** @internal */ export const Grader2$outboundSchema: z.ZodType< Grader2$Outbound, z.ZodTypeDef, Grader2 > = z.object({ type: z.literal("multi"), name: z.string(), graders: z.record( z.union([ z.lazy(() => Graders1$outboundSchema), z.lazy(() => Graders2$outboundSchema), z.lazy(() => Graders3$outboundSchema), z.lazy(() => Graders4$outboundSchema), z.lazy(() => Graders5$outboundSchema), ]), ), calculateOutput: z.string(), }).transform((v) => { return remap$(v, { calculateOutput: "calculate_output", }); }); export function grader2ToJSON(grader2: Grader2): string { return JSON.stringify(Grader2$outboundSchema.parse(grader2)); } export function grader2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Grader2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Grader2' from JSON`, ); } /** @internal */ export const Method1Input$inboundSchema: z.ZodType< Method1Input, z.ZodTypeDef, unknown > = z.object({ role: z.string(), content: z.string(), }); /** @internal */ export type Method1Input$Outbound = { role: string; content: string; }; /** @internal */ export const Method1Input$outboundSchema: z.ZodType< Method1Input$Outbound, z.ZodTypeDef, Method1Input > = z.object({ role: z.string(), content: z.string(), }); export function method1InputToJSON(method1Input: Method1Input): string { return JSON.stringify(Method1Input$outboundSchema.parse(method1Input)); } export function method1InputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Method1Input$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Method1Input' from JSON`, ); } /** @internal */ export const One5$inboundSchema: z.ZodType = z .object({ type: z.literal("label_model"), name: z.string(), model: z.string(), input: z.array(z.lazy(() => Method1Input$inboundSchema)), labels: z.array(z.string()), passing_labels: z.array(z.string()), }).transform((v) => { return remap$(v, { "passing_labels": "passingLabels", }); }); /** @internal */ export type One5$Outbound = { type: "label_model"; name: string; model: string; input: Array; labels: Array; passing_labels: Array; }; /** @internal */ export const One5$outboundSchema: z.ZodType = z.object({ type: z.literal("label_model"), name: z.string(), model: z.string(), input: z.array(z.lazy(() => Method1Input$outboundSchema)), labels: z.array(z.string()), passingLabels: z.array(z.string()), }).transform((v) => { return remap$(v, { passingLabels: "passing_labels", }); }); export function one5ToJSON(one5: One5): string { return JSON.stringify(One5$outboundSchema.parse(one5)); } export function one5FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => One5$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'One5' from JSON`, ); } /** @internal */ export const OneInput$inboundSchema: z.ZodType< OneInput, z.ZodTypeDef, unknown > = z.object({ role: z.string(), content: z.string(), }); /** @internal */ export type OneInput$Outbound = { role: string; content: string; }; /** @internal */ export const OneInput$outboundSchema: z.ZodType< OneInput$Outbound, z.ZodTypeDef, OneInput > = z.object({ role: z.string(), content: z.string(), }); export function oneInputToJSON(oneInput: OneInput): string { return JSON.stringify(OneInput$outboundSchema.parse(oneInput)); } export function oneInputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OneInput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OneInput' from JSON`, ); } /** @internal */ export const SamplingParamsReasoningEffort$inboundSchema: z.ZodNativeEnum< typeof SamplingParamsReasoningEffort > = z.nativeEnum(SamplingParamsReasoningEffort); /** @internal */ export const SamplingParamsReasoningEffort$outboundSchema: z.ZodNativeEnum< typeof SamplingParamsReasoningEffort > = SamplingParamsReasoningEffort$inboundSchema; /** @internal */ export const SamplingParams$inboundSchema: z.ZodType< SamplingParams, z.ZodTypeDef, unknown > = z.object({ max_completions_tokens: z.nullable(z.number().int()).optional(), reasoning_effort: z.nullable(SamplingParamsReasoningEffort$inboundSchema) .optional(), seed: z.nullable(z.number().int()).optional(), temperature: z.nullable(z.number()).optional(), top_p: z.nullable(z.number()).optional(), }).transform((v) => { return remap$(v, { "max_completions_tokens": "maxCompletionsTokens", "reasoning_effort": "reasoningEffort", "top_p": "topP", }); }); /** @internal */ export type SamplingParams$Outbound = { max_completions_tokens?: number | null | undefined; reasoning_effort?: string | null | undefined; seed?: number | null | undefined; temperature?: number | null | undefined; top_p?: number | null | undefined; }; /** @internal */ export const SamplingParams$outboundSchema: z.ZodType< SamplingParams$Outbound, z.ZodTypeDef, SamplingParams > = z.object({ maxCompletionsTokens: z.nullable(z.number().int()).optional(), reasoningEffort: z.nullable(SamplingParamsReasoningEffort$outboundSchema) .optional(), seed: z.nullable(z.number().int()).optional(), temperature: z.nullable(z.number()).optional(), topP: z.nullable(z.number()).optional(), }).transform((v) => { return remap$(v, { maxCompletionsTokens: "max_completions_tokens", reasoningEffort: "reasoning_effort", topP: "top_p", }); }); export function samplingParamsToJSON(samplingParams: SamplingParams): string { return JSON.stringify(SamplingParams$outboundSchema.parse(samplingParams)); } export function samplingParamsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SamplingParams$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SamplingParams' from JSON`, ); } /** @internal */ export const One4$inboundSchema: z.ZodType = z .object({ type: z.literal("score_model"), name: z.string(), model: z.string(), input: z.array(z.lazy(() => OneInput$inboundSchema)), range: z.nullable(z.array(z.number())).optional(), sampling_params: z.nullable(z.lazy(() => SamplingParams$inboundSchema)) .optional(), }).transform((v) => { return remap$(v, { "sampling_params": "samplingParams", }); }); /** @internal */ export type One4$Outbound = { type: "score_model"; name: string; model: string; input: Array; range?: Array | null | undefined; sampling_params?: SamplingParams$Outbound | null | undefined; }; /** @internal */ export const One4$outboundSchema: z.ZodType = z.object({ type: z.literal("score_model"), name: z.string(), model: z.string(), input: z.array(z.lazy(() => OneInput$outboundSchema)), range: z.nullable(z.array(z.number())).optional(), samplingParams: z.nullable(z.lazy(() => SamplingParams$outboundSchema)) .optional(), }).transform((v) => { return remap$(v, { samplingParams: "sampling_params", }); }); export function one4ToJSON(one4: One4): string { return JSON.stringify(One4$outboundSchema.parse(one4)); } export function one4FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => One4$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'One4' from JSON`, ); } /** @internal */ export const One3$inboundSchema: z.ZodType = z .object({ type: z.literal("python"), name: z.string(), source: z.string(), image_tag: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "image_tag": "imageTag", }); }); /** @internal */ export type One3$Outbound = { type: "python"; name: string; source: string; image_tag?: string | null | undefined; }; /** @internal */ export const One3$outboundSchema: z.ZodType = z.object({ type: z.literal("python"), name: z.string(), source: z.string(), imageTag: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { imageTag: "image_tag", }); }); export function one3ToJSON(one3: One3): string { return JSON.stringify(One3$outboundSchema.parse(one3)); } export function one3FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => One3$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'One3' from JSON`, ); } /** @internal */ export const EvaluationMetric$inboundSchema: z.ZodNativeEnum< typeof EvaluationMetric > = z.nativeEnum(EvaluationMetric); /** @internal */ export const EvaluationMetric$outboundSchema: z.ZodNativeEnum< typeof EvaluationMetric > = EvaluationMetric$inboundSchema; /** @internal */ export const One2$inboundSchema: z.ZodType = z .object({ type: z.literal("text_similarity"), name: z.string(), input: z.string(), reference: z.string(), evaluation_metric: EvaluationMetric$inboundSchema, }).transform((v) => { return remap$(v, { "evaluation_metric": "evaluationMetric", }); }); /** @internal */ export type One2$Outbound = { type: "text_similarity"; name: string; input: string; reference: string; evaluation_metric: string; }; /** @internal */ export const One2$outboundSchema: z.ZodType = z.object({ type: z.literal("text_similarity"), name: z.string(), input: z.string(), reference: z.string(), evaluationMetric: EvaluationMetric$outboundSchema, }).transform((v) => { return remap$(v, { evaluationMetric: "evaluation_metric", }); }); export function one2ToJSON(one2: One2): string { return JSON.stringify(One2$outboundSchema.parse(one2)); } export function one2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => One2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'One2' from JSON`, ); } /** @internal */ export const Operation$inboundSchema: z.ZodNativeEnum = z .nativeEnum(Operation); /** @internal */ export const Operation$outboundSchema: z.ZodNativeEnum = Operation$inboundSchema; /** @internal */ export const One1$inboundSchema: z.ZodType = z .object({ type: z.literal("string_check"), name: z.string(), input: z.string(), reference: z.string(), operation: Operation$inboundSchema, }); /** @internal */ export type One1$Outbound = { type: "string_check"; name: string; input: string; reference: string; operation: string; }; /** @internal */ export const One1$outboundSchema: z.ZodType = z.object({ type: z.literal("string_check"), name: z.string(), input: z.string(), reference: z.string(), operation: Operation$outboundSchema, }); export function one1ToJSON(one1: One1): string { return JSON.stringify(One1$outboundSchema.parse(one1)); } export function one1FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => One1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'One1' from JSON`, ); } /** @internal */ export const Grader1$inboundSchema: z.ZodType = z.union([ z.lazy(() => One1$inboundSchema), z.lazy(() => One2$inboundSchema), z.lazy(() => One3$inboundSchema), z.lazy(() => One4$inboundSchema), z.lazy(() => One5$inboundSchema), ]); /** @internal */ export type Grader1$Outbound = | One1$Outbound | One2$Outbound | One3$Outbound | One4$Outbound | One5$Outbound; /** @internal */ export const Grader1$outboundSchema: z.ZodType< Grader1$Outbound, z.ZodTypeDef, Grader1 > = z.union([ z.lazy(() => One1$outboundSchema), z.lazy(() => One2$outboundSchema), z.lazy(() => One3$outboundSchema), z.lazy(() => One4$outboundSchema), z.lazy(() => One5$outboundSchema), ]); export function grader1ToJSON(grader1: Grader1): string { return JSON.stringify(Grader1$outboundSchema.parse(grader1)); } export function grader1FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Grader1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Grader1' from JSON`, ); } /** @internal */ export const Grader$inboundSchema: z.ZodType = z .union([ z.lazy(() => Grader2$inboundSchema), z.union([ z.lazy(() => One1$inboundSchema), z.lazy(() => One2$inboundSchema), z.lazy(() => One3$inboundSchema), z.lazy(() => One4$inboundSchema), z.lazy(() => One5$inboundSchema), ]), ]); /** @internal */ export type Grader$Outbound = | Grader2$Outbound | One1$Outbound | One2$Outbound | One3$Outbound | One4$Outbound | One5$Outbound; /** @internal */ export const Grader$outboundSchema: z.ZodType< Grader$Outbound, z.ZodTypeDef, Grader > = z.union([ z.lazy(() => Grader2$outboundSchema), z.union([ z.lazy(() => One1$outboundSchema), z.lazy(() => One2$outboundSchema), z.lazy(() => One3$outboundSchema), z.lazy(() => One4$outboundSchema), z.lazy(() => One5$outboundSchema), ]), ]); export function graderToJSON(grader: Grader): string { return JSON.stringify(Grader$outboundSchema.parse(grader)); } export function graderFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Grader$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Grader' from JSON`, ); } /** @internal */ export const Reinforcement$inboundSchema: z.ZodType< Reinforcement, z.ZodTypeDef, unknown > = z.object({ grader: z.union([ z.lazy(() => Grader2$inboundSchema), z.union([ z.lazy(() => One1$inboundSchema), z.lazy(() => One2$inboundSchema), z.lazy(() => One3$inboundSchema), z.lazy(() => One4$inboundSchema), z.lazy(() => One5$inboundSchema), ]), ]), hyperparameters: z.nullable(ReinforcementHyperparameters$inboundSchema) .optional(), }); /** @internal */ export type Reinforcement$Outbound = { grader: | Grader2$Outbound | One1$Outbound | One2$Outbound | One3$Outbound | One4$Outbound | One5$Outbound; hyperparameters?: ReinforcementHyperparameters$Outbound | null | undefined; }; /** @internal */ export const Reinforcement$outboundSchema: z.ZodType< Reinforcement$Outbound, z.ZodTypeDef, Reinforcement > = z.object({ grader: z.union([ z.lazy(() => Grader2$outboundSchema), z.union([ z.lazy(() => One1$outboundSchema), z.lazy(() => One2$outboundSchema), z.lazy(() => One3$outboundSchema), z.lazy(() => One4$outboundSchema), z.lazy(() => One5$outboundSchema), ]), ]), hyperparameters: z.nullable(ReinforcementHyperparameters$outboundSchema) .optional(), }); export function reinforcementToJSON(reinforcement: Reinforcement): string { return JSON.stringify(Reinforcement$outboundSchema.parse(reinforcement)); } export function reinforcementFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Reinforcement$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Reinforcement' from JSON`, ); } /** @internal */ export const Method$inboundSchema: z.ZodType = z .object({ type: Type$inboundSchema, supervised: z.nullable(z.lazy(() => Supervised$inboundSchema)).optional(), dpo: z.nullable(z.lazy(() => Dpo$inboundSchema)).optional(), reinforcement: z.nullable(z.lazy(() => Reinforcement$inboundSchema)) .optional(), }); /** @internal */ export type Method$Outbound = { type: string; supervised?: Supervised$Outbound | null | undefined; dpo?: Dpo$Outbound | null | undefined; reinforcement?: Reinforcement$Outbound | null | undefined; }; /** @internal */ export const Method$outboundSchema: z.ZodType< Method$Outbound, z.ZodTypeDef, Method > = z.object({ type: Type$outboundSchema, supervised: z.nullable(z.lazy(() => Supervised$outboundSchema)).optional(), dpo: z.nullable(z.lazy(() => Dpo$outboundSchema)).optional(), reinforcement: z.nullable(z.lazy(() => Reinforcement$outboundSchema)) .optional(), }); export function methodToJSON(method: Method): string { return JSON.stringify(Method$outboundSchema.parse(method)); } export function methodFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Method$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Method' from JSON`, ); }