From b6664f5ae8d785bc2ed1ead4451c86a3791114b7 Mon Sep 17 00:00:00 2001 From: Nikes Date: Wed, 12 Mar 2025 23:15:26 +0200 Subject: [PATCH] feat: pip options in tools/functions install requirements --- backend/open_webui/env.py | 7 +++++++ backend/open_webui/utils/plugin.py | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/env.py b/backend/open_webui/env.py index 1515e4ae2..6c4d151b0 100644 --- a/backend/open_webui/env.py +++ b/backend/open_webui/env.py @@ -448,3 +448,10 @@ OTEL_RESOURCE_ATTRIBUTES = os.environ.get( OTEL_TRACES_SAMPLER = os.environ.get( "OTEL_TRACES_SAMPLER", "parentbased_always_on" ).lower() + +#################################### +# TOOLS/FUNCTIONS PIP OPTIONS +#################################### + +PIP_OPTIONS = os.getenv("PIP_OPTIONS", "").split() +PIP_PACKAGE_INDEX_OPTIONS = os.getenv("PIP_PACKAGE_INDEX_OPTIONS", "").split() diff --git a/backend/open_webui/utils/plugin.py b/backend/open_webui/utils/plugin.py index 35cddb208..685746b19 100644 --- a/backend/open_webui/utils/plugin.py +++ b/backend/open_webui/utils/plugin.py @@ -7,7 +7,7 @@ import types import tempfile import logging -from open_webui.env import SRC_LOG_LEVELS +from open_webui.env import SRC_LOG_LEVELS, PIP_OPTIONS, PIP_PACKAGE_INDEX_OPTIONS from open_webui.models.functions import Functions from open_webui.models.tools import Tools @@ -170,7 +170,7 @@ def install_frontmatter_requirements(requirements: str): try: req_list = [req.strip() for req in requirements.split(",")] log.info(f"Installing requirements: {' '.join(req_list)}") - subprocess.check_call([sys.executable, "-m", "pip", "install"] + req_list) + subprocess.check_call([sys.executable, "-m", "pip", "install"] + PIP_OPTIONS + req_list + PIP_PACKAGE_INDEX_OPTIONS) except Exception as e: log.error(f"Error installing packages: {' '.join(req_list)}") raise e