/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { safeParse } from "../lib/schemas.js"; import { ClosedEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; /** * The object type, which is always "embedding". */ export const ObjectT = { Embedding: "embedding", } as const; /** * The object type, which is always "embedding". */ export type ObjectT = ClosedEnum; /** * Represents an embedding vector returned by embedding endpoint. * * @remarks */ export type Embedding = { /** * The index of the embedding in the list of embeddings. */ index: number; /** * The embedding vector, which is a list of floats. The length of vector depends on the model as listed in the [embedding guide](/guides/querying-embedding-models). * * @remarks */ embedding: Array; /** * The object type, which is always "embedding". */ object: ObjectT; }; /** @internal */ export const ObjectT$inboundSchema: z.ZodNativeEnum = z .nativeEnum(ObjectT); /** @internal */ export const ObjectT$outboundSchema: z.ZodNativeEnum = ObjectT$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ObjectT$ { /** @deprecated use `ObjectT$inboundSchema` instead. */ export const inboundSchema = ObjectT$inboundSchema; /** @deprecated use `ObjectT$outboundSchema` instead. */ export const outboundSchema = ObjectT$outboundSchema; } /** @internal */ export const Embedding$inboundSchema: z.ZodType< Embedding, z.ZodTypeDef, unknown > = z.object({ index: z.number().int(), embedding: z.array(z.number()), object: ObjectT$inboundSchema, }); /** @internal */ export type Embedding$Outbound = { index: number; embedding: Array; object: string; }; /** @internal */ export const Embedding$outboundSchema: z.ZodType< Embedding$Outbound, z.ZodTypeDef, Embedding > = z.object({ index: z.number().int(), embedding: z.array(z.number()), object: ObjectT$outboundSchema, }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Embedding$ { /** @deprecated use `Embedding$inboundSchema` instead. */ export const inboundSchema = Embedding$inboundSchema; /** @deprecated use `Embedding$outboundSchema` instead. */ export const outboundSchema = Embedding$outboundSchema; /** @deprecated use `Embedding$Outbound` instead. */ export type Outbound = Embedding$Outbound; } export function embeddingToJSON(embedding: Embedding): string { return JSON.stringify(Embedding$outboundSchema.parse(embedding)); } export function embeddingFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Embedding$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Embedding' from JSON`, ); }