papers-app 0.3.2__tar.gz → 0.5.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 (282) hide show
  1. {papers_app-0.3.2 → papers_app-0.5.0}/PKG-INFO +12 -7
  2. {papers_app-0.3.2 → papers_app-0.5.0}/README.md +11 -6
  3. {papers_app-0.3.2 → papers_app-0.5.0}/papers/__init__.py +1 -1
  4. {papers_app-0.3.2 → papers_app-0.5.0}/papers/agent/loop.py +9 -1
  5. {papers_app-0.3.2 → papers_app-0.5.0}/papers/agent/tools.py +129 -7
  6. {papers_app-0.3.2 → papers_app-0.5.0}/papers/ai/capabilities.py +73 -3
  7. papers_app-0.5.0/papers/ai/errors.py +54 -0
  8. {papers_app-0.3.2 → papers_app-0.5.0}/papers/ai/providers.py +2 -1
  9. papers_app-0.5.0/papers/chat/answer.py +262 -0
  10. {papers_app-0.3.2 → papers_app-0.5.0}/papers/chat/store.py +21 -1
  11. {papers_app-0.3.2 → papers_app-0.5.0}/papers/cli.py +186 -151
  12. {papers_app-0.3.2 → papers_app-0.5.0}/papers/config.py +0 -3
  13. papers_app-0.5.0/papers/desktop.py +118 -0
  14. papers_app-0.5.0/papers/figure_parts.py +98 -0
  15. {papers_app-0.3.2 → papers_app-0.5.0}/papers/figures.py +37 -25
  16. {papers_app-0.3.2 → papers_app-0.5.0}/papers/library.py +6 -0
  17. {papers_app-0.3.2 → papers_app-0.5.0}/papers/llm.py +144 -33
  18. papers_app-0.5.0/papers/main.py +123 -0
  19. papers_app-0.5.0/papers/presence.py +46 -0
  20. {papers_app-0.3.2 → papers_app-0.5.0}/papers/roadmap.py +20 -9
  21. {papers_app-0.3.2 → papers_app-0.5.0}/papers/routes/__init__.py +3 -2
  22. {papers_app-0.3.2 → papers_app-0.5.0}/papers/routes/chat.py +17 -1
  23. papers_app-0.5.0/papers/routes/figure_play.py +37 -0
  24. {papers_app-0.3.2 → papers_app-0.5.0}/papers/routes/goals.py +2 -2
  25. {papers_app-0.3.2 → papers_app-0.5.0}/papers/routes/learning.py +2 -1
  26. {papers_app-0.3.2 → papers_app-0.5.0}/papers/routes/settings.py +17 -4
  27. papers_app-0.5.0/papers/scholar.py +389 -0
  28. {papers_app-0.3.2 → papers_app-0.5.0}/papers/setup.py +35 -9
  29. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/css/chat.css +30 -0
  30. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/css/goals.css +8 -2
  31. papers_app-0.5.0/papers/static/css/guide.css +244 -0
  32. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/css/map.css +13 -11
  33. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/css/recall.css +14 -0
  34. papers_app-0.5.0/papers/static/icons/apple-touch-icon.png +0 -0
  35. papers_app-0.5.0/papers/static/icons/icon-192.png +0 -0
  36. papers_app-0.5.0/papers/static/icons/icon-512.png +0 -0
  37. papers_app-0.5.0/papers/static/icons/icon-64.png +0 -0
  38. papers_app-0.5.0/papers/static/icons/icon-maskable-512.png +0 -0
  39. papers_app-0.5.0/papers/static/icons/papers.ico +0 -0
  40. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/index.html +50 -45
  41. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/chat/conversation.js +71 -11
  42. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/chat/render.js +153 -32
  43. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/chat/stream.js +11 -4
  44. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/chat/widgets.js +3 -1
  45. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/core.js +26 -9
  46. papers_app-0.5.0/papers/static/js/figureplay.js +82 -0
  47. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/main.js +25 -8
  48. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/pages/goals.js +76 -32
  49. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/pages/library.js +18 -19
  50. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/pages/map.js +5 -5
  51. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/pages/recall.js +6 -2
  52. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/pages/settings.js +51 -9
  53. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/pages/shared.js +4 -4
  54. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/pages/welcome.js +5 -5
  55. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/figures.js +5 -4
  56. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/overview.js +122 -27
  57. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader/finish.js +1 -1
  58. papers_app-0.5.0/papers/static/js/paper/reader/guide.js +169 -0
  59. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader/keys.js +4 -2
  60. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader/layout.js +10 -3
  61. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader/panel.js +114 -110
  62. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader/route.js +2 -2
  63. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader/selection.js +12 -5
  64. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader/state.js +1 -0
  65. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader/terms.js +1 -1
  66. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader/views.js +157 -126
  67. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader/vocab.js +2 -0
  68. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader.js +125 -96
  69. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/review.js +3 -3
  70. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/pdfview.js +1 -1
  71. papers_app-0.5.0/papers/static/js/rail.js +160 -0
  72. papers_app-0.5.0/papers/static/js/vendor.js +17 -0
  73. papers_app-0.5.0/papers/static/manifest.webmanifest +28 -0
  74. papers_app-0.5.0/papers/static/vendor/README.md +31 -0
  75. papers_app-0.5.0/papers/static/vendor/dompurify/purify.es.mjs +1554 -0
  76. papers_app-0.5.0/papers/static/vendor/fonts/atkinson-hyperlegible-next-latin-400-normal.woff2 +0 -0
  77. papers_app-0.5.0/papers/static/vendor/fonts/atkinson-hyperlegible-next-latin-700-normal.woff2 +0 -0
  78. papers_app-0.5.0/papers/static/vendor/fonts/atkinson-hyperlegible-next-latin-800-normal.woff2 +0 -0
  79. papers_app-0.5.0/papers/static/vendor/fonts/atkinson-hyperlegible-next-latin-ext-400-normal.woff2 +0 -0
  80. papers_app-0.5.0/papers/static/vendor/fonts/atkinson-hyperlegible-next-latin-ext-700-normal.woff2 +0 -0
  81. papers_app-0.5.0/papers/static/vendor/fonts/atkinson-hyperlegible-next-latin-ext-800-normal.woff2 +0 -0
  82. papers_app-0.5.0/papers/static/vendor/fonts/fonts.css +333 -0
  83. papers_app-0.5.0/papers/static/vendor/fonts/noto-sans-arabic-arabic-400-normal.woff2 +0 -0
  84. papers_app-0.5.0/papers/static/vendor/fonts/noto-sans-arabic-arabic-700-normal.woff2 +0 -0
  85. papers_app-0.5.0/papers/static/vendor/fonts/noto-sans-arabic-latin-400-normal.woff2 +0 -0
  86. papers_app-0.5.0/papers/static/vendor/fonts/noto-sans-arabic-latin-700-normal.woff2 +0 -0
  87. papers_app-0.5.0/papers/static/vendor/fonts/noto-sans-arabic-latin-ext-400-normal.woff2 +0 -0
  88. papers_app-0.5.0/papers/static/vendor/fonts/noto-sans-arabic-latin-ext-700-normal.woff2 +0 -0
  89. papers_app-0.5.0/papers/static/vendor/fonts/noto-sans-arabic-math-400-normal.woff2 +0 -0
  90. papers_app-0.5.0/papers/static/vendor/fonts/noto-sans-arabic-math-700-normal.woff2 +0 -0
  91. papers_app-0.5.0/papers/static/vendor/fonts/noto-sans-arabic-symbols-400-normal.woff2 +0 -0
  92. papers_app-0.5.0/papers/static/vendor/fonts/noto-sans-arabic-symbols-700-normal.woff2 +0 -0
  93. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-cyrillic-400-italic.woff2 +0 -0
  94. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-cyrillic-400-normal.woff2 +0 -0
  95. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-cyrillic-600-normal.woff2 +0 -0
  96. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-cyrillic-ext-400-italic.woff2 +0 -0
  97. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-cyrillic-ext-400-normal.woff2 +0 -0
  98. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-cyrillic-ext-600-normal.woff2 +0 -0
  99. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-greek-400-italic.woff2 +0 -0
  100. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-greek-400-normal.woff2 +0 -0
  101. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-greek-600-normal.woff2 +0 -0
  102. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-latin-400-italic.woff2 +0 -0
  103. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-latin-400-normal.woff2 +0 -0
  104. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-latin-600-normal.woff2 +0 -0
  105. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-latin-ext-400-italic.woff2 +0 -0
  106. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-latin-ext-400-normal.woff2 +0 -0
  107. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-latin-ext-600-normal.woff2 +0 -0
  108. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-vietnamese-400-italic.woff2 +0 -0
  109. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-vietnamese-400-normal.woff2 +0 -0
  110. papers_app-0.5.0/papers/static/vendor/fonts/stix-two-text-vietnamese-600-normal.woff2 +0 -0
  111. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  112. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  113. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  114. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  115. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  116. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
  117. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  118. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
  119. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
  120. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  121. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
  122. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  123. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  124. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  125. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
  126. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  127. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  128. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  129. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  130. papers_app-0.5.0/papers/static/vendor/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  131. papers_app-0.5.0/papers/static/vendor/katex/katex.min.css +1 -0
  132. papers_app-0.5.0/papers/static/vendor/katex/katex.mjs +18458 -0
  133. papers_app-0.5.0/papers/static/vendor/licenses/dompurify.txt +568 -0
  134. papers_app-0.5.0/papers/static/vendor/licenses/font-atkinson-hyperlegible-next.txt +93 -0
  135. papers_app-0.5.0/papers/static/vendor/licenses/font-noto-sans-arabic.txt +93 -0
  136. papers_app-0.5.0/papers/static/vendor/licenses/font-stix-two-text.txt +93 -0
  137. papers_app-0.5.0/papers/static/vendor/licenses/katex.txt +21 -0
  138. papers_app-0.5.0/papers/static/vendor/licenses/marked.txt +44 -0
  139. papers_app-0.5.0/papers/static/vendor/licenses/mathjs.txt +176 -0
  140. papers_app-0.5.0/papers/static/vendor/licenses/mermaid.txt +21 -0
  141. papers_app-0.5.0/papers/static/vendor/licenses/pdfjs-dist.txt +177 -0
  142. papers_app-0.5.0/papers/static/vendor/licenses/vega-embed.txt +27 -0
  143. papers_app-0.5.0/papers/static/vendor/licenses/vega-lite.txt +27 -0
  144. papers_app-0.5.0/papers/static/vendor/marked/marked.esm.js +2432 -0
  145. papers_app-0.5.0/papers/static/vendor/mathjs/math.js +3 -0
  146. papers_app-0.5.0/papers/static/vendor/mermaid/mermaid.min.js +2811 -0
  147. papers_app-0.5.0/papers/static/vendor/pdfjs/images/altText_add.svg +3 -0
  148. papers_app-0.5.0/papers/static/vendor/pdfjs/images/altText_done.svg +3 -0
  149. papers_app-0.5.0/papers/static/vendor/pdfjs/images/annotation-check.svg +11 -0
  150. papers_app-0.5.0/papers/static/vendor/pdfjs/images/annotation-comment.svg +16 -0
  151. papers_app-0.5.0/papers/static/vendor/pdfjs/images/annotation-help.svg +26 -0
  152. papers_app-0.5.0/papers/static/vendor/pdfjs/images/annotation-insert.svg +10 -0
  153. papers_app-0.5.0/papers/static/vendor/pdfjs/images/annotation-key.svg +11 -0
  154. papers_app-0.5.0/papers/static/vendor/pdfjs/images/annotation-newparagraph.svg +11 -0
  155. papers_app-0.5.0/papers/static/vendor/pdfjs/images/annotation-noicon.svg +7 -0
  156. papers_app-0.5.0/papers/static/vendor/pdfjs/images/annotation-note.svg +42 -0
  157. papers_app-0.5.0/papers/static/vendor/pdfjs/images/annotation-paperclip.svg +6 -0
  158. papers_app-0.5.0/papers/static/vendor/pdfjs/images/annotation-paragraph.svg +16 -0
  159. papers_app-0.5.0/papers/static/vendor/pdfjs/images/annotation-pushpin.svg +7 -0
  160. papers_app-0.5.0/papers/static/vendor/pdfjs/images/cursor-editorFreeHighlight.svg +6 -0
  161. papers_app-0.5.0/papers/static/vendor/pdfjs/images/cursor-editorFreeText.svg +3 -0
  162. papers_app-0.5.0/papers/static/vendor/pdfjs/images/cursor-editorInk.svg +4 -0
  163. papers_app-0.5.0/papers/static/vendor/pdfjs/images/cursor-editorTextHighlight.svg +8 -0
  164. papers_app-0.5.0/papers/static/vendor/pdfjs/images/editor-toolbar-delete.svg +5 -0
  165. papers_app-0.5.0/papers/static/vendor/pdfjs/images/loading-icon.gif +0 -0
  166. papers_app-0.5.0/papers/static/vendor/pdfjs/images/toolbarButton-editorHighlight.svg +6 -0
  167. papers_app-0.5.0/papers/static/vendor/pdfjs/images/toolbarButton-menuArrow.svg +3 -0
  168. papers_app-0.5.0/papers/static/vendor/pdfjs/pdf.min.mjs +21 -0
  169. papers_app-0.5.0/papers/static/vendor/pdfjs/pdf.worker.min.mjs +21 -0
  170. papers_app-0.5.0/papers/static/vendor/pdfjs/pdf_viewer.css +2716 -0
  171. papers_app-0.5.0/papers/static/vendor/pdfjs/pdf_viewer.mjs +8110 -0
  172. papers_app-0.5.0/papers/static/vendor/vega/vega-embed.min.js +7 -0
  173. papers_app-0.5.0/papers/static/vendor/vega/vega-lite.min.js +2 -0
  174. papers_app-0.5.0/papers/static/vendor/vega/vega.min.js +2 -0
  175. {papers_app-0.3.2 → papers_app-0.5.0}/papers/store.py +4 -0
  176. {papers_app-0.3.2 → papers_app-0.5.0}/tests/conftest.py +4 -0
  177. papers_app-0.5.0/tests/test_agent_guards.py +116 -0
  178. papers_app-0.5.0/tests/test_app_window.py +75 -0
  179. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_capabilities.py +4 -1
  180. papers_app-0.5.0/tests/test_chat.py +15 -0
  181. papers_app-0.5.0/tests/test_compare_figures.py +76 -0
  182. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_conversations.py +1 -1
  183. papers_app-0.5.0/tests/test_figure_play.py +52 -0
  184. papers_app-0.5.0/tests/test_finding_papers.py +81 -0
  185. papers_app-0.5.0/tests/test_offline.py +34 -0
  186. papers_app-0.5.0/tests/test_overview_and_guide.py +74 -0
  187. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_papers.py +3 -2
  188. papers_app-0.5.0/tests/test_plain_errors.py +47 -0
  189. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_setup.py +97 -80
  190. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_streaming.py +2 -1
  191. papers_app-0.3.2/papers/ai/errors.py +0 -13
  192. papers_app-0.3.2/papers/chat/answer.py +0 -119
  193. papers_app-0.3.2/papers/main.py +0 -73
  194. papers_app-0.3.2/papers/scholar.py +0 -173
  195. {papers_app-0.3.2 → papers_app-0.5.0}/.gitignore +0 -0
  196. {papers_app-0.3.2 → papers_app-0.5.0}/CONTRIBUTING.md +0 -0
  197. {papers_app-0.3.2 → papers_app-0.5.0}/LICENSE +0 -0
  198. {papers_app-0.3.2 → papers_app-0.5.0}/papers/__main__.py +0 -0
  199. {papers_app-0.3.2 → papers_app-0.5.0}/papers/agent/__init__.py +0 -0
  200. {papers_app-0.3.2 → papers_app-0.5.0}/papers/agent/mcp_server.py +0 -0
  201. {papers_app-0.3.2 → papers_app-0.5.0}/papers/ai/__init__.py +0 -0
  202. {papers_app-0.3.2 → papers_app-0.5.0}/papers/ai/anthropic_api.py +0 -0
  203. {papers_app-0.3.2 → papers_app-0.5.0}/papers/ai/claude_code.py +0 -0
  204. {papers_app-0.3.2 → papers_app-0.5.0}/papers/ai/codex.py +0 -0
  205. {papers_app-0.3.2 → papers_app-0.5.0}/papers/ai/openai_compat.py +0 -0
  206. {papers_app-0.3.2 → papers_app-0.5.0}/papers/ai/streaming.py +0 -0
  207. {papers_app-0.3.2 → papers_app-0.5.0}/papers/bibtex.py +0 -0
  208. {papers_app-0.3.2 → papers_app-0.5.0}/papers/chat/__init__.py +0 -0
  209. {papers_app-0.3.2 → papers_app-0.5.0}/papers/db.py +0 -0
  210. {papers_app-0.3.2 → papers_app-0.5.0}/papers/folders.py +0 -0
  211. {papers_app-0.3.2 → papers_app-0.5.0}/papers/index.py +0 -0
  212. {papers_app-0.3.2 → papers_app-0.5.0}/papers/ingest.py +0 -0
  213. {papers_app-0.3.2 → papers_app-0.5.0}/papers/keys.py +0 -0
  214. {papers_app-0.3.2 → papers_app-0.5.0}/papers/notes.py +0 -0
  215. {papers_app-0.3.2 → papers_app-0.5.0}/papers/pdf.py +0 -0
  216. {papers_app-0.3.2 → papers_app-0.5.0}/papers/routes/notes.py +0 -0
  217. {papers_app-0.3.2 → papers_app-0.5.0}/papers/routes/papers.py +0 -0
  218. {papers_app-0.3.2 → papers_app-0.5.0}/papers/routes/reading.py +0 -0
  219. {papers_app-0.3.2 → papers_app-0.5.0}/papers/routes/recall.py +0 -0
  220. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/css/base.css +0 -0
  221. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/css/components.css +0 -0
  222. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/css/library.css +0 -0
  223. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/css/paper.css +0 -0
  224. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/css/reader.css +0 -0
  225. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/css/settings.css +0 -0
  226. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/css/tokens.css +0 -0
  227. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/css/welcome.css +0 -0
  228. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/chat/answer.js +0 -0
  229. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/chat/canvas.js +0 -0
  230. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/components/combobox.js +0 -0
  231. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/components/folderpicker.js +0 -0
  232. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/covers.js +0 -0
  233. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/highlights.js +0 -0
  234. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/icons.js +0 -0
  235. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/notes.js +0 -0
  236. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader/bar.js +0 -0
  237. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader/cite.js +0 -0
  238. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader/highlighter.js +0 -0
  239. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader/progress.js +0 -0
  240. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/reader/zoom.js +0 -0
  241. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/paper/shared.js +0 -0
  242. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/readprefs.js +0 -0
  243. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/speech.js +0 -0
  244. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/textview.js +0 -0
  245. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/theme.js +0 -0
  246. {papers_app-0.3.2 → papers_app-0.5.0}/papers/static/js/tracker.js +0 -0
  247. {papers_app-0.3.2 → papers_app-0.5.0}/papers/storage.py +0 -0
  248. {papers_app-0.3.2 → papers_app-0.5.0}/pyproject.toml +0 -0
  249. {papers_app-0.3.2 → papers_app-0.5.0}/tests/__init__.py +0 -0
  250. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_abstract_figures.py +0 -0
  251. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_add_link.py +0 -0
  252. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_agent.py +0 -0
  253. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_agent_actions.py +0 -0
  254. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_ai.py +0 -0
  255. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_capture.py +0 -0
  256. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_claude_code.py +0 -0
  257. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_cli.py +0 -0
  258. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_folders.py +0 -0
  259. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_frontend.py +0 -0
  260. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_highlights_notes.py +0 -0
  261. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_keys.py +0 -0
  262. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_learning.py +0 -0
  263. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_library_covers.py +0 -0
  264. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_library_folder.py +0 -0
  265. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_metadata.py +0 -0
  266. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_never_stuck.py +0 -0
  267. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_notes_ask.py +0 -0
  268. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_prepare.py +0 -0
  269. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_progress.py +0 -0
  270. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_prompts.py +0 -0
  271. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_provider_list.py +0 -0
  272. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_providers.py +0 -0
  273. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_recall_refs.py +0 -0
  274. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_review.py +0 -0
  275. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_roadmap.py +0 -0
  276. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_scaffold.py +0 -0
  277. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_search.py +0 -0
  278. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_storage.py +0 -0
  279. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_tracker.py +0 -0
  280. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_triage.py +0 -0
  281. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_upload.py +0 -0
  282. {papers_app-0.3.2 → papers_app-0.5.0}/tests/test_vocabulary.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: papers-app
