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

import * as z from "zod/v4";
import {
  AssistantMessage,
  AssistantMessage$Outbound,
  AssistantMessage$outboundSchema,
} from "./assistantmessage.js";
import {
  SystemMessage,
  SystemMessage$Outbound,
  SystemMessage$outboundSchema,
} from "./systemmessage.js";
import {
  ToolMessage,
  ToolMessage$Outbound,
  ToolMessage$outboundSchema,
} from "./toolmessage.js";
import {
  UserMessage,
  UserMessage$Outbound,
  UserMessage$outboundSchema,
} from "./usermessage.js";

export type InstructRequestMessage =
  | (AssistantMessage & { role: "assistant" })
  | SystemMessage
  | ToolMessage
  | UserMessage;

export type InstructRequest = {
  messages: Array<
    | (AssistantMessage & { role: "assistant" })
    | SystemMessage
    | ToolMessage
    | UserMessage
  >;
};

/** @internal */
export type InstructRequestMessage$Outbound =
  | (AssistantMessage$Outbound & { role: "assistant" })
  | SystemMessage$Outbound
  | ToolMessage$Outbound
  | UserMessage$Outbound;

/** @internal */
export const InstructRequestMessage$outboundSchema: z.ZodType<
  InstructRequestMessage$Outbound,
  InstructRequestMessage
> = z.union([
  AssistantMessage$outboundSchema.and(
    z.object({ role: z.literal("assistant") }),
  ),
  SystemMessage$outboundSchema,
  ToolMessage$outboundSchema,
  UserMessage$outboundSchema,
]);

export function instructRequestMessageToJSON(
  instructRequestMessage: InstructRequestMessage,
): string {
  return JSON.stringify(
    InstructRequestMessage$outboundSchema.parse(instructRequestMessage),
  );
}

/** @internal */
export type InstructRequest$Outbound = {
  messages: Array<
    | (AssistantMessage$Outbound & { role: "assistant" })
    | SystemMessage$Outbound
    | ToolMessage$Outbound
    | UserMessage$Outbound
  >;
};

/** @internal */
export const InstructRequest$outboundSchema: z.ZodType<
  InstructRequest$Outbound,
  InstructRequest
> = z.object({
  messages: z.array(
    z.union([
      AssistantMessage$outboundSchema.and(
        z.object({ role: z.literal("assistant") }),
      ),
      SystemMessage$outboundSchema,
      ToolMessage$outboundSchema,
      UserMessage$outboundSchema,
    ]),
  ),
});

export function instructRequestToJSON(
  instructRequest: InstructRequest,
): string {
  return JSON.stringify(InstructRequest$outboundSchema.parse(instructRequest));
}
