diff --git a/backend/apps/web/models/documents.py b/backend/apps/web/models/documents.py index ccd76194..0196c38b 100644 --- a/backend/apps/web/models/documents.py +++ b/backend/apps/web/models/documents.py @@ -105,9 +105,10 @@ class DocumentsTable: ).where(Document.name == name) query.execute() - doc = Document.get(Document.name == name) + doc = Document.get(Document.name == form_data.name) return DocumentModel(**model_to_dict(doc)) - except: + except Exception as e: + print(e) return None def delete_doc_by_name(self, name: str) -> bool: diff --git a/backend/apps/web/routers/documents.py b/backend/apps/web/routers/documents.py index 42463f51..9cc0dd5d 100644 --- a/backend/apps/web/routers/documents.py +++ b/backend/apps/web/routers/documents.py @@ -97,8 +97,8 @@ async def update_doc_by_name( return doc else: raise HTTPException( - status_code=status.HTTP_401_UNAUTHORIZED, - detail=ERROR_MESSAGES.ACCESS_PROHIBITED, + status_code=status.HTTP_400_BAD_REQUEST, + detail=ERROR_MESSAGES.NAME_TAG_TAKEN, ) diff --git a/backend/constants.py b/backend/constants.py index 0f7a46a0..b923ec8b 100644 --- a/backend/constants.py +++ b/backend/constants.py @@ -18,6 +18,7 @@ class ERROR_MESSAGES(str, Enum): "Uh-oh! This username is already registered. Please choose another username." ) COMMAND_TAKEN = "Uh-oh! This command is already registered. Please choose another command string." + NAME_TAG_TAKEN = "Uh-oh! This name tag is already registered. Please choose another name tag string." INVALID_TOKEN = ( "Your session has expired or the token is invalid. Please sign in again." ) diff --git a/src/lib/apis/documents/index.ts b/src/lib/apis/documents/index.ts index 37bdde04..fb208ea4 100644 --- a/src/lib/apis/documents/index.ts +++ b/src/lib/apis/documents/index.ts @@ -111,7 +111,7 @@ type DocUpdateForm = { export const updateDocByName = async (token: string, name: string, form: DocUpdateForm) => { let error = null; - const res = await fetch(`${WEBUI_API_BASE_URL}/prompts/name/${name}/update`, { + const res = await fetch(`${WEBUI_API_BASE_URL}/documents/name/${name}/update`, { method: 'POST', headers: { Accept: 'application/json', diff --git a/src/lib/components/documents/EditDocModal.svelte b/src/lib/components/documents/EditDocModal.svelte new file mode 100644 index 00000000..36be3795 --- /dev/null +++ b/src/lib/components/documents/EditDocModal.svelte @@ -0,0 +1,151 @@ + + + +
+
+
Edit Doc
+ +
+
+ +
+
+
{ + submitHandler(); + }} + > +
+
+
Name Tag
+ +
+
+ # +
+ +
+ + +
+ +
+
Title
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+ + diff --git a/src/routes/(app)/documents/+page.svelte b/src/routes/(app)/documents/+page.svelte index f0ad1a54..fa290999 100644 --- a/src/routes/(app)/documents/+page.svelte +++ b/src/routes/(app)/documents/+page.svelte @@ -11,11 +11,16 @@ import { uploadDocToVectorDB } from '$lib/apis/rag'; import { transformFileName } from '$lib/utils'; + import EditDocModal from '$lib/components/documents/EditDocModal.svelte'; + let importFiles = ''; let inputFiles = ''; let query = ''; + let showEditDocModal = false; + let selectedDoc; + let dragged = false; const deleteDoc = async (name) => { @@ -70,6 +75,10 @@ }; +{#key selectedDoc} + +{/key} +
@@ -156,7 +165,7 @@
Add Files
- Drop any files here to add to the conversation + Drop any files here to add to my documents
@@ -232,10 +241,13 @@
- { + showEditDocModal = !showEditDocModal; + selectedDoc = doc; + }} > - +