3
- Version: 0.3.2
3
+ Version: 0.5.0
4
4
  Summary: An AI reading companion for research papers: skim, read, ask, recall. Runs on your computer.
5
5
  Project-URL: Homepage, https://github.com/hBouanane/papers
6
6
  Project-URL: Issues, https://github.com/hBouanane/papers/issues
@@ -134,18 +134,23 @@ pipx install papers-app
134
134
  If the Python it lands on is one the libraries don't support yet (a pre-release, for example), Papers starts
135
135
  itself again on Python 3.13 through uv. Without uv it tells you so; pick a released Python and try again.
136
136
 
137
- The first time, a short setup in the terminal asks two things:
137
+ The first time, a short setup in the terminal asks three things:
138
138
 
139
139
  ```
140
- 1/2 Your papers as normal files a folder with each paper's PDF and Markdown notes, for your file manager or Obsidian
141
- 2/2 The AI model provider, key (kept in your system's keychain) and model, then a quick check
140
+ 1/3 Your papers as normal files a folder with each paper's PDF and Markdown notes, for your file manager or Obsidian
141
+ 2/3 The AI model provider, key (kept in your system's keychain) and model, then a quick check
142
+ 3/3 A Papers icon on your desktop double-click it to open Papers in a window of its own
142
143
  ```
