/*
 * 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 { ClosedEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import { CheckpointOut, CheckpointOut$inboundSchema } from "./checkpointout.js";
import {
  ClassifierTargetOut,
  ClassifierTargetOut$inboundSchema,
} from "./classifiertargetout.js";
import {
  ClassifierTrainingParameters,
  ClassifierTrainingParameters$inboundSchema,
} from "./classifiertrainingparameters.js";
import { EventOut, EventOut$inboundSchema } from "./eventout.js";
import {
  JobMetadataOut,
  JobMetadataOut$inboundSchema,
} from "./jobmetadataout.js";
import {
  WandbIntegrationOut,
  WandbIntegrationOut$inboundSchema,
} from "./wandbintegrationout.js";

export const ClassifierDetailedJobOutStatus = {
  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 ClassifierDetailedJobOutStatus = ClosedEnum<
  typeof ClassifierDetailedJobOutStatus
>;

export type ClassifierDetailedJobOutIntegrations = WandbIntegrationOut;

export type ClassifierDetailedJobOut = {
  id: string;
  autoStart: boolean;
  model: string;
  status: ClassifierDetailedJobOutStatus;
  createdAt: number;
  modifiedAt: number;
  trainingFiles: Array<string>;
  validationFiles?: Array<string> | null | undefined;
  object?: "job" | undefined;
  fineTunedModel?: string | null | undefined;
  suffix?: string | null | undefined;
  integrations?: Array<WandbIntegrationOut> | null | undefined;
  trainedTokens?: number | null | undefined;
  metadata?: JobMetadataOut | null | undefined;
  jobType?: "classifier" | undefined;
  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<EventOut> | undefined;
  checkpoints?: Array<CheckpointOut> | undefined;
  classifierTargets: Array<ClassifierTargetOut>;
};

/** @internal */
export const ClassifierDetailedJobOutStatus$inboundSchema: z.ZodNativeEnum<
  typeof ClassifierDetailedJobOutStatus
> = z.nativeEnum(ClassifierDetailedJobOutStatus);

/** @internal */
export const ClassifierDetailedJobOutIntegrations$inboundSchema: z.ZodType<
  ClassifierDetailedJobOutIntegrations,
  z.ZodTypeDef,
  unknown
> = WandbIntegrationOut$inboundSchema;

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

/** @internal */
export const ClassifierDetailedJobOut$inboundSchema: z.ZodType<
  ClassifierDetailedJobOut,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: z.string(),
  auto_start: z.boolean(),
  model: z.string(),
  status: ClassifierDetailedJobOutStatus$inboundSchema,
  created_at: z.number().int(),
  modified_at: z.number().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(WandbIntegrationOut$inboundSchema))
    .optional(),
  trained_tokens: z.nullable(z.number().int()).optional(),
  metadata: z.nullable(JobMetadataOut$inboundSchema).optional(),
  job_type: z.literal("classifier").default("classifier"),
  hyperparameters: ClassifierTrainingParameters$inboundSchema,
  events: z.array(EventOut$inboundSchema).optional(),
  checkpoints: z.array(CheckpointOut$inboundSchema).optional(),
  classifier_targets: z.array(ClassifierTargetOut$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 classifierDetailedJobOutFromJSON(
  jsonString: string,
): SafeParseResult<ClassifierDetailedJobOut, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ClassifierDetailedJobOut$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ClassifierDetailedJobOut' from JSON`,
  );
}
