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 @@
+
+
+
+
+