mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-18 21:21:05 +02:00
fix: address max-effort review findings
- clamp LLM-derived page indices in _get_text_of_pages and get_text_of_pdf_pages_with_labels; dedupe get_text_of_pdf_pages - guard _normalize_tree and folders/documents iterations against explicit nulls in cloud API responses - coerce cloud OCR page numbers to int before filtering in get_page_content - folder cache: raise on missing folder id instead of caching None; stop caching name-not-found so later lookups can succeed - defang doc_id in agent doc-context prompt - append api-key hint to 401 errors (request, legacy and streaming paths) - remove stale legacy JSON workspace sample data unreadable by the SQLite storage
This commit is contained in:
parent
9ad54122bb
commit
3ff04d501a
7 changed files with 70 additions and 323 deletions
|
|
@ -521,9 +521,9 @@ def create_clean_structure_for_description(structure):
|
|||
|
||||
|
||||
def _get_text_of_pages(page_list, start_page, end_page):
|
||||
"""Concatenate text from page_list for pages [start_page, end_page] (1-indexed)."""
|
||||
"""Concatenate text from page_list for pages [start_page, end_page] (1-indexed), clamped to the valid page range."""
|
||||
text = ""
|
||||
for page_num in range(start_page - 1, end_page):
|
||||
for page_num in range(max(start_page, 1) - 1, min(end_page, len(page_list))):
|
||||
text += page_list[page_num][0]
|
||||
return text
|
||||
|
||||
|
|
@ -831,15 +831,12 @@ def get_page_tokens(pdf_path, model=None, pdf_parser="PyPDF2"):
|
|||
|
||||
|
||||
def get_text_of_pdf_pages(pdf_pages, start_page, end_page):
|
||||
text = ""
|
||||
for page_num in range(start_page-1, end_page):
|
||||
text += pdf_pages[page_num][0]
|
||||
return text
|
||||
return _get_text_of_pages(pdf_pages, start_page, end_page)
|
||||
|
||||
|
||||
def get_text_of_pdf_pages_with_labels(pdf_pages, start_page, end_page):
|
||||
text = ""
|
||||
for page_num in range(start_page-1, end_page):
|
||||
for page_num in range(max(start_page, 1) - 1, min(end_page, len(pdf_pages))):
|
||||
text += f"<physical_index_{page_num+1}>\n{pdf_pages[page_num][0]}\n<physical_index_{page_num+1}>\n"
|
||||
return text
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue