diff --git a/backend/open_webui/apps/retrieval/main.py b/backend/open_webui/apps/retrieval/main.py index eacb0d7cd..73dc08624 100644 --- a/backend/open_webui/apps/retrieval/main.py +++ b/backend/open_webui/apps/retrieval/main.py @@ -15,6 +15,9 @@ from fastapi import Depends, FastAPI, File, Form, HTTPException, UploadFile, sta from fastapi.middleware.cors import CORSMiddleware from pydantic import BaseModel + +from open_webui.apps.webui.models.knowledge import Knowledges + from open_webui.apps.retrieval.vector.connector import VECTOR_DB_CLIENT # Document loaders @@ -1277,6 +1280,7 @@ def delete_entries_from_collection(form_data: DeleteForm, user=Depends(get_admin @app.post("/reset/db") def reset_vector_db(user=Depends(get_admin_user)): VECTOR_DB_CLIENT.reset() + Knowledges.delete_all_knowledge() @app.post("/reset/uploads") @@ -1299,28 +1303,6 @@ def reset_upload_dir(user=Depends(get_admin_user)) -> bool: print(f"The directory {folder} does not exist") except Exception as e: print(f"Failed to process the directory {folder}. Reason: {e}") - - return True - - -@app.post("/reset") -def reset(user=Depends(get_admin_user)) -> bool: - folder = f"{UPLOAD_DIR}" - for filename in os.listdir(folder): - file_path = os.path.join(folder, filename) - try: - if os.path.isfile(file_path) or os.path.islink(file_path): - os.unlink(file_path) - elif os.path.isdir(file_path): - shutil.rmtree(file_path) - except Exception as e: - log.error("Failed to delete %s. Reason: %s" % (file_path, e)) - - try: - VECTOR_DB_CLIENT.reset() - except Exception as e: - log.exception(e) - return True diff --git a/backend/open_webui/apps/webui/models/knowledge.py b/backend/open_webui/apps/webui/models/knowledge.py index 2423d1f84..269ad8cc3 100644 --- a/backend/open_webui/apps/webui/models/knowledge.py +++ b/backend/open_webui/apps/webui/models/knowledge.py @@ -154,5 +154,15 @@ class KnowledgeTable: except Exception: return False + def delete_all_knowledge(self) -> bool: + with get_db() as db: + try: + db.query(Knowledge).delete() + db.commit() + + return True + except Exception: + return False + Knowledges = KnowledgeTable() diff --git a/src/lib/components/admin/Settings/Documents.svelte b/src/lib/components/admin/Settings/Documents.svelte index d94146c7d..63212b03e 100644 --- a/src/lib/components/admin/Settings/Documents.svelte +++ b/src/lib/components/admin/Settings/Documents.svelte @@ -26,6 +26,7 @@ import ResetVectorDBConfirmDialog from '$lib/components/common/ConfirmDialog.svelte'; import SensitiveInput from '$lib/components/common/SensitiveInput.svelte'; import Tooltip from '$lib/components/common/Tooltip.svelte'; + import Switch from '$lib/components/common/Switch.svelte'; const i18n = getContext('i18n'); @@ -535,13 +536,13 @@
-
{$i18n.t('Content Extraction')}
+
{$i18n.t('Content Extraction')}
-
+
{$i18n.t('Engine')}
-
-
{$i18n.t('Files')}
+
+
{$i18n.t('Query Params')}
-
+
+
+
{$i18n.t('Top K')}
+ +
+ +
+
+ + {#if querySettings.hybrid === true} +
+
+ {$i18n.t('Minimum Score')} +
+ +
+ +
+
+ {/if} +
+ + {#if querySettings.hybrid === true} +
+ {$i18n.t( + 'Note: If you set a minimum score, the search will only return documents with a score greater than or equal to the minimum score.' + )} +
+ {/if} + +
+
{$i18n.t('RAG Template')}
+ +