From 705754ea8b047f7ea2329730cd1885b26036ba36 Mon Sep 17 00:00:00 2001 From: Wang Qi Date: Tue, 7 Jul 2026 18:09:05 +0800 Subject: [PATCH] Fix PageIndex is not working (#16704) Follow on PR #16515 --- rag/svr/task_executor_refactor/task_handler.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rag/svr/task_executor_refactor/task_handler.py b/rag/svr/task_executor_refactor/task_handler.py index 06defc9b7..cce68a985 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.")