/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; 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"; import { TopLogProb, TopLogProb$inboundSchema, TopLogProb$Outbound, TopLogProb$outboundSchema, } from "./toplogprob.js"; export type LogProb = { token: string; logprob: number; bytes: Array; topLogprobs: Array; }; /** @internal */ export const LogProb$inboundSchema: z.ZodType = z.object({ token: z.string(), logprob: z.number(), bytes: z.array(z.number()), top_logprobs: z.array(TopLogProb$inboundSchema), }).transform((v) => { return remap$(v, { "top_logprobs": "topLogprobs", }); }); /** @internal */ export type LogProb$Outbound = { token: string; logprob: number; bytes: Array; top_logprobs: Array; }; /** @internal */ export const LogProb$outboundSchema: z.ZodType< LogProb$Outbound, z.ZodTypeDef, LogProb > = z.object({ token: z.string(), logprob: z.number(), bytes: z.array(z.number()), topLogprobs: z.array(TopLogProb$outboundSchema), }).transform((v) => { return remap$(v, { topLogprobs: "top_logprobs", }); }); export function logProbToJSON(logProb: LogProb): string { return JSON.stringify(LogProb$outboundSchema.parse(logProb)); } export function logProbFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => LogProb$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LogProb' from JSON`, ); }