Fix PageIndex is not working (#16704)

Follow on PR #16515
This commit is contained in:
Wang Qi
2026-07-07 18:09:05 +08:00
committed by GitHub
parent 7db3eea37b
commit 705754ea8b

View File

@@ -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.")