Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix PageIndex is not working (#16704)

Wang Qi705754ea8b04
diff --git a/rag/svr/task_executor_refactor/task_handler.py b/rag/svr/task_executor_refactor/task_handler.py
index 06defc9b74..cce68a985f 100644
--- a/rag/svr/task_executor_refactor/task_handler.py
+++ b/rag/svr/task_executor_refactor/task_handler.py
@@ -590,6 +590,10 @@ class TaskHandler:
logging.info(progress_message)
ctx.progress_cb(msg=progress_message)
+ toc_thread = None
+ if ctx.parser_id.lower() == "naive" and ctx.parser_config.get("toc_extraction", False):
+ toc_thread = asyncio.create_task(asyncio.to_thread(self._build_toc, ctx, chunks, ctx.progress_cb))
+
# Insert chunks
chunk_count = len(set([chunk["id"] for chunk in chunks]))
start_ts = timer()
@@ -615,6 +619,11 @@ class TaskHandler:
ctx.progress_cb(msg="Indexing done ({:.2f}s).".format(timer() - start_ts))
+ toc_chunk = await self._process_toc_thread(toc_thread)
+ if toc_chunk:
+ ctx.recording_context.record("toc_chunk", [toc_chunk])
+ await post_processor.insert_toc_chunk(toc_chunk, chunk_service)
+
if ctx.has_canceled_func(task_id):
abort_doc_chunking_counter(task_doc_id)
ctx.progress_cb(-1, msg="Task has been canceled.")