143
144
 
144
145
  The app's own data (database, PDFs, figures) goes to the usual place for app data; setup shows where, and Settings
145
146
  can move it.
146
147
 
147
- Then `papers` opens http://localhost:8000 in your browser. Everything can be changed later in Settings, or with
148
- `papers setup`. Options: `--port 9000`, `--data D:\Papers` (use this data folder), `--no-browser`, `--no-setup`,
148
+ Then `papers` opens Papers in a window of its own (Edge, Chrome, Chromium, Brave or Vivaldi's app window; with only
149
+ Firefox or Safari, a tab), at http://papers.localhost:8000. Closing that window stops Papers: everything is saved as
150
+ you go. `papers shortcut` puts an icon on your desktop that does the same (on Linux, in your apps menu too), and
151
+ `papers --browser` opens it in a tab of your usual browser instead, running until Ctrl+C. Everything can be changed
152
+ later in Settings, or with `papers setup`. Options: `--port 9000`, `--data D:\Papers` (use this data folder),
153
+ `--browser`, `--no-browser`, `--no-setup`,
149
154
  `--host 0.0.0.0` (reach it from other devices on your network; there is no login, so only on networks you trust).
150
155
 
151
156
  ### With Docker
@@ -163,7 +168,7 @@ Then open http://localhost:8000 and choose the AI in Settings. What each part me
163
168
  | `-d --name papers` | run in the background, named `papers` (`docker stop papers` / `docker start papers`) |
