mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-05 18:38:17 -05:00
enh: redis dict for internal models state
Co-Authored-By: cw.a <57549718+acwoo97@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user