/* * 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 { NewLogProbsContentTopLogProbs, NewLogProbsContentTopLogProbs$inboundSchema, NewLogProbsContentTopLogProbs$Outbound, NewLogProbsContentTopLogProbs$outboundSchema, } from "./newlogprobscontenttoplogprobs.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; export type NewLogProbsContent = { token?: string | undefined; logprob?: number | undefined; bytes?: Array | undefined; topLogprobs?: Array | undefined; tokenId?: number | undefined; textOffset?: number | undefined; }; /** @internal */ export const NewLogProbsContent$inboundSchema: z.ZodType< NewLogProbsContent, z.ZodTypeDef, unknown > = z.object({ token: z.string().optional(), logprob: z.number().optional(), bytes: z.array(z.number().int()).optional(), top_logprobs: z.array(NewLogProbsContentTopLogProbs$inboundSchema).optional(), token_id: z.number().int().optional(), text_offset: z.number().int().optional(), }).transform((v) => { return remap$(v, { "top_logprobs": "topLogprobs", "token_id": "tokenId", "text_offset": "textOffset", }); }); /** @internal */ export type NewLogProbsContent$Outbound = { token?: string | undefined; logprob?: number | undefined; bytes?: Array | undefined; top_logprobs?: Array | undefined; token_id?: number | undefined; text_offset?: number | undefined; }; /** @internal */ export const NewLogProbsContent$outboundSchema: z.ZodType< NewLogProbsContent$Outbound, z.ZodTypeDef, NewLogProbsContent > = z.object({ token: z.string().optional(), logprob: z.number().optional(), bytes: z.array(z.number().int()).optional(), topLogprobs: z.array(NewLogProbsContentTopLogProbs$outboundSchema).optional(), tokenId: z.number().int().optional(), textOffset: z.number().int().optional(), }).transform((v) => { return remap$(v, { topLogprobs: "top_logprobs", tokenId: "token_id", textOffset: "text_offset", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace NewLogProbsContent$ { /** @deprecated use `NewLogProbsContent$inboundSchema` instead. */ export const inboundSchema = NewLogProbsContent$inboundSchema; /** @deprecated use `NewLogProbsContent$outboundSchema` instead. */ export const outboundSchema = NewLogProbsContent$outboundSchema; /** @deprecated use `NewLogProbsContent$Outbound` instead. */ export type Outbound = NewLogProbsContent$Outbound; } export function newLogProbsContentToJSON( newLogProbsContent: NewLogProbsContent, ): string { return JSON.stringify( NewLogProbsContent$outboundSchema.parse(newLogProbsContent), ); } export function newLogProbsContentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => NewLogProbsContent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'NewLogProbsContent' from JSON`, ); }