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
5369023e
Commit
5369023e
authored
May 14, 2024
by
Jun Siang Cheah
Browse files
fix: rag, chat deletion, and webhook after config persistence change
parent
233dcb2d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
11 deletions
+11
-11
backend/apps/openai/main.py
backend/apps/openai/main.py
+3
-3
backend/apps/web/routers/chats.py
backend/apps/web/routers/chats.py
+2
-2
backend/main.py
backend/main.py
+4
-4
src/routes/+layout.svelte
src/routes/+layout.svelte
+2
-2
No files found.
backend/apps/openai/main.py
View file @
5369023e
...
@@ -119,9 +119,9 @@ async def speech(request: Request, user=Depends(get_verified_user)):
...
@@ -119,9 +119,9 @@ async def speech(request: Request, user=Depends(get_verified_user)):
headers
=
{}
headers
=
{}
headers
[
"Authorization"
]
=
f
"Bearer
{
app
.
state
.
config
.
OPENAI_API_KEYS
[
idx
]
}
"
headers
[
"Authorization"
]
=
f
"Bearer
{
app
.
state
.
config
.
OPENAI_API_KEYS
[
idx
]
}
"
headers
[
"Content-Type"
]
=
"application/json"
headers
[
"Content-Type"
]
=
"application/json"
if
"openrouter.ai"
in
app
.
state
.
OPENAI_API_BASE_URLS
[
idx
]:
if
"openrouter.ai"
in
app
.
state
.
config
.
OPENAI_API_BASE_URLS
[
idx
]:
headers
[
'
HTTP-Referer
'
]
=
"https://openwebui.com/"
headers
[
"
HTTP-Referer
"
]
=
"https://openwebui.com/"
headers
[
'
X-Title
'
]
=
"Open WebUI"
headers
[
"
X-Title
"
]
=
"Open WebUI"
r
=
None
r
=
None
try
:
try
:
r
=
requests
.
post
(
r
=
requests
.
post
(
...
...
backend/apps/web/routers/chats.py
View file @
5369023e
...
@@ -58,7 +58,7 @@ async def delete_all_user_chats(request: Request, user=Depends(get_current_user)
...
@@ -58,7 +58,7 @@ async def delete_all_user_chats(request: Request, user=Depends(get_current_user)
if
(
if
(
user
.
role
==
"user"
user
.
role
==
"user"
and
not
request
.
app
.
state
.
USER_PERMISSIONS
[
"chat"
][
"deletion"
]
and
not
request
.
app
.
state
.
config
.
USER_PERMISSIONS
[
"chat"
][
"deletion"
]
):
):
raise
HTTPException
(
raise
HTTPException
(
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
...
@@ -266,7 +266,7 @@ async def delete_chat_by_id(request: Request, id: str, user=Depends(get_current_
...
@@ -266,7 +266,7 @@ async def delete_chat_by_id(request: Request, id: str, user=Depends(get_current_
result
=
Chats
.
delete_chat_by_id
(
id
)
result
=
Chats
.
delete_chat_by_id
(
id
)
return
result
return
result
else
:
else
:
if
not
request
.
app
.
state
.
USER_PERMISSIONS
[
"chat"
][
"deletion"
]:
if
not
request
.
app
.
state
.
config
.
USER_PERMISSIONS
[
"chat"
][
"deletion"
]:
raise
HTTPException
(
raise
HTTPException
(
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
status_code
=
status
.
HTTP_401_UNAUTHORIZED
,
detail
=
ERROR_MESSAGES
.
ACCESS_PROHIBITED
,
detail
=
ERROR_MESSAGES
.
ACCESS_PROHIBITED
,
...
...
backend/main.py
View file @
5369023e
...
@@ -144,12 +144,12 @@ class RAGMiddleware(BaseHTTPMiddleware):
...
@@ -144,12 +144,12 @@ class RAGMiddleware(BaseHTTPMiddleware):
data
[
"messages"
],
citations
=
rag_messages
(
data
[
"messages"
],
citations
=
rag_messages
(
docs
=
data
[
"docs"
],
docs
=
data
[
"docs"
],
messages
=
data
[
"messages"
],
messages
=
data
[
"messages"
],
template
=
rag_app
.
state
.
RAG_TEMPLATE
,
template
=
rag_app
.
state
.
config
.
RAG_TEMPLATE
,
embedding_function
=
rag_app
.
state
.
EMBEDDING_FUNCTION
,
embedding_function
=
rag_app
.
state
.
EMBEDDING_FUNCTION
,
k
=
rag_app
.
state
.
TOP_K
,
k
=
rag_app
.
state
.
config
.
TOP_K
,
reranking_function
=
rag_app
.
state
.
sentence_transformer_rf
,
reranking_function
=
rag_app
.
state
.
sentence_transformer_rf
,
r
=
rag_app
.
state
.
RELEVANCE_THRESHOLD
,
r
=
rag_app
.
state
.
config
.
RELEVANCE_THRESHOLD
,
hybrid_search
=
rag_app
.
state
.
ENABLE_RAG_HYBRID_SEARCH
,
hybrid_search
=
rag_app
.
state
.
config
.
ENABLE_RAG_HYBRID_SEARCH
,
)
)
del
data
[
"docs"
]
del
data
[
"docs"
]
...
...
src/routes/+layout.svelte
View file @
5369023e
...
@@ -24,9 +24,9 @@
...
@@ -24,9 +24,9 @@
let backendConfig = null;
let backendConfig = null;
try {
try {
backendConfig = await getBackendConfig();
backendConfig = await getBackendConfig();
console.log(
"
Backend config:
"
, backendConfig);
console.log(
'
Backend config:
'
, backendConfig);
} catch (error) {
} catch (error) {
console.error(
"
Error loading backend config:
"
, error);
console.error(
'
Error loading backend config:
'
, error);
}
}
// Initialize i18n even if we didn't get a backend config,
// Initialize i18n even if we didn't get a backend config,
// so `/error` can show something that's not `undefined`.
// so `/error` can show something that's not `undefined`.
...
...
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