Add NEO4J_WORKSPACE env var override support

- Allow workspace override via NEO4J_WORKSPACE
- Update env.example with new config option
This commit is contained in:
yangdx 2025-07-07 04:16:44 +08:00
parent 7916b3d18f
commit 4632adb355
2 changed files with 6 additions and 0 deletions

View file

@ -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/

View file

@ -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 "",