yangdx commited on
Commit
4abaf5f
·
1 Parent(s): 1e90d6d

Fix M.env AX_GRAPH_NODES not working problem

Browse files
lightrag/kg/neo4j_impl.py CHANGED
@@ -29,12 +29,20 @@ from neo4j import ( # type: ignore
29
  AsyncManagedTransaction,
30
  )
31
 
32
- config = configparser.ConfigParser()
33
- config.read("config.ini", "utf-8")
 
 
 
 
34
 
35
  # Get maximum number of graph nodes from environment variable, default is 1000
36
  MAX_GRAPH_NODES = int(os.getenv("MAX_GRAPH_NODES", 1000))
37
 
 
 
 
 
38
  # Set neo4j logger level to ERROR to suppress warning logs
39
  logging.getLogger("neo4j").setLevel(logging.ERROR)
40
 
 
29
  AsyncManagedTransaction,
30
  )
31
 
32
+ from dotenv import load_dotenv
33
+
34
+ # use the .env that is inside the current folder
35
+ # allows to use different .env file for each lightrag instance
36
+ # the OS environment variables take precedence over the .env file
37
+ load_dotenv(dotenv_path=".env", override=False)
38
 
39
  # Get maximum number of graph nodes from environment variable, default is 1000
40
  MAX_GRAPH_NODES = int(os.getenv("MAX_GRAPH_NODES", 1000))
41
 
42
+ config = configparser.ConfigParser()
43
+ config.read("config.ini", "utf-8")
44
+
45
+
46
  # Set neo4j logger level to ERROR to suppress warning logs
47
  logging.getLogger("neo4j").setLevel(logging.ERROR)
48
 
lightrag/kg/networkx_impl.py CHANGED
@@ -21,6 +21,13 @@ from .shared_storage import (
21
  set_all_update_flags,
22
  )
23
 
 
 
 
 
 
 
 
24
  MAX_GRAPH_NODES = int(os.getenv("MAX_GRAPH_NODES", 1000))
25
 
26
 
 
21
  set_all_update_flags,
22
  )
23
 
24
+ from dotenv import load_dotenv
25
+
26
+ # use the .env that is inside the current folder
27
+ # allows to use different .env file for each lightrag instance
28
+ # the OS environment variables take precedence over the .env file
29
+ load_dotenv(dotenv_path=".env", override=False)
30
+
31
  MAX_GRAPH_NODES = int(os.getenv("MAX_GRAPH_NODES", 1000))
32
 
33
 
lightrag/kg/postgres_impl.py CHANGED
@@ -35,6 +35,13 @@ if not pm.is_installed("asyncpg"):
35
  import asyncpg # type: ignore
36
  from asyncpg import Pool # type: ignore
37
 
 
 
 
 
 
 
 
38
  # Get maximum number of graph nodes from environment variable, default is 1000
39
  MAX_GRAPH_NODES = int(os.getenv("MAX_GRAPH_NODES", 1000))
40
 
 
35
  import asyncpg # type: ignore
36
  from asyncpg import Pool # type: ignore
37
 
38
+ from dotenv import load_dotenv
39
+
40
+ # use the .env that is inside the current folder
41
+ # allows to use different .env file for each lightrag instance
42
+ # the OS environment variables take precedence over the .env file
43
+ load_dotenv(dotenv_path=".env", override=False)
44
+
45
  # Get maximum number of graph nodes from environment variable, default is 1000
46
  MAX_GRAPH_NODES = int(os.getenv("MAX_GRAPH_NODES", 1000))
47
 
lightrag/operate.py CHANGED
@@ -1560,7 +1560,7 @@ async def _find_most_related_edges_from_entities(
1560
  ):
1561
  node_names = [dp["entity_name"] for dp in node_datas]
1562
  batch_edges_dict = await knowledge_graph_inst.get_nodes_edges_batch(node_names)
1563
-
1564
  all_edges = []
1565
  seen = set()
1566
 
 
1560
  ):
1561
  node_names = [dp["entity_name"] for dp in node_datas]
1562
  batch_edges_dict = await knowledge_graph_inst.get_nodes_edges_batch(node_names)
1563
+
1564
  all_edges = []
1565
  seen = set()
1566