164
169
  | `-p 8000:8000` | the app inside listens on port 8000; this makes it http://localhost:8000 on your computer |
165
170
  | `-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` |
166
- | `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.2`) |
171
+ | `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.5.0`) |
167
172
 
168
173
  To update: `docker pull ghcr.io/hbouanane/papers:latest`, then `docker rm -f papers` and the same `docker run` again
169
174
  (the volume keeps your library). From a clone you can also build it yourself with `docker compose up -d`; see
@@ -102,18 +102,23 @@ pipx install papers-app
102
102
  If the Python it lands on is one the libraries don't support yet (a pre-release, for example), Papers starts
103
103
  itself again on Python 3.13 through uv. Without uv it tells you so; pick a released Python and try again.
104
104
 
105
- The first time, a short setup in the terminal asks two things:
105
+ The first time, a short setup in the terminal asks three things:
106
106
 
107
107
  ```
108
- 1/2 Your papers as normal files a folder with each paper's PDF and Markdown notes, for your file manager or Obsidian
109
- 2/2 The AI model provider, key (kept in your system's keychain) and model, then a quick check
108
+ 1/3 Your papers as normal files a folder with each paper's PDF and Markdown notes, for your file manager or Obsidian
109
+ 2/3 The AI model provider, key (kept in your system's keychain) and model, then a quick check
110
+ 3/3 A Papers icon on your desktop double-click it to open Papers in a window of its own
110
111
  ```
111
112
 
112
113
  The app's own data (database, PDFs, figures) goes to the usual place for app data; setup shows where, and Settings
113
114
  can move it.
114
115
 
