/* * 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 { SDKValidationError } from "./sdkvalidationerror.js"; /** * Input text to embed, encoded as a string. To embed multiple inputs in a single request, pass an array of strings. The input must not exceed the max input tokens for the model (8192 tokens for `nomic-ai/nomic-embed-text-v1.5`), cannot be an empty string, and any array must be 2048 dimensions or less. * * @remarks */ export type Input = string | Array; export const Two = { NomicAiNomicEmbedTextV15: "nomic-ai/nomic-embed-text-v1.5", ThenlperGteBase: "thenlper/gte-base", } as const; export type Two = ClosedEnum; export type Model = string | Two; export type CreateEmbeddingRequest = { /** * Input text to embed, encoded as a string. To embed multiple inputs in a single request, pass an array of strings. The input must not exceed the max input tokens for the model (8192 tokens for `nomic-ai/nomic-embed-text-v1.5`), cannot be an empty string, and any array must be 2048 dimensions or less. * * @remarks */ input: string | Array; model: string | Two; /** * The number of dimensions the resulting output embeddings should have. Only supported in `nomic-ai/nomic-embed-text-v1.5` and later models. * * @remarks */ dimensions?: number | undefined; /** * The format to return the embeddings in. Must be `float`. * * @remarks */ encodingFormat?: string | undefined; }; /** @internal */ export const Input$inboundSchema: z.ZodType = z .union([z.string(), z.array(z.string())]); /** @internal */ export type Input$Outbound = string | Array; /** @internal */ export const Input$outboundSchema: z.ZodType< Input$Outbound, z.ZodTypeDef, Input > = z.union([z.string(), z.array(z.string())]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Input$ { /** @deprecated use `Input$inboundSchema` instead. */ export const inboundSchema = Input$inboundSchema; /** @deprecated use `Input$outboundSchema` instead. */ export const outboundSchema = Input$outboundSchema; /** @deprecated use `Input$Outbound` instead. */ export type Outbound = Input$Outbound; } export function inputToJSON(input: Input): string { return JSON.stringify(Input$outboundSchema.parse(input)); } export function inputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Input$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Input' from JSON`, ); } /** @internal */ export const Two$inboundSchema: z.ZodNativeEnum = z.nativeEnum(Two); /** @internal */ export const Two$outboundSchema: z.ZodNativeEnum = Two$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Two$ { /** @deprecated use `Two$inboundSchema` instead. */ export const inboundSchema = Two$inboundSchema; /** @deprecated use `Two$outboundSchema` instead. */ export const outboundSchema = Two$outboundSchema; } /** @internal */ export const Model$inboundSchema: z.ZodType = z .union([z.string(), Two$inboundSchema]); /** @internal */ export type Model$Outbound = string | string; /** @internal */ export const Model$outboundSchema: z.ZodType< Model$Outbound, z.ZodTypeDef, Model > = z.union([z.string(), Two$outboundSchema]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Model$ { /** @deprecated use `Model$inboundSchema` instead. */ export const inboundSchema = Model$inboundSchema; /** @deprecated use `Model$outboundSchema` instead. */ export const outboundSchema = Model$outboundSchema; /** @deprecated use `Model$Outbound` instead. */ export type Outbound = Model$Outbound; } export function modelToJSON(model: Model): string { return JSON.stringify(Model$outboundSchema.parse(model)); } export function modelFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Model$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Model' from JSON`, ); } /** @internal */ export const CreateEmbeddingRequest$inboundSchema: z.ZodType< CreateEmbeddingRequest, z.ZodTypeDef, unknown > = z.object({ input: z.union([z.string(), z.array(z.string())]), model: z.union([z.string(), Two$inboundSchema]), dimensions: z.number().int().optional(), encoding_format: z.string().default("float"), }).transform((v) => { return remap$(v, { "encoding_format": "encodingFormat", }); }); /** @internal */ export type CreateEmbeddingRequest$Outbound = { input: string | Array; model: string | string; dimensions?: number | undefined; encoding_format: string; }; /** @internal */ export const CreateEmbeddingRequest$outboundSchema: z.ZodType< CreateEmbeddingRequest$Outbound, z.ZodTypeDef, CreateEmbeddingRequest > = z.object({ input: z.union([z.string(), z.array(z.string())]), model: z.union([z.string(), Two$outboundSchema]), dimensions: z.number().int().optional(), encodingFormat: z.string().default("float"), }).transform((v) => { return remap$(v, { encodingFormat: "encoding_format", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CreateEmbeddingRequest$ { /** @deprecated use `CreateEmbeddingRequest$inboundSchema` instead. */ export const inboundSchema = CreateEmbeddingRequest$inboundSchema; /** @deprecated use `CreateEmbeddingRequest$outboundSchema` instead. */ export const outboundSchema = CreateEmbeddingRequest$outboundSchema; /** @deprecated use `CreateEmbeddingRequest$Outbound` instead. */ export type Outbound = CreateEmbeddingRequest$Outbound; } export function createEmbeddingRequestToJSON( createEmbeddingRequest: CreateEmbeddingRequest, ): string { return JSON.stringify( CreateEmbeddingRequest$outboundSchema.parse(createEmbeddingRequest), ); } export function createEmbeddingRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateEmbeddingRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateEmbeddingRequest' from JSON`, ); }