/* * 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 { ChatCompletionMessageToolCallFunction, ChatCompletionMessageToolCallFunction$inboundSchema, ChatCompletionMessageToolCallFunction$Outbound, ChatCompletionMessageToolCallFunction$outboundSchema, } from "./chatcompletionmessagetoolcallfunction.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * The type of the tool. Currently, only `function` is supported. */ export const ChatCompletionMessageToolCallType = { Function: "function", } as const; /** * The type of the tool. Currently, only `function` is supported. */ export type ChatCompletionMessageToolCallType = ClosedEnum< typeof ChatCompletionMessageToolCallType >; export type ChatCompletionMessageToolCall = { /** * openai requires an index here, will default to zero since we can only return 1 call right now */ index?: number | undefined; /** * The ID of the tool call. */ id: string; /** * The type of the tool. Currently, only `function` is supported. */ type: ChatCompletionMessageToolCallType; function: ChatCompletionMessageToolCallFunction; }; /** @internal */ export const ChatCompletionMessageToolCallType$inboundSchema: z.ZodNativeEnum< typeof ChatCompletionMessageToolCallType > = z.nativeEnum(ChatCompletionMessageToolCallType); /** @internal */ export const ChatCompletionMessageToolCallType$outboundSchema: z.ZodNativeEnum< typeof ChatCompletionMessageToolCallType > = ChatCompletionMessageToolCallType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ChatCompletionMessageToolCallType$ { /** @deprecated use `ChatCompletionMessageToolCallType$inboundSchema` instead. */ export const inboundSchema = ChatCompletionMessageToolCallType$inboundSchema; /** @deprecated use `ChatCompletionMessageToolCallType$outboundSchema` instead. */ export const outboundSchema = ChatCompletionMessageToolCallType$outboundSchema; } /** @internal */ export const ChatCompletionMessageToolCall$inboundSchema: z.ZodType< ChatCompletionMessageToolCall, z.ZodTypeDef, unknown > = z.object({ index: z.number().int().optional(), id: z.string(), type: ChatCompletionMessageToolCallType$inboundSchema, function: ChatCompletionMessageToolCallFunction$inboundSchema, }); /** @internal */ export type ChatCompletionMessageToolCall$Outbound = { index?: number | undefined; id: string; type: string; function: ChatCompletionMessageToolCallFunction$Outbound; }; /** @internal */ export const ChatCompletionMessageToolCall$outboundSchema: z.ZodType< ChatCompletionMessageToolCall$Outbound, z.ZodTypeDef, ChatCompletionMessageToolCall > = z.object({ index: z.number().int().optional(), id: z.string(), type: ChatCompletionMessageToolCallType$outboundSchema, function: ChatCompletionMessageToolCallFunction$outboundSchema, }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ChatCompletionMessageToolCall$ { /** @deprecated use `ChatCompletionMessageToolCall$inboundSchema` instead. */ export const inboundSchema = ChatCompletionMessageToolCall$inboundSchema; /** @deprecated use `ChatCompletionMessageToolCall$outboundSchema` instead. */ export const outboundSchema = ChatCompletionMessageToolCall$outboundSchema; /** @deprecated use `ChatCompletionMessageToolCall$Outbound` instead. */ export type Outbound = ChatCompletionMessageToolCall$Outbound; } export function chatCompletionMessageToolCallToJSON( chatCompletionMessageToolCall: ChatCompletionMessageToolCall, ): string { return JSON.stringify( ChatCompletionMessageToolCall$outboundSchema.parse( chatCompletionMessageToolCall, ), ); } export function chatCompletionMessageToolCallFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ChatCompletionMessageToolCall$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChatCompletionMessageToolCall' from JSON`, ); }