From e6639cb37f70befdf43d28002d5e810def2b64d8 Mon Sep 17 00:00:00 2001 From: inubimambo Date: Wed, 9 Jul 2025 21:32:56 +0800 Subject: [PATCH 1/2] Add favicon --- public/favicon-32x32.svg | 38 ++++++++++++++++++++++++++++++++++++++ public/favicon.svg | 32 ++++++++++++++++++++++++++++++++ public/images/favicon.svg | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 public/favicon-32x32.svg create mode 100644 public/favicon.svg create mode 100644 public/images/favicon.svg diff --git a/public/favicon-32x32.svg b/public/favicon-32x32.svg new file mode 100644 index 0000000..f604fc5 --- /dev/null +++ b/public/favicon-32x32.svg @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AI + diff --git a/public/favicon.svg b/public/favicon.svg new file mode 100644 index 0000000..8a07f50 --- /dev/null +++ b/public/favicon.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AI + diff --git a/public/images/favicon.svg b/public/images/favicon.svg new file mode 100644 index 0000000..f604fc5 --- /dev/null +++ b/public/images/favicon.svg @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AI + From 10573072ff5e07b1f24353a67c101c0f28f82f27 Mon Sep 17 00:00:00 2001 From: inubimambo Date: Wed, 9 Jul 2025 21:42:08 +0800 Subject: [PATCH 2/2] Fix: RAG can get corrupted upon uploading other file types --- public/js/main.js | 55 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/public/js/main.js b/public/js/main.js index 0667f63..9906645 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -53,9 +53,60 @@ function initializeFileUpload() { function showFileInfo(file) { if (fileName && fileSize && fileInfo) { - fileName.textContent = file.name; - fileSize.textContent = `(${formatFileSize(file.size)})`; + // Define allowed file types for client-side validation + const allowedExtensions = ['.pdf', '.txt', '.doc', '.docx', '.xlsx', '.xls', '.md', '.json', '.csv', '.xml']; + const allowedMimeTypes = [ + 'application/pdf', + 'text/plain', + 'text/markdown', + 'text/csv', + 'text/xml', + 'application/xml', + 'application/json', + 'application/msword', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'application/vnd.ms-excel', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' + ]; + + // Get file extension + const fileExtension = '.' + file.name.split('.').pop().toLowerCase(); + const fileMimeType = file.type.toLowerCase(); + + // Check if file type is allowed + const isExtensionAllowed = allowedExtensions.includes(fileExtension); + const isMimeTypeAllowed = allowedMimeTypes.includes(fileMimeType) || fileMimeType === ''; + + if (!isExtensionAllowed) { + // Show error for invalid file type + fileInfo.innerHTML = ` +
+ + Invalid file type! "${fileExtension}" files are not supported. +
Only document files (PDF, Word, Excel, text files) are allowed to prevent RAG corruption. +
+ `; + fileInfo.classList.remove('d-none'); + uploadBtn.disabled = true; + return; + } + + // Show valid file info + fileInfo.innerHTML = ` +
+ + ${file.name} + (${formatFileSize(file.size)}) +
+ + + File type supported for AI processing + +
+
+ `; fileInfo.classList.remove('d-none'); + uploadBtn.disabled = false; } }