/*
 * 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 {
  ClassifierTrainingParameters,
  ClassifierTrainingParameters$inboundSchema,
} from "./classifiertrainingparameters.js";
import {
  JobMetadataOut,
  JobMetadataOut$inboundSchema,
} from "./jobmetadataout.js";
import {
  WandbIntegrationOut,
  WandbIntegrationOut$inboundSchema,
} from "./wandbintegrationout.js";

/**
 * The current status of the fine-tuning job.
 */
export const ClassifierJobOutStatus = {
  Queued: "QUEUED",
  Started: "STARTED",
  Validating: "VALIDATING",
  Validated: "VALIDATED",
  Running: "RUNNING",
  FailedValidation: "FAILED_VALIDATION",
  Failed: "FAILED",
  Success: "SUCCESS",
  Cancelled: "CANCELLED",
  CancellationRequested: "CANCELLATION_REQUESTED",
} as const;
/**
 * The current status of the fine-tuning job.
 */
export type ClassifierJobOutStatus = ClosedEnum<typeof ClassifierJobOutStatus>;

export type ClassifierJobOutIntegrations = WandbIntegrationOut;

export type ClassifierJobOut = {
  /**
   * The ID of the job.
   */
  id: string;
  autoStart: boolean;
  model: string;
  /**
   * The current status of the fine-tuning job.
   */
  status: ClassifierJobOutStatus;
  /**
   * The UNIX timestamp (in seconds) for when the fine-tuning job was created.
   */
  createdAt: number;
  /**
   * The UNIX timestamp (in seconds) for when the fine-tuning job was last modified.
   */
  modifiedAt: number;
  /**
   * A list containing the IDs of uploaded files that contain training data.
   */
  trainingFiles: Array<string>;
  /**
   * A list containing the IDs of uploaded files that contain validation data.
   */
  validationFiles?: Array<string> | null | undefined;
  /**
   * The object type of the fine-tuning job.
   */
  object?: "job" | undefined;
  /**
   * The name of the fine-tuned model that is being created. The value will be `null` if the fine-tuning job is still running.
   */
  fineTunedModel?: string | null | undefined;
  /**
   * Optional text/code that adds more context for the model. When given a `prompt` and a `suffix` the model will fill what is between them. When `suffix` is not provided, the model will simply execute completion starting with `prompt`.
   */
  suffix?: string | null | undefined;
  /**
   * A list of integrations enabled for your fine-tuning job.
   */
  integrations?: Array<WandbIntegrationOut> | null | undefined;
  /**
   * Total number of tokens trained.
   */
  trainedTokens?: number | null | undefined;
  metadata?: JobMetadataOut | null | undefined;
  /**
   * The type of job (`FT` for fine-tuning).
   */
  jobType?: "classifier" | undefined;
  hyperparameters: ClassifierTrainingParameters;
};

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

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

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

/** @internal */
export const ClassifierJobOut$inboundSchema: z.ZodType<
  ClassifierJobOut,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: z.string(),
  auto_start: z.boolean(),
  model: z.string(),
  status: ClassifierJobOutStatus$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,
}).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",
  });
});

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