Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
1ff3eb80
Commit
1ff3eb80
authored
Jan 08, 2024
by
Timothy J. Baek
Browse files
feat: doc upload error handling
parent
eddb6fc7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
5 deletions
+13
-5
backend/apps/web/routers/documents.py
backend/apps/web/routers/documents.py
+3
-3
backend/constants.py
backend/constants.py
+2
-0
src/routes/(app)/documents/+page.svelte
src/routes/(app)/documents/+page.svelte
+8
-2
No files found.
backend/apps/web/routers/documents.py
View file @
1ff3eb80
...
@@ -49,13 +49,13 @@ async def create_new_doc(form_data: DocumentForm, user=Depends(get_current_user)
...
@@ -49,13 +49,13 @@ async def create_new_doc(form_data: DocumentForm, user=Depends(get_current_user)
return
doc
return
doc
else
:
else
:
raise
HTTPException
(
raise
HTTPException
(
status_code
=
status
.
HTTP_40
1_UNAUTHORIZED
,
status_code
=
status
.
HTTP_40
0_BAD_REQUEST
,
detail
=
ERROR_MESSAGES
.
DEFAULT
()
,
detail
=
ERROR_MESSAGES
.
FILE_EXISTS
,
)
)
else
:
else
:
raise
HTTPException
(
raise
HTTPException
(
status_code
=
status
.
HTTP_400_BAD_REQUEST
,
status_code
=
status
.
HTTP_400_BAD_REQUEST
,
detail
=
ERROR_MESSAGES
.
COMMAND
_TAKEN
,
detail
=
ERROR_MESSAGES
.
NAME_TAG
_TAKEN
,
)
)
...
...
backend/constants.py
View file @
1ff3eb80
...
@@ -18,6 +18,8 @@ class ERROR_MESSAGES(str, Enum):
...
@@ -18,6 +18,8 @@ class ERROR_MESSAGES(str, Enum):
"Uh-oh! This username is already registered. Please choose another username."
"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."
COMMAND_TAKEN
=
"Uh-oh! This command is already registered. Please choose another command string."
FILE_EXISTS
=
"Uh-oh! This file is already registered. Please choose another file."
NAME_TAG_TAKEN
=
"Uh-oh! This name tag is already registered. Please choose another name tag string."
NAME_TAG_TAKEN
=
"Uh-oh! This name tag is already registered. Please choose another name tag string."
INVALID_TOKEN
=
(
INVALID_TOKEN
=
(
"Your session has expired or the token is invalid. Please sign in again."
"Your session has expired or the token is invalid. Please sign in again."
...
...
src/routes/(app)/documents/+page.svelte
View file @
1ff3eb80
...
@@ -29,7 +29,10 @@
...
@@ -29,7 +29,10 @@
};
};
const uploadDoc = async (file) => {
const uploadDoc = async (file) => {
const res = await uploadDocToVectorDB(localStorage.token, '', file);
const res = await uploadDocToVectorDB(localStorage.token, '', file).catch((error) => {
toast.error(error);
return null;
});
if (res) {
if (res) {
await createNewDoc(
await createNewDoc(
...
@@ -38,7 +41,10 @@
...
@@ -38,7 +41,10 @@
res.filename,
res.filename,
transformFileName(res.filename),
transformFileName(res.filename),
res.filename
res.filename
);
).catch((error) => {
toast.error(error);
return null;
});
await documents.set(await getDocs(localStorage.token));
await documents.set(await getDocs(localStorage.token));
}
}
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment