papers-app 0.2.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. {papers_app-0.2.0 → papers_app-0.3.0}/CONTRIBUTING.md +8 -3
  2. papers_app-0.3.0/PKG-INFO +240 -0
  3. papers_app-0.3.0/README.md +209 -0
  4. {papers_app-0.2.0 → papers_app-0.3.0}/papers/__init__.py +1 -1
  5. {papers_app-0.2.0 → papers_app-0.3.0}/papers/agent/loop.py +3 -2
  6. {papers_app-0.2.0 → papers_app-0.3.0}/papers/agent/tools.py +36 -3
  7. papers_app-0.3.0/papers/ai/capabilities.py +98 -0
  8. {papers_app-0.2.0 → papers_app-0.3.0}/papers/chat/answer.py +27 -0
  9. {papers_app-0.2.0 → papers_app-0.3.0}/papers/cli.py +21 -4
  10. papers_app-0.3.0/papers/config.py +109 -0
  11. {papers_app-0.2.0 → papers_app-0.3.0}/papers/figures.py +45 -0
  12. {papers_app-0.2.0 → papers_app-0.3.0}/papers/llm.py +72 -19
  13. papers_app-0.3.0/papers/roadmap.py +174 -0
  14. papers_app-0.3.0/papers/routes/goals.py +128 -0
  15. {papers_app-0.2.0 → papers_app-0.3.0}/papers/routes/learning.py +36 -3
  16. {papers_app-0.2.0 → papers_app-0.3.0}/papers/routes/settings.py +33 -3
  17. {papers_app-0.2.0 → papers_app-0.3.0}/papers/scholar.py +2 -1
  18. papers_app-0.3.0/papers/setup.py +250 -0
  19. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/css/chat.css +277 -241
  20. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/css/components.css +8 -1
  21. papers_app-0.3.0/papers/static/css/goals.css +257 -0
  22. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/css/paper.css +23 -0
  23. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/css/reader.css +9 -8
  24. papers_app-0.3.0/papers/static/css/settings.css +82 -0
  25. papers_app-0.3.0/papers/static/css/welcome.css +113 -0
  26. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/index.html +1 -0
  27. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/chat/answer.js +4 -1
  28. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/chat/canvas.js +2 -1
  29. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/chat/conversation.js +27 -19
  30. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/chat/render.js +30 -3
  31. papers_app-0.3.0/papers/static/js/chat/widgets.js +399 -0
  32. papers_app-0.3.0/papers/static/js/icons.js +27 -0
  33. papers_app-0.3.0/papers/static/js/pages/goals.js +405 -0
  34. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/pages/library.js +4 -5
  35. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/pages/map.js +23 -0
  36. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/pages/recall.js +7 -0
  37. papers_app-0.3.0/papers/static/js/pages/settings.js +312 -0
  38. papers_app-0.3.0/papers/static/js/pages/welcome.js +91 -0
  39. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/figures.js +3 -2
  40. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/overview.js +4 -1
  41. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader/layout.js +3 -2
  42. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader/panel.js +6 -1
  43. papers_app-0.3.0/papers/static/js/paper/review.js +212 -0
  44. papers_app-0.3.0/papers/storage.py +73 -0
  45. {papers_app-0.2.0 → papers_app-0.3.0}/pyproject.toml +2 -0
  46. {papers_app-0.2.0 → papers_app-0.3.0}/tests/conftest.py +1 -0
  47. papers_app-0.3.0/tests/test_capabilities.py +103 -0
  48. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_papers.py +1 -1
  49. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_review.py +37 -0
  50. papers_app-0.3.0/tests/test_roadmap.py +67 -0
  51. papers_app-0.3.0/tests/test_setup.py +59 -0
  52. papers_app-0.3.0/tests/test_storage.py +47 -0
  53. papers_app-0.2.0/PKG-INFO +0 -138
  54. papers_app-0.2.0/README.md +0 -109
  55. papers_app-0.2.0/papers/config.py +0 -52
  56. papers_app-0.2.0/papers/routes/goals.py +0 -65
  57. papers_app-0.2.0/papers/static/css/goals.css +0 -85
  58. papers_app-0.2.0/papers/static/css/settings.css +0 -36
  59. papers_app-0.2.0/papers/static/js/chat/widgets.js +0 -161
  60. papers_app-0.2.0/papers/static/js/pages/goals.js +0 -149
  61. papers_app-0.2.0/papers/static/js/pages/settings.js +0 -225
  62. papers_app-0.2.0/papers/static/js/paper/review.js +0 -109
  63. {papers_app-0.2.0 → papers_app-0.3.0}/.gitignore +0 -0
  64. {papers_app-0.2.0 → papers_app-0.3.0}/LICENSE +0 -0
  65. {papers_app-0.2.0 → papers_app-0.3.0}/papers/__main__.py +0 -0
  66. {papers_app-0.2.0 → papers_app-0.3.0}/papers/agent/__init__.py +0 -0
  67. {papers_app-0.2.0 → papers_app-0.3.0}/papers/agent/mcp_server.py +0 -0
  68. {papers_app-0.2.0 → papers_app-0.3.0}/papers/ai/__init__.py +0 -0
  69. {papers_app-0.2.0 → papers_app-0.3.0}/papers/ai/anthropic_api.py +0 -0
  70. {papers_app-0.2.0 → papers_app-0.3.0}/papers/ai/claude_code.py +0 -0
  71. {papers_app-0.2.0 → papers_app-0.3.0}/papers/ai/codex.py +0 -0
  72. {papers_app-0.2.0 → papers_app-0.3.0}/papers/ai/errors.py +0 -0
  73. {papers_app-0.2.0 → papers_app-0.3.0}/papers/ai/openai_compat.py +0 -0
  74. {papers_app-0.2.0 → papers_app-0.3.0}/papers/ai/providers.py +0 -0
  75. {papers_app-0.2.0 → papers_app-0.3.0}/papers/ai/streaming.py +0 -0
  76. {papers_app-0.2.0 → papers_app-0.3.0}/papers/bibtex.py +0 -0
  77. {papers_app-0.2.0 → papers_app-0.3.0}/papers/chat/__init__.py +0 -0
  78. {papers_app-0.2.0 → papers_app-0.3.0}/papers/chat/store.py +0 -0
  79. {papers_app-0.2.0 → papers_app-0.3.0}/papers/db.py +0 -0
  80. {papers_app-0.2.0 → papers_app-0.3.0}/papers/folders.py +0 -0
  81. {papers_app-0.2.0 → papers_app-0.3.0}/papers/index.py +0 -0
  82. {papers_app-0.2.0 → papers_app-0.3.0}/papers/ingest.py +0 -0
  83. {papers_app-0.2.0 → papers_app-0.3.0}/papers/keys.py +0 -0
  84. {papers_app-0.2.0 → papers_app-0.3.0}/papers/library.py +0 -0
  85. {papers_app-0.2.0 → papers_app-0.3.0}/papers/main.py +0 -0
  86. {papers_app-0.2.0 → papers_app-0.3.0}/papers/notes.py +0 -0
  87. {papers_app-0.2.0 → papers_app-0.3.0}/papers/pdf.py +0 -0
  88. {papers_app-0.2.0 → papers_app-0.3.0}/papers/routes/__init__.py +0 -0
  89. {papers_app-0.2.0 → papers_app-0.3.0}/papers/routes/chat.py +0 -0
  90. {papers_app-0.2.0 → papers_app-0.3.0}/papers/routes/notes.py +0 -0
  91. {papers_app-0.2.0 → papers_app-0.3.0}/papers/routes/papers.py +0 -0
  92. {papers_app-0.2.0 → papers_app-0.3.0}/papers/routes/reading.py +0 -0
  93. {papers_app-0.2.0 → papers_app-0.3.0}/papers/routes/recall.py +0 -0
  94. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/css/base.css +0 -0
  95. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/css/library.css +0 -0
  96. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/css/map.css +0 -0
  97. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/css/recall.css +0 -0
  98. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/css/tokens.css +0 -0
  99. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/chat/stream.js +0 -0
  100. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/components/combobox.js +0 -0
  101. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/components/folderpicker.js +0 -0
  102. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/core.js +0 -0
  103. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/covers.js +0 -0
  104. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/highlights.js +0 -0
  105. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/main.js +0 -0
  106. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/notes.js +0 -0
  107. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/pages/shared.js +0 -0
  108. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader/bar.js +0 -0
  109. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader/cite.js +0 -0
  110. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader/finish.js +0 -0
  111. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader/highlighter.js +0 -0
  112. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader/keys.js +0 -0
  113. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader/progress.js +0 -0
  114. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader/route.js +0 -0
  115. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader/selection.js +0 -0
  116. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader/state.js +0 -0
  117. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader/terms.js +0 -0
  118. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader/views.js +0 -0
  119. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader/vocab.js +0 -0
  120. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader/zoom.js +0 -0
  121. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/reader.js +0 -0
  122. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/paper/shared.js +0 -0
  123. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/pdfview.js +0 -0
  124. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/readprefs.js +0 -0
  125. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/speech.js +0 -0
  126. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/textview.js +0 -0
  127. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/theme.js +0 -0
  128. {papers_app-0.2.0 → papers_app-0.3.0}/papers/static/js/tracker.js +0 -0
  129. {papers_app-0.2.0 → papers_app-0.3.0}/papers/store.py +0 -0
  130. {papers_app-0.2.0 → papers_app-0.3.0}/tests/__init__.py +0 -0
  131. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_abstract_figures.py +0 -0
  132. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_add_link.py +0 -0
  133. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_agent.py +0 -0
  134. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_agent_actions.py +0 -0
  135. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_ai.py +0 -0
  136. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_capture.py +0 -0
  137. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_claude_code.py +0 -0
  138. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_conversations.py +0 -0
  139. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_folders.py +0 -0
  140. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_frontend.py +0 -0
  141. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_highlights_notes.py +0 -0
  142. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_keys.py +0 -0
  143. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_learning.py +0 -0
  144. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_library_covers.py +0 -0
  145. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_library_folder.py +0 -0
  146. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_metadata.py +0 -0
  147. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_never_stuck.py +0 -0
  148. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_notes_ask.py +0 -0
  149. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_prepare.py +0 -0
  150. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_progress.py +0 -0
  151. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_prompts.py +0 -0
  152. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_provider_list.py +0 -0
  153. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_providers.py +0 -0
  154. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_recall_refs.py +0 -0
  155. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_scaffold.py +0 -0
  156. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_search.py +0 -0
  157. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_streaming.py +0 -0
  158. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_tracker.py +0 -0
  159. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_triage.py +0 -0
  160. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_upload.py +0 -0
  161. {papers_app-0.2.0 → papers_app-0.3.0}/tests/test_vocabulary.py +0 -0
