feat: Finish implement workspace isolation in lightrag_server #2445
+400
−291
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.
Description
In this PR #2369, it proposed a way to get workspace from request header. It focused on pipeline status and in-mem storage. For the routers, it does not cover. All requests sent to server is still in the hardcoded workspace in env. In this new PR, they are fixed.
Related Issues
[Reference any related issues or tasks addressed by this pull request.]
Issue #1289
Issue #2373
Discussion #1016
Changes Made
[List the specific changes made in this pull request.]
create_doc_managerandcreate_ragin lightrag_server and pass to routerscreate_doc_managerandcreate_ragto create instances for given workspaceLIGHTRAG-WORKSPACEChecklist
Additional Notes
[Add any additional notes or context for the reviewer(s).]
Note
Route all API requests to per-workspace LightRAG/DocumentManager instances via LIGHTRAG-WORKSPACE header and add WebUI control to switch workspaces.
create_rag(request)andcreate_doc_manager(request); derive workspace fromLIGHTRAG-WORKSPACEheader (fallback to default).documents,graph,query,ollama) to acceptRequestand fetch workspace-scoped instances; changeinclude_routerusage to pass factory functions.workspacein/health; set default viaset_default_workspace.localStorageand reload.LIGHTRAG-WORKSPACEwith all requests (axios interceptor and streaming fetch).Written by Cursor Bugbot for commit 4d2d781. This will update automatically on new commits. Configure here.