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

import * as z from "zod/v3";
import {
  FunctionName,
  FunctionName$Outbound,
  FunctionName$outboundSchema,
} from "./functionname.js";
import { ToolTypes, ToolTypes$outboundSchema } from "./tooltypes.js";

/**
 * ToolChoice is either a ToolChoiceEnum or a ToolChoice
 */
export type ToolChoice = {
  type?: ToolTypes | undefined;
  /**
   * this restriction of `Function` is used to select a specific function to call
   */
  function: FunctionName;
};

/** @internal */
export type ToolChoice$Outbound = {
  type?: string | undefined;
  function: FunctionName$Outbound;
};

/** @internal */
export const ToolChoice$outboundSchema: z.ZodType<
  ToolChoice$Outbound,
  z.ZodTypeDef,
  ToolChoice
> = z.object({
  type: ToolTypes$outboundSchema.optional(),
  function: FunctionName$outboundSchema,
});

export function toolChoiceToJSON(toolChoice: ToolChoice): string {
  return JSON.stringify(ToolChoice$outboundSchema.parse(toolChoice));
}
