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
96d7c3e9
Commit
96d7c3e9
authored
Jun 20, 2024
by
Timothy J. Baek
Browse files
fix: raise error
parent
c4bd6011
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
6 deletions
+3
-6
backend/main.py
backend/main.py
+3
-6
No files found.
backend/main.py
View file @
96d7c3e9
...
@@ -330,11 +330,11 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
...
@@ -330,11 +330,11 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
body
=
await
request
.
body
()
body
=
await
request
.
body
()
body_str
=
body
.
decode
(
"utf-8"
)
body_str
=
body
.
decode
(
"utf-8"
)
data
=
json
.
loads
(
body_str
)
if
body_str
else
{}
data
=
json
.
loads
(
body_str
)
if
body_str
else
{}
user
=
get_current_user
(
user
=
get_current_user
(
request
,
request
,
get_http_authorization_cred
(
request
.
headers
.
get
(
"Authorization"
)),
get_http_authorization_cred
(
request
.
headers
.
get
(
"Authorization"
)),
)
)
# Flag to skip RAG completions if file_handler is present in tools/functions
# Flag to skip RAG completions if file_handler is present in tools/functions
skip_files
=
False
skip_files
=
False
...
@@ -346,8 +346,6 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
...
@@ -346,8 +346,6 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
)
)
model
=
app
.
state
.
MODELS
[
model_id
]
model
=
app
.
state
.
MODELS
[
model_id
]
print
(
":"
,
data
)
# Check if the model has any filters
# Check if the model has any filters
for
filter_id
in
model
[
"info"
][
"meta"
].
get
(
"filterIds"
,
[]):
for
filter_id
in
model
[
"info"
][
"meta"
].
get
(
"filterIds"
,
[]):
filter
=
Functions
.
get_function_by_id
(
filter_id
)
filter
=
Functions
.
get_function_by_id
(
filter_id
)
...
@@ -377,12 +375,11 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
...
@@ -377,12 +375,11 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
)
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
f
"Error:
{
e
}
"
)
print
(
f
"Error:
{
e
}
"
)
r
aise
HTTPException
(
r
eturn
JSONResponse
(
status_code
=
status
.
HTTP_400_BAD_REQUEST
,
status_code
=
status
.
HTTP_400_BAD_REQUEST
,
detail
=
e
,
content
=
{
"detail"
:
str
(
e
)}
,
)
)
print
(
"Filtered:"
,
data
)
# Set the task model
# Set the task model
task_model_id
=
data
[
"model"
]
task_model_id
=
data
[
"model"
]
# Check if the user has a custom task model and use that model
# Check if the user has a custom task model and use that model
...
...
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