diff --git a/backend/open_webui/routers/models.py b/backend/open_webui/routers/models.py index f9437b5b87..f8b89ea5e8 100644 --- a/backend/open_webui/routers/models.py +++ b/backend/open_webui/routers/models.py @@ -62,6 +62,8 @@ def add_chat_variables_schema(model_dict: dict) -> dict: schema = get_chat_variables_schema(system) if schema: model_dict.setdefault('meta', {})['chat_variables_schema'] = schema + elif isinstance(model_dict.get('meta'), dict): + model_dict['meta'].pop('chat_variables_schema', None) return model_dict diff --git a/backend/open_webui/utils/models.py b/backend/open_webui/utils/models.py index 3926bfa9be..0bd933115b 100644 --- a/backend/open_webui/utils/models.py +++ b/backend/open_webui/utils/models.py @@ -187,6 +187,8 @@ async def get_all_models(request, refresh: bool = False, user: UserModel = None) schema = get_chat_variables_schema(custom_model.params.model_dump().get('system')) if schema: model['info'].setdefault('meta', {})['chat_variables_schema'] = schema + elif isinstance(model['info'].get('meta'), dict): + model['info']['meta'].pop('chat_variables_schema', None) action_ids = [] filter_ids = [] @@ -239,6 +241,8 @@ async def get_all_models(request, refresh: bool = False, user: UserModel = None) schema = get_chat_variables_schema(custom_model.params.model_dump().get('system')) if schema: info.setdefault('meta', {})['chat_variables_schema'] = schema + elif isinstance(info.get('meta'), dict): + info['meta'].pop('chat_variables_schema', None) if 'params' in info: # Remove params to avoid exposing sensitive info del info['params']