PageIndex icon indicating copy to clipboard operation
PageIndex copied to clipboard

fix: address Copilot review on utils-split PR

Open denis-samatov opened this issue 8 months ago • 0 comments

Summary

This PR addresses the automated Copilot review comments left on the feature/utils-split PR.

Changes

pageindex/core/pdf.py

  • Fix KeyError crash: get_page_tokens() now wraps tiktoken.encoding_for_model() in try/except KeyError and falls back to cl100k_base — consistent with the same fallback logic already in core/llm.py's count_tokens()

tests/conftest.py

  • Fix broken sys.path: Replaced ../src with .. (project root). The repo has no src/ directory, so the previous path was silently adding a non-existent location to sys.path, masking potential import failures

pageindex/utils.py

  • Restore backward compatibility: Added explicit wrappers for the removed legacy symbols llm_completion and llm_acompletion. Without these, any code importing from pageindex.utils would raise NameError at runtime. The wrappers delegate to the new ChatGPT_API and ChatGPT_API_async in core/llm, with a thread-executor fallback for the async path

Testing

All 11 unit tests pass:

11 passed in 0.51s

denis-samatov avatar Mar 26 '26 13:03 denis-samatov