import { AppError } from '../utils/errors.js'; /** * Embedder configuration */ export interface EmbedderConfig { /** HuggingFace model path */ modelPath: string; /** Batch size */ batchSize: number; /** Model cache directory */ cacheDir: string; /** Device type */ device?: string; /** * Embedding quantization dtype (fp32, fp16, q8, int8, ...). Passed through to * transformers.js — no allowlist. Undefined means "unset": initialize() then * applies the fp32 default. The unset-vs-explicit-fp32 distinction is * preserved on purpose (it gates failure-path error enrichment). */ dtype?: string; } /** * Embedding generation error */ export declare class EmbeddingError extends AppError { constructor(message: string, cause?: Error); } /** * Embedding generation class using Transformers.js * * Responsibilities: * - Generate embedding vectors (dimension depends on model) * - Transformers.js wrapper * - Batch processing (size 8) */ export declare class Embedder { private model; private initPromise; private readonly config; constructor(config: EmbedderConfig); /** * Release resources held by the Embedder pipeline */ dispose(): Promise; /** * Initialize Transformers.js model */ initialize(): Promise; /** * Best-effort failure-path enrichment for an explicit `RAG_DTYPE`. * * When the load failed and a dtype was explicitly requested, consult the * model's available dtypes and, if the requested one is absent, return a * message that names what the model provides. The enumeration is a Hub * network call wrapped in its own try/catch: if it fails (e.g. air-gapped * after caching) it degrades to a generic clear, dtype-aware message rather * than surfacing a confusing secondary error (TD-3). This method never throws * and never converts the load failure into a fallback — the caller always * re-throws. * * @param nativeMessage - The underlying load-failure message. * @returns The message to wrap in the thrown `EmbeddingError`. */ private enrichDtypeFailureMessage; /** * Ensure model is initialized (lazy initialization) * This method is called automatically by embed() and embedBatch() */ private ensureInitialized; /** * Convert single text to embedding vector * * @param text - Text * @returns Embedding vector (dimension depends on model) */ embed(text: string): Promise; /** * Convert multiple texts to embedding vectors with batch processing * * @param texts - Array of texts * @returns Array of embedding vectors (dimension depends on model) */ embedBatch(texts: string[]): Promise; } //# sourceMappingURL=index.d.ts.map