mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-18 21:21:05 +02:00
fix: exact md page selection + restore CHATGPT_API_KEY alias
Address PR #272 review: - get_md_page_content / retrieve._get_md_page_content returned every node whose line_num fell in [min(pages), max(pages)], so a non-contiguous spec like "5,100" over-fetched everything in between. Match the exact requested line numbers instead, mirroring the PDF path. (Same bug as #280.) - Restore the CHATGPT_API_KEY -> OPENAI_API_KEY backward-compat alias dropped when pageindex/utils.py became a re-export shim; users with only CHATGPT_API_KEY set would otherwise fail auth after upgrading. It now runs in __init__.py right after load_dotenv. Adds regression tests for both. Claude-Session: https://claude.ai/code/session_01Kx5DgKbhK1N8autqXH8SmS
This commit is contained in:
parent
2d46d68052
commit
2a69c76b7f
5 changed files with 91 additions and 6 deletions
|
|
@ -7,6 +7,13 @@
|
|||
from dotenv import load_dotenv as _load_dotenv
|
||||
_load_dotenv()
|
||||
|
||||
# Backward compatibility: honor CHATGPT_API_KEY as an alias for OPENAI_API_KEY
|
||||
# (kept from the pre-SDK pageindex.utils). Runs after load_dotenv so a value in
|
||||
# .env is picked up too; only fills OPENAI_API_KEY when it isn't already set.
|
||||
import os as _os
|
||||
if not _os.getenv("OPENAI_API_KEY") and _os.getenv("CHATGPT_API_KEY"):
|
||||
_os.environ["OPENAI_API_KEY"] = _os.getenv("CHATGPT_API_KEY")
|
||||
|
||||
# Upstream exports (backward compatibility). Import from the canonical
|
||||
# pageindex.index.* modules directly so `import pageindex` does NOT trip the
|
||||
# top-level deprecation shims (pageindex.page_index / .page_index_md / .utils).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue