mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-27 21:04:08 +01:00
🧩 feat: OpenDocument Format File Upload and Native ODS Parsing (#11959)
* ✨ feat: Add support for OpenDocument MIME types in file configuration
Updated the applicationMimeTypes regex to include support for OASIS OpenDocument formats, enhancing the file type recognition capabilities of the data provider.
* feat: document processing with OpenDocument support
Added support for OpenDocument Spreadsheet (ODS) MIME type in the file processing service and updated the document parser to handle ODS files. Included tests to verify correct parsing of ODS documents and updated file configuration to recognize OpenDocument formats.
* refactor: Enhance document processing to support additional Excel MIME types
Updated the document processing logic to utilize a regex for matching Excel MIME types, improving flexibility in handling various Excel file formats. Added tests to ensure correct parsing of new MIME types, including multiple Excel variants and OpenDocument formats. Adjusted file configuration to include these MIME types for better recognition in the file processing service.
* feat: Add support for additional OpenDocument MIME types in file processing
Enhanced the document processing service to support ODT, ODP, and ODG MIME types. Updated tests to verify correct routing through the OCR strategy for these new formats. Adjusted documentation to reflect changes in handled MIME types for improved clarity.
This commit is contained in:
parent
3a079b980a
commit
046e92217f
7 changed files with 220 additions and 26 deletions
|
|
@ -83,6 +83,10 @@ const PDF_MIME = 'application/pdf';
|
|||
const DOCX_MIME = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
|
||||
const XLSX_MIME = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
||||
const XLS_MIME = 'application/vnd.ms-excel';
|
||||
const ODS_MIME = 'application/vnd.oasis.opendocument.spreadsheet';
|
||||
const ODT_MIME = 'application/vnd.oasis.opendocument.text';
|
||||
const ODP_MIME = 'application/vnd.oasis.opendocument.presentation';
|
||||
const ODG_MIME = 'application/vnd.oasis.opendocument.graphics';
|
||||
|
||||
const makeReq = ({ mimetype = PDF_MIME, ocrConfig = null } = {}) => ({
|
||||
user: { id: 'user-123' },
|
||||
|
|
@ -138,6 +142,9 @@ describe('processAgentFileUpload', () => {
|
|||
['DOCX', DOCX_MIME],
|
||||
['XLSX', XLSX_MIME],
|
||||
['XLS', XLS_MIME],
|
||||
['ODS', ODS_MIME],
|
||||
['Excel variant (msexcel)', 'application/msexcel'],
|
||||
['Excel variant (x-msexcel)', 'application/x-msexcel'],
|
||||
])('uses document_parser automatically for %s when no OCR is configured', async (_, mime) => {
|
||||
mergeFileConfig.mockReturnValue(makeFileConfig());
|
||||
const req = makeReq({ mimetype: mime, ocrConfig: null });
|
||||
|
|
@ -229,6 +236,23 @@ describe('processAgentFileUpload', () => {
|
|||
expect(getStrategyFunctions).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test.each([
|
||||
['ODT', ODT_MIME],
|
||||
['ODP', ODP_MIME],
|
||||
['ODG', ODG_MIME],
|
||||
])('routes %s through configured OCR when OCR supports the type', async (_, mime) => {
|
||||
mergeFileConfig.mockReturnValue(makeFileConfig({ ocrSupportedMimeTypes: [mime] }));
|
||||
const req = makeReq({
|
||||
mimetype: mime,
|
||||
ocrConfig: { strategy: FileSources.mistral_ocr },
|
||||
});
|
||||
|
||||
await processAgentFileUpload({ req, res: mockRes, metadata: makeMetadata() });
|
||||
|
||||
expect(checkCapability).toHaveBeenCalledWith(expect.anything(), AgentCapabilities.ocr);
|
||||
expect(getStrategyFunctions).toHaveBeenCalledWith(FileSources.mistral_ocr);
|
||||
});
|
||||
|
||||
test('throws instead of falling back to parseText when document_parser fails for a document MIME type', async () => {
|
||||
getStrategyFunctions.mockReturnValue({
|
||||
handleFileUpload: jest.fn().mockRejectedValue(new Error('No text found in document')),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue