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

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

/**
 * Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content.
 */
export type Prediction = {
  type?: "content" | undefined;
  content?: string | undefined;
};

/** @internal */
export const Prediction$inboundSchema: z.ZodType<
  Prediction,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: z.literal("content").default("content"),
  content: z.string().default(""),
});
/** @internal */
export type Prediction$Outbound = {
  type: "content";
  content: string;
};

/** @internal */
export const Prediction$outboundSchema: z.ZodType<
  Prediction$Outbound,
  z.ZodTypeDef,
  Prediction
> = z.object({
  type: z.literal("content").default("content" as const),
  content: z.string().default(""),
});

export function predictionToJSON(prediction: Prediction): string {
  return JSON.stringify(Prediction$outboundSchema.parse(prediction));
}
export function predictionFromJSON(
  jsonString: string,
): SafeParseResult<Prediction, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => Prediction$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'Prediction' from JSON`,
  );
}
