mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
💻 fix(client): Allow Code Filetypes and Suppress Known Vite Warnings (#2492)
* refactor(vite): suppress known warnings * fix: allow known code filetypes if there is a mismatch of expected type, or originalFile.type is empty * refactor(useFileHandling): naming, use variable
This commit is contained in:
parent
738207de50
commit
f94a782b4f
4 changed files with 55 additions and 10 deletions
|
|
@ -4,6 +4,7 @@ import { useState, useEffect, useCallback } from 'react';
|
|||
import {
|
||||
megabyte,
|
||||
EModelEndpoint,
|
||||
codeTypeMapping,
|
||||
mergeFileConfig,
|
||||
fileConfig as defaultFileConfig,
|
||||
} from 'librechat-data-provider';
|
||||
|
|
@ -125,7 +126,11 @@ const useFileHandling = (params?: UseFileHandling) => {
|
|||
startUploadTimer(extendedFile.file_id, extendedFile.file?.name || 'File');
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('file', extendedFile.file as File, encodeURIComponent(extendedFile.file?.name || 'File'));
|
||||
formData.append(
|
||||
'file',
|
||||
extendedFile.file as File,
|
||||
encodeURIComponent(extendedFile.file?.name || 'File'),
|
||||
);
|
||||
formData.append('file_id', extendedFile.file_id);
|
||||
if (extendedFile.width) {
|
||||
formData.append('width', extendedFile.width?.toString());
|
||||
|
|
@ -168,10 +173,12 @@ const useFileHandling = (params?: UseFileHandling) => {
|
|||
for (let i = 0; i < fileList.length; i++) {
|
||||
let originalFile = fileList[i];
|
||||
let fileType = originalFile.type;
|
||||
const extension = originalFile.name.split('.').pop() ?? '';
|
||||
const knownCodeType = codeTypeMapping[extension];
|
||||
|
||||
// Infer MIME type for Markdown files when the type is empty
|
||||
if (!fileType && originalFile.name.endsWith('.md')) {
|
||||
fileType = 'text/markdown';
|
||||
// Infer MIME type for Known Code files when the type is empty or a mismatch
|
||||
if (knownCodeType && (!fileType || fileType !== knownCodeType)) {
|
||||
fileType = knownCodeType;
|
||||
}
|
||||
|
||||
// Check if the file type is still empty after the extension check
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue