/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { safeParse } from "../lib/schemas.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { FunctionParameters, FunctionParameters$inboundSchema, FunctionParameters$Outbound, FunctionParameters$outboundSchema, } from "./functionparameters.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; export type FunctionObject = { /** * A description of what the function does, used by the model to choose when and how to call the function. */ description?: string | undefined; /** * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. */ name: string; /** * The parameters the functions accepts, described as a JSON Schema object. * * @remarks * * To describe a function that accepts no parameters, provide the value `{"type": "object", "properties": {}}`. */ parameters: FunctionParameters; }; /** @internal */ export const FunctionObject$inboundSchema: z.ZodType< FunctionObject, z.ZodTypeDef, unknown > = z.object({ description: z.string().optional(), name: z.string(), parameters: FunctionParameters$inboundSchema, }); /** @internal */ export type FunctionObject$Outbound = { description?: string | undefined; name: string; parameters: FunctionParameters$Outbound; }; /** @internal */ export const FunctionObject$outboundSchema: z.ZodType< FunctionObject$Outbound, z.ZodTypeDef, FunctionObject > = z.object({ description: z.string().optional(), name: z.string(), parameters: FunctionParameters$outboundSchema, }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace FunctionObject$ { /** @deprecated use `FunctionObject$inboundSchema` instead. */ export const inboundSchema = FunctionObject$inboundSchema; /** @deprecated use `FunctionObject$outboundSchema` instead. */ export const outboundSchema = FunctionObject$outboundSchema; /** @deprecated use `FunctionObject$Outbound` instead. */ export type Outbound = FunctionObject$Outbound; } export function functionObjectToJSON(functionObject: FunctionObject): string { return JSON.stringify(FunctionObject$outboundSchema.parse(functionObject)); } export function functionObjectFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FunctionObject$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FunctionObject' from JSON`, ); }