From eb68b21e0fe435b9639c5bcb7e9579cdf1946376 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 30 Apr 2025 16:01:23 +0400 Subject: [PATCH] refac --- backend/open_webui/main.py | 12 ++++++------ backend/open_webui/utils/plugin.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 7bd082721..27cdb8691 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -383,7 +383,7 @@ from open_webui.utils.auth import ( get_admin_user, get_verified_user, ) -from open_webui.utils.plugin import install_admin_tool_and_function_dependencies +from open_webui.utils.plugin import install_tool_and_function_dependencies from open_webui.utils.oauth import OAuthManager from open_webui.utils.security_headers import SecurityHeadersMiddleware @@ -446,6 +446,11 @@ async def lifespan(app: FastAPI): if LICENSE_KEY: get_license_data(app, LICENSE_KEY) + # This should be blocking (sync) so functions are not deactivated on first /get_models calls + # when the first user lands on the / route. + log.info("Installing external dependencies of functions and tools...") + install_tool_and_function_dependencies() + pool_size = THREAD_POOL_SIZE if pool_size and pool_size > 0: limiter = anyio.to_thread.current_default_thread_limiter() @@ -453,11 +458,6 @@ async def lifespan(app: FastAPI): asyncio.create_task(periodic_usage_pool_cleanup()) - # This should be blocking (sync) so functions are not deactivated on first /get_models calls - # when the first user lands on the / route. - log.info("Installing external dependencies of functions and tools...") - install_admin_tool_and_function_dependencies() - yield diff --git a/backend/open_webui/utils/plugin.py b/backend/open_webui/utils/plugin.py index b9780a173..9c2ee1bbd 100644 --- a/backend/open_webui/utils/plugin.py +++ b/backend/open_webui/utils/plugin.py @@ -185,7 +185,7 @@ def install_frontmatter_requirements(requirements: str): log.info("No requirements found in frontmatter.") -def install_admin_tool_and_function_dependencies(): +def install_tool_and_function_dependencies(): """ Install all dependencies for all admin tools and active functions.