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
a8a45134
Commit
a8a45134
authored
Jun 22, 2024
by
Timothy J. Baek
Browse files
refac
parent
ae567796
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
backend/main.py
backend/main.py
+20
-5
No files found.
backend/main.py
View file @
a8a45134
...
@@ -858,13 +858,28 @@ async def generate_chat_completions(form_data: dict, user=Depends(get_verified_u
...
@@ -858,13 +858,28 @@ async def generate_chat_completions(form_data: dict, user=Depends(get_verified_u
print
(
pipe_id
)
print
(
pipe_id
)
pipe
=
webui_app
.
state
.
FUNCTIONS
[
pipe_id
].
pipe
pipe
=
webui_app
.
state
.
FUNCTIONS
[
pipe_id
].
pipe
if
form_data
[
"stream"
]:
# Get the signature of the function
sig
=
inspect
.
signature
(
pipe
)
param
=
{
"body"
:
form_data
}
if
"__user__"
in
sig
.
parameters
:
param
=
{
**
param
,
"__user__"
:
{
"id"
:
user
.
id
,
"email"
:
user
.
email
,
"name"
:
user
.
name
,
"role"
:
user
.
role
,
},
}
if
form_data
[
"stream"
]:
async
def
stream_content
():
async
def
stream_content
():
if
inspect
.
iscoroutinefunction
(
pipe
):
if
inspect
.
iscoroutinefunction
(
pipe
):
res
=
await
pipe
(
body
=
form_data
)
res
=
await
pipe
(
**
param
)
else
:
else
:
res
=
pipe
(
body
=
form_data
)
res
=
pipe
(
**
param
)
if
isinstance
(
res
,
str
):
if
isinstance
(
res
,
str
):
message
=
stream_message_template
(
form_data
[
"model"
],
res
)
message
=
stream_message_template
(
form_data
[
"model"
],
res
)
...
@@ -910,9 +925,9 @@ async def generate_chat_completions(form_data: dict, user=Depends(get_verified_u
...
@@ -910,9 +925,9 @@ async def generate_chat_completions(form_data: dict, user=Depends(get_verified_u
)
)
else
:
else
:
if
inspect
.
iscoroutinefunction
(
pipe
):
if
inspect
.
iscoroutinefunction
(
pipe
):
res
=
await
pipe
(
body
=
form_data
)
res
=
await
pipe
(
**
param
)
else
:
else
:
res
=
pipe
(
body
=
form_data
)
res
=
pipe
(
**
param
)
if
isinstance
(
res
,
dict
):
if
isinstance
(
res
,
dict
):
return
res
return
res
...
...
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