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

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import * as openEnums from "../../types/enums.js";
import { OpenEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import { Checkpoint, Checkpoint$inboundSchema } from "./checkpoint.js";
import {
  ClassifierTargetResult,
  ClassifierTargetResult$inboundSchema,
} from "./classifiertargetresult.js";
import {
  ClassifierTrainingParameters,
  ClassifierTrainingParameters$inboundSchema,
} from "./classifiertrainingparameters.js";
import { Event, Event$inboundSchema } from "./event.js";
import { JobMetadata, JobMetadata$inboundSchema } from "./jobmetadata.js";
import {
  WandbIntegrationResult,
  WandbIntegrationResult$inboundSchema,
} from "./wandbintegrationresult.js";

export const ClassifierFineTuningJobDetailsStatus = {
  Queued: "QUEUED",
  Started: "STARTED",
  Validating: "VALIDATING",
  Validated: "VALIDATED",
  Running: "RUNNING",
  FailedValidation: "FAILED_VALIDATION",
  Failed: "FAILED",
  Success: "SUCCESS",
  Cancelled: "CANCELLED",
  CancellationRequested: "CANCELLATION_REQUESTED",
} as const;
export type ClassifierFineTuningJobDetailsStatus = OpenEnum<
  typeof ClassifierFineTuningJobDetailsStatus
>;

export type ClassifierFineTuningJobDetailsIntegration = WandbIntegrationResult;

export type ClassifierFineTuningJobDetails = {
  id: string;
  autoStart: boolean;
  model: string;
  status: ClassifierFineTuningJobDetailsStatus;
  createdAt: number;
  modifiedAt: number;
  trainingFiles: Array<string>;
  validationFiles?: Array<string> | null | undefined;
  object: "job";
  fineTunedModel?: string | null | undefined;
  suffix?: string | null | undefined;
  integrations?: Array<WandbIntegrationResult> | null | undefined;
  trainedTokens?: number | null | undefined;
  metadata?: JobMetadata | null | undefined;
  jobType: "classifier";
  hyperparameters: ClassifierTrainingParameters;
  /**
   * Event items are created every time the status of a fine-tuning job changes. The timestamped list of all events is accessible here.
   */
  events?: Array<Event> | undefined;
  checkpoints?: Array<Checkpoint> | undefined;
  classifierTargets: Array<ClassifierTargetResult>;
};

/** @internal */
export const ClassifierFineTuningJobDetailsStatus$inboundSchema: z.ZodType<
  ClassifierFineTuningJobDetailsStatus,
  unknown
> = openEnums.inboundSchema(ClassifierFineTuningJobDetailsStatus);

/** @internal */
export const ClassifierFineTuningJobDetailsIntegration$inboundSchema: z.ZodType<
  ClassifierFineTuningJobDetailsIntegration,
  unknown
> = WandbIntegrationResult$inboundSchema;

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

/** @internal */
export const ClassifierFineTuningJobDetails$inboundSchema: z.ZodType<
  ClassifierFineTuningJobDetails,
  unknown
> = z.object({
  id: z.string(),
  auto_start: z.boolean(),
  model: z.string(),
  status: ClassifierFineTuningJobDetailsStatus$inboundSchema,
  created_at: z.int(),
  modified_at: z.int(),
  training_files: z.array(z.string()),
  validation_files: z.nullable(z.array(z.string())).optional(),
  object: z.literal("job").default("job"),
  fine_tuned_model: z.nullable(z.string()).optional(),
  suffix: z.nullable(z.string()).optional(),
  integrations: z.nullable(z.array(WandbIntegrationResult$inboundSchema))
    .optional(),
  trained_tokens: z.nullable(z.int()).optional(),
  metadata: z.nullable(JobMetadata$inboundSchema).optional(),
  job_type: z.literal("classifier"),
  hyperparameters: ClassifierTrainingParameters$inboundSchema,
  events: z.array(Event$inboundSchema).optional(),
  checkpoints: z.array(Checkpoint$inboundSchema).optional(),
  classifier_targets: z.array(ClassifierTargetResult$inboundSchema),
}).transform((v) => {
  return remap$(v, {
    "auto_start": "autoStart",
    "created_at": "createdAt",
    "modified_at": "modifiedAt",
    "training_files": "trainingFiles",
    "validation_files": "validationFiles",
    "fine_tuned_model": "fineTunedModel",
    "trained_tokens": "trainedTokens",
    "job_type": "jobType",
    "classifier_targets": "classifierTargets",
  });
});

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