export interface DocumentChunk { id: string; documentId: string; documentName: string; content: string; index: number; metadata?: Record; } export interface RAGDocument { id: string; name: string; type: 'pdf' | 'url' | 'text'; url?: string; content: string; chunks: DocumentChunk[]; createdAt: Date; metadata?: Record; } export interface RetrievalResult { chunks: DocumentChunk[]; scores: number[]; context: string; } export interface ChunkingOptions { chunkSize?: number; overlap?: number; preserveParagraphs?: boolean; } /** * Split text into chunks for RAG processing */ export declare function chunkText(text: string, documentId: string, documentName: string, options?: ChunkingOptions): DocumentChunk[]; /** * Retrieve relevant chunks based on query */ export declare function retrieveRelevantChunks(query: string, documents: RAGDocument[], topK?: number): RetrievalResult; /** * Build RAG context for AI prompt */ export declare function buildRAGContext(retrievalResult: RetrievalResult): string; /** * Fetch content from URL */ export declare function fetchUrlContent(url: string): Promise; /** * Extract text from text file */ export declare function extractTextFromFile(file: File): Promise; /** * Generate unique document ID */ export declare function generateDocumentId(): string; /** * Estimate token count (rough approximation) */ export declare function estimateTokenCount(text: string): number; /** * Validate document size */ export declare function validateDocumentSize(text: string, maxTokens?: number): boolean;