Skip to content

Commit 464e703

Browse files
committed
refac
1 parent 518702c commit 464e703

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

backend/open_webui/main.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,18 @@ async def unload_model(request: Request, form_data: ModelUnloadForm, user=Depend
906906
"""
907907
model_id = form_data.model
908908

909-
# --- Ollama provider ---
910909
ollama_models = getattr(request.app.state, 'OLLAMA_MODELS', None) or {}
910+
openai_models = getattr(request.app.state, 'OPENAI_MODELS', None) or {}
911+
912+
seen = set()
913+
while model_id not in ollama_models and model_id not in openai_models and model_id not in seen:
914+
seen.add(model_id)
915+
model_info = await Models.get_model_by_id(model_id)
916+
if not model_info or not model_info.base_model_id:
917+
break
918+
model_id = model_info.base_model_id
919+
920+
# --- Ollama provider ---
911921
if model_id in ollama_models:
912922
ollama_config = await Config.get_many('ollama.base_urls', 'ollama.api_configs')
913923
ollama_base_urls = ollama_config.get('ollama.base_urls') or []
@@ -955,7 +965,6 @@ async def unload_model(request: Request, form_data: ModelUnloadForm, user=Depend
955965
return {'status': True}
956966

957967
# --- OpenAI-compatible providers ---
958-
openai_models = getattr(request.app.state, 'OPENAI_MODELS', None) or {}
959968
if model_id in openai_models:
960969
openai_config = await Config.get_many('openai.api_configs', 'openai.api_base_urls', 'openai.api_keys')
961970
openai_api_configs = openai_config.get('openai.api_configs') or {}

0 commit comments

Comments
 (0)