-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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
What problem does this solve?
There's currently no way to register a callback that fires after all documents finish processing. The only option is to await immediately after ainsert / apipeline_process_enqueue_documents at the call site, which doesn't work well for server contexts (e.g. document_routes.py) or out-of-process consumers.
Proposed API
async def on_documents_processed(results: list[DocProcessingStatus]) -> None:
# triggered once all enqueued docs reach PROCESSED or FAILED
...
rag = LightRAG(
...
on_insert_complete=on_documents_processed,
)Or alternatively, accept it as a parameter on apipeline_process_enqueue_documents itself:
await rag.apipeline_process_enqueue_documents(
on_complete=on_documents_processed
)Why not just await?
Awaiting works fine for direct library use, but the server's pipeline_index_file fires processing as a background task — there's no clean external hook point without patching the router or monkey-patching the rag instance.
Alternatives considered
- Polling
doc_statusstorage — works but is wasteful - Monkey-patching
rag.apipeline_process_enqueue_documents— fragile across version updates
Additional Context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request