/* * 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 { ClosedEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { Embedding, Embedding$inboundSchema, Embedding$Outbound, Embedding$outboundSchema, } from "./embedding.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * The object type, which is always "list". */ export const CreateEmbeddingResponseObject = { List: "list", } as const; /** * The object type, which is always "list". */ export type CreateEmbeddingResponseObject = ClosedEnum< typeof CreateEmbeddingResponseObject >; /** * The usage information for the request. */ export type Usage = { /** * The number of tokens used by the prompt. */ promptTokens: number; /** * The total number of tokens used by the request. */ totalTokens: number; }; export type CreateEmbeddingResponse = { /** * The list of embeddings generated by the model. */ data: Array; /** * The name of the model used to generate the embedding. */ model: string; /** * The object type, which is always "list". */ object: CreateEmbeddingResponseObject; /** * The usage information for the request. */ usage: Usage; }; /** @internal */ export const CreateEmbeddingResponseObject$inboundSchema: z.ZodNativeEnum< typeof CreateEmbeddingResponseObject > = z.nativeEnum(CreateEmbeddingResponseObject); /** @internal */ export const CreateEmbeddingResponseObject$outboundSchema: z.ZodNativeEnum< typeof CreateEmbeddingResponseObject > = CreateEmbeddingResponseObject$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CreateEmbeddingResponseObject$ { /** @deprecated use `CreateEmbeddingResponseObject$inboundSchema` instead. */ export const inboundSchema = CreateEmbeddingResponseObject$inboundSchema; /** @deprecated use `CreateEmbeddingResponseObject$outboundSchema` instead. */ export const outboundSchema = CreateEmbeddingResponseObject$outboundSchema; } /** @internal */ export const Usage$inboundSchema: z.ZodType = z .object({ prompt_tokens: z.number().int(), total_tokens: z.number().int(), }).transform((v) => { return remap$(v, { "prompt_tokens": "promptTokens", "total_tokens": "totalTokens", }); }); /** @internal */ export type Usage$Outbound = { prompt_tokens: number; total_tokens: number; }; /** @internal */ export const Usage$outboundSchema: z.ZodType< Usage$Outbound, z.ZodTypeDef, Usage > = z.object({ promptTokens: z.number().int(), totalTokens: z.number().int(), }).transform((v) => { return remap$(v, { promptTokens: "prompt_tokens", totalTokens: "total_tokens", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Usage$ { /** @deprecated use `Usage$inboundSchema` instead. */ export const inboundSchema = Usage$inboundSchema; /** @deprecated use `Usage$outboundSchema` instead. */ export const outboundSchema = Usage$outboundSchema; /** @deprecated use `Usage$Outbound` instead. */ export type Outbound = Usage$Outbound; } export function usageToJSON(usage: Usage): string { return JSON.stringify(Usage$outboundSchema.parse(usage)); } export function usageFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Usage$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Usage' from JSON`, ); } /** @internal */ export const CreateEmbeddingResponse$inboundSchema: z.ZodType< CreateEmbeddingResponse, z.ZodTypeDef, unknown > = z.object({ data: z.array(Embedding$inboundSchema), model: z.string(), object: CreateEmbeddingResponseObject$inboundSchema, usage: z.lazy(() => Usage$inboundSchema), }); /** @internal */ export type CreateEmbeddingResponse$Outbound = { data: Array; model: string; object: string; usage: Usage$Outbound; }; /** @internal */ export const CreateEmbeddingResponse$outboundSchema: z.ZodType< CreateEmbeddingResponse$Outbound, z.ZodTypeDef, CreateEmbeddingResponse > = z.object({ data: z.array(Embedding$outboundSchema), model: z.string(), object: CreateEmbeddingResponseObject$outboundSchema, usage: z.lazy(() => Usage$outboundSchema), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CreateEmbeddingResponse$ { /** @deprecated use `CreateEmbeddingResponse$inboundSchema` instead. */ export const inboundSchema = CreateEmbeddingResponse$inboundSchema; /** @deprecated use `CreateEmbeddingResponse$outboundSchema` instead. */ export const outboundSchema = CreateEmbeddingResponse$outboundSchema; /** @deprecated use `CreateEmbeddingResponse$Outbound` instead. */ export type Outbound = CreateEmbeddingResponse$Outbound; } export function createEmbeddingResponseToJSON( createEmbeddingResponse: CreateEmbeddingResponse, ): string { return JSON.stringify( CreateEmbeddingResponse$outboundSchema.parse(createEmbeddingResponse), ); } export function createEmbeddingResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateEmbeddingResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateEmbeddingResponse' from JSON`, ); }