/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: b782f07bc1ff */ import * as z from "zod/v4"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { smartUnion } from "../../types/smartUnion.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ContentChunk, ContentChunk$inboundSchema } from "./contentchunk.js"; import { ToolCall, ToolCall$inboundSchema } from "./toolcall.js"; export type DeltaMessageContent = string | Array; export type DeltaMessage = { role?: string | null | undefined; content?: string | Array | null | undefined; toolCalls?: Array | null | undefined; toolCallId?: string | null | undefined; /** * If the completion returns multiple messages, this is to specify which message this delta is for. */ index?: number | null | undefined; metadata?: { [k: string]: any } | null | undefined; }; /** @internal */ export const DeltaMessageContent$inboundSchema: z.ZodType< DeltaMessageContent, unknown > = smartUnion([z.string(), z.array(ContentChunk$inboundSchema)]); export function deltaMessageContentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DeltaMessageContent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DeltaMessageContent' from JSON`, ); } /** @internal */ export const DeltaMessage$inboundSchema: z.ZodType = z .object({ role: z.nullable(z.string()).optional(), content: z.nullable( smartUnion([z.string(), z.array(ContentChunk$inboundSchema)]), ).optional(), tool_calls: z.nullable(z.array(ToolCall$inboundSchema)).optional(), tool_call_id: z.nullable(z.string()).optional(), index: z.nullable(z.int()).optional(), metadata: z.nullable(z.record(z.string(), z.any())).optional(), }).transform((v) => { return remap$(v, { "tool_calls": "toolCalls", "tool_call_id": "toolCallId", }); }); export function deltaMessageFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DeltaMessage$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DeltaMessage' from JSON`, ); }