/* * 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 { ChatMessageContent, ChatMessageContent$inboundSchema, ChatMessageContent$Outbound, ChatMessageContent$outboundSchema, } from "./chatmessagecontent.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * The role of the messages author. One of `system`, `user`, or `assistant`. */ export const Role = { System: "system", User: "user", Assistant: "assistant", } as const; /** * The role of the messages author. One of `system`, `user`, or `assistant`. */ export type Role = ClosedEnum; export type Content = string | Array; export type ChatCompletionRequestMessage = { /** * The role of the messages author. One of `system`, `user`, or `assistant`. */ role: Role; content: string | Array | null; /** * The name of the author of this message. May contain a-z, A-Z, 0-9, and underscores, with a maximum length of 64 characters. */ name?: string | undefined; }; /** @internal */ export const Role$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Role, ); /** @internal */ export const Role$outboundSchema: z.ZodNativeEnum = Role$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Role$ { /** @deprecated use `Role$inboundSchema` instead. */ export const inboundSchema = Role$inboundSchema; /** @deprecated use `Role$outboundSchema` instead. */ export const outboundSchema = Role$outboundSchema; } /** @internal */ export const Content$inboundSchema: z.ZodType = z.union([z.string(), z.array(ChatMessageContent$inboundSchema)]); /** @internal */ export type Content$Outbound = string | Array; /** @internal */ export const Content$outboundSchema: z.ZodType< Content$Outbound, z.ZodTypeDef, Content > = z.union([z.string(), z.array(ChatMessageContent$outboundSchema)]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Content$ { /** @deprecated use `Content$inboundSchema` instead. */ export const inboundSchema = Content$inboundSchema; /** @deprecated use `Content$outboundSchema` instead. */ export const outboundSchema = Content$outboundSchema; /** @deprecated use `Content$Outbound` instead. */ export type Outbound = Content$Outbound; } export function contentToJSON(content: Content): string { return JSON.stringify(Content$outboundSchema.parse(content)); } export function contentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Content$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Content' from JSON`, ); } /** @internal */ export const ChatCompletionRequestMessage$inboundSchema: z.ZodType< ChatCompletionRequestMessage, z.ZodTypeDef, unknown > = z.object({ role: Role$inboundSchema, content: z.nullable( z.union([z.string(), z.array(ChatMessageContent$inboundSchema)]), ), name: z.string().optional(), }); /** @internal */ export type ChatCompletionRequestMessage$Outbound = { role: string; content: string | Array | null; name?: string | undefined; }; /** @internal */ export const ChatCompletionRequestMessage$outboundSchema: z.ZodType< ChatCompletionRequestMessage$Outbound, z.ZodTypeDef, ChatCompletionRequestMessage > = z.object({ role: Role$outboundSchema, content: z.nullable( z.union([z.string(), z.array(ChatMessageContent$outboundSchema)]), ), name: z.string().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ChatCompletionRequestMessage$ { /** @deprecated use `ChatCompletionRequestMessage$inboundSchema` instead. */ export const inboundSchema = ChatCompletionRequestMessage$inboundSchema; /** @deprecated use `ChatCompletionRequestMessage$outboundSchema` instead. */ export const outboundSchema = ChatCompletionRequestMessage$outboundSchema; /** @deprecated use `ChatCompletionRequestMessage$Outbound` instead. */ export type Outbound = ChatCompletionRequestMessage$Outbound; } export function chatCompletionRequestMessageToJSON( chatCompletionRequestMessage: ChatCompletionRequestMessage, ): string { return JSON.stringify( ChatCompletionRequestMessage$outboundSchema.parse( chatCompletionRequestMessage, ), ); } export function chatCompletionRequestMessageFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ChatCompletionRequestMessage$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChatCompletionRequestMessage' from JSON`, ); }