/* * 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 { SDKValidationError } from "./sdkvalidationerror.js"; /** * The type of the tool. Currently, only `function` is supported. */ export const ChatCompletionNamedToolChoiceType = { Function: "function", } as const; /** * The type of the tool. Currently, only `function` is supported. */ export type ChatCompletionNamedToolChoiceType = ClosedEnum< typeof ChatCompletionNamedToolChoiceType >; export type FunctionT = { /** * The name of the function to call. */ name: string; }; /** * Specifies a tool the model should use. Use to force the model to call a specific function. */ export type ChatCompletionNamedToolChoice = { /** * The type of the tool. Currently, only `function` is supported. */ type: ChatCompletionNamedToolChoiceType; function: FunctionT; }; /** @internal */ export const ChatCompletionNamedToolChoiceType$inboundSchema: z.ZodNativeEnum< typeof ChatCompletionNamedToolChoiceType > = z.nativeEnum(ChatCompletionNamedToolChoiceType); /** @internal */ export const ChatCompletionNamedToolChoiceType$outboundSchema: z.ZodNativeEnum< typeof ChatCompletionNamedToolChoiceType > = ChatCompletionNamedToolChoiceType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ChatCompletionNamedToolChoiceType$ { /** @deprecated use `ChatCompletionNamedToolChoiceType$inboundSchema` instead. */ export const inboundSchema = ChatCompletionNamedToolChoiceType$inboundSchema; /** @deprecated use `ChatCompletionNamedToolChoiceType$outboundSchema` instead. */ export const outboundSchema = ChatCompletionNamedToolChoiceType$outboundSchema; } /** @internal */ export const FunctionT$inboundSchema: z.ZodType< FunctionT, z.ZodTypeDef, unknown > = z.object({ name: z.string(), }); /** @internal */ export type FunctionT$Outbound = { name: string; }; /** @internal */ export const FunctionT$outboundSchema: z.ZodType< FunctionT$Outbound, z.ZodTypeDef, FunctionT > = z.object({ name: z.string(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace FunctionT$ { /** @deprecated use `FunctionT$inboundSchema` instead. */ export const inboundSchema = FunctionT$inboundSchema; /** @deprecated use `FunctionT$outboundSchema` instead. */ export const outboundSchema = FunctionT$outboundSchema; /** @deprecated use `FunctionT$Outbound` instead. */ export type Outbound = FunctionT$Outbound; } export function functionToJSON(functionT: FunctionT): string { return JSON.stringify(FunctionT$outboundSchema.parse(functionT)); } export function functionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FunctionT$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FunctionT' from JSON`, ); } /** @internal */ export const ChatCompletionNamedToolChoice$inboundSchema: z.ZodType< ChatCompletionNamedToolChoice, z.ZodTypeDef, unknown > = z.object({ type: ChatCompletionNamedToolChoiceType$inboundSchema, function: z.lazy(() => FunctionT$inboundSchema), }); /** @internal */ export type ChatCompletionNamedToolChoice$Outbound = { type: string; function: FunctionT$Outbound; }; /** @internal */ export const ChatCompletionNamedToolChoice$outboundSchema: z.ZodType< ChatCompletionNamedToolChoice$Outbound, z.ZodTypeDef, ChatCompletionNamedToolChoice > = z.object({ type: ChatCompletionNamedToolChoiceType$outboundSchema, function: z.lazy(() => FunctionT$outboundSchema), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ChatCompletionNamedToolChoice$ { /** @deprecated use `ChatCompletionNamedToolChoice$inboundSchema` instead. */ export const inboundSchema = ChatCompletionNamedToolChoice$inboundSchema; /** @deprecated use `ChatCompletionNamedToolChoice$outboundSchema` instead. */ export const outboundSchema = ChatCompletionNamedToolChoice$outboundSchema; /** @deprecated use `ChatCompletionNamedToolChoice$Outbound` instead. */ export type Outbound = ChatCompletionNamedToolChoice$Outbound; } export function chatCompletionNamedToolChoiceToJSON( chatCompletionNamedToolChoice: ChatCompletionNamedToolChoice, ): string { return JSON.stringify( ChatCompletionNamedToolChoice$outboundSchema.parse( chatCompletionNamedToolChoice, ), ); } export function chatCompletionNamedToolChoiceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ChatCompletionNamedToolChoice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChatCompletionNamedToolChoice' from JSON`, ); }