/*
 * 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";

export type CompletionTrainingParameters = {
  trainingSteps?: number | null | undefined;
  learningRate: number | undefined;
  weightDecay?: number | null | undefined;
  warmupFraction?: number | null | undefined;
  epochs?: number | null | undefined;
  seqLen?: number | null | undefined;
  fimRatio?: number | null | undefined;
};

/** @internal */
export const CompletionTrainingParameters$inboundSchema: z.ZodType<
  CompletionTrainingParameters,
  z.ZodTypeDef,
  unknown
> = z.object({
  training_steps: z.nullable(z.number().int()).optional(),
  learning_rate: z.number().default(0.0001),
  weight_decay: z.nullable(z.number()).optional(),
  warmup_fraction: z.nullable(z.number()).optional(),
  epochs: z.nullable(z.number()).optional(),
  seq_len: z.nullable(z.number().int()).optional(),
  fim_ratio: z.nullable(z.number()).optional(),
}).transform((v) => {
  return remap$(v, {
    "training_steps": "trainingSteps",
    "learning_rate": "learningRate",
    "weight_decay": "weightDecay",
    "warmup_fraction": "warmupFraction",
    "seq_len": "seqLen",
    "fim_ratio": "fimRatio",
  });
});

export function completionTrainingParametersFromJSON(
  jsonString: string,
): SafeParseResult<CompletionTrainingParameters, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CompletionTrainingParameters$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CompletionTrainingParameters' from JSON`,
  );
}
