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
4c9fa6cf
"src/include/Array.hpp" did not exist on "17f3d2d4bccebcc3a70606a916f93dc90e5eaa3a"
Commit
4c9fa6cf
authored
Jun 24, 2024
by
Timothy J. Baek
Browse files
enh: pipe handling
parent
837944dc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
backend/apps/webui/main.py
backend/apps/webui/main.py
+13
-5
No files found.
backend/apps/webui/main.py
View file @
4c9fa6cf
...
@@ -233,6 +233,16 @@ async def generate_function_chat_completion(form_data, user):
...
@@ -233,6 +233,16 @@ async def generate_function_chat_completion(form_data, user):
res
=
await
pipe
(
**
params
)
res
=
await
pipe
(
**
params
)
else
:
else
:
res
=
pipe
(
**
params
)
res
=
pipe
(
**
params
)
# Directly return if the response is a StreamingResponse
if
isinstance
(
res
,
StreamingResponse
):
async
for
data
in
res
.
body_iterator
:
yield
data
return
if
isinstance
(
res
,
dict
):
yield
f
"data:
{
json
.
dumps
(
res
)
}
\n\n
"
return
except
Exception
as
e
:
except
Exception
as
e
:
print
(
f
"Error:
{
e
}
"
)
print
(
f
"Error:
{
e
}
"
)
yield
f
"data:
{
json
.
dumps
(
{
'error'
:
{
'detail'
:
str
(
e
)
}}
)
}
\n\n
"
yield
f
"data:
{
json
.
dumps
(
{
'error'
:
{
'detail'
:
str
(
e
)
}}
)
}
\n\n
"
...
@@ -285,15 +295,13 @@ async def generate_function_chat_completion(form_data, user):
...
@@ -285,15 +295,13 @@ async def generate_function_chat_completion(form_data, user):
res
=
await
pipe
(
**
params
)
res
=
await
pipe
(
**
params
)
else
:
else
:
res
=
pipe
(
**
params
)
res
=
pipe
(
**
params
)
if
isinstance
(
res
,
StreamingResponse
):
return
res
except
Exception
as
e
:
except
Exception
as
e
:
print
(
f
"Error:
{
e
}
"
)
print
(
f
"Error:
{
e
}
"
)
return
{
"error"
:
{
"detail"
:
str
(
e
)}}
return
{
"error"
:
{
"detail"
:
str
(
e
)}}
if
inspect
.
iscoroutinefunction
(
pipe
):
res
=
await
pipe
(
**
params
)
else
:
res
=
pipe
(
**
params
)
if
isinstance
(
res
,
dict
):
if
isinstance
(
res
,
dict
):
return
res
return
res
elif
isinstance
(
res
,
BaseModel
):
elif
isinstance
(
res
,
BaseModel
):
...
...
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