A command line research assistant for a single PDF. Load a document, then ask questions about it, summarize sections, and pull out key concepts, powered by the Gemini API (gemini-2.5-flash-lite).
pip install -r requirements.txt
On first run, it will ask for a Gemini API key and save it to
~/.pdfmind_config.json. Get a free key from
Google AI Studio.
python main.py path/to/document.pdf
This loads the PDF and starts an interactive session.
chapters- list detected chapters and sectionssummarize- summarize the whole documentsummarize <n>- summarize chapter or section number nsummarize <a>-<b>- summarize pages a to bconcepts- extract key concepts from the whole documentconcepts <n>- extract key concepts from chapter or section nask <question>- ask a question about the documentpages- show the total page countkey- update the stored Gemini API keyhelp- show the command listexit- quit
pdf_reader.pyextracts text from the PDF page by page using pypdf, and tries to detect chapter or section headings using simple text patterns such as "Chapter 1" or "2.1 Background". This detection is approximate and may miss headings or pick up extra ones, depending on how the PDF was made.gemini_client.pyhandles the API key and sends prompts to Gemini.main.pyties it together into an interactive command line session.
- Chapter detection is heuristic and works best on documents with clear, text based headings such as "Chapter 1" or numbered section titles. Scanned PDFs without selectable text will not work well.
- For
askand whole documentsummarizeorconcepts, the entire document text is sent to Gemini in one request. This works for most papers, reports, and short books, but very large documents may exceed the model's context limit.