From 269151cd2ccbfc1c0dc366f30c0f04da56f38dbb Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 18 Nov 2024 07:18:47 -0800 Subject: [PATCH] enh: arena model access control --- backend/open_webui/main.py | 11 +++++++++++ .../Settings/Evaluations/ArenaModelModal.svelte | 15 ++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 6aac7a231..d53e1e820 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -1114,6 +1114,17 @@ async def get_models(user=Depends(get_verified_user)): if user.role == "user": filtered_models = [] for model in models: + if model.get("arena"): + if has_access( + user.id, + type="read", + access_control=model.get("info", {}) + .get("meta", {}) + .get("access_control", {}), + ): + filtered_models.append(model) + continue + model_info = Models.get_model_by_id(model["id"]) if model_info: if user.id == model_info.user_id or has_access( diff --git a/src/lib/components/admin/Settings/Evaluations/ArenaModelModal.svelte b/src/lib/components/admin/Settings/Evaluations/ArenaModelModal.svelte index 9816d242a..e13200db8 100644 --- a/src/lib/components/admin/Settings/Evaluations/ArenaModelModal.svelte +++ b/src/lib/components/admin/Settings/Evaluations/ArenaModelModal.svelte @@ -9,6 +9,7 @@ import Minus from '$lib/components/icons/Minus.svelte'; import PencilSolid from '$lib/components/icons/PencilSolid.svelte'; import { toast } from 'svelte-sonner'; + import AccessControl from '$lib/components/workspace/common/AccessControl.svelte'; export let show = false; export let edit = false; @@ -39,6 +40,8 @@ let modelIds = []; let filterMode = 'include'; + let accessControl = {}; + let imageInputElement; let loading = false; @@ -74,7 +77,8 @@ profile_image_url: profileImageUrl, description: description || null, model_ids: modelIds.length > 0 ? modelIds : null, - filter_mode: modelIds.length > 0 ? (filterMode ? filterMode : null) : null + filter_mode: modelIds.length > 0 ? (filterMode ? filterMode : null) : null, + access_control: accessControl } }; @@ -98,6 +102,7 @@ description = model.meta.description; modelIds = model.meta.model_ids || []; filterMode = model.meta?.filter_mode ?? 'include'; + accessControl = model.meta?.access_control ?? {}; } }; @@ -283,6 +288,14 @@
+
+
+ +
+
+ +
+
{$i18n.t('Models')}