Merge pull request #1221 from danielaskdd/main
Browse filesRefactor: Standardize .env loading behavior across modules
- lightrag/api/auth.py +4 -1
- lightrag/api/lightrag_server.py +4 -4
- lightrag/api/run_with_gunicorn.py +4 -3
- lightrag/api/utils_api.py +5 -3
- lightrag/utils.py +4 -3
lightrag/api/auth.py
CHANGED
@@ -5,7 +5,10 @@ from fastapi import HTTPException, status
|
|
5 |
from pydantic import BaseModel
|
6 |
from dotenv import load_dotenv
|
7 |
|
8 |
-
|
|
|
|
|
|
|
9 |
|
10 |
|
11 |
class TokenPayload(BaseModel):
|
|
|
5 |
from pydantic import BaseModel
|
6 |
from dotenv import load_dotenv
|
7 |
|
8 |
+
# use the .env that is inside the current folder
|
9 |
+
# allows to use different .env file for each lightrag instance
|
10 |
+
# the OS environment variables take precedence over the .env file
|
11 |
+
load_dotenv(dotenv_path=".env", override=False)
|
12 |
|
13 |
|
14 |
class TokenPayload(BaseModel):
|
lightrag/api/lightrag_server.py
CHANGED
@@ -47,10 +47,10 @@ from lightrag.kg.shared_storage import (
|
|
47 |
from fastapi.security import OAuth2PasswordRequestForm
|
48 |
from lightrag.api.auth import auth_handler
|
49 |
|
50 |
-
#
|
51 |
-
#
|
52 |
-
#
|
53 |
-
load_dotenv(".env")
|
54 |
|
55 |
# Initialize config parser
|
56 |
config = configparser.ConfigParser()
|
|
|
47 |
from fastapi.security import OAuth2PasswordRequestForm
|
48 |
from lightrag.api.auth import auth_handler
|
49 |
|
50 |
+
# use the .env that is inside the current folder
|
51 |
+
# allows to use different .env file for each lightrag instance
|
52 |
+
# the OS environment variables take precedence over the .env file
|
53 |
+
load_dotenv(dotenv_path=".env", override=False)
|
54 |
|
55 |
# Initialize config parser
|
56 |
config = configparser.ConfigParser()
|
lightrag/api/run_with_gunicorn.py
CHANGED
@@ -11,9 +11,10 @@ from lightrag.api.utils_api import parse_args, display_splash_screen, check_env_
|
|
11 |
from lightrag.kg.shared_storage import initialize_share_data, finalize_share_data
|
12 |
from dotenv import load_dotenv
|
13 |
|
14 |
-
#
|
15 |
-
#
|
16 |
-
|
|
|
17 |
|
18 |
|
19 |
def check_and_install_dependencies():
|
|
|
11 |
from lightrag.kg.shared_storage import initialize_share_data, finalize_share_data
|
12 |
from dotenv import load_dotenv
|
13 |
|
14 |
+
# use the .env that is inside the current folder
|
15 |
+
# allows to use different .env file for each lightrag instance
|
16 |
+
# the OS environment variables take precedence over the .env file
|
17 |
+
load_dotenv(dotenv_path=".env", override=False)
|
18 |
|
19 |
|
20 |
def check_and_install_dependencies():
|
lightrag/api/utils_api.py
CHANGED
@@ -25,7 +25,7 @@ def check_env_file():
|
|
25 |
"""
|
26 |
if not os.path.exists(".env"):
|
27 |
warning_msg = (
|
28 |
-
"Warning:
|
29 |
)
|
30 |
ASCIIColors.yellow(warning_msg)
|
31 |
|
@@ -38,8 +38,10 @@ def check_env_file():
|
|
38 |
return True
|
39 |
|
40 |
|
41 |
-
#
|
42 |
-
|
|
|
|
|
43 |
|
44 |
global_args = {"main_args": None}
|
45 |
|
|
|
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 |
|
|
|
38 |
return True
|
39 |
|
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 |
global_args = {"main_args": None}
|
47 |
|
lightrag/utils.py
CHANGED
@@ -19,9 +19,10 @@ import tiktoken
|
|
19 |
from lightrag.prompt import PROMPTS
|
20 |
from dotenv import load_dotenv
|
21 |
|
22 |
-
#
|
23 |
-
|
24 |
-
|
|
|
25 |
|
26 |
VERBOSE_DEBUG = os.getenv("VERBOSE", "false").lower() == "true"
|
27 |
|
|
|
19 |
from lightrag.prompt import PROMPTS
|
20 |
from dotenv import load_dotenv
|
21 |
|
22 |
+
# use the .env that is inside the current folder
|
23 |
+
# allows to use different .env file for each lightrag instance
|
24 |
+
# the OS environment variables take precedence over the .env file
|
25 |
+
load_dotenv(dotenv_path=".env", override=False)
|
26 |
|
27 |
VERBOSE_DEBUG = os.getenv("VERBOSE", "false").lower() == "true"
|
28 |
|