From 50afbc5319960522a4e1108551f206ef05f84285 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 27 Jul 2026 00:34:18 +0200 Subject: [PATCH] fix: allow setting model order via MODEL_ORDER_LIST env var (#27420) With ENABLE_PERSISTENT_CONFIG=False the admin's model order is reset on every restart because ui.model_order_list falls back to its DEFAULT_CONFIG default, and unlike every other Models setting (DEFAULT_MODELS, DEFAULT_PINNED_MODELS, DEFAULT_MODEL_METADATA and DEFAULT_MODEL_PARAMS) that default was hardcoded to an empty list with no environment variable to source it from. This adds a MODEL_ORDER_LIST environment variable parsed as a JSON array using the same guarded pattern as the neighbouring DEFAULT_MODEL_METADATA and DEFAULT_MODEL_PARAMS defaults, falling back to an empty list on parse errors. Behaviour when the variable is unset is unchanged. Fixes #27206 --- backend/open_webui/config.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index 3ff2578251..da26676924 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -1664,7 +1664,13 @@ if default_prompt_suggestions == []: DEFAULT_PROMPT_SUGGESTIONS = default_prompt_suggestions -MODEL_ORDER_LIST = [] +try: + model_order_list = json.loads(os.getenv('MODEL_ORDER_LIST', '[]')) +except Exception as e: + log.exception(f'Error loading MODEL_ORDER_LIST: {e}') + model_order_list = [] + +MODEL_ORDER_LIST = model_order_list try: default_model_metadata = json.loads(os.getenv('DEFAULT_MODEL_METADATA', '{}'))