From 4632adb355b8670da8b417f2063830fab19a94e2 Mon Sep 17 00:00:00 2001 From: yangdx Date: Mon, 7 Jul 2025 04:16:44 +0800 Subject: [PATCH] Add NEO4J_WORKSPACE env var override support - Allow workspace override via NEO4J_WORKSPACE - Update env.example with new config option --- env.example | 1 + lightrag/kg/neo4j_impl.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/env.example b/env.example index d2be92c9..4738c8b0 100644 --- a/env.example +++ b/env.example @@ -156,6 +156,7 @@ POSTGRES_MAX_CONNECTIONS=12 NEO4J_URI=neo4j+s://xxxxxxxx.databases.neo4j.io NEO4J_USERNAME=neo4j NEO4J_PASSWORD='your_password' +# NEO4J_WORKSPACE=forced_workspace_name ### MongoDB Configuration MONGO_URI=mongodb://root:root@localhost:27017/ diff --git a/lightrag/kg/neo4j_impl.py b/lightrag/kg/neo4j_impl.py index 756dc7c8..63a3300a 100644 --- a/lightrag/kg/neo4j_impl.py +++ b/lightrag/kg/neo4j_impl.py @@ -51,6 +51,11 @@ logging.getLogger("neo4j").setLevel(logging.ERROR) @dataclass class Neo4JStorage(BaseGraphStorage): def __init__(self, namespace, global_config, embedding_func, workspace=None): + # Check NEO4J_WORKSPACE environment variable and override workspace if set + neo4j_workspace = os.environ.get("NEO4J_WORKSPACE") + if neo4j_workspace and neo4j_workspace.strip(): + workspace = neo4j_workspace + super().__init__( namespace=namespace, workspace=workspace or "",