Skip to content

Commit 7c816f0

Browse files
committed
Add support for local mode, to prevent running potentially vulnerable extensions like browser
1 parent e63a296 commit 7c816f0

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

llms/extensions/browser/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ def install(ctx):
2424
ctx.disabled = True
2525
return
2626

27+
if not ctx.is_local:
28+
ctx.log("Browser extension is only supported in local mode.")
29+
ctx.disabled = True
30+
return
31+
2732
def ensure_dir(path):
2833
os.makedirs(path, exist_ok=True)
2934
return path

llms/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
DEBUG = os.getenv("DEBUG") == "1"
6262
MOCK = os.getenv("MOCK") == "1"
6363
MOCK_DIR = os.getenv("MOCK_DIR")
64+
LLMS_MODE = os.getenv("LLMS_MODE", "local")
6465
DISABLE_EXTENSIONS = (os.getenv("LLMS_DISABLE") or "").split(",")
6566
DEFAULT_LIMITS = {
6667
"client_timeout": 120,
@@ -2874,6 +2875,8 @@ def __init__(self, cli_args: argparse.Namespace, extra_args: Dict[str, Any]):
28742875
self.extra_args = extra_args
28752876
self.config = None
28762877
self.limits = DEFAULT_LIMITS
2878+
self.mode = LLMS_MODE
2879+
self.is_local = self.mode == "local"
28772880
self.error_auth_required = create_error_response("Authentication required", "Unauthorized")
28782881
self.ui_extensions = []
28792882
self.chat_request_filters = []
@@ -3121,6 +3124,8 @@ def __init__(self, app: AppExtensions, path: str):
31213124
self.app = app
31223125
self.config = app.config
31233126
self.limits = app.limits
3127+
self.mode = app.mode
3128+
self.is_local = app.is_local
31243129
self.cli_args = app.cli_args
31253130
self.extra_args = app.extra_args
31263131
self.error_auth_required = app.error_auth_required

0 commit comments

Comments
 (0)