/** * Cross-environment OpenAI Embeddings adapter battery. * * @module @nhtio/adk/batteries/embeddings/openai/adapter * * @remarks * Opinionated embeddings battery for the OpenAI `/v1/embeddings` wire shape. Ships an * {@link OpenAIEmbeddingsAdapter} that targets any OpenAI-`/v1/embeddings`-compatible endpoint * (OpenAI proper, Azure-behind-proxy, vLLM, Together, a local gateway, etc.) over raw `fetch` — * no SDK dependency, so it runs unchanged in Node, the browser, edge runtimes, and workers. * * The class shares its method surface, return types, prefix handling, and option base with the * WebLLM Embeddings battery: the two differ only in their engine. See * {@link @nhtio/adk/batteries/embeddings/openai/types!BaseEmbeddingsAdapterOptions}. * * Construction validates options eagerly via {@link @nhtio/adk/batteries/embeddings/openai/validation!validateOptions} and throws * {@link @nhtio/adk/batteries/embeddings/openai/exceptions!E_INVALID_OPENAI_EMBEDDINGS_OPTIONS} on failure — config bugs fail loud, not at embed time. */ import type { EmbedOptions } from "./types"; /** * Embeddings adapter for the OpenAI `/v1/embeddings` wire shape. * * @remarks * Reusable: construct once, call {@link OpenAIEmbeddingsAdapter.embed} / {@link embedMany} as many * times as needed. `embedMany` issues one request per call (OpenAI embeds a batch in a single * round-trip); `embed` is sugar over `embedMany([text])`. */ export declare class OpenAIEmbeddingsAdapter { #private; /** * Whether this battery can run in the current environment. For the HTTP-backed OpenAI battery * this is always `true` (a `fetch` is always resolvable); present for surface-parity with the * WebLLM battery's WebGPU gate. */ static isAvailable(): boolean; /** * @param options - Constructor options. Validated eagerly. * @throws {@link @nhtio/adk/batteries/embeddings/openai/exceptions!E_INVALID_OPENAI_EMBEDDINGS_OPTIONS} when `options` does not satisfy * {@link @nhtio/adk/batteries/embeddings/openai/validation!openAIEmbeddingsOptionsSchema} (e.g. missing `model`). */ constructor(options: unknown); /** Declared output dimensionality (from options), or `undefined` if not configured. */ get dimensions(): number | undefined; /** See {@link OpenAIEmbeddingsAdapter.isAvailable}. Instance alias for surface-parity. */ isAvailable(): boolean; /** * No-op warm-up. The OpenAI battery has no engine to preload; present for surface-parity with * the WebLLM battery so callers can treat the two interchangeably. */ preload(): Promise; /** * No-op state reset. Present for surface-parity with the WebLLM battery. */ reset(): void; /** * Embeds a single string. * * @param text - The input text. * @param opts - Per-call options (`kind`). * @returns The embedding vector as a plain `number[]`. */ embed(text: string, opts?: EmbedOptions): Promise; /** * Embeds a batch of strings in a single request. * * @param texts - The input texts. * @param opts - Per-call options (`kind`). Defaults to `kind: 'document'`. * @returns One embedding vector per input, in input order, each a plain `number[]`. * @throws {@link @nhtio/adk/batteries/embeddings/openai/exceptions!E_OPENAI_EMBEDDINGS_HTTP_ERROR} on a non-2xx response or transport failure. * @throws {@link @nhtio/adk/batteries/embeddings/openai/exceptions!E_OPENAI_EMBEDDINGS_REQUEST_TIMEOUT} when the handshake exceeds `requestTimeoutMs`. * @throws {@link @nhtio/adk/batteries/embeddings/openai/exceptions!E_OPENAI_EMBEDDINGS_MALFORMED_RESPONSE} when the 2xx body is not the expected shape. */ embedMany(texts: string[], opts?: EmbedOptions): Promise; }