/* * 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 { FineTuningError, FineTuningError$inboundSchema, FineTuningError$Outbound, FineTuningError$outboundSchema, } from "./finetuningerror.js"; import { IntegrationObject, IntegrationObject$inboundSchema, IntegrationObject$Outbound, IntegrationObject$outboundSchema, } from "./integrationobject.js"; import { JobStatus, JobStatus$inboundSchema, JobStatus$outboundSchema, } from "./jobstatus.js"; import { Method, Method$inboundSchema, Method$Outbound, Method$outboundSchema, } from "./method.js"; export type FineTuningJobBatchSize = string | number; export type FineTuningJobLearningRateMultiplier = string | number; export type FineTuningJobNEpochs = string | number; export type FineTuningJobHyperparameters = { batchSize?: string | number | null | undefined; learningRateMultiplier?: string | number | null | undefined; nEpochs?: string | number | null | undefined; }; export type FineTuningJob = { id: string; object: "fine_tuning.job"; createdAt: number; model: string; trainingFile: string; validationFile?: string | null | undefined; fineTunedModel?: string | null | undefined; organizationId: string; status: JobStatus; resultFiles: Array; seed: number; hyperparameters: FineTuningJobHyperparameters; method?: Method | null | undefined; finishedAt?: number | null | undefined; estimatedFinish?: number | null | undefined; trainedTokens?: number | null | undefined; error?: FineTuningError | null | undefined; integrations?: Array | null | undefined; metadata?: { [k: string]: string } | null | undefined; suffix?: string | null | undefined; }; /** @internal */ export const FineTuningJobBatchSize$inboundSchema: z.ZodType< FineTuningJobBatchSize, z.ZodTypeDef, unknown > = z.union([z.string(), z.number().int()]); /** @internal */ export type FineTuningJobBatchSize$Outbound = string | number; /** @internal */ export const FineTuningJobBatchSize$outboundSchema: z.ZodType< FineTuningJobBatchSize$Outbound, z.ZodTypeDef, FineTuningJobBatchSize > = z.union([z.string(), z.number().int()]); export function fineTuningJobBatchSizeToJSON( fineTuningJobBatchSize: FineTuningJobBatchSize, ): string { return JSON.stringify( FineTuningJobBatchSize$outboundSchema.parse(fineTuningJobBatchSize), ); } export function fineTuningJobBatchSizeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FineTuningJobBatchSize$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FineTuningJobBatchSize' from JSON`, ); } /** @internal */ export const FineTuningJobLearningRateMultiplier$inboundSchema: z.ZodType< FineTuningJobLearningRateMultiplier, z.ZodTypeDef, unknown > = z.union([z.string(), z.number()]); /** @internal */ export type FineTuningJobLearningRateMultiplier$Outbound = string | number; /** @internal */ export const FineTuningJobLearningRateMultiplier$outboundSchema: z.ZodType< FineTuningJobLearningRateMultiplier$Outbound, z.ZodTypeDef, FineTuningJobLearningRateMultiplier > = z.union([z.string(), z.number()]); export function fineTuningJobLearningRateMultiplierToJSON( fineTuningJobLearningRateMultiplier: FineTuningJobLearningRateMultiplier, ): string { return JSON.stringify( FineTuningJobLearningRateMultiplier$outboundSchema.parse( fineTuningJobLearningRateMultiplier, ), ); } export function fineTuningJobLearningRateMultiplierFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FineTuningJobLearningRateMultiplier$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FineTuningJobLearningRateMultiplier' from JSON`, ); } /** @internal */ export const FineTuningJobNEpochs$inboundSchema: z.ZodType< FineTuningJobNEpochs, z.ZodTypeDef, unknown > = z.union([z.string(), z.number().int()]); /** @internal */ export type FineTuningJobNEpochs$Outbound = string | number; /** @internal */ export const FineTuningJobNEpochs$outboundSchema: z.ZodType< FineTuningJobNEpochs$Outbound, z.ZodTypeDef, FineTuningJobNEpochs > = z.union([z.string(), z.number().int()]); export function fineTuningJobNEpochsToJSON( fineTuningJobNEpochs: FineTuningJobNEpochs, ): string { return JSON.stringify( FineTuningJobNEpochs$outboundSchema.parse(fineTuningJobNEpochs), ); } export function fineTuningJobNEpochsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FineTuningJobNEpochs$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FineTuningJobNEpochs' from JSON`, ); } /** @internal */ export const FineTuningJobHyperparameters$inboundSchema: z.ZodType< FineTuningJobHyperparameters, z.ZodTypeDef, unknown > = z.object({ batch_size: z.nullable(z.union([z.string(), z.number().int()])).optional(), learning_rate_multiplier: z.nullable(z.union([z.string(), z.number()])) .optional(), n_epochs: z.nullable(z.union([z.string(), z.number().int()])).optional(), }).transform((v) => { return remap$(v, { "batch_size": "batchSize", "learning_rate_multiplier": "learningRateMultiplier", "n_epochs": "nEpochs", }); }); /** @internal */ export type FineTuningJobHyperparameters$Outbound = { batch_size?: string | number | null | undefined; learning_rate_multiplier?: string | number | null | undefined; n_epochs?: string | number | null | undefined; }; /** @internal */ export const FineTuningJobHyperparameters$outboundSchema: z.ZodType< FineTuningJobHyperparameters$Outbound, z.ZodTypeDef, FineTuningJobHyperparameters > = z.object({ batchSize: z.nullable(z.union([z.string(), z.number().int()])).optional(), learningRateMultiplier: z.nullable(z.union([z.string(), z.number()])) .optional(), nEpochs: z.nullable(z.union([z.string(), z.number().int()])).optional(), }).transform((v) => { return remap$(v, { batchSize: "batch_size", learningRateMultiplier: "learning_rate_multiplier", nEpochs: "n_epochs", }); }); export function fineTuningJobHyperparametersToJSON( fineTuningJobHyperparameters: FineTuningJobHyperparameters, ): string { return JSON.stringify( FineTuningJobHyperparameters$outboundSchema.parse( fineTuningJobHyperparameters, ), ); } export function fineTuningJobHyperparametersFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FineTuningJobHyperparameters$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FineTuningJobHyperparameters' from JSON`, ); } /** @internal */ export const FineTuningJob$inboundSchema: z.ZodType< FineTuningJob, z.ZodTypeDef, unknown > = z.object({ id: z.string(), object: z.literal("fine_tuning.job"), created_at: z.number().int(), model: z.string(), training_file: z.string(), validation_file: z.nullable(z.string()).optional(), fine_tuned_model: z.nullable(z.string()).optional(), organization_id: z.string(), status: JobStatus$inboundSchema, result_files: z.array(z.string()), seed: z.number().int(), hyperparameters: z.lazy(() => FineTuningJobHyperparameters$inboundSchema), method: z.nullable(Method$inboundSchema).optional(), finished_at: z.nullable(z.number().int()).optional(), estimated_finish: z.nullable(z.number().int()).optional(), trained_tokens: z.nullable(z.number().int()).optional(), error: z.nullable(FineTuningError$inboundSchema).optional(), integrations: z.nullable(z.array(IntegrationObject$inboundSchema)).optional(), metadata: z.nullable(z.record(z.string())).optional(), suffix: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "created_at": "createdAt", "training_file": "trainingFile", "validation_file": "validationFile", "fine_tuned_model": "fineTunedModel", "organization_id": "organizationId", "result_files": "resultFiles", "finished_at": "finishedAt", "estimated_finish": "estimatedFinish", "trained_tokens": "trainedTokens", }); }); /** @internal */ export type FineTuningJob$Outbound = { id: string; object: "fine_tuning.job"; created_at: number; model: string; training_file: string; validation_file?: string | null | undefined; fine_tuned_model?: string | null | undefined; organization_id: string; status: string; result_files: Array; seed: number; hyperparameters: FineTuningJobHyperparameters$Outbound; method?: Method$Outbound | null | undefined; finished_at?: number | null | undefined; estimated_finish?: number | null | undefined; trained_tokens?: number | null | undefined; error?: FineTuningError$Outbound | null | undefined; integrations?: Array | null | undefined; metadata?: { [k: string]: string } | null | undefined; suffix?: string | null | undefined; }; /** @internal */ export const FineTuningJob$outboundSchema: z.ZodType< FineTuningJob$Outbound, z.ZodTypeDef, FineTuningJob > = z.object({ id: z.string(), object: z.literal("fine_tuning.job"), createdAt: z.number().int(), model: z.string(), trainingFile: z.string(), validationFile: z.nullable(z.string()).optional(), fineTunedModel: z.nullable(z.string()).optional(), organizationId: z.string(), status: JobStatus$outboundSchema, resultFiles: z.array(z.string()), seed: z.number().int(), hyperparameters: z.lazy(() => FineTuningJobHyperparameters$outboundSchema), method: z.nullable(Method$outboundSchema).optional(), finishedAt: z.nullable(z.number().int()).optional(), estimatedFinish: z.nullable(z.number().int()).optional(), trainedTokens: z.nullable(z.number().int()).optional(), error: z.nullable(FineTuningError$outboundSchema).optional(), integrations: z.nullable(z.array(IntegrationObject$outboundSchema)) .optional(), metadata: z.nullable(z.record(z.string())).optional(), suffix: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { createdAt: "created_at", trainingFile: "training_file", validationFile: "validation_file", fineTunedModel: "fine_tuned_model", organizationId: "organization_id", resultFiles: "result_files", finishedAt: "finished_at", estimatedFinish: "estimated_finish", trainedTokens: "trained_tokens", }); }); export function fineTuningJobToJSON(fineTuningJob: FineTuningJob): string { return JSON.stringify(FineTuningJob$outboundSchema.parse(fineTuningJob)); } export function fineTuningJobFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FineTuningJob$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FineTuningJob' from JSON`, ); }