From b9b86df786e61669566016bd74ba705d72f47d49 Mon Sep 17 00:00:00 2001 From: yangdx Date: Sat, 3 May 2025 23:00:09 +0800 Subject: [PATCH] Persistent LLM cache on error --- lightrag/lightrag.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lightrag/lightrag.py b/lightrag/lightrag.py index c16a7b68..080c02bc 100644 --- a/lightrag/lightrag.py +++ b/lightrag/lightrag.py @@ -1010,6 +1010,10 @@ class LightRAG: if not task.done(): task.cancel() + # Persistent llm cache + if self.llm_response_cache: + await self.llm_response_cache.index_done_callback + # Update document status to failed await self.doc_status.upsert( { @@ -1028,7 +1032,7 @@ class LightRAG: } ) - # Semphore was released here + # Semphore released, concurrency controlled by graph_db_lock in merge_nodes_and_edges instead if file_extraction_stage_ok: try: @@ -1082,6 +1086,10 @@ class LightRAG: pipeline_status["latest_message"] = error_msg pipeline_status["history_messages"].append(error_msg) + # Persistent llm cache + if self.llm_response_cache: + await self.llm_response_cache.index_done_callback + # Update document status to failed await self.doc_status.upsert( {