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
5621025c
Commit
5621025c
authored
Jun 20, 2024
by
Timothy J. Baek
Browse files
feat: async filter support
parent
6bb2f418
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
18 deletions
+45
-18
backend/main.py
backend/main.py
+45
-18
No files found.
backend/main.py
View file @
5621025c
...
...
@@ -384,15 +384,29 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
try
:
if
hasattr
(
function_module
,
"inlet"
):
data
=
function_module
.
inlet
(
data
,
{
"id"
:
user
.
id
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
},
)
inlet
=
function_module
.
inlet
if
inspect
.
iscoroutinefunction
(
inlet
):
data
=
await
inlet
(
data
,
{
"id"
:
user
.
id
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
},
)
else
:
data
=
inlet
(
data
,
{
"id"
:
user
.
id
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
},
)
except
Exception
as
e
:
print
(
f
"Error:
{
e
}
"
)
return
JSONResponse
(
...
...
@@ -1007,15 +1021,28 @@ async def chat_completed(form_data: dict, user=Depends(get_verified_user)):
try
:
if
hasattr
(
function_module
,
"outlet"
):
data
=
function_module
.
outlet
(
data
,
{
"id"
:
user
.
id
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
},
)
outlet
=
function_module
.
outlet
if
inspect
.
iscoroutinefunction
(
outlet
):
data
=
await
outlet
(
data
,
{
"id"
:
user
.
id
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
},
)
else
:
data
=
outlet
(
data
,
{
"id"
:
user
.
id
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
},
)
except
Exception
as
e
:
print
(
f
"Error:
{
e
}
"
)
return
JSONResponse
(
...
...
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