From b2bc7770fd9d1f55dfec8e06b646bda3ecd609ea Mon Sep 17 00:00:00 2001 From: zrguo <49157727+LarFii@users.noreply.github.com> Date: Wed, 5 Feb 2025 01:30:57 +0800 Subject: [PATCH] Revert "Integrated the GraphML Visualizer as an optional component of LightRAG" --- README.md | 6 - .../OpenWebuiTool/openwebui_tool.py | 0 .../VisualizationTool}/README-zh.md | 0 extra/VisualizationTool/README.md | 88 ++++++++++++ .../VisualizationTool}/assets/place_font_here | 0 .../VisualizationTool/graph_visualizer.py | 14 +- .../VisualizationTool}/requirements.txt | 0 lightrag/__init__.py | 2 +- lightrag/api/__init__.py | 2 +- lightrag/api/lightrag_server.py | 9 +- lightrag/tools/__init__.py | 0 lightrag/tools/lightrag_visualizer/README.md | 136 ------------------ setup.py | 12 -- 13 files changed, 92 insertions(+), 177 deletions(-) rename {external_bindings => extra}/OpenWebuiTool/openwebui_tool.py (100%) rename {lightrag/tools/lightrag_visualizer => extra/VisualizationTool}/README-zh.md (100%) create mode 100644 extra/VisualizationTool/README.md rename {lightrag/tools/lightrag_visualizer => extra/VisualizationTool}/assets/place_font_here (100%) rename lightrag/tools/lightrag_visualizer/__init__.py => extra/VisualizationTool/graph_visualizer.py (99%) rename {lightrag/tools/lightrag_visualizer => extra/VisualizationTool}/requirements.txt (100%) delete mode 100644 lightrag/tools/__init__.py delete mode 100644 lightrag/tools/lightrag_visualizer/README.md diff --git a/README.md b/README.md index ee5519f5..dd570608 100644 --- a/README.md +++ b/README.md @@ -1058,12 +1058,6 @@ LightRag can be installed with API support to serve a Fast api interface to perf The documentation can be found [here](lightrag/api/README.md) -## Graph viewer -LightRag can be installed with Tools support to add extra tools like the graphml 3d visualizer. - -The documentation can be found [here](lightrag/tools/lightrag_visualizer/README.md) - - ## Star History diff --git a/external_bindings/OpenWebuiTool/openwebui_tool.py b/extra/OpenWebuiTool/openwebui_tool.py similarity index 100% rename from external_bindings/OpenWebuiTool/openwebui_tool.py rename to extra/OpenWebuiTool/openwebui_tool.py diff --git a/lightrag/tools/lightrag_visualizer/README-zh.md b/extra/VisualizationTool/README-zh.md similarity index 100% rename from lightrag/tools/lightrag_visualizer/README-zh.md rename to extra/VisualizationTool/README-zh.md diff --git a/extra/VisualizationTool/README.md b/extra/VisualizationTool/README.md new file mode 100644 index 00000000..a2581703 --- /dev/null +++ b/extra/VisualizationTool/README.md @@ -0,0 +1,88 @@ +# 3D GraphML Viewer + +An interactive 3D graph visualization tool based on Dear ImGui and ModernGL. + +## Features + +- **3D Interactive Visualization**: High-performance 3D graphics rendering using ModernGL +- **Multiple Layout Algorithms**: Support for various graph layouts + - Spring layout + - Circular layout + - Shell layout + - Random layout +- **Community Detection**: Automatic detection and visualization of graph community structures +- **Interactive Controls**: + - WASD + QE keys for camera movement + - Right mouse drag for view angle control + - Node selection and highlighting + - Adjustable node size and edge width + - Configurable label display + - Quick navigation between node connections + +## Tech Stack + +- **imgui_bundle**: User interface +- **ModernGL**: OpenGL graphics rendering +- **NetworkX**: Graph data structures and algorithms +- **NumPy**: Numerical computations +- **community**: Community detection + +## Usage + +1. **Launch the Program**: + ```bash + python -m pip install -r requirements.txt + python graph_visualizer.py + ``` + +2. **Load Font**: + - Place the font file `font.ttf` in the `assets` directory + - Or modify the `CUSTOM_FONT` constant to use a different font file + +3. **Load Graph File**: + - Click the "Load GraphML" button in the interface + - Select a graph file in GraphML format + +4. **Interactive Controls**: + - **Camera Movement**: + - W: Move forward + - S: Move backward + - A: Move left + - D: Move right + - Q: Move up + - E: Move down + - **View Control**: + - Hold right mouse button and drag to rotate view + - **Node Interaction**: + - Hover mouse to highlight nodes + - Click to select nodes + +5. **Visualization Settings**: + - Adjustable via UI control panel: + - Layout type + - Node size + - Edge width + - Label visibility + - Label size + - Background color + +## Customization Options + +- **Node Scaling**: Adjust node size via `node_scale` parameter +- **Edge Width**: Modify edge width using `edge_width` parameter +- **Label Display**: Toggle label visibility with `show_labels` +- **Label Size**: Adjust label size using `label_size` +- **Label Color**: Set label color through `label_color` +- **View Distance**: Control maximum label display distance with `label_culling_distance` + +## Performance Optimizations + +- Efficient graphics rendering using ModernGL +- View distance culling for label display optimization +- Community detection algorithms for optimized visualization of large-scale graphs + +## System Requirements + +- Python 3.10+ +- Graphics card with OpenGL 3.3+ support +- Supported Operating Systems: Windows/Linux/MacOS diff --git a/lightrag/tools/lightrag_visualizer/assets/place_font_here b/extra/VisualizationTool/assets/place_font_here similarity index 100% rename from lightrag/tools/lightrag_visualizer/assets/place_font_here rename to extra/VisualizationTool/assets/place_font_here diff --git a/lightrag/tools/lightrag_visualizer/__init__.py b/extra/VisualizationTool/graph_visualizer.py similarity index 99% rename from lightrag/tools/lightrag_visualizer/__init__.py rename to extra/VisualizationTool/graph_visualizer.py index dd20553a..1521a6b3 100644 --- a/lightrag/tools/lightrag_visualizer/__init__.py +++ b/extra/VisualizationTool/graph_visualizer.py @@ -1,6 +1,6 @@ """ 3D GraphML Viewer using Dear ImGui and ModernGL -Author: ParisNeo, ArnoChen +Author: LoLLMs, ArnoChen Description: An interactive 3D GraphML viewer using imgui_bundle and ModernGL Version: 2.0 """ @@ -8,18 +8,6 @@ Version: 2.0 from typing import Optional, Tuple, Dict, List import numpy as np import networkx as nx -import pipmaster as pm - -# Added automatic libraries install using pipmaster -if not pm.is_installed("moderngl"): - pm.install("moderngl") -if not pm.is_installed("imgui_bundle"): - pm.install("imgui_bundle") -if not pm.is_installed("pyglm"): - pm.install("pyglm") -if not pm.is_installed("python-louvain"): - pm.install("python-louvain") - import moderngl from imgui_bundle import imgui, immapp, hello_imgui import community diff --git a/lightrag/tools/lightrag_visualizer/requirements.txt b/extra/VisualizationTool/requirements.txt similarity index 100% rename from lightrag/tools/lightrag_visualizer/requirements.txt rename to extra/VisualizationTool/requirements.txt diff --git a/lightrag/__init__.py b/lightrag/__init__.py index d68bded0..12bd2ea9 100644 --- a/lightrag/__init__.py +++ b/lightrag/__init__.py @@ -1,5 +1,5 @@ from .lightrag import LightRAG as LightRAG, QueryParam as QueryParam -__version__ = "1.1.5" +__version__ = "1.1.4" __author__ = "Zirui Guo" __url__ = "https://github.com/HKUDS/LightRAG" diff --git a/lightrag/api/__init__.py b/lightrag/api/__init__.py index 9f0b3540..70239ed3 100644 --- a/lightrag/api/__init__.py +++ b/lightrag/api/__init__.py @@ -1 +1 @@ -__api_version__ = "1.0.4" +__api_version__ = "1.0.3" diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index 27ce8a8d..ec58f552 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -557,14 +557,7 @@ class DocumentManager: def __init__( self, input_dir: str, - supported_extensions: tuple = ( - ".txt", - ".md", - ".pdf", - ".docx", - ".pptx", - ".xlsx", - ), + supported_extensions: tuple = (".txt", ".md", ".pdf", ".docx", ".pptx", "xlsx"), ): self.input_dir = Path(input_dir) self.supported_extensions = supported_extensions diff --git a/lightrag/tools/__init__.py b/lightrag/tools/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/lightrag/tools/lightrag_visualizer/README.md b/lightrag/tools/lightrag_visualizer/README.md deleted file mode 100644 index 14e9b344..00000000 --- a/lightrag/tools/lightrag_visualizer/README.md +++ /dev/null @@ -1,136 +0,0 @@ -# LightRAG 3D Graph Viewer - -An interactive 3D graph visualization tool included in the LightRAG package for visualizing and analyzing RAG (Retrieval-Augmented Generation) graphs and other graph structures. - -![image](https://github.com/user-attachments/assets/b0d86184-99fc-468c-96ed-c611f14292bf) - -## Installation - -### Quick Install -```bash -pip install lightrag-hku[tools] # Install with visualization tool only -# or -pip install lightrag-hku[api,tools] # Install with both API and visualization tools -``` - -## Launch the Viewer -```bash -lightrag-viewer -``` - -## Features - -- **3D Interactive Visualization**: High-performance 3D graphics rendering using ModernGL -- **Multiple Layout Algorithms**: Support for various graph layouts - - Spring layout - - Circular layout - - Shell layout - - Random layout -- **Community Detection**: Automatic detection and visualization of graph community structures -- **Interactive Controls**: - - WASD + QE keys for camera movement - - Right mouse drag for view angle control - - Node selection and highlighting - - Adjustable node size and edge width - - Configurable label display - - Quick navigation between node connections - -## Tech Stack - -- **imgui_bundle**: User interface -- **ModernGL**: OpenGL graphics rendering -- **NetworkX**: Graph data structures and algorithms -- **NumPy**: Numerical computations -- **community**: Community detection - -## Interactive Controls - -### Camera Movement -- W: Move forward -- S: Move backward -- A: Move left -- D: Move right -- Q: Move up -- E: Move down - -### View Control -- Hold right mouse button and drag to rotate view - -### Node Interaction -- Hover mouse to highlight nodes -- Click to select nodes - -## Visualization Settings - -Adjustable via UI control panel: -- Layout type -- Node size -- Edge width -- Label visibility -- Label size -- Background color - -## Customization Options - -- **Node Scaling**: Adjust node size via `node_scale` parameter -- **Edge Width**: Modify edge width using `edge_width` parameter -- **Label Display**: Toggle label visibility with `show_labels` -- **Label Size**: Adjust label size using `label_size` -- **Label Color**: Set label color through `label_color` -- **View Distance**: Control maximum label display distance with `label_culling_distance` - -## System Requirements - -- Python 3.9+ -- Graphics card with OpenGL 3.3+ support -- Supported Operating Systems: Windows/Linux/MacOS - -## Troubleshooting - -### Common Issues - -1. **Command Not Found** - ```bash - # Make sure you installed with the 'tools' option - pip install lightrag-hku[tools] - - # Verify installation - pip list | grep lightrag-hku - ``` - -2. **ModernGL Initialization Failed** - ```bash - # Check OpenGL version - glxinfo | grep "OpenGL version" - - # Update graphics drivers if needed - ``` - -3. **Font Loading Issues** - - The required fonts are included in the package - - If issues persist, check your graphics drivers - -## Usage with LightRAG - -The viewer is particularly useful for: -- Visualizing RAG knowledge graphs -- Analyzing document relationships -- Exploring semantic connections -- Debugging retrieval patterns - -## Performance Optimizations - -- Efficient graphics rendering using ModernGL -- View distance culling for label display optimization -- Community detection algorithms for optimized visualization of large-scale graphs - -## Support - -- GitHub Issues: [LightRAG Repository](https://github.com/URL-to-lightrag) -- Documentation: [LightRAG Docs](https://URL-to-docs) - -## License - -This tool is part of LightRAG and is distributed under the MIT License. See `LICENSE` for more information. - -Note: This visualization tool is an optional component of the LightRAG package. Install with the [tools] option to access the viewer functionality. diff --git a/setup.py b/setup.py index e080a1dd..38eff646 100644 --- a/setup.py +++ b/setup.py @@ -62,16 +62,6 @@ def read_api_requirements(): return api_deps -def read_extra_requirements(): - api_deps = [] - try: - with open("./lightrag/extra/VisualizationTool/requirements.txt") as f: - api_deps = [line.strip() for line in f if line.strip()] - except FileNotFoundError: - print("Warning: API requirements.txt not found.") - return api_deps - - metadata = retrieve_metadata() long_description = read_long_description() requirements = read_requirements() @@ -107,12 +97,10 @@ setuptools.setup( }, extras_require={ "api": read_api_requirements(), # API requirements as optional - "tools": read_extra_requirements(), # API requirements as optional }, entry_points={ "console_scripts": [ "lightrag-server=lightrag.api.lightrag_server:main [api]", - "lightrag-viewer=lightrag.tools.lightrag_visualizer:main [tools]", ], }, )