From 4d0a316717e628bd15f4a04f647fdcb4d3258189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Catal=C3=A1?= Date: Wed, 12 Feb 2025 21:32:19 +0100 Subject: [PATCH 1/8] exclude .env file with potentionally sensitive information like LLM API KEYS --- .dockerignore | 1 + Dockerfile | 1 - docker-compose.yml | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..2eea525d --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8c9474de..4532ee61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,7 +33,6 @@ WORKDIR /app COPY --from=builder /root/.local /root/.local COPY ./lightrag ./lightrag COPY setup.py . -COPY .env . RUN pip install . # Make sure scripts in .local are usable diff --git a/docker-compose.yml b/docker-compose.yml index a4713279..b5659692 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,7 @@ services: volumes: - ./data/rag_storage:/app/data/rag_storage - ./data/inputs:/app/data/inputs + - .env:/app/.env env_file: - .env environment: From cacb429ad91850d029bf3186711329c86a94a82b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Catal=C3=A1?= Date: Thu, 13 Feb 2025 11:35:38 +0100 Subject: [PATCH 2/8] fix linting --- .dockerignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 2eea525d..4c49bd78 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1 @@ -.env \ No newline at end of file +.env From 438caa776d89426d19bf8624b841057608fb1bc4 Mon Sep 17 00:00:00 2001 From: ultrageopro Date: Thu, 13 Feb 2025 15:26:45 +0300 Subject: [PATCH 3/8] fix: neo4j MAX_CONNECTION_POOL_SIZE impl --- lightrag/kg/neo4j_impl.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lightrag/kg/neo4j_impl.py b/lightrag/kg/neo4j_impl.py index 587a9167..731b7cc1 100644 --- a/lightrag/kg/neo4j_impl.py +++ b/lightrag/kg/neo4j_impl.py @@ -55,9 +55,11 @@ class Neo4JStorage(BaseGraphStorage): PASSWORD = os.environ[ "NEO4J_PASSWORD", config.get("neo4j", "password", fallback=None) ] - MAX_CONNECTION_POOL_SIZE = os.environ.get( - "NEO4J_MAX_CONNECTION_POOL_SIZE", - config.get("neo4j", "connection_pool_size", fallback=800), + MAX_CONNECTION_POOL_SIZE = int( + os.environ.get( + "NEO4J_MAX_CONNECTION_POOL_SIZE", + config.get("neo4j", "connection_pool_size", fallback=800), + ) ) DATABASE = os.environ.get( "NEO4J_DATABASE", re.sub(r"[^a-zA-Z0-9-]", "-", namespace) From 1a0d7d6ecef8e4452d69c81f03d114cf575a3205 Mon Sep 17 00:00:00 2001 From: ultrageopro Date: Thu, 13 Feb 2025 15:29:18 +0300 Subject: [PATCH 4/8] fix: linting --- lightrag/api/lightrag_server.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index fe52f592..a442074d 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -101,6 +101,7 @@ def estimate_tokens(text: str) -> int: return int(tokens) + def get_default_host(binding_type: str) -> str: default_hosts = { "ollama": os.getenv("LLM_BINDING_HOST", "http://localhost:11434"), From e1d9dba20de356ba4e8eb214c361ad5f1fecbdae Mon Sep 17 00:00:00 2001 From: yangdx Date: Thu, 13 Feb 2025 20:40:29 +0800 Subject: [PATCH 5/8] Fix typos in documentation tree structure and storage implementation names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Correct menu tree structure in splash screen • Fix MilvusVectorDBStorage typo • Update storage env requirements --- lightrag/api/lightrag_server.py | 4 ++-- lightrag/lightrag.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index fe52f592..94d59f69 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -246,11 +246,11 @@ def display_splash_screen(args: argparse.Namespace) -> None: ASCIIColors.yellow(f"{protocol}://:{args.port}") ASCIIColors.white(" ├─ API Documentation (local): ", end="") ASCIIColors.yellow(f"{protocol}://localhost:{args.port}/docs") - ASCIIColors.white(" └─ Alternative Documentation (local): ", end="") + ASCIIColors.white(" ├─ Alternative Documentation (local): ", end="") ASCIIColors.yellow(f"{protocol}://localhost:{args.port}/redoc") ASCIIColors.white(" ├─ WebUI (local): ", end="") ASCIIColors.yellow(f"{protocol}://localhost:{args.port}/webui") - ASCIIColors.white(" ├─ Graph Viewer (local): ", end="") + ASCIIColors.white(" └─ Graph Viewer (local): ", end="") ASCIIColors.yellow(f"{protocol}://localhost:{args.port}/graph-viewer") ASCIIColors.yellow("\n📝 Note:") diff --git a/lightrag/lightrag.py b/lightrag/lightrag.py index d53a252d..daf4de20 100644 --- a/lightrag/lightrag.py +++ b/lightrag/lightrag.py @@ -69,7 +69,7 @@ STORAGE_IMPLEMENTATIONS = { "VECTOR_STORAGE": { "implementations": [ "NanoVectorDBStorage", - "MilvusVectorDBStorge", + "MilvusVectorDBStorage", "ChromaVectorDBStorage", "TiDBVectorDBStorage", "PGVectorStorage", @@ -123,7 +123,7 @@ STORAGE_ENV_REQUIREMENTS = { ], # Vector Storage Implementations "NanoVectorDBStorage": [], - "MilvusVectorDBStorge": [], + "MilvusVectorDBStorage": [], "ChromaVectorDBStorage": [], "TiDBVectorDBStorage": ["TIDB_USER", "TIDB_PASSWORD", "TIDB_DATABASE"], "PGVectorStorage": ["POSTGRES_USER", "POSTGRES_PASSWORD", "POSTGRES_DATABASE"], From 47268c2ab167fd6d2ed28141dd665f238d549829 Mon Sep 17 00:00:00 2001 From: yangdx Date: Thu, 13 Feb 2025 21:01:34 +0800 Subject: [PATCH 6/8] Fix linting --- lightrag/api/lightrag_server.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index 94d59f69..28085723 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -101,6 +101,7 @@ def estimate_tokens(text: str) -> int: return int(tokens) + def get_default_host(binding_type: str) -> str: default_hosts = { "ollama": os.getenv("LLM_BINDING_HOST", "http://localhost:11434"), From a50cdbc177a302df6f58b57ac19fbc7ef40d7b35 Mon Sep 17 00:00:00 2001 From: ultrageopro Date: Thu, 13 Feb 2025 18:07:24 +0300 Subject: [PATCH 7/8] fix: incorrect usage of os.environ.get method in neo4j --- lightrag/kg/neo4j_impl.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lightrag/kg/neo4j_impl.py b/lightrag/kg/neo4j_impl.py index 731b7cc1..b0839172 100644 --- a/lightrag/kg/neo4j_impl.py +++ b/lightrag/kg/neo4j_impl.py @@ -48,13 +48,13 @@ class Neo4JStorage(BaseGraphStorage): self._driver = None self._driver_lock = asyncio.Lock() - URI = os.environ["NEO4J_URI", config.get("neo4j", "uri", fallback=None)] - USERNAME = os.environ[ + URI = os.environ.get("NEO4J_URI", config.get("neo4j", "uri", fallback=None)) + USERNAME = os.environ.get( "NEO4J_USERNAME", config.get("neo4j", "username", fallback=None) - ] - PASSWORD = os.environ[ + ) + PASSWORD = os.environ( "NEO4J_PASSWORD", config.get("neo4j", "password", fallback=None) - ] + ) MAX_CONNECTION_POOL_SIZE = int( os.environ.get( "NEO4J_MAX_CONNECTION_POOL_SIZE", From 8773ad983f8d42ed7cea1f91c963d84b70c83d78 Mon Sep 17 00:00:00 2001 From: ultrageopro Date: Thu, 13 Feb 2025 18:09:24 +0300 Subject: [PATCH 8/8] fix: incorrect usage of os.environ.get in PASSWORD --- lightrag/kg/neo4j_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightrag/kg/neo4j_impl.py b/lightrag/kg/neo4j_impl.py index b0839172..e9a53110 100644 --- a/lightrag/kg/neo4j_impl.py +++ b/lightrag/kg/neo4j_impl.py @@ -52,7 +52,7 @@ class Neo4JStorage(BaseGraphStorage): USERNAME = os.environ.get( "NEO4J_USERNAME", config.get("neo4j", "username", fallback=None) ) - PASSWORD = os.environ( + PASSWORD = os.environ.get( "NEO4J_PASSWORD", config.get("neo4j", "password", fallback=None) ) MAX_CONNECTION_POOL_SIZE = int(