enh: redis dict for internal models state

Co-Authored-By: cw.a <57549718+acwoo97@users.noreply.github.com>
This commit is contained in:
Timothy Jaeryang Baek
2025-11-27 01:33:52 -05:00
parent ff4b1b9824
commit b5e5617a41
4 changed files with 28 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ import sys
from aiocache import cached
from fastapi import Request
from open_webui.socket.utils import RedisDict
from open_webui.routers import openai, ollama
from open_webui.functions import get_function_models
@@ -323,7 +324,12 @@ async def get_all_models(request, refresh: bool = False, user: UserModel = None)
log.debug(f"get_all_models() returned {len(models)} models")
request.app.state.MODELS = {model["id"]: model for model in models}
models_dict = {model["id"]: model for model in models}
if isinstance(request.app.state.MODELS, RedisDict):
request.app.state.MODELS.set(models_dict)
else:
request.app.state.MODELS = models_dict
return models