Feat: Add Optional LLM Cache Deletion for Document Deletion#2244
Merged
danielaskdd merged 4 commits intoHKUDS:mainfrom Oct 22, 2025
Merged
Feat: Add Optional LLM Cache Deletion for Document Deletion#2244danielaskdd merged 4 commits intoHKUDS:mainfrom
danielaskdd merged 4 commits intoHKUDS:mainfrom
Conversation
• Add delete_llm_cache parameter to API • Collect cache IDs from text chunks • Delete cache after graph operations • Update UI with new checkbox option • Add i18n translations for cache option
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Feat: Add Optional LLM Cache Deletion for Document Deletion
Summary
Implements an optional feature to delete cached LLM extraction results when deleting documents, providing users with better control over cache management and storage cleanup.
🎯 Motivation
Previously, when deleting documents, the associated LLM cache entries (entity extraction results) remained in storage indefinitely. This led to:
This PR addresses these issues by adding an optional cache cleanup mechanism during document deletion.
🔧 Changes Made
Backend Changes
lightrag/lightrag.pydelete_llm_cacheparameter toadelete_by_doc_id()method (defaults toFalsefor backward compatibility)lightrag/api/routers/document_routes.pydelete_llm_cachefield toDeleteDocRequestmodelbackground_delete_documents()to pass cache deletion flagFrontend Changes
lightrag_webui/src/api/lightrag.tsdeleteLLMCacheparameter todeleteDocuments()functionlightrag_webui/src/components/documents/DeleteDocumentsDialog.tsxLocalization
deleteLLMCacheOptiontranslations for 5 languages:💡 Implementation Details
Cache Collection Strategy
Deletion Timing
This order ensures:
Error Handling
🔄 Breaking Changes
None - This is a backward-compatible addition. Existing code will continue to work unchanged as
delete_llm_cachedefaults toFalse.