/** * QR Video RAG - Retriever * * Retrieves knowledge from QR-encoded videos using semantic search */ import { VectorDatabase, Embedder, QRVideoStoreIndexEntry, SearchResult, FrameExtractionOptions } from './types'; /** * QR Video Store Retriever * * Performs semantic search and retrieves decoded text from QR-encoded videos */ export declare class QRVideoStoreRetriever { private database; private embedder; private verbose; private frameCache; private maxCacheSize; /** * Create a new QR Video Store Retriever * * @param database Vector database containing chunk embeddings * @param embedder Embedding generator for query encoding * @param options Optional configuration * * @example * ```typescript * const retriever = new QRVideoStoreRetriever( * createSupabaseAdapter(supabase), * createGeminiEmbedder(apiKey), * { verbose: true, maxCacheSize: 100 } * ); * ``` */ constructor(database: VectorDatabase, embedder: Embedder, options?: { verbose?: boolean; maxCacheSize?: number; }); /** * Retrieve relevant chunk metadata based on semantic search * * @param query Search query text * @param matchCount Number of results to return * @returns Array of matching index entries with similarity scores * * @example * ```typescript * const matches = await retriever.retrieveChunks( * "How do I configure authentication?", * 5 * ); * console.log(matches[0].similarity); // 0.85 * ``` */ retrieveChunks(query: string, matchCount?: number): Promise; /** * Extract a specific frame from video as buffer * * @param videoPath Path to the video file * @param frameNumber Frame number to extract (0-indexed) * @returns Buffer containing PNG image data, or null if extraction fails * * @example * ```typescript * const frameBuffer = await retriever.extractFrameAsBuffer( * "./knowledge.mp4", * 42 * ); * if (frameBuffer) { * fs.writeFileSync("frame-42.png", frameBuffer); * } * ``` */ extractFrameAsBuffer(videoPath: string, frameNumber: number, options?: Partial): Promise; /** * Decode QR code from image buffer * * @param imageBuffer Buffer containing PNG/JPG image data * @returns Decoded text, or null if QR code cannot be read * * @example * ```typescript * const qrImage = fs.readFileSync("qr-code.png"); * const text = await retriever.decodeQrCodeFromBuffer(qrImage); * console.log(text); // "Hello, World!" * ``` */ decodeQrCodeFromBuffer(imageBuffer: Buffer): Promise; /** * Search for relevant content and decode it from video * * This is the main retrieval method that combines semantic search * with frame extraction and QR decoding. * * @param query Search query text * @param videoPath Path to the QR video file * @param matchCount Number of results to return (default: 5) * @returns Array of search results with decoded text and similarity scores * * @example * ```typescript * const results = await retriever.search( * "authentication configuration", * "./docs.mp4", * 3 * ); * * for (const result of results) { * console.log(`[${result.similarity.toFixed(2)}] ${result.text}`); * } * ``` */ search(query: string, videoPath: string, matchCount?: number): Promise; /** * Search across multiple video files * * @param query Search query text * @param videoPaths Array of video file paths * @param matchCountPerVideo Number of results per video * @returns Aggregated and sorted results from all videos * * @example * ```typescript * const results = await retriever.searchMultiple( * "API documentation", * ["./docs-v1.mp4", "./docs-v2.mp4"], * 3 * ); * ``` */ searchMultiple(query: string, videoPaths: string[], matchCountPerVideo?: number): Promise; /** * Retrieve a specific frame by document ID and frame number * * @param videoPath Path to the video file * @param documentId Document identifier * @param frameNumber Frame number * @returns Decoded text or null */ getFrameByNumber(videoPath: string, frameNumber: number): Promise; /** * Clear the frame cache */ clearCache(): void; /** * Get cache statistics */ getCacheStats(): { size: number; maxSize: number; hitRate?: number; }; /** * Add item to cache with LRU eviction */ private addToCache; /** * Batch decode multiple frames from a video * * @param videoPath Path to video file * @param frameNumbers Array of frame numbers to decode * @returns Map of frame number to decoded text */ batchDecodeFrames(videoPath: string, frameNumbers: number[]): Promise>; } //# sourceMappingURL=retriever.d.ts.map