/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { safeParse } from "../lib/schemas.js"; import { ClosedEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { ChatCompletionNamedToolChoice, ChatCompletionNamedToolChoice$inboundSchema, ChatCompletionNamedToolChoice$Outbound, ChatCompletionNamedToolChoice$outboundSchema, } from "./chatcompletionnamedtoolchoice.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` or `any` means the model must call one or more tools. * * @remarks */ export const ChatCompletionToolChoiceOption1 = { None: "none", Auto: "auto", Any: "any", Required: "required", } as const; /** * `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` or `any` means the model must call one or more tools. * * @remarks */ export type ChatCompletionToolChoiceOption1 = ClosedEnum< typeof ChatCompletionToolChoiceOption1 >; /** * Controls which (if any) tool is called by the model. * * @remarks * `none` means the model will not call any tool and instead generates a message. * `auto` means the model can pick between generating a message or calling one or more tools. * `required` or "any" means the model must call one or more tools. * Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. * * `none` is the default when no tools are present. `auto` is the default if tools are present. */ export type ChatCompletionToolChoiceOption = | ChatCompletionNamedToolChoice | ChatCompletionToolChoiceOption1; /** @internal */ export const ChatCompletionToolChoiceOption1$inboundSchema: z.ZodNativeEnum< typeof ChatCompletionToolChoiceOption1 > = z.nativeEnum(ChatCompletionToolChoiceOption1); /** @internal */ export const ChatCompletionToolChoiceOption1$outboundSchema: z.ZodNativeEnum< typeof ChatCompletionToolChoiceOption1 > = ChatCompletionToolChoiceOption1$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ChatCompletionToolChoiceOption1$ { /** @deprecated use `ChatCompletionToolChoiceOption1$inboundSchema` instead. */ export const inboundSchema = ChatCompletionToolChoiceOption1$inboundSchema; /** @deprecated use `ChatCompletionToolChoiceOption1$outboundSchema` instead. */ export const outboundSchema = ChatCompletionToolChoiceOption1$outboundSchema; } /** @internal */ export const ChatCompletionToolChoiceOption$inboundSchema: z.ZodType< ChatCompletionToolChoiceOption, z.ZodTypeDef, unknown > = z.union([ ChatCompletionNamedToolChoice$inboundSchema, ChatCompletionToolChoiceOption1$inboundSchema, ]); /** @internal */ export type ChatCompletionToolChoiceOption$Outbound = | ChatCompletionNamedToolChoice$Outbound | string; /** @internal */ export const ChatCompletionToolChoiceOption$outboundSchema: z.ZodType< ChatCompletionToolChoiceOption$Outbound, z.ZodTypeDef, ChatCompletionToolChoiceOption > = z.union([ ChatCompletionNamedToolChoice$outboundSchema, ChatCompletionToolChoiceOption1$outboundSchema, ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ChatCompletionToolChoiceOption$ { /** @deprecated use `ChatCompletionToolChoiceOption$inboundSchema` instead. */ export const inboundSchema = ChatCompletionToolChoiceOption$inboundSchema; /** @deprecated use `ChatCompletionToolChoiceOption$outboundSchema` instead. */ export const outboundSchema = ChatCompletionToolChoiceOption$outboundSchema; /** @deprecated use `ChatCompletionToolChoiceOption$Outbound` instead. */ export type Outbound = ChatCompletionToolChoiceOption$Outbound; } export function chatCompletionToolChoiceOptionToJSON( chatCompletionToolChoiceOption: ChatCompletionToolChoiceOption, ): string { return JSON.stringify( ChatCompletionToolChoiceOption$outboundSchema.parse( chatCompletionToolChoiceOption, ), ); } export function chatCompletionToolChoiceOptionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ChatCompletionToolChoiceOption$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChatCompletionToolChoiceOption' from JSON`, ); }