mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-11 20:05:19 +00:00
refac/fix: base model cache
This commit is contained in:
parent
31c63d8898
commit
05a9b72670
1 changed files with 7 additions and 3 deletions
|
|
@ -82,10 +82,13 @@ async def get_all_models(request, refresh: bool = False, user: UserModel = None)
|
||||||
and request.app.state.BASE_MODELS
|
and request.app.state.BASE_MODELS
|
||||||
and (request.app.state.config.ENABLE_BASE_MODELS_CACHE and not refresh)
|
and (request.app.state.config.ENABLE_BASE_MODELS_CACHE and not refresh)
|
||||||
):
|
):
|
||||||
models = request.app.state.BASE_MODELS
|
base_models = request.app.state.BASE_MODELS
|
||||||
else:
|
else:
|
||||||
models = await get_all_base_models(request, user=user)
|
base_models = await get_all_base_models(request, user=user)
|
||||||
request.app.state.BASE_MODELS = models
|
request.app.state.BASE_MODELS = base_models
|
||||||
|
|
||||||
|
# deep copy the base models to avoid modifying the original list
|
||||||
|
models = [model.copy() for model in base_models]
|
||||||
|
|
||||||
# If there are no models, return an empty list
|
# If there are no models, return an empty list
|
||||||
if len(models) == 0:
|
if len(models) == 0:
|
||||||
|
|
@ -145,6 +148,7 @@ async def get_all_models(request, refresh: bool = False, user: UserModel = None)
|
||||||
custom_models = Models.get_all_models()
|
custom_models = Models.get_all_models()
|
||||||
for custom_model in custom_models:
|
for custom_model in custom_models:
|
||||||
if custom_model.base_model_id is None:
|
if custom_model.base_model_id is None:
|
||||||
|
# Applied directly to a base model
|
||||||
for model in models:
|
for model in models:
|
||||||
if custom_model.id == model["id"] or (
|
if custom_model.id == model["id"] or (
|
||||||
model.get("owned_by") == "ollama"
|
model.get("owned_by") == "ollama"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue