diff --git a/README.md b/README.md index dd570608..49c092cb 100644 --- a/README.md +++ b/README.md @@ -1058,6 +1058,12 @@ 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 API support to serve a Fast api interface to perform data upload and indexing/Rag operations/Rescan of the input folder etc.. + +The documentation can be found [here](lightrag/tools/lightrag_visualizer/README.md) + + ## Star History diff --git a/extra/OpenWebuiTool/openwebui_tool.py b/external_bindings/OpenWebuiTool/openwebui_tool.py similarity index 100% rename from extra/OpenWebuiTool/openwebui_tool.py rename to external_bindings/OpenWebuiTool/openwebui_tool.py diff --git a/extra/VisualizationTool/README.md b/extra/VisualizationTool/README.md deleted file mode 100644 index a2581703..00000000 --- a/extra/VisualizationTool/README.md +++ /dev/null @@ -1,88 +0,0 @@ -# 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/__init__.py b/lightrag/__init__.py index 12bd2ea9..d68bded0 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.4" +__version__ = "1.1.5" __author__ = "Zirui Guo" __url__ = "https://github.com/HKUDS/LightRAG" diff --git a/lightrag/api/__init__.py b/lightrag/api/__init__.py index 70239ed3..9f0b3540 100644 --- a/lightrag/api/__init__.py +++ b/lightrag/api/__init__.py @@ -1 +1 @@ -__api_version__ = "1.0.3" +__api_version__ = "1.0.4" diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index 2680a2ec..27ce8a8d 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -557,7 +557,14 @@ 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/extra/VisualizationTool/assets/place_font_here b/lightrag/tools/__init__.py similarity index 100% rename from extra/VisualizationTool/assets/place_font_here rename to lightrag/tools/__init__.py diff --git a/extra/VisualizationTool/README-zh.md b/lightrag/tools/lightrag_visualizer/README-zh.md similarity index 100% rename from extra/VisualizationTool/README-zh.md rename to lightrag/tools/lightrag_visualizer/README-zh.md diff --git a/lightrag/tools/lightrag_visualizer/README.md b/lightrag/tools/lightrag_visualizer/README.md new file mode 100644 index 00000000..d708dc6d --- /dev/null +++ b/lightrag/tools/lightrag_visualizer/README.md @@ -0,0 +1,135 @@ +# 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. + +## 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/extra/VisualizationTool/graph_visualizer.py b/lightrag/tools/lightrag_visualizer/__init__.py similarity index 99% rename from extra/VisualizationTool/graph_visualizer.py rename to lightrag/tools/lightrag_visualizer/__init__.py index 9bbd6235..69552d8c 100644 --- a/extra/VisualizationTool/graph_visualizer.py +++ b/lightrag/tools/lightrag_visualizer/__init__.py @@ -1,6 +1,6 @@ """ 3D GraphML Viewer using Dear ImGui and ModernGL -Author: LoLLMs, ArnoChen +Author: ParisNeo, ArnoChen Description: An interactive 3D GraphML viewer using imgui_bundle and ModernGL Version: 2.0 """ @@ -8,6 +8,16 @@ 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") + import moderngl from imgui_bundle import imgui, immapp, hello_imgui import community diff --git a/lightrag/tools/lightrag_visualizer/assets/place_font_here b/lightrag/tools/lightrag_visualizer/assets/place_font_here new file mode 100644 index 00000000..e69de29b diff --git a/extra/VisualizationTool/requirements.txt b/lightrag/tools/lightrag_visualizer/requirements.txt similarity index 100% rename from extra/VisualizationTool/requirements.txt rename to lightrag/tools/lightrag_visualizer/requirements.txt diff --git a/setup.py b/setup.py index 38eff646..e080a1dd 100644 --- a/setup.py +++ b/setup.py @@ -62,6 +62,16 @@ 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() @@ -97,10 +107,12 @@ 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]", ], }, )