standardize .env loading behavior across modules

This commit is contained in:
yangdx
2025-03-29 03:48:38 +08:00
parent 9559ed857b
commit 65574459f9
4 changed files with 13 additions and 8 deletions

View File

@@ -24,9 +24,7 @@ def check_env_file():
Returns True if should continue, False if should exit. Returns True if should continue, False if should exit.
""" """
if not os.path.exists(".env"): if not os.path.exists(".env"):
warning_msg = ( warning_msg = "Warning: Startup directory must contain .env file for multi-instance support."
"Warning: Startup directory must contain .env file for multi-instance support."
)
ASCIIColors.yellow(warning_msg) ASCIIColors.yellow(warning_msg)
# Check if running in interactive terminal # Check if running in interactive terminal

View File

@@ -16,7 +16,10 @@ import numpy as np
from .utils import EmbeddingFunc from .utils import EmbeddingFunc
from .types import KnowledgeGraph 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): class TextChunkSchema(TypedDict):

View File

@@ -55,8 +55,10 @@ from .utils import (
from .types import KnowledgeGraph from .types import KnowledgeGraph
from dotenv import load_dotenv from dotenv import load_dotenv
# Load environment variables # use the .env that is inside the current folder
load_dotenv(override=True) # 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 # TODO: TO REMOVE @Yannick
config = configparser.ConfigParser() config = configparser.ConfigParser()

View File

@@ -38,8 +38,10 @@ from .prompt import GRAPH_FIELD_SEP, PROMPTS
import time import time
from dotenv import load_dotenv from dotenv import load_dotenv
# Load environment variables # use the .env that is inside the current folder
load_dotenv(override=True) # 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( def chunking_by_token_size(