Timothy J. Baek 7 maanden geleden
bovenliggende
commit
1d8b3b8c51

+ 12 - 1
src/lib/components/chat/Chat.svelte

@@ -700,7 +700,7 @@
 				childrenIds: [],
 				role: 'user',
 				content: userPrompt,
-				files: _files.length > 0 ? _files : undefined,
+				files: chatFiles.length > 0 ? chatFiles : undefined,
 				timestamp: Math.floor(Date.now() / 1000), // Unix epoch
 				models: selectedModels
 			};
@@ -947,6 +947,12 @@
 			...(responseMessage?.files ?? []).filter((item) => ['web_search_results'].includes(item.type))
 		);
 
+		// Remove duplicates
+		files = files.filter(
+			(item, index, array) =>
+				array.findIndex((i) => JSON.stringify(i) === JSON.stringify(item)) === index
+		);
+
 		scrollToBottom();
 
 		eventTarget.dispatchEvent(
@@ -1246,6 +1252,11 @@
 			),
 			...(responseMessage?.files ?? []).filter((item) => ['web_search_results'].includes(item.type))
 		);
+		// Remove duplicates
+		files = files.filter(
+			(item, index, array) =>
+				array.findIndex((i) => JSON.stringify(i) === JSON.stringify(item)) === index
+		);
 
 		scrollToBottom();
 

+ 2 - 15
src/lib/components/chat/MessageInput.svelte

@@ -133,21 +133,8 @@
 				fileItem.id = uploadedFile.id;
 				fileItem.url = `${WEBUI_API_BASE_URL}/files/${uploadedFile.id}`;
 
-				// TODO: Check if tools & functions have files support to skip this step to delegate file processing
-				// Default Upload to VectorDB
-				if (
-					SUPPORTED_FILE_TYPE.includes(file['type']) ||
-					SUPPORTED_FILE_EXTENSIONS.includes(file.name.split('.').at(-1))
-				) {
-					processFileItem(fileItem);
-				} else {
-					toast.error(
-						$i18n.t(`Unknown file type '{{file_type}}'. Proceeding with the file upload anyway.`, {
-							file_type: file['type']
-						})
-					);
-					processFileItem(fileItem);
-				}
+				// Try to extract content of the file for retrieval, even non-supported file types
+				processFileItem(fileItem);
 			} else {
 				files = files.filter((item) => item.status !== null);
 			}

+ 1 - 1
src/lib/components/common/FileItem.svelte

@@ -25,7 +25,7 @@
 </script>
 
 {#if file}
-	<FileItemModal bind:show={showModal} {file} />
+	<FileItemModal bind:show={showModal} bind:file />
 {/if}
 
 <div class="relative group">