[Feature Request]: Chunk-level document updates (add / delete / modify chunks)
Do you need to file a feature request?
- I have searched the existing feature request and this feature request is not already filed.
- I believe this is a legitimate feature request, not just a question or bug.
Feature Request Description
Chunk-level document updates in RAGAnything: add, delete or replace individual chunks of an already processed document, instead of re-processing the whole document when a small part of it changes.
Re-processing re-parses and re-extracts every chunk, and repeats all of the multimodal analysis. For large documents that change a few facts at a time, most of that work is wasted.
LightRAG is getting these operations in HKUDS/LightRAG#4054 (feature request HKUDS/LightRAG#4055): aadd_chunks_to_doc, adelete_chunks_from_doc and amodify_chunk_in_doc. They re-extract only the changed chunks. Entities and relations fed only by removed chunks are deleted, and shared ones are rebuilt from the chunks that remain.
Proposal. Expose the same three methods, with sync forms, on RAGAnything through a small mixin that forwards to self.lightrag:
ids = await rag.aadd_chunks_to_doc("doc-123", ["Rent is $2,000 per month."])
new_id = await rag.amodify_chunk_in_doc("doc-123", ids[0], "Rent is $2,150 per month.")
result = await rag.adelete_chunks_from_doc("doc-123", [new_id])- No parser check. Like
aquery, these calls parse nothing, so they use the LightRAG instance directly and skip_ensure_lightrag_initialized's parser check. Updating chunks should not require MinerU to be installed. - Older LightRAG releases. With a
lightrag-hkurelease that lacks the methods (the current pin is<1.5), each call raisesNotImplementedErrornaming the missing method. The wrappers can therefore merge before the dependency is raised.
Implementation, docs and tests are in #371, opened as a draft until the LightRAG side is merged.
Additional Context
Raising the lightrag-hku pin to a release that includes these methods is left to the maintainers, since it spans the whole 1.5 line (the automated <1.6 bump in #299 was closed).
Source: HKUDS/RAG-Anything