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
ae567796
Commit
ae567796
authored
Jun 22, 2024
by
Timothy J. Baek
Browse files
refac
parent
9220fdc4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
29 deletions
+42
-29
backend/apps/webui/main.py
backend/apps/webui/main.py
+3
-1
backend/main.py
backend/main.py
+39
-28
No files found.
backend/apps/webui/main.py
View file @
ae567796
...
...
@@ -130,7 +130,9 @@ async def get_pipe_models():
manifold_pipe_name
=
p
[
"name"
]
if
hasattr
(
function_module
,
"name"
):
manifold_pipe_name
=
f
"
{
pipe
.
name
}{
manifold_pipe_name
}
"
manifold_pipe_name
=
(
f
"
{
function_module
.
name
}{
manifold_pipe_name
}
"
)
pipe_models
.
append
(
{
...
...
backend/main.py
View file @
ae567796
...
...
@@ -389,26 +389,31 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
if
hasattr
(
function_module
,
"inlet"
):
inlet
=
function_module
.
inlet
if
inspect
.
iscoroutinefunction
(
inlet
):
data
=
await
inlet
(
data
,
{
# Get the signature of the function
sig
=
inspect
.
signature
(
inlet
)
param
=
{
"body"
:
data
}
if
"__user__"
in
sig
.
parameters
:
param
=
{
**
param
,
"__user__"
:
{
"id"
:
user
.
id
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
},
)
}
if
"__id__"
in
sig
.
parameters
:
param
=
{
**
param
,
"__id__"
:
filter_id
,
}
if
inspect
.
iscoroutinefunction
(
inlet
):
data
=
await
inlet
(
**
param
)
else
:
data
=
inlet
(
data
,
{
"id"
:
user
.
id
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
},
)
data
=
inlet
(
**
param
)
except
Exception
as
e
:
print
(
f
"Error:
{
e
}
"
)
...
...
@@ -1031,26 +1036,32 @@ async def chat_completed(form_data: dict, user=Depends(get_verified_user)):
try
:
if
hasattr
(
function_module
,
"outlet"
):
outlet
=
function_module
.
outlet
if
inspect
.
iscoroutinefunction
(
outlet
):
data
=
await
outlet
(
data
,
{
# Get the signature of the function
sig
=
inspect
.
signature
(
outlet
)
param
=
{
"body"
:
data
}
if
"__user__"
in
sig
.
parameters
:
param
=
{
**
param
,
"__user__"
:
{
"id"
:
user
.
id
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
},
)
}
if
"__id__"
in
sig
.
parameters
:
param
=
{
**
param
,
"__id__"
:
filter_id
,
}
if
inspect
.
iscoroutinefunction
(
outlet
):
data
=
await
outlet
(
**
param
)
else
:
data
=
outlet
(
data
,
{
"id"
:
user
.
id
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
},
)
data
=
outlet
(
**
param
)
except
Exception
as
e
:
print
(
f
"Error:
{
e
}
"
)
...
...
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