/* * 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 { FunctionObject, FunctionObject$inboundSchema, FunctionObject$Outbound, FunctionObject$outboundSchema, } from "./functionobject.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * The type of the tool. Currently, only `function` is supported. */ export const Type = { Function: "function", } as const; /** * The type of the tool. Currently, only `function` is supported. */ export type Type = ClosedEnum; export type ChatCompletionTool = { /** * The type of the tool. Currently, only `function` is supported. */ type: Type; function: FunctionObject; }; /** @internal */ export const Type$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Type, ); /** @internal */ export const Type$outboundSchema: z.ZodNativeEnum = Type$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Type$ { /** @deprecated use `Type$inboundSchema` instead. */ export const inboundSchema = Type$inboundSchema; /** @deprecated use `Type$outboundSchema` instead. */ export const outboundSchema = Type$outboundSchema; } /** @internal */ export const ChatCompletionTool$inboundSchema: z.ZodType< ChatCompletionTool, z.ZodTypeDef, unknown > = z.object({ type: Type$inboundSchema, function: FunctionObject$inboundSchema, }); /** @internal */ export type ChatCompletionTool$Outbound = { type: string; function: FunctionObject$Outbound; }; /** @internal */ export const ChatCompletionTool$outboundSchema: z.ZodType< ChatCompletionTool$Outbound, z.ZodTypeDef, ChatCompletionTool > = z.object({ type: Type$outboundSchema, function: FunctionObject$outboundSchema, }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ChatCompletionTool$ { /** @deprecated use `ChatCompletionTool$inboundSchema` instead. */ export const inboundSchema = ChatCompletionTool$inboundSchema; /** @deprecated use `ChatCompletionTool$outboundSchema` instead. */ export const outboundSchema = ChatCompletionTool$outboundSchema; /** @deprecated use `ChatCompletionTool$Outbound` instead. */ export type Outbound = ChatCompletionTool$Outbound; } export function chatCompletionToolToJSON( chatCompletionTool: ChatCompletionTool, ): string { return JSON.stringify( ChatCompletionTool$outboundSchema.parse(chatCompletionTool), ); } export function chatCompletionToolFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ChatCompletionTool$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChatCompletionTool' from JSON`, ); }