Fix TOC handling, retries, and config/docs #83
+242
−81
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Batch fixes for several open issues in the open-source repo (no merge requested).
Changes
process_toc_no_page_numberswhen TOC exists but has no page indices (addresses code no used def process_toc_no_page_numbers #30)extract_toc_contentto prevent infinite loops (addresses fix: prevent infinite loop in extract_toc_content #64)fix_incorrect_toclist index shadowing bug (addresses fix: prevent list_index variable shadowing in fix_incorrect_toc #66)KeyErrorinprocess_none_page_numbersby usingpop()(addresses fix: use pop() instead of del in process_none_page_numbers #69)ChatGPT_API_with_finish_reasonreturn a consistent(content, finish_reason)tuple on error (addresses fix: ChatGPT_API_with_finish_reason returns inconsistent type on error #62)chat_history(addresses Reuse OpenAI clients to improve throughput #71)utils.create_node_mapping()used by notebooks (addresses no create_node_mapping() in utils #41)PyPDF2==3.0.1withpypdf>=4.0.0+ compatibility import (addresses 🔒 Argus Security Scan Report - AI-Powered Analysis Findings #79)--max-tokens-per-nodefor page grouping to reduce context overflow risk (addresses Issue: Token limit not enforced →tokens_limit_reached+ unpacking crash #15)meta_processorby logging and falling back to a minimal 1-node structure (addresses Exception: Processing failed #39)--if-add-node-text, fix default for--if-add-doc-description, and note quoting paths with spaces (addresses run_pageindex.py doesn't return the text of the content and has wrong indices #42, If the file name has Spaces, it will simply fail #7).env(CHATGPT_MODEL) and OpenAI-compatible endpoints viaCHATGPT_BASE_URLTesting
python -m py_compile pageindex/utils.py pageindex/page_index.py pageindex/page_index_md.py run_pageindex.pypython run_pageindex.py --md_path /tmp/pageindex_sample.md --if-add-node-summary no --if-add-doc-description no(no API calls)