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
faca8c8b
Commit
faca8c8b
authored
Jul 28, 2024
by
Timothy J. Baek
Browse files
feat: multiple action support
parent
4ad81810
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
9 deletions
+39
-9
backend/main.py
backend/main.py
+39
-9
No files found.
backend/main.py
View file @
faca8c8b
...
@@ -1043,6 +1043,31 @@ async def get_all_models():
...
@@ -1043,6 +1043,31 @@ async def get_all_models():
model
[
"actions"
]
=
[]
model
[
"actions"
]
=
[]
for
action_id
in
action_ids
:
for
action_id
in
action_ids
:
action
=
Functions
.
get_function_by_id
(
action_id
)
action
=
Functions
.
get_function_by_id
(
action_id
)
if
action_id
in
webui_app
.
state
.
FUNCTIONS
:
function_module
=
webui_app
.
state
.
FUNCTIONS
[
action_id
]
else
:
function_module
,
_
,
_
=
load_function_module_by_id
(
action_id
)
webui_app
.
state
.
FUNCTIONS
[
action_id
]
=
function_module
if
hasattr
(
function_module
,
"actions"
):
actions
=
function_module
.
actions
model
[
"actions"
].
extend
(
[
{
"id"
:
f
"
{
action_id
}
.
{
_action
[
'id'
]
}
"
,
"name"
:
_action
.
get
(
"name"
,
f
"
{
action
.
name
}
(
{
_action
[
'id'
]
}
)"
),
"description"
:
action
.
meta
.
description
,
"icon_url"
:
_action
.
get
(
"icon_url"
,
action
.
meta
.
manifest
.
get
(
"icon_url"
,
None
)
),
}
for
_action
in
actions
]
)
else
:
model
[
"actions"
].
append
(
model
[
"actions"
].
append
(
{
{
"id"
:
action_id
,
"id"
:
action_id
,
...
@@ -1288,6 +1313,11 @@ async def chat_completed(form_data: dict, user=Depends(get_verified_user)):
...
@@ -1288,6 +1313,11 @@ async def chat_completed(form_data: dict, user=Depends(get_verified_user)):
async
def
chat_completed
(
async
def
chat_completed
(
action_id
:
str
,
form_data
:
dict
,
user
=
Depends
(
get_verified_user
)
action_id
:
str
,
form_data
:
dict
,
user
=
Depends
(
get_verified_user
)
):
):
if
"."
in
action_id
:
action_id
,
sub_action_id
=
action_id
.
split
(
"."
)
else
:
sub_action_id
=
None
action
=
Functions
.
get_function_by_id
(
action_id
)
action
=
Functions
.
get_function_by_id
(
action_id
)
if
not
action
:
if
not
action
:
raise
HTTPException
(
raise
HTTPException
(
...
@@ -1340,7 +1370,7 @@ async def chat_completed(
...
@@ -1340,7 +1370,7 @@ async def chat_completed(
# Extra parameters to be passed to the function
# Extra parameters to be passed to the function
extra_params
=
{
extra_params
=
{
"__model__"
:
model
,
"__model__"
:
model
,
"__id__"
:
action_id
,
"__id__"
:
sub_action_id
if
sub_action_id
is
not
None
else
action_id
,
"__event_emitter__"
:
__event_emitter__
,
"__event_emitter__"
:
__event_emitter__
,
"__event_call__"
:
__event_call__
,
"__event_call__"
:
__event_call__
,
}
}
...
...
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