115
- Then `papers` opens http://localhost:8000 in your browser. Everything can be changed later in Settings, or with
116
- `papers setup`. Options: `--port 9000`, `--data D:\Papers` (use this data folder), `--no-browser`, `--no-setup`,
116
+ Then `papers` opens Papers in a window of its own (Edge, Chrome, Chromium, Brave or Vivaldi's app window; with only
117
+ Firefox or Safari, a tab), at http://papers.localhost:8000. Closing that window stops Papers: everything is saved as
118
+ you go. `papers shortcut` puts an icon on your desktop that does the same (on Linux, in your apps menu too), and
119
+ `papers --browser` opens it in a tab of your usual browser instead, running until Ctrl+C. Everything can be changed
120
+ later in Settings, or with `papers setup`. Options: `--port 9000`, `--data D:\Papers` (use this data folder),
121
+ `--browser`, `--no-browser`, `--no-setup`,
117
122
  `--host 0.0.0.0` (reach it from other devices on your network; there is no login, so only on networks you trust).
118
123
 
119
124
  ### With Docker
@@ -131,7 +136,7 @@ Then open http://localhost:8000 and choose the AI in Settings. What each part me
131
136
  | `-d --name papers` | run in the background, named `papers` (`docker stop papers` / `docker start papers`) |
132
137
  | `-p 8000:8000` | the app inside listens on port 8000; this makes it http://localhost:8000 on your computer |
133
138
  | `-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` |
134
- | `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.2`) |
139
+ | `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.5.0`) |
135
140
 
136
141
  To update: `docker pull ghcr.io/hbouanane/papers:latest`, then `docker rm -f papers` and the same `docker run` again
137
142
  (the volume keeps your library). From a clone you can also build it yourself with `docker compose up -d`; see
@@ -1,2 +1,2 @@
1
1
  """Papers: an AI reading companion for research papers."""
2
- __version__ = "0.3.2"
2
+ __version__ = "0.5.0"
@@ -31,7 +31,15 @@ AGENT = """You can use tools to work precisely, like a careful researcher, befor
31
31
  - search_paper and read_section: read the exact text instead of relying on memory of it;
32
32
  - look_at_figure: see a figure or table (with its caption) before you describe it. Once you have seen it, you can
33
33
  point at its parts with numbered boxes in a ```figure visual, the way the tool's answer explains; boxes on a
34
- figure you haven't looked at in this answer are removed;
34
+ figure you haven't looked at in this answer are removed. Use this while you explain: when the passage you are
35
+ explaining describes something a figure shows ("as shown in Figure 2", a step, a component, a curve), look at that
36
+ figure and show it with one or two boxes on exactly that part, and say in a sentence "this is the part the passage
37
+ is about". Don't box a figure the explanation doesn't need;
38
+ - compare_with_figure: put one of this paper's figures next to one from another paper in the reader's library
39
+ (figures, not tables), then show what they share in a ```compare visual, the way the tool's answer explains. Use it
40
+ when the reader asks to compare, or when your explanation is clearer by showing the same thing in two figures
41
+ (the idea you're explaining here, drawn in a paper they've read; the same component in two architectures). Not as
42
+ decoration: only when seeing both helps. A comparison you didn't make with the tool in this answer is removed;
35
43
  - search_library: connect this paper to the reader's other papers when that helps;
36
44
  - get_notes and get_vocabulary: what the reader noted and is learning, to fit the answer to them.
37
45
  - save_note, highlight, save_word, add_paper: these change the reader's library. Use them only when the reader asks
@@ -153,7 +153,8 @@ def look_at_figure(paper: dict, number: int, kind: str = "figure") -> Result:
153
153
  "images). Don't describe what the image looks like, and don't put boxes on it.",
154
154
  f"Read about {name} {number} (the image isn't sent to this model)")
155
155
  image = (figures.folder(paper["id"]) / figures.image_name(kind, f["number"])).read_bytes()
156
- grid = figures.with_grid(image)
156
+ from papers.ai import capabilities
157
+ grid = figures.with_grid(image) if capabilities.allows("pointing") else None # boxes in the wrong place are worse than none
157
158
  if not grid:
158
159
  return Result(about + "\n\nShow it without boxes.", f"Looked at {name} {number}", image=image)
159
160
  return Result(about + POINTING, f"Looked at {name} {number}", image=grid)
@@ -161,12 +162,13 @@ def look_at_figure(paper: dict, number: int, kind: str = "figure") -> Result:
161
162
 
162
163
  POINTING = """
163
164
 
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."""
165
+ The image has a grid drawn over it like a chessboard, for you only (the reader sees the figure without it): columns
166
+ A to T, lettered along the top and bottom edges; rows 1 to 20, numbered down the left and right edges; every fifth
167
+ line is darker. A cell is its column and row, like C7. To point at a part of the figure, name the cells it covers in a
168
+ ```figure block: "from" is the cell at its top-left corner, "to" the cell at its bottom-right corner, for example
169
+ {"figure": 1, "boxes": [{"from": "C5", "to": "H11", "label": "the encoder stack"}]}. Read the letter above or below
170
+ the part and the number beside it from the edges; cover the whole part and nothing else. If you can't tell exactly
171
+ where a part is, leave the box out."""
170
172
 
171
173
 
172
174
  def can_see() -> bool:
@@ -184,6 +186,117 @@ def seen(steps: list[dict]) -> set[tuple[str, int]]:
184
186
  return found
185
187
 
186
188
 
