diff --git a/lightrag/api/utils_api.py b/lightrag/api/utils_api.py index 02715b87..c01b7a37 100644 --- a/lightrag/api/utils_api.py +++ b/lightrag/api/utils_api.py @@ -24,9 +24,7 @@ def check_env_file(): Returns True if should continue, False if should exit. """ if not os.path.exists(".env"): - warning_msg = ( - "Warning: Startup directory must contain .env file for multi-instance support." - ) + warning_msg = "Warning: Startup directory must contain .env file for multi-instance support." ASCIIColors.yellow(warning_msg) # Check if running in interactive terminal diff --git a/lightrag/base.py b/lightrag/base.py index 3db337e5..ad41fc58 100644 --- a/lightrag/base.py +++ b/lightrag/base.py @@ -16,7 +16,10 @@ import numpy as np from .utils import EmbeddingFunc from .types import KnowledgeGraph -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 TextChunkSchema(TypedDict): diff --git a/lightrag/lightrag.py b/lightrag/lightrag.py index 7ebcebc7..dece78b4 100644 --- a/lightrag/lightrag.py +++ b/lightrag/lightrag.py @@ -55,8 +55,10 @@ from .utils import ( from .types import KnowledgeGraph 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) # TODO: TO REMOVE @Yannick config = configparser.ConfigParser() diff --git a/lightrag/operate.py b/lightrag/operate.py index 816227f5..083a8c65 100644 --- a/lightrag/operate.py +++ b/lightrag/operate.py @@ -38,8 +38,10 @@ from .prompt import GRAPH_FIELD_SEP, PROMPTS import time 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) def chunking_by_token_size(