Feat: Add Comprehensive Offline Deployment Solution #2194
Merged
+629
−156
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Offline Deployment Support With Cache Management and Layered Dependencies
🎯 Problem Statement
LightRAG uses dynamic package installation (
pipmaster) for optional features based on file types and configurations. In offline or air-gapped environments where internet access is unavailable, these dynamic installations fail, preventing users from deploying LightRAG in restricted network environments.Additionally, tiktoken downloads BPE encoding models on first use from OpenAI's CDN, which also fails in offline environments.
💡 Solution Overview
Implemented a comprehensive offline deployment solution with:
📦 Changes Made
1. Layered Dependency System (
pyproject.toml)Added flexible optional dependency groups:
Usage:
2. Tiktoken Cache Downloader
Created CLI command to pre-download tiktoken models:
New Files:
lightrag/tools/download_cache.py- CLI implementationCLI Command:
Entry Point in
pyproject.toml:3. Requirements Files for pip
Created modular requirements files:
requirements-offline-docs.txt- Document processing onlyrequirements-offline-storage.txt- Storage backends onlyrequirements-offline-llm.txt- LLM providers onlyrequirements-offline.txt- Complete offline package4. Comprehensive Documentation
New File:
docs/OfflineDeployment.mdIncludes:
Updated:
README.md- Added prominent link to offline deployment guide5. Cleanup and Compatibility Fixes
Removed:
scripts/download_tiktoken_cache.py(duplicate of CLI command)lmdeploy>=0.2.0from offline dependencies (Python version compatibility issues)Note:
lightrag/llm/lmdeploy.pyis preserved - it uses pipmaster for dynamic installation when needed.🚀 How to Use
Online Environment (Preparation)
Offline Environment (Deployment)
📊 Benefits
📚 Documentation
docs/OfflineDeployment.md- Complete offline deployment guideREADME.md- Added offline deployment referencepyproject.toml- Added layered optional dependencies and CLI commandType: Enhancement
Category: Deployment, Infrastructure
Backward Compatibility: Full (no breaking changes)