189
+ # ---------- Comparing a figure with one from another paper ----------
190
+ COMPARING = """
191
+
192
+ The image shows both figures side by side: LEFT is Figure {left} of this paper, RIGHT is Figure {right} of "{title}".
193
+ Each has its own chessboard grid: columns A to T lettered along its top and bottom edges, rows 1 to 20 numbered down
194
+ its sides, every fifth line darker; a cell is its column and row, like C7. To show what they share, write:
195
+ ```compare
196
+ {{"left": {{"figure": {left}, "boxes": [{{"from": "C5", "to": "H11", "label": "the encoder"}}]}},
197
+ "right": {{"paper": {paper}, "figure": {right}, "boxes": [{{"from": "B3", "to": "K9", "label": "the RNN encoder"}}]}},
198
+ "pairs": [{{"left": 1, "right": 1, "same": "turns the input into vectors"}}]}}
199
+ ```
200
+ Boxes are numbered from 1 on each side; a pair joins a left box and a right box that do the same job. Rules: box
201
+ only parts you can clearly see; pair only parts that truly play the same role (the same component, step or
202
+ quantity), each box at most once; leave out anything you're unsure of; at most 6 pairs. If the two figures show
203
+ different kinds of things, say so in words and write no pairs: a wrong match is worse than none."""
204
+
205
+
206
+ def _library_paper(paper: dict, wanted: str) -> tuple[dict | None, list[str]]:
207
+ """The reader's paper whose title best matches `wanted` (not this one), or None and some titles to choose from."""
208
+ with db.connect() as conn:
209
+ rows = [dict(r) for r in conn.execute("select id, title from papers where id != ? and coalesce(archived, 0) = 0",
210
+ (paper["id"],))]
211
+ norm = lambda s: re.sub(r"[^a-z0-9 ]", "", (s or "").lower())
212
+ want = norm(wanted)
213
+ words = {w for w in want.split() if len(w) > 2}
214
+ scored = []
215
+ for r in rows:
216
+ title = norm(r["title"])
217
+ if title == want:
218
+ return r, []
219
+ if words:
220
+ share = len(words & set(title.split())) / len(words)
221
+ if share >= 0.6:
222
+ scored.append((share, r))
223
+ scored.sort(key=lambda x: -x[0])
224
+ if scored and (len(scored) == 1 or scored[0][0] > scored[1][0]):
225
+ return scored[0][1], []
226
+ return None, [r["title"] for _, r in scored[:6]] or [r["title"] for r in rows[:8]]
227
+
228
+
229
+ def _side_by_side(left: bytes, right: bytes) -> bytes | None:
230
+ """Two figures next to each other under LEFT / RIGHT labels, the same height, for one look."""
231
+ try:
232
+ import io
233
+
234
+ from PIL import Image, ImageDraw
235
+ a, b = (Image.open(io.BytesIO(x)).convert("RGB") for x in (left, right))
236
+ h = max(a.height, b.height)
237
+ a, b = (im.resize((max(1, round(im.width * h / im.height)), h)) for im in (a, b))
238
+ sheet = Image.new("RGB", (a.width + b.width + 30, h + 36), "white")
239
+ sheet.paste(a, (0, 36))
240
+ sheet.paste(b, (a.width + 30, 36))
241
+ ink = ImageDraw.Draw(sheet)
242
+ ink.line([(a.width + 15, 0), (a.width + 15, h + 36)], fill=(120, 120, 120), width=3)
243
+ for x, word in ((6, "LEFT"), (a.width + 36, "RIGHT")):
244
+ ink.text((x, 8), word, fill=(0, 0, 0))
245
+ out = io.BytesIO()
246
+ sheet.save(out, "PNG")
247
+ return out.getvalue()
248
+ except Exception:
249
+ return None
250
+
251
+
252
+ def compare_with_figure(paper: dict, own_figure: int, other_paper: str, other_figure: int) -> Result:
253
+ """This paper's figure next to a figure of another paper in the reader's library, to say what they share."""
254
+ from papers.ai import capabilities
255
+ mine = _figure(paper, "figure", int(own_figure))
256
+ if not mine:
257
+ tables = any(f["kind"] == "table" and f["number"] == int(own_figure) for f in figures.for_paper(paper["id"]))
258
+ return Result("Comparing works on figures only, not tables." if tables else f"Figure {own_figure} wasn't found in this paper.",
259
+ f"Couldn't compare Figure {own_figure}")
260
+ other, choices = _library_paper(paper, other_paper)
261
+ if not other:
262
+ listing = "\n".join(f"- {t}" for t in choices) or "(none)"
263
+ return Result(f"No single paper in the reader's library matches “{other_paper}”. Ask again with one of these exact "
264
+ f"titles, or ask the reader which paper they mean:\n{listing}", "Looked for the other paper")
265
+ theirs = _figure({"id": other["id"]}, "figure", int(other_figure))
266
+ if not theirs:
267
+ have = ", ".join(f"{'Table' if f['kind'] == 'table' else 'Figure'} {f['number']}" for f in figures.for_paper(other["id"]))
268
+ return Result(f"“{other['title']}” has no Figure {other_figure} (comparing works on figures, not tables). "
269
+ f"It has: {have or 'no figures found in its PDF'}.", "Looked for the other figure")
270
+ about = (f"LEFT: Figure {mine['number']} of this paper: {mine['caption']}\n"
271
+ f"RIGHT: Figure {theirs['number']} of “{other['title']}”: {theirs['caption']}")
272
+ summary = f"Compared Figure {mine['number']} with Figure {theirs['number']} of “{other['title']}”"
273
+ if not can_see():
274
+ return Result(about + "\n\nYou were given the captions only, not the images: compare what the captions say, and "
275
+ "don't draw boxes or pairs.", summary + " (captions only)")
276
+ read = lambda pid, f: (figures.folder(pid) / figures.image_name("figure", f["number"])).read_bytes()
277
+ left, right = read(paper["id"], mine), read(other["id"], theirs)
278
+ pointing = capabilities.allows("pointing")
279
+ if pointing:
280
+ left, right = figures.with_grid(left) or left, figures.with_grid(right) or right
281
+ image = _side_by_side(left, right)
282
+ if not image:
283
+ return Result(about + "\n\nThe images couldn't be shown together: compare in words.", summary + " (in words)")
284
+ if not pointing:
285
+ return Result(about + "\n\nCompare them in words; don't draw boxes.", summary, image=image)
286
+ return Result(about + COMPARING.format(left=mine["number"], right=theirs["number"], title=other["title"].replace('"', "'"),
287
+ paper=other["id"]), summary, image=image)
288
+
289
+
290
+ def compared(steps: list[dict]) -> set[tuple[int, int, str]]:
291
+ """(this figure, other figure, other paper's title) for every comparison the model really looked at."""
292
+ found = set()
293
+ for s in steps:
294
+ m = re.match(r"Compared Figure (\d+) with Figure (\d+) of “(.+)”$", s.get("summary") or "")
295
+ if m and s.get("name") == "compare_with_figure":
296
+ found.add((int(m.group(1)), int(m.group(2)), m.group(3)))
297
+ return found
298
+
299
+
187
300
  def search_library(paper: dict, idea: str) -> Result:
188
301
  found = [c for c in index.candidates(idea, limit=6) if c["id"] != paper["id"]]
189
302
  if not found:
@@ -299,6 +412,15 @@ TOOLS = {
299
412
  "description": "See one of the paper's figures or tables (the image, its caption and where the text mentions it).",
300
413
  "schema": _schema({"number": {"type": "integer"}, "kind": {"type": "string", "enum": ["figure", "table"]}}, ["number", "kind"]),
301
414
  },
