// hf-space/src/lib/knowledge/parser/index.ts import { parsePDF } from './pdf'; import { parseDOCX } from './docx'; import { parseText } from './text'; export interface ParsedDocument { content: string; pages?: number; } export async function parseDocument(buffer: Buffer, fileType: string): Promise { switch (fileType) { case 'pdf': return parsePDF(buffer); case 'docx': return parseDOCX(buffer); case 'md': case 'txt': return parseText(buffer); default: throw new Error(`Unsupported file type: ${fileType}`); } }