/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 51417fff99a1
 */

import * as z from "zod/v4";
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 { Metric, Metric$inboundSchema } from "./metric.js";

export type Checkpoint = {
  /**
   * Metrics at the step number during the fine-tuning job. Use these metrics to assess if the training is going smoothly (loss should decrease, token accuracy should increase).
   */
  metrics: Metric;
  /**
   * The step number that the checkpoint was created at.
   */
  stepNumber: number;
  /**
   * The UNIX timestamp (in seconds) for when the checkpoint was created.
   */
  createdAt: number;
};

/** @internal */
export const Checkpoint$inboundSchema: z.ZodType<Checkpoint, unknown> = z
  .object({
    metrics: Metric$inboundSchema,
    step_number: z.int(),
    created_at: z.int(),
  }).transform((v) => {
    return remap$(v, {
      "step_number": "stepNumber",
      "created_at": "createdAt",
    });
  });

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