Daniel.y commited on
Commit
0a78449
·
unverified ·
2 Parent(s): 8409ff3 2f216f2

Merge pull request #1222 from danielaskdd/main

Browse files

standardize .env loading behavior across modules

lightrag/api/utils_api.py CHANGED
@@ -24,9 +24,7 @@ def check_env_file():
24
  Returns True if should continue, False if should exit.
25
  """
26
  if not os.path.exists(".env"):
27
- warning_msg = (
28
- "Warning: Startup directory must contain .env file for multi-instance support."
29
- )
30
  ASCIIColors.yellow(warning_msg)
31
 
32
  # Check if running in interactive terminal
 
24
  Returns True if should continue, False if should exit.
25
  """
26
  if not os.path.exists(".env"):
27
+ warning_msg = "Warning: Startup directory must contain .env file for multi-instance support."
 
 
28
  ASCIIColors.yellow(warning_msg)
29
 
30
  # Check if running in interactive terminal
lightrag/base.py CHANGED
@@ -16,7 +16,10 @@ import numpy as np
16
  from .utils import EmbeddingFunc
17
  from .types import KnowledgeGraph
18
 
19
- load_dotenv()
 
 
 
20
 
21
 
22
  class TextChunkSchema(TypedDict):
 
16
  from .utils import EmbeddingFunc
17
  from .types import KnowledgeGraph
18
 
19
+ # use the .env that is inside the current folder
20
+ # allows to use different .env file for each lightrag instance
21
+ # the OS environment variables take precedence over the .env file
22
+ load_dotenv(dotenv_path=".env", override=False)
23
 
24
 
25
  class TextChunkSchema(TypedDict):
lightrag/lightrag.py CHANGED
@@ -55,8 +55,10 @@ from .utils import (
55
  from .types import KnowledgeGraph
56
  from dotenv import load_dotenv
57
 
58
- # Load environment variables
59
- load_dotenv(override=True)
 
 
60
 
61
  # TODO: TO REMOVE @Yannick
62
  config = configparser.ConfigParser()
 
55
  from .types import KnowledgeGraph
56
  from dotenv import load_dotenv
57
 
58
+ # use the .env that is inside the current folder
59
+ # allows to use different .env file for each lightrag instance
60
+ # the OS environment variables take precedence over the .env file
61
+ load_dotenv(dotenv_path=".env", override=False)
62
 
63
  # TODO: TO REMOVE @Yannick
64
  config = configparser.ConfigParser()
lightrag/operate.py CHANGED
@@ -38,8 +38,10 @@ from .prompt import GRAPH_FIELD_SEP, PROMPTS
38
  import time
39
  from dotenv import load_dotenv
40
 
41
- # Load environment variables
42
- load_dotenv(override=True)
 
 
43
 
44
 
45
  def chunking_by_token_size(
 
38
  import time
39
  from dotenv import load_dotenv
40
 
41
+ # use the .env that is inside the current folder
42
+ # allows to use different .env file for each lightrag instance
43
+ # the OS environment variables take precedence over the .env file
44
+ load_dotenv(dotenv_path=".env", override=False)
45
 
46
 
47
  def chunking_by_token_size(