/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Chunk, Chunk$inboundSchema, Chunk$Outbound, Chunk$outboundSchema, } from "./chunk.js"; /** * Response model for text generation. */ export type TextResponse = { /** * The generated text. */ text: string; /** * The generated text chunks. */ chunks: Array; }; /** @internal */ export const TextResponse$inboundSchema: z.ZodType< TextResponse, z.ZodTypeDef, unknown > = z.object({ text: z.string(), chunks: z.array(Chunk$inboundSchema), }); /** @internal */ export type TextResponse$Outbound = { text: string; chunks: Array; }; /** @internal */ export const TextResponse$outboundSchema: z.ZodType< TextResponse$Outbound, z.ZodTypeDef, TextResponse > = z.object({ text: z.string(), chunks: z.array(Chunk$outboundSchema), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TextResponse$ { /** @deprecated use `TextResponse$inboundSchema` instead. */ export const inboundSchema = TextResponse$inboundSchema; /** @deprecated use `TextResponse$outboundSchema` instead. */ export const outboundSchema = TextResponse$outboundSchema; /** @deprecated use `TextResponse$Outbound` instead. */ export type Outbound = TextResponse$Outbound; } export function textResponseToJSON(textResponse: TextResponse): string { return JSON.stringify(TextResponse$outboundSchema.parse(textResponse)); } export function textResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TextResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TextResponse' from JSON`, ); }