/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type LLMResponse = { response: string; tokensUsed: number; }; /** @internal */ export const LLMResponse$inboundSchema: z.ZodType< LLMResponse, z.ZodTypeDef, unknown > = z.object({ response: z.string(), tokens_used: z.number().int(), }).transform((v) => { return remap$(v, { "tokens_used": "tokensUsed", }); }); /** @internal */ export type LLMResponse$Outbound = { response: string; tokens_used: number; }; /** @internal */ export const LLMResponse$outboundSchema: z.ZodType< LLMResponse$Outbound, z.ZodTypeDef, LLMResponse > = z.object({ response: z.string(), tokensUsed: z.number().int(), }).transform((v) => { return remap$(v, { tokensUsed: "tokens_used", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace LLMResponse$ { /** @deprecated use `LLMResponse$inboundSchema` instead. */ export const inboundSchema = LLMResponse$inboundSchema; /** @deprecated use `LLMResponse$outboundSchema` instead. */ export const outboundSchema = LLMResponse$outboundSchema; /** @deprecated use `LLMResponse$Outbound` instead. */ export type Outbound = LLMResponse$Outbound; } export function llmResponseToJSON(llmResponse: LLMResponse): string { return JSON.stringify(LLMResponse$outboundSchema.parse(llmResponse)); } export function llmResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => LLMResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LLMResponse' from JSON`, ); }