415
+ "compare_with_figure": {
416
+ "fn": compare_with_figure, "label": "Comparing two figures",
417
+ "description": "Put one of this paper's figures next to a figure of another paper in the reader's library, to "
418
+ "show the same thing in both (for example the same architecture drawn two ways). Use it when the "
419
+ "reader asks to compare, or when the explanation is clearer by seeing both; not otherwise. "
420
+ "Figures only, not tables. Give the other paper's title as the reader's library has it.",
421
+ "schema": _schema({"own_figure": {"type": "integer"}, "other_paper": {"type": "string"},
422
+ "other_figure": {"type": "integer"}}, ["own_figure", "other_paper", "other_figure"]),
423
+ },
302
424
  "search_library": {
303
425
  "fn": search_library, "label": "Searching your library",
304
426
  "description": "Find the reader's other papers about an idea, to connect this paper to what they read before.",
@@ -1,4 +1,5 @@
1
- """What the chosen model can do, found out by asking it: can it see an image, can it call a tool?
1
+ """What the chosen model can do, found out by asking it: can it see an image, call a tool, write clean JSON for
2
+ the visuals, and point at a place on a picture by naming grid cells?
2
3
 
3
4
  Claude (API or subscription) can do both, and the ChatGPT subscription runs without the app's tools, so those are
4
5
  known. For OpenAI-compatible providers nobody can tell from the model's name, so two tiny real requests are sent:
@@ -66,6 +67,65 @@ def calls_tools() -> dict:
66
67
  return {"ok": False, "note": "This model was offered a tool and didn't use it, so Deep mode may not work. Quick does."}
67
68
 
68
69
 
70
+ def _text(data: dict) -> str:
71
+ return data["choices"][0]["message"].get("content") or ""
72
+
73
+
74
+ def writes_json() -> dict:
75
+ """Charts, formulas and widgets in answers are JSON; a model that can't write it cleanly leaves broken boxes."""
76
+ a, b = random.randint(2, 40), random.randint(2, 40)
77
+ try:
78
+ data = openai_compat.send({"messages": [{"role": "user", "content":
79
+ 'Reply with only this JSON, filled in, and nothing else: {"sum": <the sum of ' + f"{a} and {b}" + '>, "words": ["two", "short", "words"]}'}]})
80
+ except AIError as e:
81
+ return {"ok": None, "note": f"Couldn't check: {e}"}
82
+ reply = _text(data).strip()
83
+ reply = reply.split("```")[1].removeprefix("json") if reply.count("```") >= 2 else reply # a fenced answer is fine
84
+ try:
85
+ value = json.loads(reply.strip())
86
+ good = isinstance(value, dict) and value.get("sum") == a + b and isinstance(value.get("words"), list)
87
+ except ValueError:
88
+ good = False
89
+ if good:
90
+ return {"ok": True, "note": "This model writes the charts, formulas and interactive widgets cleanly."}
91
+ return {"ok": False, "note": "This model's JSON came back broken, so answers use diagrams and tables instead of charts and widgets."}
92
+
93
+
94
+ def points_at() -> dict:
95
+ """Figure boxes: show a gridded picture with one coloured square and ask which cells it covers."""
96
+ from papers import figures
97
+ size, (c0, r0), span = 600, (random.randint(2, figures.GRID - 8), random.randint(2, figures.GRID - 8)), random.randint(3, 5)
98
+ try:
99
+ from PIL import Image, ImageDraw
100
+ except ImportError:
101
+ return {"ok": None, "note": "Couldn't check pointing (no imaging library)."}
102
+ import io
103
+ picture = Image.new("RGB", (size, size), "white")
104
+ cell = size / figures.GRID
105
+ ImageDraw.Draw(picture).rectangle([c0 * cell, r0 * cell, (c0 + span) * cell - 1, (r0 + span) * cell - 1], fill=(30, 60, 220))
106
+ raw = io.BytesIO()
107
+ picture.save(raw, "PNG")
108
+ grid = figures.with_grid(raw.getvalue())
109
+ if not grid:
110
+ return {"ok": None, "note": "Couldn't check pointing."}
111
+ try:
112
+ data = openai_compat.send({"messages": [{"role": "user", "content": [
113
+ {"type": "text", "text": "The picture has a grid like a chessboard: columns A to T lettered along the top and bottom "
114
+ "edges, rows 1 to 20 numbered down the sides. Which cells does the blue square cover? Answer "
115
+ "only as FROM to TO, the top-left cell and the bottom-right cell, like C7 to F10."},
116
+ {"type": "image_url", "image_url": {"url": "data:image/png;base64," + base64.b64encode(grid).decode()}}]}]})
117
+ except AIError as e:
118
+ return {"ok": None, "note": f"Couldn't check pointing: {e}"}
119
+ import re
120
+ cells = re.findall(r"\b([A-T])(1\d|20|[1-9])\b", _text(data).upper())
121
+ want = [(chr(65 + c0), r0 + 1), (chr(65 + c0 + span - 1), r0 + span)]
122
+ got = [(c, int(r)) for c, r in cells[:2]]
123
+ close = len(got) == 2 and all(abs(ord(g[0]) - ord(w[0])) <= 1 and abs(g[1] - w[1]) <= 1 for g, w in zip(got, want))
124
+ if close:
125
+ return {"ok": True, "note": "This model can point at parts of a figure with numbered boxes."}
126
+ return {"ok": False, "note": "This model couldn't point at the right place on a picture, so figures are shown without boxes."}
127
+
128
+
69
129
  def _key() -> str:
70
130
  return f"ai_caps:{providers.provider()}:{providers.openai_config()['model']}"
71
131
 
@@ -75,7 +135,9 @@ def known() -> dict | None:
75
135
  kind = providers.backend()
76
136
  if kind in ("api", "claude-code"):
77
137
  return {"images": {"ok": True, "note": "Claude can see images."},
78
- "tools": {"ok": True, "note": "Claude can use tools, so Deep mode works."}, "checked": False}
138
+ "tools": {"ok": True, "note": "Claude can use tools, so Deep mode works."},
139
+ "json": {"ok": True, "note": "Claude writes the charts, formulas and interactive widgets cleanly."},
140
+ "pointing": {"ok": True, "note": "Claude can point at parts of a figure with numbered boxes."}, "checked": False}
79
141
  if kind == "codex":
