From 24885a2e38b90eb52f4497f35bf578091accf6c6 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 21 Oct 2024 04:14:49 -0700 Subject: [PATCH] refac --- backend/open_webui/apps/webui/main.py | 5 +++++ backend/open_webui/main.py | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/open_webui/apps/webui/main.py b/backend/open_webui/apps/webui/main.py index 11346ba55..e93cbfb76 100644 --- a/backend/open_webui/apps/webui/main.py +++ b/backend/open_webui/apps/webui/main.py @@ -144,6 +144,11 @@ async def get_status(): } +async def get_all_models(): + pipe_models = await get_pipe_models() + return pipe_models + + def get_function_module(pipe_id: str): # Check if function is already loaded if pipe_id not in app.state.FUNCTIONS: diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 5b3ca7e64..aeb622e81 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -57,7 +57,7 @@ from open_webui.apps.webui.internal.db import Session from open_webui.apps.webui.main import ( app as webui_app, generate_function_chat_completion, - get_pipe_models, + get_all_models as get_open_webui_models, ) from open_webui.apps.webui.models.functions import Functions from open_webui.apps.webui.models.models import Models @@ -904,11 +904,11 @@ webui_app.state.EMBEDDING_FUNCTION = retrieval_app.state.EMBEDDING_FUNCTION async def get_all_models(): # TODO: Optimize this function - pipe_models = [] + open_webui_models = [] openai_models = [] ollama_models = [] - pipe_models = await get_pipe_models() + open_webui_models = await get_open_webui_models() if app.state.config.ENABLE_OPENAI_API: openai_models = await get_openai_models() @@ -928,7 +928,7 @@ async def get_all_models(): for model in ollama_models["models"] ] - models = pipe_models + openai_models + ollama_models + models = open_webui_models + openai_models + ollama_models global_action_ids = [ function.id for function in Functions.get_global_action_functions()