LibreChat/packages/data-provider/src
Danny Avila 7ce898d6a0
📄 feat: Local Text Extraction for PDF, DOCX, and XLS/XLSX (#11900)
* feat: Added "document parser" OCR strategy

The document parser uses libraries to parse the text out of known document types.
This lets LibreChat handle some complex document types without having to use a
secondary service (like Mistral or standing up a RAG API server).

To enable the document parser, set the ocr strategy to "document_parser" in
librechat.yaml.

We now support:

- PDFs using pdfjs
- DOCX using mammoth
- XLS/XLSX using SheetJS

(The associated packages were also added to the project.)

* fix: applied Copilot code review suggestions

- Properly calculate length of text based on UTF8.

- Avoid issues with loading / blocking PDF parsing.

* fix: improved docs on parseDocument()

* chore: move to packages/api for TS support

* refactor: make document processing the default ocr strategy

- Introduced support for additional document types in the OCR strategy, including PDF, DOCX, and XLS/XLSX.
- Updated the file upload handling to dynamically select the appropriate parsing strategy based on the file type.
- Refactored the document parsing functions to use asynchronous imports for improved performance and maintainability.

* test: add unit tests for processAgentFileUpload functionality

- Introduced a new test suite for the processAgentFileUpload function in process.spec.js.
- Implemented various test cases to validate OCR strategy selection based on file types, including PDF, DOCX, XLSX, and XLS.
- Mocked dependencies to ensure isolated testing of file upload handling and strategy selection logic.
- Enhanced coverage for scenarios involving OCR capability checks and default strategy fallbacks.

* chore: update pdfjs-dist version and enhance document parsing tests

- Bumped pdfjs-dist dependency to version 5.4.624 in both api and packages/api.
- Refactored document parsing tests to use 'originalname' instead of 'filename' for file objects.
- Added a new test case for parsing XLS files to improve coverage of document types supported by the parser.
- Introduced a sample XLS file for testing purposes.

* feat: enforce text size limit and improve OCR fallback handling in processAgentFileUpload

- Added a check to ensure extracted text does not exceed the 15MB storage limit, throwing an error if it does.
- Refactored the OCR handling logic to improve fallback behavior when the configured OCR fails, ensuring a more robust document processing flow.
- Enhanced unit tests to cover scenarios for oversized text and fallback mechanisms, ensuring proper error handling and functionality.

* fix: correct OCR URL construction in performOCR function

- Updated the OCR URL construction to ensure it correctly appends '/ocr' to the base URL if not already present, improving the reliability of the OCR request.

---------

Co-authored-by: Dan Lew <daniel@mightyacorn.com>
2026-02-22 14:22:45 -05:00
..
react-query 🛸 feat: Remote Agent Access with External API Support (#11503) 2026-01-28 17:44:33 -05:00
types 📄 feat: Local Text Extraction for PDF, DOCX, and XLS/XLSX (#11900) 2026-02-22 14:22:45 -05:00
accessPermissions.ts 🛸 feat: Remote Agent Access with External API Support (#11503) 2026-01-28 17:44:33 -05:00
actions.ts 🛡️ fix: Implement TOCTOU-Safe SSRF Protection for Actions and MCP (#11722) 2026-02-11 22:09:58 -05:00
api-endpoints.ts 🛡️ fix: Secure MCP/Actions OAuth Flows, Resolve Race Condition & Tool Cache Cleanup (#11756) 2026-02-12 14:22:05 -05:00
artifacts.ts 🪟 fix: Windows Build (npm) (#3889) 2024-09-02 10:01:09 -04:00
azure.ts 🔃 refactor: Decouple Effects from AppService, move to data-schemas (#9974) 2025-10-05 06:37:57 -04:00
bedrock.ts 🤖 feat: Claude Sonnet 4.6 support (#11829) 2026-02-17 15:24:03 -05:00
config.ts 📄 feat: Local Text Extraction for PDF, DOCX, and XLS/XLSX (#11900) 2026-02-22 14:22:45 -05:00
createPayload.ts ⏸ refactor: Improve UX for Parallel Streams (Multi-Convo) (#11096) 2025-12-25 01:43:54 -05:00
data-service.ts 🛡️ fix: Secure MCP/Actions OAuth Flows, Resolve Race Condition & Tool Cache Cleanup (#11756) 2026-02-12 14:22:05 -05:00
feedback.ts 📈 feat: Chat rating for feedback (#5878) 2025-05-30 12:16:34 -04:00
file-config.spec.ts 📂 refactor: Cleanup File Filtering Logic, Improve Validation (#10414) 2025-11-10 19:05:30 -05:00
file-config.ts 🆔 fix: Atomic File Dedupe, Bedrock Tokens Fix, and Allowed MIME Types (#11675) 2026-02-07 13:26:18 -05:00
generate.ts 🪐 feat: Initial OpenAI Responses API Support (#8149) 2025-06-30 18:34:47 -04:00
headers-helpers.ts chore: add back data-provider 2023-07-30 11:50:24 -04:00
index.ts 📡 refactor: MCP Runtime Config Sync with Redis Distributed Locking (#10352) 2025-12-11 16:36:15 -05:00
keys.ts 🛸 feat: Remote Agent Access with External API Support (#11503) 2026-01-28 17:44:33 -05:00
mcp.ts 🔒 fix: Restrict MCP Stdio Transport via API (#11184) 2026-01-03 12:47:11 -05:00
messages.ts 🐛 fix: String Interpolation in Messages Endpoint from #9155 (#9312) 2025-08-27 13:48:48 -04:00
models.ts 🗂️ refactor: Artifacts via Model Specs & Scope Badge Persistence by Spec Context (#11796) 2026-02-14 13:56:50 -05:00
parameterSettings.ts 🎮 feat: Bedrock Parameters for OpenAI GPT-OSS models (#11798) 2026-02-14 14:10:32 -05:00
parsers.ts 🎭 feat: Override Custom Endpoint Schema with Specified Params Endpoint (#11788) 2026-02-13 23:04:51 -05:00
permissions.ts 🛸 feat: Remote Agent Access with External API Support (#11503) 2026-01-28 17:44:33 -05:00
request.ts 🧭 fix: Add Base Path Support for Login/Register and Image Paths (#10116) 2025-11-21 11:25:14 -05:00
roles.ts 🛸 feat: Remote Agent Access with External API Support (#11503) 2026-01-28 17:44:33 -05:00
schemas.spec.ts 🤖 feat: Claude Opus 4.6 - 1M Context, Premium Pricing, Adaptive Thinking (#11670) 2026-02-06 18:35:36 -05:00
schemas.ts 🎮 feat: Bedrock Parameters for OpenAI GPT-OSS models (#11798) 2026-02-14 14:10:32 -05:00
types.ts 🗂️ refactor: Artifacts via Model Specs & Scope Badge Persistence by Spec Context (#11796) 2026-02-14 13:56:50 -05:00
utils.ts 📂 refactor: Cleanup File Filtering Logic, Improve Validation (#10414) 2025-11-10 19:05:30 -05:00