/** * Embedding Provider for LLM Browser (V-002) * * Provides text embedding generation using @xenova/transformers. * Uses all-MiniLM-L6-v2 model (384 dimensions) by default. * Falls back gracefully when transformers library is not available. */ /** * Configuration options for EmbeddingProvider */ export interface EmbeddingProviderOptions { /** Model to use for embeddings (default: 'Xenova/all-MiniLM-L6-v2') */ model?: string; /** Whether to quantize the model for faster inference (default: true) */ quantized?: boolean; /** Cache directory for downloaded models */ cacheDir?: string; } /** * Embedding generation result */ export interface EmbeddingResult { /** The embedding vector */ vector: Float32Array; /** The model used to generate the embedding */ model: string; /** Number of tokens in the input */ tokenCount?: number; } /** * Batch embedding generation result */ export interface BatchEmbeddingResult { /** Array of embedding vectors */ vectors: Float32Array[]; /** The model used to generate the embeddings */ model: string; /** Processing time in milliseconds */ processingTimeMs: number; } /** * EmbeddingProvider - Wraps @xenova/transformers for text embedding generation * * Provides singleton access to embedding generation with lazy model loading. * Falls back gracefully when the library is unavailable. */ export declare class EmbeddingProvider { private static instance; private static loadError; private pipeline; private transformers; private initialized; private initializing; private initPromise; private readonly modelName; private readonly quantized; private readonly cacheDir?; /** * Model dimensions for known models */ private static readonly MODEL_DIMENSIONS; /** * Default model for embeddings */ static readonly DEFAULT_MODEL = "Xenova/all-MiniLM-L6-v2"; private constructor(); /** * Check if the transformers library is available */ static isAvailable(): Promise; /** * Create or get the singleton EmbeddingProvider instance * * @param options Configuration options (only used for first creation) * @returns EmbeddingProvider instance or null if unavailable */ static create(options?: EmbeddingProviderOptions): Promise; /** * Reset the singleton (for testing) */ static reset(): void; /** * Initialize the embedding model */ initialize(): Promise; private doInitialize; /** * Generate an embedding for a single text * * @param text Text to embed * @returns Embedding result with vector */ generateEmbedding(text: string): Promise; /** * Generate embeddings for multiple texts in batch * * @param texts Array of texts to embed * @returns Batch embedding result with vectors */ generateBatch(texts: string[]): Promise; /** * Get the number of dimensions for the current model */ getDimensions(): number; /** * Get the current model name */ getModelName(): string; /** * Check if the provider is initialized */ isInitialized(): boolean; /** * Ensure the provider is initialized before use */ private ensureInitialized; } /** * Create a new EmbeddingProvider instance * Convenience function for non-singleton usage */ export declare function createEmbeddingProvider(options?: EmbeddingProviderOptions): Promise; /** * Check if embedding generation is available */ export declare function isEmbeddingAvailable(): Promise; //# sourceMappingURL=embedding-provider.d.ts.map