From 44574c434d379e58605b9b83b58d975cc959da7c Mon Sep 17 00:00:00 2001 From: kahghi Date: Mon, 20 Jan 2025 15:27:55 +0800 Subject: [PATCH] removed unnecessary GCS_PROJECT_ID variable --- backend/open_webui/config.py | 1 - backend/open_webui/storage/provider.py | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index a982c48b9..306686195 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -590,7 +590,6 @@ S3_BUCKET_NAME = os.environ.get("S3_BUCKET_NAME", None) S3_ENDPOINT_URL = os.environ.get("S3_ENDPOINT_URL", None) GCS_BUCKET_NAME = os.environ.get("GCS_BUCKET_NAME", None) -GCS_PROJECT_ID = os.environ.get("GCS_PROJECT_ID", None) GOOGLE_APPLICATION_CREDENTIALS_JSON = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS_JSON", None) #################################### diff --git a/backend/open_webui/storage/provider.py b/backend/open_webui/storage/provider.py index 233231f97..334e9afae 100644 --- a/backend/open_webui/storage/provider.py +++ b/backend/open_webui/storage/provider.py @@ -13,7 +13,6 @@ from open_webui.config import ( S3_REGION_NAME, S3_SECRET_ACCESS_KEY, GCS_BUCKET_NAME, - GCS_PROJECT_ID, GOOGLE_APPLICATION_CREDENTIALS_JSON, STORAGE_PROVIDER, UPLOAD_DIR, @@ -145,11 +144,11 @@ class S3StorageProvider(StorageProvider): class GCSStorageProvider(StorageProvider): def __init__(self): - if GCS_PROJECT_ID: - self.gcs_client = storage.Client(project=GCS_PROJECT_ID) - if GOOGLE_APPLICATION_CREDENTIALS_JSON: + if GCS_BUCKET_NAME and GOOGLE_APPLICATION_CREDENTIALS_JSON: self.gcs_client = storage.Client.from_service_account_info(info=json.loads(GOOGLE_APPLICATION_CREDENTIALS_JSON)) - + if GCS_BUCKET_NAME and not GOOGLE_APPLICATION_CREDENTIALS_JSON: + # defaults to environment, be it GCE VM or user credentials + self.gcs_client = storage.Client() self.bucket_name = GCS_BUCKET_NAME self.bucket = self.gcs_client.bucket(GCS_BUCKET_NAME)