mirror of
https://github.com/open-webui/open-webui
synced 2025-06-04 03:37:35 +00:00
feat: multiple action support
This commit is contained in:
parent
4ad8181088
commit
faca8c8b53
@ -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)):
|
|||||||
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(
|
|||||||
# 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__,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user