/* * 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 { collectExtraKeys as collectExtraKeys$, safeParse, } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreateEvalRunRequest = { /** * Optional external end-user identifier forwarded by the API gateway. */ xOnBehalfOf?: string | undefined; createEvalRunRequest: components.CreateEvalRunRequest; }; export type Stop = string | Array; export const Truncation = { Auto: "auto", Disabled: "disabled", } as const; export type Truncation = ClosedEnum; export const ServiceTier = { Auto: "auto", Default: "default", Flex: "flex", Priority: "priority", } as const; export type ServiceTier = ClosedEnum; export type PrefillThink = boolean | string; export type Generation = { instructions?: string | undefined; temperature?: number | undefined; topP?: number | undefined; maxOutputTokens?: number | undefined; /** * lm-eval alias for max_output_tokens. */ maxGenToks?: number | undefined; stop?: string | Array | undefined; /** * lm-eval generate_until stop sequences. */ until?: Array | undefined; maxToolCalls?: number | undefined; reasoning?: any | undefined; text?: any | undefined; tools?: Array | undefined; toolChoice?: any | undefined; parallelToolCalls?: boolean | undefined; truncation?: Truncation | undefined; serviceTier?: ServiceTier | undefined; presencePenalty?: number | undefined; frequencyPenalty?: number | undefined; topK?: number | undefined; minP?: number | undefined; repetitionPenalty?: number | undefined; doSample?: boolean | undefined; extraBody?: { [k: string]: any } | undefined; chatTemplateKwargs?: { [k: string]: any } | undefined; prefillThink?: boolean | string | undefined; useCache?: boolean | undefined; timeoutSeconds?: number | undefined; maxRetries?: number | undefined; maxEmptyRetries?: number | undefined; additionalProperties?: { [k: string]: any } | undefined; }; export type RequestCounts = { total: number; completed: number; failed: number; }; /** * OK */ export type CreateEvalRunResponseBody = { id: string; object: "eval.run"; suiteId: string; suiteVersion: number; suiteVersionId: string; /** * The org that owns this run. */ orgId: string; /** * The team that owns this run. */ teamId: string; status: components.EvalRunStatus; models: Array; taskIds: Array | null; judgeModel: string | null; embeddingModel: string | null; generation: Generation; requestCounts: RequestCounts; metrics: { [k: string]: any } | null; error: { [k: string]: any } | null; artifactFileIds: Array; metadata: { [k: string]: string }; createdAt: number; startedAt: number | null; completedAt: number | null; cancelledAt: number | null; failedAt: number | null; }; /** @internal */ export const CreateEvalRunRequest$inboundSchema: z.ZodType< CreateEvalRunRequest, z.ZodTypeDef, unknown > = z.object({ "X-On-Behalf-Of": z.string().optional(), CreateEvalRunRequest: components.CreateEvalRunRequest$inboundSchema, }).transform((v) => { return remap$(v, { "X-On-Behalf-Of": "xOnBehalfOf", "CreateEvalRunRequest": "createEvalRunRequest", }); }); /** @internal */ export type CreateEvalRunRequest$Outbound = { "X-On-Behalf-Of"?: string | undefined; CreateEvalRunRequest: components.CreateEvalRunRequest$Outbound; }; /** @internal */ export const CreateEvalRunRequest$outboundSchema: z.ZodType< CreateEvalRunRequest$Outbound, z.ZodTypeDef, CreateEvalRunRequest > = z.object({ xOnBehalfOf: z.string().optional(), createEvalRunRequest: components.CreateEvalRunRequest$outboundSchema, }).transform((v) => { return remap$(v, { xOnBehalfOf: "X-On-Behalf-Of", createEvalRunRequest: "CreateEvalRunRequest", }); }); export function createEvalRunRequestToJSON( createEvalRunRequest: CreateEvalRunRequest, ): string { return JSON.stringify( CreateEvalRunRequest$outboundSchema.parse(createEvalRunRequest), ); } export function createEvalRunRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateEvalRunRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateEvalRunRequest' from JSON`, ); } /** @internal */ export const Stop$inboundSchema: z.ZodType = z .union([z.string(), z.array(z.string())]); /** @internal */ export type Stop$Outbound = string | Array; /** @internal */ export const Stop$outboundSchema: z.ZodType = z.union([z.string(), z.array(z.string())]); export function stopToJSON(stop: Stop): string { return JSON.stringify(Stop$outboundSchema.parse(stop)); } export function stopFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Stop$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Stop' from JSON`, ); } /** @internal */ export const Truncation$inboundSchema: z.ZodNativeEnum = z .nativeEnum(Truncation); /** @internal */ export const Truncation$outboundSchema: z.ZodNativeEnum = Truncation$inboundSchema; /** @internal */ export const ServiceTier$inboundSchema: z.ZodNativeEnum = z .nativeEnum(ServiceTier); /** @internal */ export const ServiceTier$outboundSchema: z.ZodNativeEnum = ServiceTier$inboundSchema; /** @internal */ export const PrefillThink$inboundSchema: z.ZodType< PrefillThink, z.ZodTypeDef, unknown > = z.union([z.boolean(), z.string()]); /** @internal */ export type PrefillThink$Outbound = boolean | string; /** @internal */ export const PrefillThink$outboundSchema: z.ZodType< PrefillThink$Outbound, z.ZodTypeDef, PrefillThink > = z.union([z.boolean(), z.string()]); export function prefillThinkToJSON(prefillThink: PrefillThink): string { return JSON.stringify(PrefillThink$outboundSchema.parse(prefillThink)); } export function prefillThinkFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PrefillThink$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PrefillThink' from JSON`, ); } /** @internal */ export const Generation$inboundSchema: z.ZodType< Generation, z.ZodTypeDef, unknown > = collectExtraKeys$( z.object({ instructions: z.string().optional(), temperature: z.number().optional(), top_p: z.number().optional(), max_output_tokens: z.number().int().optional(), max_gen_toks: z.number().int().optional(), stop: z.union([z.string(), z.array(z.string())]).optional(), until: z.array(z.string()).optional(), max_tool_calls: z.number().int().optional(), reasoning: z.any().optional(), text: z.any().optional(), tools: z.array(z.nullable(z.any())).optional(), tool_choice: z.any().optional(), parallel_tool_calls: z.boolean().optional(), truncation: Truncation$inboundSchema.optional(), service_tier: ServiceTier$inboundSchema.optional(), presence_penalty: z.number().optional(), frequency_penalty: z.number().optional(), top_k: z.number().int().optional(), min_p: z.number().optional(), repetition_penalty: z.number().optional(), do_sample: z.boolean().optional(), extra_body: z.record(z.any()).optional(), chat_template_kwargs: z.record(z.any()).optional(), prefill_think: z.union([z.boolean(), z.string()]).optional(), use_cache: z.boolean().optional(), timeout_seconds: z.number().int().optional(), max_retries: z.number().int().optional(), max_empty_retries: z.number().int().optional(), }).catchall(z.any()), "additionalProperties", true, ).transform((v) => { return remap$(v, { "top_p": "topP", "max_output_tokens": "maxOutputTokens", "max_gen_toks": "maxGenToks", "max_tool_calls": "maxToolCalls", "tool_choice": "toolChoice", "parallel_tool_calls": "parallelToolCalls", "service_tier": "serviceTier", "presence_penalty": "presencePenalty", "frequency_penalty": "frequencyPenalty", "top_k": "topK", "min_p": "minP", "repetition_penalty": "repetitionPenalty", "do_sample": "doSample", "extra_body": "extraBody", "chat_template_kwargs": "chatTemplateKwargs", "prefill_think": "prefillThink", "use_cache": "useCache", "timeout_seconds": "timeoutSeconds", "max_retries": "maxRetries", "max_empty_retries": "maxEmptyRetries", }); }); /** @internal */ export type Generation$Outbound = { instructions?: string | undefined; temperature?: number | undefined; top_p?: number | undefined; max_output_tokens?: number | undefined; max_gen_toks?: number | undefined; stop?: string | Array | undefined; until?: Array | undefined; max_tool_calls?: number | undefined; reasoning?: any | undefined; text?: any | undefined; tools?: Array | undefined; tool_choice?: any | undefined; parallel_tool_calls?: boolean | undefined; truncation?: string | undefined; service_tier?: string | undefined; presence_penalty?: number | undefined; frequency_penalty?: number | undefined; top_k?: number | undefined; min_p?: number | undefined; repetition_penalty?: number | undefined; do_sample?: boolean | undefined; extra_body?: { [k: string]: any } | undefined; chat_template_kwargs?: { [k: string]: any } | undefined; prefill_think?: boolean | string | undefined; use_cache?: boolean | undefined; timeout_seconds?: number | undefined; max_retries?: number | undefined; max_empty_retries?: number | undefined; [additionalProperties: string]: unknown; }; /** @internal */ export const Generation$outboundSchema: z.ZodType< Generation$Outbound, z.ZodTypeDef, Generation > = z.object({ instructions: z.string().optional(), temperature: z.number().optional(), topP: z.number().optional(), maxOutputTokens: z.number().int().optional(), maxGenToks: z.number().int().optional(), stop: z.union([z.string(), z.array(z.string())]).optional(), until: z.array(z.string()).optional(), maxToolCalls: z.number().int().optional(), reasoning: z.any().optional(), text: z.any().optional(), tools: z.array(z.nullable(z.any())).optional(), toolChoice: z.any().optional(), parallelToolCalls: z.boolean().optional(), truncation: Truncation$outboundSchema.optional(), serviceTier: ServiceTier$outboundSchema.optional(), presencePenalty: z.number().optional(), frequencyPenalty: z.number().optional(), topK: z.number().int().optional(), minP: z.number().optional(), repetitionPenalty: z.number().optional(), doSample: z.boolean().optional(), extraBody: z.record(z.any()).optional(), chatTemplateKwargs: z.record(z.any()).optional(), prefillThink: z.union([z.boolean(), z.string()]).optional(), useCache: z.boolean().optional(), timeoutSeconds: z.number().int().optional(), maxRetries: z.number().int().optional(), maxEmptyRetries: z.number().int().optional(), additionalProperties: z.record(z.any()).optional(), }).transform((v) => { return { ...v.additionalProperties, ...remap$(v, { topP: "top_p", maxOutputTokens: "max_output_tokens", maxGenToks: "max_gen_toks", maxToolCalls: "max_tool_calls", toolChoice: "tool_choice", parallelToolCalls: "parallel_tool_calls", serviceTier: "service_tier", presencePenalty: "presence_penalty", frequencyPenalty: "frequency_penalty", topK: "top_k", minP: "min_p", repetitionPenalty: "repetition_penalty", doSample: "do_sample", extraBody: "extra_body", chatTemplateKwargs: "chat_template_kwargs", prefillThink: "prefill_think", useCache: "use_cache", timeoutSeconds: "timeout_seconds", maxRetries: "max_retries", maxEmptyRetries: "max_empty_retries", additionalProperties: null, }), }; }); export function generationToJSON(generation: Generation): string { return JSON.stringify(Generation$outboundSchema.parse(generation)); } export function generationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Generation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Generation' from JSON`, ); } /** @internal */ export const RequestCounts$inboundSchema: z.ZodType< RequestCounts, z.ZodTypeDef, unknown > = z.object({ total: z.number().int(), completed: z.number().int(), failed: z.number().int(), }); /** @internal */ export type RequestCounts$Outbound = { total: number; completed: number; failed: number; }; /** @internal */ export const RequestCounts$outboundSchema: z.ZodType< RequestCounts$Outbound, z.ZodTypeDef, RequestCounts > = z.object({ total: z.number().int(), completed: z.number().int(), failed: z.number().int(), }); export function requestCountsToJSON(requestCounts: RequestCounts): string { return JSON.stringify(RequestCounts$outboundSchema.parse(requestCounts)); } export function requestCountsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RequestCounts$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RequestCounts' from JSON`, ); } /** @internal */ export const CreateEvalRunResponseBody$inboundSchema: z.ZodType< CreateEvalRunResponseBody, z.ZodTypeDef, unknown > = z.object({ id: z.string(), object: z.literal("eval.run"), suite_id: z.string(), suite_version: z.number().int(), suite_version_id: z.string(), org_id: z.string(), team_id: z.string(), status: components.EvalRunStatus$inboundSchema, models: z.array(z.string()), task_ids: z.nullable(z.array(z.string())), judge_model: z.nullable(z.string()), embedding_model: z.nullable(z.string()), generation: z.lazy(() => Generation$inboundSchema), request_counts: z.lazy(() => RequestCounts$inboundSchema), metrics: z.nullable(z.record(z.any())), error: z.nullable(z.record(z.any())), artifact_file_ids: z.array(z.string()), metadata: z.record(z.string()), created_at: z.number().int(), started_at: z.nullable(z.number().int()), completed_at: z.nullable(z.number().int()), cancelled_at: z.nullable(z.number().int()), failed_at: z.nullable(z.number().int()), }).transform((v) => { return remap$(v, { "suite_id": "suiteId", "suite_version": "suiteVersion", "suite_version_id": "suiteVersionId", "org_id": "orgId", "team_id": "teamId", "task_ids": "taskIds", "judge_model": "judgeModel", "embedding_model": "embeddingModel", "request_counts": "requestCounts", "artifact_file_ids": "artifactFileIds", "created_at": "createdAt", "started_at": "startedAt", "completed_at": "completedAt", "cancelled_at": "cancelledAt", "failed_at": "failedAt", }); }); /** @internal */ export type CreateEvalRunResponseBody$Outbound = { id: string; object: "eval.run"; suite_id: string; suite_version: number; suite_version_id: string; org_id: string; team_id: string; status: string; models: Array; task_ids: Array | null; judge_model: string | null; embedding_model: string | null; generation: Generation$Outbound; request_counts: RequestCounts$Outbound; metrics: { [k: string]: any } | null; error: { [k: string]: any } | null; artifact_file_ids: Array; metadata: { [k: string]: string }; created_at: number; started_at: number | null; completed_at: number | null; cancelled_at: number | null; failed_at: number | null; }; /** @internal */ export const CreateEvalRunResponseBody$outboundSchema: z.ZodType< CreateEvalRunResponseBody$Outbound, z.ZodTypeDef, CreateEvalRunResponseBody > = z.object({ id: z.string(), object: z.literal("eval.run"), suiteId: z.string(), suiteVersion: z.number().int(), suiteVersionId: z.string(), orgId: z.string(), teamId: z.string(), status: components.EvalRunStatus$outboundSchema, models: z.array(z.string()), taskIds: z.nullable(z.array(z.string())), judgeModel: z.nullable(z.string()), embeddingModel: z.nullable(z.string()), generation: z.lazy(() => Generation$outboundSchema), requestCounts: z.lazy(() => RequestCounts$outboundSchema), metrics: z.nullable(z.record(z.any())), error: z.nullable(z.record(z.any())), artifactFileIds: z.array(z.string()), metadata: z.record(z.string()), createdAt: z.number().int(), startedAt: z.nullable(z.number().int()), completedAt: z.nullable(z.number().int()), cancelledAt: z.nullable(z.number().int()), failedAt: z.nullable(z.number().int()), }).transform((v) => { return remap$(v, { suiteId: "suite_id", suiteVersion: "suite_version", suiteVersionId: "suite_version_id", orgId: "org_id", teamId: "team_id", taskIds: "task_ids", judgeModel: "judge_model", embeddingModel: "embedding_model", requestCounts: "request_counts", artifactFileIds: "artifact_file_ids", createdAt: "created_at", startedAt: "started_at", completedAt: "completed_at", cancelledAt: "cancelled_at", failedAt: "failed_at", }); }); export function createEvalRunResponseBodyToJSON( createEvalRunResponseBody: CreateEvalRunResponseBody, ): string { return JSON.stringify( CreateEvalRunResponseBody$outboundSchema.parse(createEvalRunResponseBody), ); } export function createEvalRunResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateEvalRunResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateEvalRunResponseBody' from JSON`, ); }