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
8dcb3d78
Commit
8dcb3d78
authored
Jul 11, 2024
by
Timothy J. Baek
Browse files
refac
parent
4dd77b78
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
6 deletions
+30
-6
backend/apps/webui/main.py
backend/apps/webui/main.py
+25
-1
backend/constants.py
backend/constants.py
+5
-5
No files found.
backend/apps/webui/main.py
View file @
8dcb3d78
...
...
@@ -47,6 +47,8 @@ from config import (
OAUTH_PICTURE_CLAIM
,
)
from
apps.socket.main
import
get_event_call
,
get_event_emitter
import
inspect
import
uuid
import
time
...
...
@@ -197,8 +199,21 @@ async def generate_function_chat_completion(form_data, user):
metadata
=
form_data
[
"metadata"
]
del
form_data
[
"metadata"
]
__event_emitter__
=
None
__event_call__
=
None
__task__
=
None
if
metadata
:
print
(
metadata
)
if
(
metadata
.
get
(
"session_id"
)
and
metadata
.
get
(
"chat_id"
)
and
metadata
.
get
(
"message_id"
)
):
__event_emitter__
=
await
get_event_emitter
(
metadata
)
__event_call__
=
await
get_event_call
(
metadata
)
if
metadata
.
get
(
"task"
):
__task__
=
metadata
.
get
(
"task"
)
if
model_info
:
if
model_info
.
base_model_id
:
...
...
@@ -314,6 +329,15 @@ async def generate_function_chat_completion(form_data, user):
params
=
{
**
params
,
"__user__"
:
__user__
}
if
"__event_emitter__"
in
sig
.
parameters
:
params
=
{
**
params
,
"__event_emitter__"
:
__event_emitter__
}
if
"__event_call__"
in
sig
.
parameters
:
params
=
{
**
params
,
"__event_call__"
:
__event_call__
}
if
"__task__"
in
sig
.
parameters
:
params
=
{
**
params
,
"__task__"
:
__task__
}
if
form_data
[
"stream"
]:
async
def
stream_content
():
...
...
backend/constants.py
View file @
8dcb3d78
...
...
@@ -95,8 +95,8 @@ class TASKS(str, Enum):
def
__str__
(
self
)
->
str
:
return
super
().
__str__
()
DEFAULT
=
lambda
task
=
""
:
f
"
{
task
if
task
else
'
default
'
}
"
TITLE_GENERATION
=
"
T
itle
G
eneration"
EMOJI_GENERATION
=
"
E
moji
G
eneration"
QUERY_GENERATION
=
"
Q
uery
G
eneration"
FUNCTION_CALLING
=
"
F
unction
C
alling"
DEFAULT
=
lambda
task
=
""
:
f
"
{
task
if
task
else
'
generation
'
}
"
TITLE_GENERATION
=
"
t
itle
_g
eneration"
EMOJI_GENERATION
=
"
e
moji
_g
eneration"
QUERY_GENERATION
=
"
q
uery
_g
eneration"
FUNCTION_CALLING
=
"
f
unction
_c
alling"
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