diff --git a/lightrag/api/auth.py b/lightrag/api/auth.py index 50648504..58175b9d 100644 --- a/lightrag/api/auth.py +++ b/lightrag/api/auth.py @@ -5,7 +5,10 @@ from fastapi import HTTPException, status from pydantic import BaseModel from dotenv import load_dotenv -load_dotenv() +# use the .env that is inside the current folder +# allows to use different .env file for each lightrag instance +# the OS environment variables take precedence over the .env file +load_dotenv(dotenv_path=".env", override=False) class TokenPayload(BaseModel): diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index 266b0f92..8110d6d4 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -47,10 +47,10 @@ from lightrag.kg.shared_storage import ( from fastapi.security import OAuth2PasswordRequestForm from lightrag.api.auth import auth_handler -# Load environment variables -# Updated to use the .env that is inside the current folder -# This update allows the user to put a different.env file for each lightrag folder -load_dotenv(".env") +# use the .env that is inside the current folder +# allows to use different .env file for each lightrag instance +# the OS environment variables take precedence over the .env file +load_dotenv(dotenv_path=".env", override=False) # Initialize config parser config = configparser.ConfigParser() diff --git a/lightrag/api/run_with_gunicorn.py b/lightrag/api/run_with_gunicorn.py index 8d71ba36..065a12a1 100644 --- a/lightrag/api/run_with_gunicorn.py +++ b/lightrag/api/run_with_gunicorn.py @@ -11,9 +11,10 @@ from lightrag.api.utils_api import parse_args, display_splash_screen, check_env_ from lightrag.kg.shared_storage import initialize_share_data, finalize_share_data from dotenv import load_dotenv -# Updated to use the .env that is inside the current folder -# This update allows the user to put a different.env file for each lightrag folder -load_dotenv(".env") +# use the .env that is inside the current folder +# allows to use different .env file for each lightrag instance +# the OS environment variables take precedence over the .env file +load_dotenv(dotenv_path=".env", override=False) def check_and_install_dependencies(): diff --git a/lightrag/api/utils_api.py b/lightrag/api/utils_api.py index e88d545f..75e42c92 100644 --- a/lightrag/api/utils_api.py +++ b/lightrag/api/utils_api.py @@ -38,8 +38,10 @@ def check_env_file(): return True -# Load environment variables -load_dotenv() +# use the .env that is inside the current folder +# allows to use different .env file for each lightrag instance +# the OS environment variables take precedence over the .env file +load_dotenv(dotenv_path=".env", override=False) global_args = {"main_args": None} diff --git a/lightrag/utils.py b/lightrag/utils.py index 31f49ee1..44a85425 100644 --- a/lightrag/utils.py +++ b/lightrag/utils.py @@ -19,9 +19,10 @@ import tiktoken from lightrag.prompt import PROMPTS from dotenv import load_dotenv -# Load environment variables -load_dotenv(override=True) - +# use the .env that is inside the current folder +# allows to use different .env file for each lightrag instance +# the OS environment variables take precedence over the .env file +load_dotenv(dotenv_path=".env", override=False) VERBOSE_DEBUG = os.getenv("VERBOSE", "false").lower() == "true"