From 34cd3d79e8688f589e3dd2f03415f8a8f9a13115 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 16 Feb 2026 23:52:32 -0600 Subject: [PATCH] refac --- backend/open_webui/utils/models.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/backend/open_webui/utils/models.py b/backend/open_webui/utils/models.py index 0d2d6bdce8..e2f9e5bcad 100644 --- a/backend/open_webui/utils/models.py +++ b/backend/open_webui/utils/models.py @@ -395,11 +395,13 @@ def get_filtered_models(models, user, db=None): user.role == "user" or (user.role == "admin" and not BYPASS_ADMIN_ACCESS_CONTROL) ) and not BYPASS_MODEL_ACCESS_CONTROL: - model_ids = [model["id"] for model in models if not model.get("arena")] - model_infos = { - model_info.id: model_info - for model_info in Models.get_models_by_ids(model_ids) - } + model_infos = {} + for model in models: + if model.get("arena"): + continue + info = model.get("info") + if info: + model_infos[model["id"]] = info user_group_ids = { group.id for group in Groups.get_groups_by_member_id(user.id, db=db) @@ -429,12 +431,12 @@ def get_filtered_models(models, user, db=None): filtered_models.append(model) continue - model_info = model_infos.get(model["id"], None) + model_info = model_infos.get(model["id"]) if model_info: if ( (user.role == "admin" and BYPASS_ADMIN_ACCESS_CONTROL) - or user.id == model_info.user_id - or model_info.id in accessible_model_ids + or user.id == model_info["user_id"] + or model["id"] in accessible_model_ids ): filtered_models.append(model)