From 6747478f673462be13ae1cc62013852c8bd94c0c Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Thu, 3 Oct 2024 21:05:55 -0700 Subject: [PATCH] refac --- backend/open_webui/apps/retrieval/main.py | 2 +- backend/open_webui/constants.py | 2 ++ .../Knowledge/Collection/Files.svelte | 20 +++++++++++++++++++ .../workspace/Knowledge/Files.svelte | 7 ------- 4 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 src/lib/components/workspace/Knowledge/Collection/Files.svelte delete mode 100644 src/lib/components/workspace/Knowledge/Files.svelte diff --git a/backend/open_webui/apps/retrieval/main.py b/backend/open_webui/apps/retrieval/main.py index 613271596..d901cf719 100644 --- a/backend/open_webui/apps/retrieval/main.py +++ b/backend/open_webui/apps/retrieval/main.py @@ -649,7 +649,7 @@ def save_docs_to_vector_db( ) if existing_docs: log.info(f"Document with hash {metadata['hash']} already exists") - return True + raise ValueError(ERROR_MESSAGES.DUPLICATE_CONTENT) if split: text_splitter = RecursiveCharacterTextSplitter( diff --git a/backend/open_webui/constants.py b/backend/open_webui/constants.py index df6f9b37b..e8c456b9e 100644 --- a/backend/open_webui/constants.py +++ b/backend/open_webui/constants.py @@ -94,6 +94,8 @@ class ERROR_MESSAGES(str, Enum): lambda size="": f"Oops! The file you're trying to upload is too large. Please upload a file that is less than {size}." ) + DUPLICATE_CONTENT = "The content provided is a duplicate. Please ensure that the content is unique before proceeding." + class TASKS(str, Enum): def __str__(self) -> str: diff --git a/src/lib/components/workspace/Knowledge/Collection/Files.svelte b/src/lib/components/workspace/Knowledge/Collection/Files.svelte new file mode 100644 index 000000000..01a5ce720 --- /dev/null +++ b/src/lib/components/workspace/Knowledge/Collection/Files.svelte @@ -0,0 +1,20 @@ + + +
+ {#each files as file (file.id)} +
+ +
+ {/each} +
diff --git a/src/lib/components/workspace/Knowledge/Files.svelte b/src/lib/components/workspace/Knowledge/Files.svelte deleted file mode 100644 index 73109670a..000000000 --- a/src/lib/components/workspace/Knowledge/Files.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - -
- {JSON.stringify(files)} -