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

import * as z from "zod/v3";
import { remap as remap$ } from "../../lib/primitives.js";
import {
  JudgeClassificationOutput,
  JudgeClassificationOutput$Outbound,
  JudgeClassificationOutput$outboundSchema,
} from "./judgeclassificationoutput.js";
import {
  JudgeRegressionOutput,
  JudgeRegressionOutput$Outbound,
  JudgeRegressionOutput$outboundSchema,
} from "./judgeregressionoutput.js";

export type PutJudgeInSchemaOutput =
  | (JudgeClassificationOutput & { type: "CLASSIFICATION" })
  | (JudgeRegressionOutput & { type: "REGRESSION" });

export type PutJudgeInSchema = {
  name: string;
  description: string;
  modelName: string;
  output:
    | (JudgeClassificationOutput & { type: "CLASSIFICATION" })
    | (JudgeRegressionOutput & { type: "REGRESSION" });
  instructions: string;
  tools: Array<string>;
};

/** @internal */
export type PutJudgeInSchemaOutput$Outbound =
  | (JudgeClassificationOutput$Outbound & { type: "CLASSIFICATION" })
  | (JudgeRegressionOutput$Outbound & { type: "REGRESSION" });

/** @internal */
export const PutJudgeInSchemaOutput$outboundSchema: z.ZodType<
  PutJudgeInSchemaOutput$Outbound,
  z.ZodTypeDef,
  PutJudgeInSchemaOutput
> = z.union([
  JudgeClassificationOutput$outboundSchema.and(
    z.object({ type: z.literal("CLASSIFICATION") }),
  ),
  JudgeRegressionOutput$outboundSchema.and(
    z.object({ type: z.literal("REGRESSION") }),
  ),
]);

export function putJudgeInSchemaOutputToJSON(
  putJudgeInSchemaOutput: PutJudgeInSchemaOutput,
): string {
  return JSON.stringify(
    PutJudgeInSchemaOutput$outboundSchema.parse(putJudgeInSchemaOutput),
  );
}

/** @internal */
export type PutJudgeInSchema$Outbound = {
  name: string;
  description: string;
  model_name: string;
  output:
    | (JudgeClassificationOutput$Outbound & { type: "CLASSIFICATION" })
    | (JudgeRegressionOutput$Outbound & { type: "REGRESSION" });
  instructions: string;
  tools: Array<string>;
};

/** @internal */
export const PutJudgeInSchema$outboundSchema: z.ZodType<
  PutJudgeInSchema$Outbound,
  z.ZodTypeDef,
  PutJudgeInSchema
> = z.object({
  name: z.string(),
  description: z.string(),
  modelName: z.string(),
  output: z.union([
    JudgeClassificationOutput$outboundSchema.and(
      z.object({ type: z.literal("CLASSIFICATION") }),
    ),
    JudgeRegressionOutput$outboundSchema.and(
      z.object({ type: z.literal("REGRESSION") }),
    ),
  ]),
  instructions: z.string(),
  tools: z.array(z.string()),
}).transform((v) => {
  return remap$(v, {
    modelName: "model_name",
  });
});

export function putJudgeInSchemaToJSON(
  putJudgeInSchema: PutJudgeInSchema,
): string {
  return JSON.stringify(
    PutJudgeInSchema$outboundSchema.parse(putJudgeInSchema),
  );
}
