PageIndex
PageIndex copied to clipboard
fix: address Copilot review on utils-split PR
Summary
This PR addresses the automated Copilot review comments left on the feature/utils-split PR.
Changes
pageindex/core/pdf.py
- Fix
KeyErrorcrash:get_page_tokens()now wrapstiktoken.encoding_for_model()intry/except KeyErrorand falls back tocl100k_base— consistent with the same fallback logic already incore/llm.py'scount_tokens()
tests/conftest.py
- Fix broken sys.path: Replaced
../srcwith..(project root). The repo has nosrc/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_completionandllm_acompletion. Without these, any code importing frompageindex.utilswould raiseNameErrorat runtime. The wrappers delegate to the newChatGPT_APIandChatGPT_API_asyncincore/llm, with a thread-executor fallback for the async path
Testing
All 11 unit tests pass:
11 passed in 0.51s