mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-24 22:46:38 +00:00
1.3 KiB
1.3 KiB
LoLLMs Anything to Markdown Library
Overview
JavaScript library to convert various file types to Markdown.
Key Features
- Supports: txt, docx, pdf, pptx, and more
- Asynchronous processing
- Object-oriented design
Import
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.9.359/pdf.min.js"></script><!-- Required for pdf use -->
<script src="/lollms_assets/js/lollms_anything_to_markdown"></script>
Core Class: LollmsFileLoader
Methods
loadFile(file)
: Main method to process filesreadTextFile(file)
,readDocxFile(file)
,readPdfFile(file)
,readPptxFile(file)
: Type-specific readersconvertToMarkdown(content, fileExtension)
: Converts content to Markdown
Usage
const lollmsFileLoader = new LollmsFileLoader();
const markdown = await lollmsFileLoader.loadFile(file);
Extensibility
- Add new file types by creating reader methods
- Enhance Markdown conversion logic
- Implement caching or post-processing
Error Handling
Uses Promise-based approach. Wrap loadFile
in try-catch.
Dependencies
Requires external libraries for DOCX, PDF, and PPTX processing.
This concise documentation provides the essential information for an LLM-based developer to understand and work with the library, while saving context tokens.