UNPKG

@restnfeel/agentc-starter-kit

Version:

한국어 기업용 CMS 모듈 - Task Master AI와 함께 빠르게 웹사이트를 구현할 수 있는 재사용 가능한 컴포넌트 시스템

26 lines (21 loc) 749 B
import { Document } from "../types"; import { BaseDocumentLoader } from "./base"; import * as mammoth from "mammoth"; export class DocxDocumentLoader extends BaseDocumentLoader { supportedExtensions = ["docx", "doc"]; async load(filePath: string, content: Buffer): Promise<Document> { try { const result = await mammoth.extractRawText({ buffer: content }); const cleanedText = this.cleanText(result.value); const metadata = this.createBaseMetadata(filePath, content.length); return { id: this.generateDocumentId(filePath), content: cleanedText, metadata, source: filePath, }; } catch (error) { throw new Error(`Failed to load DOCX document: ${error}`); } } }