mirror of
https://github.com/open-webui/open-webui.git
synced 2026-04-29 17:06:40 -05:00
feat: sort action buttons by valve priority (#21790)
feat: sort action buttons by valve priority Action buttons under assistant messages were rendered in non-deterministic order due to set() deduplication. They now respect the priority field from function Valves, sorted ascending (lower value = appears first, default 0), matching the existing filter priority mechanism.
This commit is contained in:
@@ -331,12 +331,18 @@ async def get_all_models(request, refresh: bool = False, user: UserModel = None)
|
||||
elif meta.get(key) is None:
|
||||
meta[key] = copy.deepcopy(value)
|
||||
|
||||
def get_action_priority(action_id):
|
||||
valves = Functions.get_function_valves_by_id(action_id)
|
||||
return valves.get("priority", 0) if valves else 0
|
||||
|
||||
for model in models:
|
||||
action_ids = [
|
||||
action_id
|
||||
for action_id in list(set(model.pop("action_ids", []) + global_action_ids))
|
||||
if action_id in enabled_action_ids
|
||||
]
|
||||
action_ids.sort(key=get_action_priority)
|
||||
|
||||
filter_ids = [
|
||||
filter_id
|
||||
for filter_id in list(set(model.pop("filter_ids", []) + global_filter_ids))
|
||||
|
||||
Reference in New Issue
Block a user