{"version":3,"file":"helpers.mjs","names":[],"sources":["../../../../src/batteries/embeddings/openai/helpers.ts"],"sourcesContent":["/**\n * Shared, engine-agnostic helpers for the embeddings batteries.\n *\n * @module @nhtio/adk/batteries/embeddings/openai/helpers\n *\n * @remarks\n * Owned by the OpenAI Embeddings battery (the environment-neutral one) and re-used by the WebLLM\n * Embeddings battery, so query/document prefixing behaves identically across both — the engine is\n * the only difference between the batteries.\n */\n\nimport type { BaseEmbeddingsAdapterOptions, EmbeddingKind } from './types'\n\n/**\n * Applies the configured query/document instruction prefix to a batch of inputs.\n *\n * @remarks\n * `kind: 'query'` → prepend `queryPrefix` (if set); `kind: 'document'` → prepend `documentPrefix`\n * (if set). When the relevant prefix is unset, inputs pass through verbatim. This is the single\n * source of truth for prefix handling shared by both batteries.\n *\n * @param texts - The raw inputs to embed.\n * @param kind - Whether these are queries or documents.\n * @param options - Carries `queryPrefix` / `documentPrefix`.\n * @returns A new array with prefixes applied (never mutates the input).\n */\nexport const applyEmbeddingPrefix = (\n  texts: readonly string[],\n  kind: EmbeddingKind,\n  options: Pick<BaseEmbeddingsAdapterOptions, 'queryPrefix' | 'documentPrefix'>\n): string[] => {\n  const prefix = kind === 'query' ? options.queryPrefix : options.documentPrefix\n  if (!prefix) return texts.slice()\n  return texts.map((t) => `${prefix}${t}`)\n}\n"],"mappings":";;;;;;;;;;;;;;AA0BA,IAAa,wBACX,OACA,MACA,YACa;CACb,MAAM,SAAS,SAAS,UAAU,QAAQ,cAAc,QAAQ;CAChE,IAAI,CAAC,QAAQ,OAAO,MAAM,MAAM;CAChC,OAAO,MAAM,KAAK,MAAM,GAAG,SAAS,GAAG;AACzC"}