/*
 * 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";
import {
  ModelCapabilities,
  ModelCapabilities$inboundSchema,
} from "./modelcapabilities.js";

/**
 * Extra fields for fine-tuned models.
 */
export type FTModelCard = {
  id: string;
  object: string | undefined;
  created?: number | undefined;
  ownedBy: string | undefined;
  capabilities: ModelCapabilities;
  name?: string | null | undefined;
  description?: string | null | undefined;
  maxContextLength: number | undefined;
  aliases?: Array<string> | undefined;
  deprecation?: Date | null | undefined;
  deprecationReplacementModel?: string | null | undefined;
  defaultModelTemperature?: number | null | undefined;
  type?: "fine-tuned" | undefined;
  job: string;
  root: string;
  archived: boolean | undefined;
};

/** @internal */
export const FTModelCard$inboundSchema: z.ZodType<
  FTModelCard,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: z.string(),
  object: z.string().default("model"),
  created: z.number().int().optional(),
  owned_by: z.string().default("mistralai"),
  capabilities: ModelCapabilities$inboundSchema,
  name: z.nullable(z.string()).optional(),
  description: z.nullable(z.string()).optional(),
  max_context_length: z.number().int().default(32768),
  aliases: z.array(z.string()).optional(),
  deprecation: z.nullable(
    z.string().datetime({ offset: true }).transform(v => new Date(v)),
  ).optional(),
  deprecation_replacement_model: z.nullable(z.string()).optional(),
  default_model_temperature: z.nullable(z.number()).optional(),
  type: z.literal("fine-tuned").default("fine-tuned"),
  job: z.string(),
  root: z.string(),
  archived: z.boolean().default(false),
}).transform((v) => {
  return remap$(v, {
    "owned_by": "ownedBy",
    "max_context_length": "maxContextLength",
    "deprecation_replacement_model": "deprecationReplacementModel",
    "default_model_temperature": "defaultModelTemperature",
  });
});

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