Credentials. The script needs two API keys set as environment variables, so keep them out of shared code and shell history.
Credentials. The PDF is uploaded to the cloud PageIndex service, so do not send confidential documents you are not allowed to share with that service.
Who it is forAn analyst or developer with a long annual report or technical PDF who needs the exact page for a specific figure, and who is past the point where one request can hold every page.
The problemA single multiple-choice request cannot hold every page of a long document, so flat page search fails on reports over a few dozen pages.
The outcomeThe script prints the sections and pages it kept, so you can open the right page of the report and check the figure.
What you need first
- Python with pip available
- A TypeSafe API key from the TypeSafe console
- A PageIndex API key from the PageIndex dashboard
- The PDF you want to search
Steps
- Run
pip install -r requirements.txtin the repo folder. - Run
export TYPESAFE_API_KEY="..."and replace the value with your TypeSafe key. - Run
export PAGEINDEX_API_KEY="..."and replace the value with your PageIndex key. - Run
python tree_search.py NVIDIA_10K.pdf "What was NVIDIA's total revenue for fiscal year 2026?"with your own PDF and question. - Note the printed doc_id, then ask another question with
python tree_search.py pi-... "<your question>"so the PDF is not uploaded again. (inferred, check the README)
Prompt for your agent
Using the repo VectifyAI/jev-doc-search, run tree_search.py on <path-to-pdf> with the question <question>. Report the sections and pages it kept and the doc_id. Verify by opening the first kept page of the PDF and confirming the figure or claim appears there.
Caveat. The README tests tree search on two annual reports and two questions, so verify each returned page against the source document before relying on it.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for VectifyAI/jev-doc-search and "Find the page that answers a question in a long PDF"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer