lollms-webui/endpoints/docs/lollms_anything_to_markdown
2024-12-03 08:49:27 +01:00
..
DOC.md enhanced lollms client 2024-08-30 00:57:14 +02:00
README.md Update README.md 2024-12-03 08:49:27 +01:00

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/mammoth/1.6.0/mammoth.browser.min.js"></script>
<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 files
  • readTextFile(file), readDocxFile(file), readPdfFile(file), readPptxFile(file): Type-specific readers
  • convertToMarkdown(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.