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

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { smartUnion } from "../../types/smartUnion.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type Answer = string | number;

export type JudgeOutput = {
  analysis: string;
  answer: string | number;
};

/** @internal */
export const Answer$inboundSchema: z.ZodType<Answer, unknown> = smartUnion([
  z.string(),
  z.number(),
]);

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

/** @internal */
export const JudgeOutput$inboundSchema: z.ZodType<JudgeOutput, unknown> = z
  .object({
    analysis: z.string(),
    answer: smartUnion([z.string(), z.number()]),
  });

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