/*
 * 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 {
  EmbeddingDtype,
  EmbeddingDtype$outboundSchema,
} from "./embeddingdtype.js";
import {
  EncodingFormat,
  EncodingFormat$outboundSchema,
} from "./encodingformat.js";

/**
 * The text content to be embedded, can be a string or an array of strings for fast processing in bulk.
 */
export type EmbeddingRequestInputs = string | Array<string>;

export type EmbeddingRequest = {
  /**
   * The ID of the model to be used for embedding.
   */
  model: string;
  metadata?: { [k: string]: any } | null | undefined;
  /**
   * The text content to be embedded, can be a string or an array of strings for fast processing in bulk.
   */
  inputs: string | Array<string>;
  /**
   * The dimension of the output embeddings when feature available. If not provided, a default output dimension will be used.
   */
  outputDimension?: number | null | undefined;
  outputDtype?: EmbeddingDtype | undefined;
  encodingFormat?: EncodingFormat | undefined;
};

/** @internal */
export type EmbeddingRequestInputs$Outbound = string | Array<string>;

/** @internal */
export const EmbeddingRequestInputs$outboundSchema: z.ZodType<
  EmbeddingRequestInputs$Outbound,
  z.ZodTypeDef,
  EmbeddingRequestInputs
> = z.union([z.string(), z.array(z.string())]);

export function embeddingRequestInputsToJSON(
  embeddingRequestInputs: EmbeddingRequestInputs,
): string {
  return JSON.stringify(
    EmbeddingRequestInputs$outboundSchema.parse(embeddingRequestInputs),
  );
}

/** @internal */
export type EmbeddingRequest$Outbound = {
  model: string;
  metadata?: { [k: string]: any } | null | undefined;
  input: string | Array<string>;
  output_dimension?: number | null | undefined;
  output_dtype?: string | undefined;
  encoding_format?: string | undefined;
};

/** @internal */
export const EmbeddingRequest$outboundSchema: z.ZodType<
  EmbeddingRequest$Outbound,
  z.ZodTypeDef,
  EmbeddingRequest
> = z.object({
  model: z.string(),
  metadata: z.nullable(z.record(z.any())).optional(),
  inputs: z.union([z.string(), z.array(z.string())]),
  outputDimension: z.nullable(z.number().int()).optional(),
  outputDtype: EmbeddingDtype$outboundSchema.optional(),
  encodingFormat: EncodingFormat$outboundSchema.optional(),
}).transform((v) => {
  return remap$(v, {
    inputs: "input",
    outputDimension: "output_dimension",
    outputDtype: "output_dtype",
    encodingFormat: "encoding_format",
  });
});

export function embeddingRequestToJSON(
  embeddingRequest: EmbeddingRequest,
): string {
  return JSON.stringify(
    EmbeddingRequest$outboundSchema.parse(embeddingRequest),
  );
}