80
142
  return {"images": {"ok": False, "note": "Through a ChatGPT subscription the figures aren't sent."},
81
143
  "tools": {"ok": False, "note": "Through a ChatGPT subscription Deep answers from the paper's text, without the app's tools."},
@@ -86,11 +148,19 @@ def known() -> dict | None:
86
148
  return None
87
149
 
88
150
 
151
+ def allows(skill: str) -> bool:
152
+ """Whether to use a skill ("tools", "json", "pointing") with the chosen model: yes unless a check found it can't."""
153
+ return ((known() or {}).get(skill) or {}).get("ok") is not False
154
+
155
+
89
156
  def check() -> dict:
90
157
  """Ask the model (OpenAI-compatible providers), remember the answers, and set "Look at figures" to match."""
91
158
  if providers.backend() != "openai":
92
159
  return known()
93
- found = {"images": sees_images(), "tools": calls_tools(), "checked": True}
160
+ found = {"images": sees_images(), "tools": calls_tools(), "json": writes_json(), "checked": True}
161
+ sees = found["images"]["ok"]
162
+ found["pointing"] = (points_at() if sees else {"ok": None, "note": "Couldn't check pointing."} if sees is None
163
+ else {"ok": False, "note": "No boxes on figures: this model can't see them."})
94
164
  if found["images"]["ok"] is not None or found["tools"]["ok"] is not None: # nothing learned: nothing to remember
95
165
  db.set_setting(_key(), json.dumps(found))
96
166
  if found["images"]["ok"] is not None:
@@ -0,0 +1,54 @@
1
+ import json
2
+ import re
3
+
4
+
5
+ class AIError(Exception):
6
+ """Anything that kept the model from answering; the message is shown to the user as is."""
7
+
8
+
9
+ # What went wrong, said for people. Each rule: what the raw message looks like -> what the reader is told.
10
+ # The first that matches wins; a message that is already plain is left as it is.
11
+ PLAIN = [
12
+ (r"isn't signed in|not signed in",
13
+ None), # the sign-in messages are already written for people; only their raw tail goes
14
+ (r"usage limit|hit your .{0,20}limit|quota|credit balance|insufficient.{0,10}(funds|credits)|billing",
15
+ "You've reached the AI's usage limit for now{resets}. Try again later, or pick another provider in Settings."),
16
+ (r"\b429\b|rate.?limit|too many requests|overloaded|\b529\b",
17
+ "The AI is busy right now{resets}. Wait a moment and try again."),
18
+ (r"\b40[13]\b|invalid.{0,20}(api.?)?key|incorrect api key|unauthori[sz]ed|authentication|credentials?|permission denied|forbidden",
19
+ "The AI didn't accept the API key. Check the key in Settings › AI model."),
20
+ (r"model.{0,40}(not found|does not exist|not available|unknown)|no such model|\b404\b",
21
+ "That model wasn't found. Pick another one in Settings › AI model (List models shows what's there)."),
22
+ (r"context.{0,20}(length|window|limit)|too many tokens|maximum.{0,20}tokens|prompt is too long|request too large|\b413\b",
23
+ "This paper is too long for the model. In Settings › AI model › More options, send less of the paper, or pick a larger model."),
24
+ (r"timed? ?out|timeout|took too long",
25
+ "The AI took too long to answer. Try again; a smaller question or Quick mode is faster."),
26
+ (r"connect|connection|unreachable|network|getaddrinfo|name resolution|refused|ssl|certificate",
27
+ "Couldn't reach the AI. Check your internet connection, or that the model's app (Ollama, LM Studio) is running."),
28
+ (r"\b5\d\d\b|internal server error|bad gateway|service unavailable",
29
+ "The AI's service is having trouble right now. Try again in a moment."),
30
+ ]
31
+ TECHNICAL = re.compile(r"[{}\[\]<>]|traceback|exception|error:|errno|\bhttps?://|\.py\b|\(\d{3}\)|\b[a-z_]+error\b", re.IGNORECASE)
32
+
33
+
34
+ def plain(message: str) -> str:
35
+ """The message for the reader: what happened and what to do, without codes, JSON or tracebacks.
36
+ The raw message is still kept (logged, and shown under Details) for whoever needs it."""
37
+ text = " ".join(str(message or "").split())
38
+ resets = re.search(r"resets? (?:at )?([0-9][^().,;]{0,30})", text, re.IGNORECASE)
39
+ for pattern, said in PLAIN:
40
+ if re.search(pattern, text, re.IGNORECASE):
41
+ if said is None: # already plain: drop a raw "(...)" tail
42
+ return re.sub(r"\s*\((?:[^()]*\b(?:error|failed|oauth|401|403|expired)\b[^()]*)\)\s*$", "", text, flags=re.IGNORECASE)
43
+ return said.format(resets=f" (it resets at {resets.group(1).strip()})" if resets else "")
44
+ if text and not TECHNICAL.search(text) and len(text) < 300:
45
+ return text
46
+ return "The AI couldn't answer this time. Try again; if it keeps happening, check Settings › AI model."
47
+
48
+
49
+ def json_in(text: str) -> dict:
50
+ """The JSON object inside a model's text answer (models sometimes wrap it in prose or code fences)."""
51
+ try:
52
+ return json.loads(text[text.index("{"): text.rindex("}") + 1])
53
+ except ValueError as e:
54
+ raise AIError("The model didn't answer in the expected format. Try again, or choose a stronger model.") from e
@@ -22,7 +22,8 @@ PROVIDERS = [
22
22
  {"id": "openrouter", "group": "key", "kind": "openai", "name": "OpenRouter (hundreds of models)", "base_url": "https://openrouter.ai/api/v1", "key": True},
23
23
  {"id": "ollama", "group": "local", "kind": "openai", "name": "Ollama", "base_url": "http://localhost:11434/v1", "key": False},
24
24
  {"id": "lmstudio", "group": "local", "kind": "openai", "name": "LM Studio", "base_url": "http://localhost:1234/v1", "key": False},
25
- {"id": "custom", "group": "other", "kind": "openai", "name": "Any OpenAI-compatible server", "base_url": "", "key": False},
25
+ {"id": "custom", "group": "other", "kind": "openai", "name": "Any OpenAI-compatible server", "base_url": "", "key": False,
26
+ "key_optional": True}, # many such servers (DeepSeek, Together, a company gateway) need one, local ones don't
26
27
  ]
27
28
  BY_ID = {p["id"]: p for p in PROVIDERS}
28
29
  DEFAULT_FOR_KIND = {"claude-code": "claude-plan", "codex": "chatgpt-plan", "api": "anthropic"}