@@ -29,17 +29,20 @@ CI runs both on Python 3.11 to 3.13 and checks that the Docker image starts.
29
29
  ```
30
30
  papers/
31
31
  cli.py the `papers` command: options, then starts the server and opens the browser
32
- config.py where data lives and every environment variable
32
+ config.py where data lives (the data folder, and config.json which remembers the chosen one) and every
33
+ environment variable
34
+ setup.py the first-run setup in the terminal (banner, data folder, library folder, AI); `papers setup`
35
+ storage.py what is kept where, with sizes, and moving the data folder (Settings › Where everything is kept)
33
36
  main.py builds the app: the routers below, error handling, the web files, the Inbox watcher
34
37
 
35
38
  routes/ the HTTP API, one file per part of the app
36
39
  papers.py add (search result, link, PDF), list, edit, delete, the PDF file, prepare
37
- goals.py goals (stored as "topics"), finding papers for them, BibTeX export
40
+ goals.py goals (stored as "topics"), finding papers for them, the reading roadmap, BibTeX export
38
41
  reading.py progress, finishing, figures and tables, references, the chain a paper is in
39
42
  learning.py key points, vocabulary, explain/translate/ask (streamed), quiz and spaced review
40
43
  notes.py notes and highlights
41
44
  recall.py full-text search and "which paper had this idea?"
42
- settings.py name, language, AI provider, library folder and the folder picker
45
+ settings.py name, language, AI provider, what the AI can do, storage (show and move), the folder picker
43
46
 
44
47
  store.py reading and writing papers; every change also updates the search index and the folder
45
48
  ingest.py turning a PDF into a paper, the Inbox, and preparing papers ahead of time with the AI
@@ -58,6 +61,8 @@ papers/
58
61
  scholar.py Semantic Scholar and arXiv library.py the library folder (PDFs + Markdown notes)
59
62
  notes.py notes and highlights storage folders.py the folder picker
60
63
  bibtex.py BibTeX entries
64
+ roadmap.py a goal's reading roadmap: search widely, let the AI pick and order papers in stages, add the
65
+ chosen ones to the goal and fetch their PDFs in the background
61
66
 
62
67
  static/ the web app (no build step; ES modules loaded by the browser)
63
68
  index.html the page shell; links the stylesheets below in order
@@ -0,0 +1,240 @@
1
+ Metadata-Version: 2.5
2
+ Name: papers-app
3
+ Version: 0.3.0
4
+ Summary: An AI reading companion for research papers: skim, read, ask, recall. Runs on your computer.
5
+ Project-URL: Homepage, https://github.com/hBouanane/papers
6
+ Project-URL: Issues, https://github.com/hBouanane/papers/issues
7
+ Author: hBouanane
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: ai,llm,papers,pdf,reading,research
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Web Environment
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Scientific/Engineering
16
+ Requires-Python: >=3.11
17
+ Requires-Dist: anthropic>=0.40
18
+ Requires-Dist: fastapi>=0.115
19
+ Requires-Dist: httpx>=0.27
20
+ Requires-Dist: keyring>=24
21
+ Requires-Dist: pdfplumber>=0.11
22
+ Requires-Dist: pypdf>=5
23
+ Requires-Dist: python-multipart>=0.0.9
24
+ Requires-Dist: questionary>=2
25
+ Requires-Dist: rich>=13
26
+ Requires-Dist: uvicorn>=0.30
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=8; extra == 'dev'
29
+ Requires-Dist: ruff>=0.6; extra == 'dev'
30
+ Description-Content-Type: text/markdown
31
+
32
+ <h1 align="center">Papers</h1>
33
+
34
+ <p align="center"><strong>An AI reading companion for research papers.</strong><br>
35
+ Find the right papers for what you're working on, read them with an AI that knows the whole paper,
36
+ and remember what you read.</p>
37
+
38
+ <p align="center">
39
+ <a href="https://pypi.org/project/papers-app/"><img alt="PyPI" src="https://img.shields.io/pypi/v/papers-app?color=1d3fbb"></a>
40
+ <a href="https://pypi.org/project/papers-app/"><img alt="Python 3.11+" src="https://img.shields.io/pypi/pyversions/papers-app"></a>
41
+ <a href="https://github.com/hBouanane/papers/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/hBouanane/papers/actions/workflows/ci.yml/badge.svg"></a>
42
+ <a href="https://github.com/hBouanane/papers/pkgs/container/papers"><img alt="Docker image" src="https://img.shields.io/badge/docker-ghcr.io%2Fhbouanane%2Fpapers-1d3fbb?logo=docker&logoColor=white"></a>
43
+ <a href="LICENSE"><img alt="MIT license" src="https://img.shields.io/github/license/hBouanane/papers"></a>
44
+ </p>
45
+
46
+ <p align="center">
47
+ <code>uvx papers-app</code>
48
+ </p>
49
+
50
+ ![The welcome page: a paper being highlighted, asked about and scored](docs/screenshots/welcome.gif)
51
+
52
+ ![The Library: the paper you're reading, the others on your desk, what's due for review, and your goals](docs/screenshots/library.png)
53
+
54
+ ## About
55
+
56
+ Reading research papers is slow when you're new to a field: you don't know which papers matter, in what order to
57
+ read them, or what half the words mean. Papers is the companion for that.
58
+
59
+ - **Start from a goal.** Say what you're trying to understand. Papers searches Semantic Scholar and arXiv and the AI
60
+ suggests a **reading roadmap**: the basics first, then the core methods, then the newest work, with why each
61
+ paper and about how long it takes. Tick the ones you want (or keep them all) and they're added, PDFs included.
62
+ - **Read with an AI that has the whole paper.** Select a passage and press **Explain**, **Simplify** or
63
+ **Translate**, or just ask. Answers cite the paper's sections and figures, write formulas properly, and can
64
+ draw charts and small interactive widgets. Every question is a conversation you can come back to.
65
+ - **Remember it.** Key points for every paper, its hard words marked in the text, a quiz when you finish, spaced
66
+ review, and **Recall**: describe an idea in your own words and find where you read it.
67
+
68
+ It runs on your computer. Your library (papers, notes, highlights, conversations) is a folder on your disk, and you
69
+ choose the AI: your Claude or ChatGPT subscription, an API key, or a model running locally with Ollama or LM Studio.
70
+
71
+ ## A tour
72
+
73
+ <table>
74
+ <tr>
75
+ <td width="50%"><img src="docs/screenshots/chat-figure.png" alt="A Deep answer that points at the encoder, the decoder and where they connect in the paper's Figure 1"><br>
76
+ <b>Ask about a figure.</b> The AI looks at the figure and points at the parts it is talking about.</td>
77
+ <td width="50%"><img src="docs/screenshots/chat-widget.png" alt="An answer with a plot of the learning-rate schedule and sliders to change it"><br>
78
+ <b>Play with a formula.</b> Answers can draw plots and small widgets with sliders, for any field.</td>
79
+ </tr>
80
+ <tr>
81
+ <td width="50%"><img src="docs/screenshots/goal-papers.png" alt="A goal: its papers shown by their first pages, and one line from each"><br>
82
+ <b>Goals.</b> Each goal keeps its papers together, shown by their first pages, with one line on what each says.</td>
83
+ <td width="50%"><img src="docs/screenshots/recall.png" alt="Recall: search your papers by an idea in your own words"><br>
84
+ <b>Recall.</b> "Where did I read that?" Searches every paper, your notes and the explanations you asked for.</td>
85
+ </tr>
86
+ <tr>
87
+ <td width="50%"><img src="docs/screenshots/goal.png" alt="A goal's reading roadmap: stages of papers with why and how long each"><br>
88
+ <b>Reading roadmap.</b> For each goal, the best papers in reading order. Pick some or all; PDFs download for you,
89
+ and your progress shows as you read (<i>Start here</i>, <i>Next up</i>).</td>
90
+ <td width="50%"><img src="docs/screenshots/reader.png" alt="Reading a paper with an explanation of a formula beside it"><br>
91
+ <b>Reader.</b> Select a passage to have it explained, simplified or translated, beside the page.</td>
92
+ </tr>
93
+ <tr>
94
+ <td><img src="docs/screenshots/paper.png" alt="A paper's page: abstract, key points, figures, words, notes, references"><br>
95
+ <b>Each paper at a glance.</b> Key points, figures and tables, its vocabulary, your notes, and its references
96
+ (follow one to grow a chain on the Map).</td>
97
+ <td><img src="docs/screenshots/reader-dark.png" alt="The reader in the dark theme"><br>
98
+ <b>Light, dim or dark</b>, with the PDF pages dimmed to match.</td>
99
+ </tr>
100
+ <tr>
101
+ <td><img src="docs/screenshots/settings-features.png" alt="Settings: what the AI can do, Quick and Deep"><br>
102
+ <b>Quick or Deep.</b> Quick answers at once from the paper; Deep lets the AI search it, read sections, look at
103
+ figures and check your library first.</td>
104
+ </tr>
105
+ </table>
106
+
107
+ ## Install
108
+
109
+ With Python 3.11 or newer, one command (like `npx` for Node):
110
+
111
+ ```bash
112
+ uvx papers-app
113
+ ```
114
+
115
+ or install it to keep it around, then start it with `papers`:
116
+
117
+ ```bash
118
+ pipx install papers-app
119
+ ```
120
+
121
+ The first time, a short setup in the terminal asks three things, so it's clear from the start where everything goes:
122
+
123
+ ```
124
+ 1/3 Your library where the database, PDFs and figures are kept (one folder)
125
+ 2/3 A folder to browse optional: each paper's PDF and Markdown notes, for your file manager or Obsidian
126
+ 3/3 The AI model provider, key (kept in your system's keychain) and model, then a quick check
127
+ ```
128
+
129
+ Then `papers` opens http://localhost:8000 in your browser. Everything can be changed later in Settings, or with
130
+ `papers setup`. Options: `--port 9000`, `--data D:\Papers` (use this data folder), `--no-browser`, `--no-setup`,
131
+ `--host 0.0.0.0` (reach it from other devices on your network; there is no login, so only on networks you trust).
132
+
133
+ ### With Docker
134
+
135
+ The image is published on GitHub's registry, so one command pulls it and starts the app:
136
+
137
+ ```bash
138
+ docker run -d --name papers -p 8000:8000 -v papers-data:/data ghcr.io/hbouanane/papers:latest
139
+ ```
140
+
141
+ Then open http://localhost:8000 and choose the AI in Settings. What each part means:
142
+
143
+ | Part | Meaning |
144
+ | --- | --- |
145
+ | `-d --name papers` | run in the background, named `papers` (`docker stop papers` / `docker start papers`) |
146
+ | `-p 8000:8000` | the app inside listens on port 8000; this makes it http://localhost:8000 on your computer |
147
+ | `-v papers-data:/data` | your library (database, PDFs, figures) lives in `/data` inside the container; this keeps it in a Docker volume called `papers-data`, so it survives updates and restarts. Use a folder instead with `-v ~/Papers-data:/data` |
148
+ | `ghcr.io/hbouanane/papers:latest` | the image: on GitHub's registry (`ghcr.io`), from this repository, the newest release (or a version, e.g. `:0.3.0`) |
149
+
150
+ To update: `docker pull ghcr.io/hbouanane/papers:latest`, then `docker rm -f papers` and the same `docker run` again
151
+ (the volume keeps your library). From a clone you can also build it yourself with `docker compose up -d`; see
152
+ [docker-compose.yml](docker-compose.yml) to use a folder on your computer for the library folder, or a model running
153
+ on your computer (Ollama, LM Studio). Subscriptions (Claude, ChatGPT) need their app on the same computer, so in
154
+ Docker use an API key or a local model.
155
+
156
+ ### From the source
157
+
158
+ ```bash
159
+ git clone https://github.com/hBouanane/papers && cd papers
160
+ python -m venv .venv
161
+ .venv/Scripts/pip install -e ".[dev]" # macOS/Linux: .venv/bin/pip
162
+ .venv/Scripts/papers
163
+ ```
164
+
165
+ ## Where everything is kept
166
+
167
+ Settings › *Where everything is kept* shows all of it, with sizes:
168
+
169
+ | What | Where |
170
+ | --- | --- |
171
+ | Your library: the database (papers, notes, highlights, goals, conversations), PDFs, figure images | One **data folder**, chosen at the first start. Default: `%APPDATA%\Papers`, `~/Library/Application Support/Papers` or `~/.local/share/papers`. **Move…** in Settings copies it elsewhere and switches to it (the old folder is left for you to delete) |
172
+ | API keys | Your system's keychain (Windows Credential Manager, macOS Keychain, the Secret Service on Linux); in the database only where there's none (Docker, servers). Never sent back to the page |
173
+ | Which data folder to use | A small `config.json` beside the default data folder (`PAPERS_CONFIG` to put it elsewhere) |
174
+ | A browsable copy (optional) | The **library folder**: one folder per goal, each paper as `Author et al. Year - Title.pdf` with a `.md` notes file (key points, explanations, quiz, `[[links]]` to related papers, so Obsidian shows a graph). PDFs dropped into its `Inbox` are imported within about 10 seconds |
175
+
176
+ ## Choosing an AI model
177
+
178
+ Settings › AI model has one list of providers, each set up the same way: its key if it needs one, then **List
179
+ models** and pick one. Changes save as you make them, and **Check it works** sends one short question to make sure.
180
+ Each provider keeps its own key and model, so you can switch freely.
181
+
182
+ - **Use your subscription**: Claude (Pro, Max) through [Claude Code](https://claude.com/claude-code), or
183
+ ChatGPT (Plus, Pro) through OpenAI's [Codex CLI](https://developers.openai.com/codex/cli/reference)
184
+ (`npm install -g @openai/codex`, then `codex login`). Both run on your computer with your own account,
185
+ for your own use: don't host the app for others on your subscription.
186
+ - **Pay per use with an API key**: Anthropic, OpenAI, Google Gemini (has a free tier), Mistral, Groq, or
187
+ OpenRouter (hundreds of models).
188
+ - **On this computer**: [Ollama](https://ollama.com) or [LM Studio](https://lmstudio.ai). Free, and nothing
189
+ leaves your machine.
190
+ - **Other**: any OpenAI-compatible server (vLLM, llama.cpp, a company gateway), by its address.
191
+
192
+ Small local models can't read a whole paper; *More options* can send just its beginning.
193
+ With a subscription the app runs the official CLI on your computer (`claude -p` or `codex exec`), which signs in
194
+ with your own account; usage counts toward your plan. The app never reads or stores those credentials.
195
+ `PAPERS_CLAUDE_BIN` and `PAPERS_CODEX_BIN` point at a specific binary if needed.
196
+
197
+ ## Asking the AI
198
+
199
+ Select text in a paper and press **Explain** (a short lesson: the problem, the idea, the formula read slowly, a worked
200
+ example, why it works, where it connects in the paper), **Simplify** (the same passage in plain English) or
201
+ **Translate**. Each starts a conversation you can keep going; **History** keeps them per paper, and **Add to chat**
202
+ attaches more passages. Answers can contain formulas, clickable citations ([§3.4], [Fig. 1]), charts, diagrams, the
203
+ paper's own figures with "look here" boxes, and interactive widgets.
204
+
205
+ The chat has two modes:
206
+
207
+ | | **Quick** | **Deep** |
208
+ | --- | --- | --- |
209
+ | How it answers | One step: the whole paper (and the conversation so far) goes to the model with your question | In steps: the AI searches the paper, reads sections, looks at figures, checks your notes and library, then answers. You see each step |
210
+ | Can it act | No | When you ask: saves notes, highlights passages, adds words or a paper from the references, each with Undo |
211
+ | Speed | Fast | Slower, more thorough |
212
+ | Needs | Any model | Claude (subscription or API key) or a model with tool calling. To let it see figures, turn on *Look at figures* in Settings |
213
+
214
+ The buttons on a selection (Explain, Simplify, Translate) answer Quick; **Deeper** under an answer goes Deep.
215
+ In Settings › *What the AI can do*, *Interactive pages* lets the AI write small demos that run in a sealed frame (no
216
+ access to the app, your files or the internet).
217
+
218
+ ## Settings from the environment
219
+
220
+ | Variable | What it does |
221
+ | --- | --- |
222
+ | `PAPERS_DATA` | The data folder (same as `--data`); it wins over the one chosen in the setup |
223
+ | `PAPERS_CONFIG` | Where `config.json` (which data folder to use) is kept |
224
+ | `ANTHROPIC_API_KEY`, `OPENAI_API_KEY` | API keys, if you'd rather not type them in Settings |
225
+ | `S2_API_KEY` | A Semantic Scholar key; without one, search often falls back to arXiv because of rate limits |
226
+ | `PAPERS_MODEL` | The Claude model used by default (`claude-opus-5-5`) |
227
+ | `PAPERS_INBOX_POLL` | Seconds between Inbox checks (`0` turns it off) |
228
+
229
+ ## Contributing
230
+
231
+ Contributions are welcome: bug reports, ideas and pull requests. [CONTRIBUTING.md](CONTRIBUTING.md) explains how the
232
+ code is laid out, how to run it and the tests (no keys needed: AI and network calls are faked), and where to start
233
+ for common changes. Please follow the [code of conduct](CODE_OF_CONDUCT.md). Changes are listed in
234
+ [CHANGELOG.md](CHANGELOG.md); the design is in [SPEC.md](SPEC.md) and [DESIGN.md](DESIGN.md).
235
+
236
+ Found a security problem? Please report it privately: see [SECURITY.md](SECURITY.md).
237
+
238
+ ## License
239
+
240
+ [MIT](LICENSE)
@@ -0,0 +1,209 @@
1
+ <h1 align="center">Papers</h1>
2
+
3
+ <p align="center"><strong>An AI reading companion for research papers.</strong><br>
4
+ Find the right papers for what you're working on, read them with an AI that knows the whole paper,
5
+ and remember what you read.</p>
6
+
7
+ <p align="center">
8
+ <a href="https://pypi.org/project/papers-app/"><img alt="PyPI" src="https://img.shields.io/pypi/v/papers-app?color=1d3fbb"></a>
9
+ <a href="https://pypi.org/project/papers-app/"><img alt="Python 3.11+" src="https://img.shields.io/pypi/pyversions/papers-app"></a>
10
+ <a href="https://github.com/hBouanane/papers/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/hBouanane/papers/actions/workflows/ci.yml/badge.svg"></a>
11
+ <a href="https://github.com/hBouanane/papers/pkgs/container/papers"><img alt="Docker image" src="https://img.shields.io/badge/docker-ghcr.io%2Fhbouanane%2Fpapers-1d3fbb?logo=docker&logoColor=white"></a>
12
+ <a href="LICENSE"><img alt="MIT license" src="https://img.shields.io/github/license/hBouanane/papers"></a>
13
+ </p>
14
+
15
+ <p align="center">
16
+ <code>uvx papers-app</code>
17
+ </p>
18
+
19
+ ![The welcome page: a paper being highlighted, asked about and scored](docs/screenshots/welcome.gif)
20
+
21
+ ![The Library: the paper you're reading, the others on your desk, what's due for review, and your goals](docs/screenshots/library.png)
22
+
23
+ ## About
24
+
25
+ Reading research papers is slow when you're new to a field: you don't know which papers matter, in what order to
26
+ read them, or what half the words mean. Papers is the companion for that.
27
+
28
+ - **Start from a goal.** Say what you're trying to understand. Papers searches Semantic Scholar and arXiv and the AI
29
+ suggests a **reading roadmap**: the basics first, then the core methods, then the newest work, with why each
30
+ paper and about how long it takes. Tick the ones you want (or keep them all) and they're added, PDFs included.
31
+ - **Read with an AI that has the whole paper.** Select a passage and press **Explain**, **Simplify** or
32
+ **Translate**, or just ask. Answers cite the paper's sections and figures, write formulas properly, and can
33
+ draw charts and small interactive widgets. Every question is a conversation you can come back to.
34
+ - **Remember it.** Key points for every paper, its hard words marked in the text, a quiz when you finish, spaced
35
+ review, and **Recall**: describe an idea in your own words and find where you read it.
36
+
37
+ It runs on your computer. Your library (papers, notes, highlights, conversations) is a folder on your disk, and you
38
+ choose the AI: your Claude or ChatGPT subscription, an API key, or a model running locally with Ollama or LM Studio.
39
+
40
+ ## A tour
41
+
42
+ <table>
43
+ <tr>
44
+ <td width="50%"><img src="docs/screenshots/chat-figure.png" alt="A Deep answer that points at the encoder, the decoder and where they connect in the paper's Figure 1"><br>
45
+ <b>Ask about a figure.</b> The AI looks at the figure and points at the parts it is talking about.</td>
46
+ <td width="50%"><img src="docs/screenshots/chat-widget.png" alt="An answer with a plot of the learning-rate schedule and sliders to change it"><br>
47
+ <b>Play with a formula.</b> Answers can draw plots and small widgets with sliders, for any field.</td>
48
+ </tr>
49
+ <tr>
50
+ <td width="50%"><img src="docs/screenshots/goal-papers.png" alt="A goal: its papers shown by their first pages, and one line from each"><br>
51
+ <b>Goals.</b> Each goal keeps its papers together, shown by their first pages, with one line on what each says.</td>
52
+ <td width="50%"><img src="docs/screenshots/recall.png" alt="Recall: search your papers by an idea in your own words"><br>
53
+ <b>Recall.</b> "Where did I read that?" Searches every paper, your notes and the explanations you asked for.</td>
54
+ </tr>
55
+ <tr>
56
+ <td width="50%"><img src="docs/screenshots/goal.png" alt="A goal's reading roadmap: stages of papers with why and how long each"><br>
57
+ <b>Reading roadmap.</b> For each goal, the best papers in reading order. Pick some or all; PDFs download for you,
58
+ and your progress shows as you read (<i>Start here</i>, <i>Next up</i>).</td>
59
+ <td width="50%"><img src="docs/screenshots/reader.png" alt="Reading a paper with an explanation of a formula beside it"><br>
60
+ <b>Reader.</b> Select a passage to have it explained, simplified or translated, beside the page.</td>
61
+ </tr>
62
+ <tr>
63
+ <td><img src="docs/screenshots/paper.png" alt="A paper's page: abstract, key points, figures, words, notes, references"><br>
64
+ <b>Each paper at a glance.</b> Key points, figures and tables, its vocabulary, your notes, and its references
65
+ (follow one to grow a chain on the Map).</td>
66
+ <td><img src="docs/screenshots/reader-dark.png" alt="The reader in the dark theme"><br>
67
+ <b>Light, dim or dark</b>, with the PDF pages dimmed to match.</td>
68
+ </tr>
69
+ <tr>
70
+ <td><img src="docs/screenshots/settings-features.png" alt="Settings: what the AI can do, Quick and Deep"><br>
71
+ <b>Quick or Deep.</b> Quick answers at once from the paper; Deep lets the AI search it, read sections, look at
72
+ figures and check your library first.</td>
73
+ </tr>
74
+ </table>
75
+
76
+ ## Install
77
+
78
+ With Python 3.11 or newer, one command (like `npx` for Node):
79
+
80
+ ```bash
81
+ uvx papers-app
82
+ ```
83
+
84
+ or install it to keep it around, then start it with `papers`:
85
+
86
+ ```bash
87
+ pipx install papers-app
88
+ ```
89
+
90
+ The first time, a short setup in the terminal asks three things, so it's clear from the start where everything goes:
91
+
92
+ ```
93
+ 1/3 Your library where the database, PDFs and figures are kept (one folder)
94
+ 2/3 A folder to browse optional: each paper's PDF and Markdown notes, for your file manager or Obsidian
95
+ 3/3 The AI model provider, key (kept in your system's keychain) and model, then a quick check
96
+ ```
97
+
98
+ Then `papers` opens http://localhost:8000 in your browser. Everything can be changed later in Settings, or with
99
+ `papers setup`. Options: `--port 9000`, `--data D:\Papers` (use this data folder), `--no-browser`, `--no-setup`,
100
+ `--host 0.0.0.0` (reach it from other devices on your network; there is no login, so only on networks you trust).
101
+
102
+ ### With Docker
103
+
104
+ The image is published on GitHub's registry, so one command pulls it and starts the app:
105
+
106
+ ```bash
107
+ docker run -d --name papers -p 8000:8000 -v papers-data:/data ghcr.io/hbouanane/papers:latest
108
+ ```
109
+
110
+ Then open http://localhost:8000 and choose the AI in Settings. What each part means:
111
+
112
+ | Part | Meaning |
113
+ | --- | --- |
114
+ | `-d --name papers` | run in the background, named `papers` (`docker stop papers` / `docker start papers`) |
115
+ | `-p 8000:8000` | the app inside listens on port 8000; this makes it http://localhost:8000 on your computer |
116
+ | `-v papers-data:/data` | your library (database, PDFs, figures) lives in `/data` inside the container; this keeps it in a Docker volume called `papers-data`, so it survives updates and restarts. Use a folder instead with `-v ~/Papers-data:/data` |
117
+ | `ghcr.io/hbouanane/papers:latest` | the image: on GitHub's registry (`ghcr.io`), from this repository, the newest release (or a version, e.g. `:0.3.0`) |
118
+
119
+ To update: `docker pull ghcr.io/hbouanane/papers:latest`, then `docker rm -f papers` and the same `docker run` again
120
+ (the volume keeps your library). From a clone you can also build it yourself with `docker compose up -d`; see
121
+ [docker-compose.yml](docker-compose.yml) to use a folder on your computer for the library folder, or a model running
122
+ on your computer (Ollama, LM Studio). Subscriptions (Claude, ChatGPT) need their app on the same computer, so in
123
+ Docker use an API key or a local model.
124
+
125
+ ### From the source
126
+
127
+ ```bash
128
+ git clone https://github.com/hBouanane/papers && cd papers
129
+ python -m venv .venv
130
+ .venv/Scripts/pip install -e ".[dev]" # macOS/Linux: .venv/bin/pip
131
+ .venv/Scripts/papers
132
+ ```
133
+
134
+ ## Where everything is kept
135
+
136
+ Settings › *Where everything is kept* shows all of it, with sizes:
137
+
138
+ | What | Where |
139
+ | --- | --- |
140
+ | Your library: the database (papers, notes, highlights, goals, conversations), PDFs, figure images | One **data folder**, chosen at the first start. Default: `%APPDATA%\Papers`, `~/Library/Application Support/Papers` or `~/.local/share/papers`. **Move…** in Settings copies it elsewhere and switches to it (the old folder is left for you to delete) |
141
+ | API keys | Your system's keychain (Windows Credential Manager, macOS Keychain, the Secret Service on Linux); in the database only where there's none (Docker, servers). Never sent back to the page |
142
+ | Which data folder to use | A small `config.json` beside the default data folder (`PAPERS_CONFIG` to put it elsewhere) |
143
+ | A browsable copy (optional) | The **library folder**: one folder per goal, each paper as `Author et al. Year - Title.pdf` with a `.md` notes file (key points, explanations, quiz, `[[links]]` to related papers, so Obsidian shows a graph). PDFs dropped into its `Inbox` are imported within about 10 seconds |
144
+
145
+ ## Choosing an AI model
146
+
147
+ Settings › AI model has one list of providers, each set up the same way: its key if it needs one, then **List
148
+ models** and pick one. Changes save as you make them, and **Check it works** sends one short question to make sure.
149
+ Each provider keeps its own key and model, so you can switch freely.
150
+
151
+ - **Use your subscription**: Claude (Pro, Max) through [Claude Code](https://claude.com/claude-code), or
152
+ ChatGPT (Plus, Pro) through OpenAI's [Codex CLI](https://developers.openai.com/codex/cli/reference)
153
+ (`npm install -g @openai/codex`, then `codex login`). Both run on your computer with your own account,
154
+ for your own use: don't host the app for others on your subscription.
155
+ - **Pay per use with an API key**: Anthropic, OpenAI, Google Gemini (has a free tier), Mistral, Groq, or
156
+ OpenRouter (hundreds of models).
157
+ - **On this computer**: [Ollama](https://ollama.com) or [LM Studio](https://lmstudio.ai). Free, and nothing
158
+ leaves your machine.
159
+ - **Other**: any OpenAI-compatible server (vLLM, llama.cpp, a company gateway), by its address.
160
+
161
+ Small local models can't read a whole paper; *More options* can send just its beginning.
162
+ With a subscription the app runs the official CLI on your computer (`claude -p` or `codex exec`), which signs in
163
+ with your own account; usage counts toward your plan. The app never reads or stores those credentials.
164
+ `PAPERS_CLAUDE_BIN` and `PAPERS_CODEX_BIN` point at a specific binary if needed.
165
+
166
+ ## Asking the AI
167
+
168
+ Select text in a paper and press **Explain** (a short lesson: the problem, the idea, the formula read slowly, a worked
169
+ example, why it works, where it connects in the paper), **Simplify** (the same passage in plain English) or
170
+ **Translate**. Each starts a conversation you can keep going; **History** keeps them per paper, and **Add to chat**
171
+ attaches more passages. Answers can contain formulas, clickable citations ([§3.4], [Fig. 1]), charts, diagrams, the
172
+ paper's own figures with "look here" boxes, and interactive widgets.
173
+
174
+ The chat has two modes:
175
+
176
+ | | **Quick** | **Deep** |
177
+ | --- | --- | --- |
178
+ | How it answers | One step: the whole paper (and the conversation so far) goes to the model with your question | In steps: the AI searches the paper, reads sections, looks at figures, checks your notes and library, then answers. You see each step |
179
+ | Can it act | No | When you ask: saves notes, highlights passages, adds words or a paper from the references, each with Undo |
180
+ | Speed | Fast | Slower, more thorough |
181
+ | Needs | Any model | Claude (subscription or API key) or a model with tool calling. To let it see figures, turn on *Look at figures* in Settings |
182
+
183
+ The buttons on a selection (Explain, Simplify, Translate) answer Quick; **Deeper** under an answer goes Deep.
184
+ In Settings › *What the AI can do*, *Interactive pages* lets the AI write small demos that run in a sealed frame (no
185
+ access to the app, your files or the internet).
186
+
187
+ ## Settings from the environment
188
+
189
+ | Variable | What it does |
190
+ | --- | --- |
191
+ | `PAPERS_DATA` | The data folder (same as `--data`); it wins over the one chosen in the setup |
192
+ | `PAPERS_CONFIG` | Where `config.json` (which data folder to use) is kept |
193
+ | `ANTHROPIC_API_KEY`, `OPENAI_API_KEY` | API keys, if you'd rather not type them in Settings |
194
+ | `S2_API_KEY` | A Semantic Scholar key; without one, search often falls back to arXiv because of rate limits |
195
+ | `PAPERS_MODEL` | The Claude model used by default (`claude-opus-5-5`) |
196
+ | `PAPERS_INBOX_POLL` | Seconds between Inbox checks (`0` turns it off) |
197
+
198
+ ## Contributing
199
+
200
+ Contributions are welcome: bug reports, ideas and pull requests. [CONTRIBUTING.md](CONTRIBUTING.md) explains how the
201
+ code is laid out, how to run it and the tests (no keys needed: AI and network calls are faked), and where to start
202
+ for common changes. Please follow the [code of conduct](CODE_OF_CONDUCT.md). Changes are listed in
203
+ [CHANGELOG.md](CHANGELOG.md); the design is in [SPEC.md](SPEC.md) and [DESIGN.md](DESIGN.md).
204
+
205
+ Found a security problem? Please report it privately: see [SECURITY.md](SECURITY.md).
206
+
207
+ ## License
208
+
209
+ [MIT](LICENSE)
@@ -1,2 +1,2 @@
1
1
  """Papers: an AI reading companion for research papers."""
2
- __version__ = "0.2.0"
2
+ __version__ = "0.3.0"
@@ -30,8 +30,9 @@ MAX_ACTIONS = 5 # notes, highlights, words and papers added per answer
30
30
 
31
31
  AGENT = """You can use tools to work precisely, like a careful researcher, before you answer:
32
32
  - search_paper and read_section: read the exact text instead of relying on memory of it;
33
- - look_at_figure: see a figure or table (with its caption) before you describe it; once you've seen it you can draw
34
- accurate "look here" boxes on it in a ```figure visual;
33
+ - look_at_figure: see a figure or table (with its caption) before you describe it. Once you have seen it, you can
34
+ point at its parts with numbered boxes in a ```figure visual, the way the tool's answer explains; boxes on a
35
+ figure you haven't looked at in this answer are removed;
35
36
  - search_library: connect this paper to the reader's other papers when that helps;
36
37
  - get_notes and get_vocabulary: what the reader noted and is learning, to fit the answer to them.
37
38
  - save_note, highlight, save_word, add_paper: these change the reader's library. Use them only when the reader asks
@@ -11,6 +11,7 @@ from dataclasses import dataclass, field
11
11
 
12
12
  from papers import db, figures, index
13
13
  from papers import notes as notes_db
14
+ from papers.ai import providers
14
15
  from papers.store import get_paper
15
16
 
16
17
 
@@ -143,12 +144,44 @@ def look_at_figure(paper: dict, number: int, kind: str = "figure") -> Result:
143
144
  if not f:
144
145
  have = ", ".join(f"{'Table' if x['kind'] == 'table' else 'Figure'} {x['number']}" for x in figures.for_paper(paper["id"]))
145
146
  return Result(f"{name} {number} wasn't found in the PDF. Found: {have or 'none'}.", f"Looked for {name} {number}")
146
- image = (figures.folder(paper["id"]) / figures.image_name(kind, f["number"])).read_bytes()
147
147
  text = paper.get("text") or ""
148
148
  mentions = [m.start() for m in re.finditer(rf"\b{name}\s+{number}\b", text)][:3]
149
149
  around = "\n…\n".join(text[max(0, i - 300):i + 400] for i in mentions)
150
- return Result(f"{f['caption']} (page {f['page']}).\nWhere the paper mentions it:\n{around or '(not mentioned in the text)'}",
151
- f"Looked at {name} {number}", image=image)
150
+ about = f"{f['caption']} (page {f['page']}).\nWhere the paper mentions it:\n{around or '(not mentioned in the text)'}"
151
+ if not can_see():
152
+ return Result(about + "\n\nYou were given the caption and the text only, not the image (this model isn't sent "
153
+ "images). Don't describe what the image looks like, and don't put boxes on it.",
154
+ f"Read about {name} {number} (the image isn't sent to this model)")
155
+ image = (figures.folder(paper["id"]) / figures.image_name(kind, f["number"])).read_bytes()
156
+ grid = figures.with_grid(image)
157
+ if not grid:
158
+ return Result(about + "\n\nShow it without boxes.", f"Looked at {name} {number}", image=image)
159
+ return Result(about + POINTING, f"Looked at {name} {number}", image=grid)
160
+
161
+
162
+ POINTING = """
163
+
164
+ The image has a grid drawn over it, for you only (the reader sees the figure without it): columns A to J from left to
165
+ right, rows 1 to 10 from top to bottom, each cell named in its corner. To point at a part of the figure, name the
166
+ cells it covers in a ```figure block: "from" is the cell at its top-left corner, "to" the cell at its bottom-right
167
+ corner, for example {"figure": 1, "boxes": [{"from": "B3", "to": "E5", "label": "the encoder stack"}]}. Read the cell
168
+ names off the image; cover the whole part and nothing else. If you can't tell exactly where a part is, leave the
169
+ box out."""
170
+
171
+
172
+ def can_see() -> bool:
173
+ """Whether the model gets the figure's image: always, except OpenAI-compatible models with images turned off."""
174
+ return providers.backend() != "openai" or setting_vision()
175
+
176
+
177
+ def seen(steps: list[dict]) -> set[tuple[str, int]]:
178
+ """The figures and tables the model really looked at in an answer, from its steps."""
179
+ found = set()
180
+ for s in steps:
181
+ m = re.match(r"Looked at (Figure|Table) (\d+)$", s.get("summary") or "")
182
+ if m and s.get("name") == "look_at_figure":
183
+ found.add((m.group(1).lower(), int(m.group(2))))
184
+ return found
152
185
 
153
186
 
154
187
  def search_library(paper: dict, idea: str) -> Result: