pepa-workers 0.9.0__py3-none-any.whl
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.
- pepa_workers/__init__.py +0 -0
- pepa_workers/__main__.py +3 -0
- pepa_workers/apps/pepa-console/README.md +42 -0
- pepa_workers/apps/pepa-console/cli/__init__.py +0 -0
- pepa_workers/apps/pepa-console/cli/ui.py +202 -0
- pepa_workers/apps/pepa-console/cli/workers_menu.py +29 -0
- pepa_workers/apps/pepa-console/guides/index.md +65 -0
- pepa_workers/apps/pepa-console/guides/models.md +41 -0
- pepa_workers/apps/pepa-console/guides/pepa-plan.md +23 -0
- pepa_workers/apps/pepa-console/guides/pepa-prep.md +19 -0
- pepa_workers/apps/pepa-console/guides/pepa-read.md +17 -0
- pepa_workers/apps/pepa-console/guides/pepa-review.md +39 -0
- pepa_workers/apps/pepa-console/guides/pepa-sum.md +28 -0
- pepa_workers/apps/pepa-console/manage.py +152 -0
- pepa_workers/apps/pepa-console/pyproject.toml +6 -0
- pepa_workers/apps/pepa-console/registry.py +238 -0
- pepa_workers/apps/pepa-console/requirements.txt +4 -0
- pepa_workers/apps/pepa-console/runner.py +140 -0
- pepa_workers/apps/pepa-console/web/__init__.py +0 -0
- pepa_workers/apps/pepa-console/web/app.py +108 -0
- pepa_workers/apps/pepa-console/web/ask_routes.py +282 -0
- pepa_workers/apps/pepa-console/web/asking.py +742 -0
- pepa_workers/apps/pepa-console/web/batches.py +32 -0
- pepa_workers/apps/pepa-console/web/citations.py +380 -0
- pepa_workers/apps/pepa-console/web/connections.py +134 -0
- pepa_workers/apps/pepa-console/web/documents.py +330 -0
- pepa_workers/apps/pepa-console/web/draft_routes.py +177 -0
- pepa_workers/apps/pepa-console/web/drafting.py +809 -0
- pepa_workers/apps/pepa-console/web/estimates.py +106 -0
- pepa_workers/apps/pepa-console/web/explore.py +337 -0
- pepa_workers/apps/pepa-console/web/explore_routes.py +468 -0
- pepa_workers/apps/pepa-console/web/folders.py +426 -0
- pepa_workers/apps/pepa-console/web/jobs.py +928 -0
- pepa_workers/apps/pepa-console/web/kept.py +249 -0
- pepa_workers/apps/pepa-console/web/keys.py +191 -0
- pepa_workers/apps/pepa-console/web/lists.py +122 -0
- pepa_workers/apps/pepa-console/web/maps.py +235 -0
- pepa_workers/apps/pepa-console/web/mascot.py +197 -0
- pepa_workers/apps/pepa-console/web/models.py +619 -0
- pepa_workers/apps/pepa-console/web/names.py +43 -0
- pepa_workers/apps/pepa-console/web/options.py +219 -0
- pepa_workers/apps/pepa-console/web/papers.py +603 -0
- pepa_workers/apps/pepa-console/web/paths.py +504 -0
- pepa_workers/apps/pepa-console/web/reviews.py +57 -0
- pepa_workers/apps/pepa-console/web/routes.py +972 -0
- pepa_workers/apps/pepa-console/web/settings.py +64 -0
- pepa_workers/apps/pepa-console/web/static/buddy.js +169 -0
- pepa_workers/apps/pepa-console/web/static/console.css +869 -0
- pepa_workers/apps/pepa-console/web/static/console.js +2996 -0
- pepa_workers/apps/pepa-console/web/static/theme.js +32 -0
- pepa_workers/apps/pepa-console/web/templates/_add_to_list.html +25 -0
- pepa_workers/apps/pepa-console/web/templates/_ask_form.html +77 -0
- pepa_workers/apps/pepa-console/web/templates/_check_form.html +51 -0
- pepa_workers/apps/pepa-console/web/templates/_file_field.html +11 -0
- pepa_workers/apps/pepa-console/web/templates/_icons.html +17 -0
- pepa_workers/apps/pepa-console/web/templates/_look_in.html +9 -0
- pepa_workers/apps/pepa-console/web/templates/_missing.html +21 -0
- pepa_workers/apps/pepa-console/web/templates/_notes_field.html +11 -0
- pepa_workers/apps/pepa-console/web/templates/_outline_form.html +53 -0
- pepa_workers/apps/pepa-console/web/templates/_page_head.html +5 -0
- pepa_workers/apps/pepa-console/web/templates/_pager.html +9 -0
- pepa_workers/apps/pepa-console/web/templates/_paper_picker.html +50 -0
- pepa_workers/apps/pepa-console/web/templates/_papers.html +55 -0
- pepa_workers/apps/pepa-console/web/templates/_references.html +9 -0
- pepa_workers/apps/pepa-console/web/templates/_run.html +45 -0
- pepa_workers/apps/pepa-console/web/templates/_run_form.html +30 -0
- pepa_workers/apps/pepa-console/web/templates/_setting.html +71 -0
- pepa_workers/apps/pepa-console/web/templates/_settings_tabs.html +9 -0
- pepa_workers/apps/pepa-console/web/templates/_shown_run.html +5 -0
- pepa_workers/apps/pepa-console/web/templates/_side.html +55 -0
- pepa_workers/apps/pepa-console/web/templates/app.html +168 -0
- pepa_workers/apps/pepa-console/web/templates/apps.html +14 -0
- pepa_workers/apps/pepa-console/web/templates/ask.html +92 -0
- pepa_workers/apps/pepa-console/web/templates/base.html +88 -0
- pepa_workers/apps/pepa-console/web/templates/chapters.html +58 -0
- pepa_workers/apps/pepa-console/web/templates/conversation.html +57 -0
- pepa_workers/apps/pepa-console/web/templates/develop_read.html +81 -0
- pepa_workers/apps/pepa-console/web/templates/explore.html +144 -0
- pepa_workers/apps/pepa-console/web/templates/files.html +72 -0
- pepa_workers/apps/pepa-console/web/templates/folders.html +93 -0
- pepa_workers/apps/pepa-console/web/templates/guide.html +15 -0
- pepa_workers/apps/pepa-console/web/templates/job.html +17 -0
- pepa_workers/apps/pepa-console/web/templates/jobs.html +42 -0
- pepa_workers/apps/pepa-console/web/templates/library.html +232 -0
- pepa_workers/apps/pepa-console/web/templates/lists.html +61 -0
- pepa_workers/apps/pepa-console/web/templates/map.html +109 -0
- pepa_workers/apps/pepa-console/web/templates/models.html +172 -0
- pepa_workers/apps/pepa-console/web/templates/not_found.html +9 -0
- pepa_workers/apps/pepa-console/web/templates/paper.html +116 -0
- pepa_workers/apps/pepa-console/web/templates/references.html +63 -0
- pepa_workers/apps/pepa-console/web/templates/review.html +28 -0
- pepa_workers/apps/pepa-console/web/templates/theme.html +91 -0
- pepa_workers/apps/pepa-console/web/templates/view.html +52 -0
- pepa_workers/apps/pepa-console/web/undo.py +71 -0
- pepa_workers/apps/pepa-console/web/word_export.py +67 -0
- pepa_workers/apps/pepa-plan/README.md +39 -0
- pepa_workers/apps/pepa-plan/backends/__init__.py +0 -0
- pepa_workers/apps/pepa-plan/backends/anthropic_client.py +347 -0
- pepa_workers/apps/pepa-plan/backends/llm.py +66 -0
- pepa_workers/apps/pepa-plan/backends/openai_client.py +345 -0
- pepa_workers/apps/pepa-plan/backends/prompt.py +214 -0
- pepa_workers/apps/pepa-plan/cli/__init__.py +0 -0
- pepa_workers/apps/pepa-plan/cli/costs.py +94 -0
- pepa_workers/apps/pepa-plan/cli/install.py +80 -0
- pepa_workers/apps/pepa-plan/cli/items.py +30 -0
- pepa_workers/apps/pepa-plan/cli/menu.py +57 -0
- pepa_workers/apps/pepa-plan/cli/outline.py +253 -0
- pepa_workers/apps/pepa-plan/cli/progress.py +49 -0
- pepa_workers/apps/pepa-plan/cli/review.py +77 -0
- pepa_workers/apps/pepa-plan/cli/show_config.py +89 -0
- pepa_workers/apps/pepa-plan/cli/templates.py +107 -0
- pepa_workers/apps/pepa-plan/cli/ui.py +202 -0
- pepa_workers/apps/pepa-plan/config.py +277 -0
- pepa_workers/apps/pepa-plan/corpus/__init__.py +0 -0
- pepa_workers/apps/pepa-plan/corpus/join.py +30 -0
- pepa_workers/apps/pepa-plan/corpus/load.py +19 -0
- pepa_workers/apps/pepa-plan/corpus/parse_para.py +11 -0
- pepa_workers/apps/pepa-plan/manage.py +132 -0
- pepa_workers/apps/pepa-plan/plan/__init__.py +0 -0
- pepa_workers/apps/pepa-plan/plan/labels.py +65 -0
- pepa_workers/apps/pepa-plan/plan/outline.py +13 -0
- pepa_workers/apps/pepa-plan/plan/refine.py +13 -0
- pepa_workers/apps/pepa-plan/pyproject.toml +7 -0
- pepa_workers/apps/pepa-plan/requirements.txt +4 -0
- pepa_workers/apps/pepa-plan/secrets.example.yaml +20 -0
- pepa_workers/apps/pepa-plan/skeleton/__init__.py +0 -0
- pepa_workers/apps/pepa-plan/skeleton/blueprint.py +182 -0
- pepa_workers/apps/pepa-plan/skeleton/build.py +456 -0
- pepa_workers/apps/pepa-plan/skeleton/examples.py +48 -0
- pepa_workers/apps/pepa-plan/skeleton/moves.py +61 -0
- pepa_workers/apps/pepa-plan/skeleton/recover.py +78 -0
- pepa_workers/apps/pepa-plan/templates/example.plan.md +36 -0
- pepa_workers/apps/pepa-prep/README.md +36 -0
- pepa_workers/apps/pepa-prep/cli/__init__.py +0 -0
- pepa_workers/apps/pepa-prep/cli/config_cmd.py +128 -0
- pepa_workers/apps/pepa-prep/cli/extract_cmd.py +292 -0
- pepa_workers/apps/pepa-prep/cli/install.py +56 -0
- pepa_workers/apps/pepa-prep/cli/items.py +18 -0
- pepa_workers/apps/pepa-prep/cli/menu.py +68 -0
- pepa_workers/apps/pepa-prep/cli/ui.py +202 -0
- pepa_workers/apps/pepa-prep/extract/__init__.py +0 -0
- pepa_workers/apps/pepa-prep/extract/anchor.py +246 -0
- pepa_workers/apps/pepa-prep/extract/categorise.py +96 -0
- pepa_workers/apps/pepa-prep/extract/chapter.py +255 -0
- pepa_workers/apps/pepa-prep/extract/complete.py +67 -0
- pepa_workers/apps/pepa-prep/extract/config.py +108 -0
- pepa_workers/apps/pepa-prep/extract/marks.py +103 -0
- pepa_workers/apps/pepa-prep/extract/ocr.py +49 -0
- pepa_workers/apps/pepa-prep/extract/pdf.py +242 -0
- pepa_workers/apps/pepa-prep/extract/shape.py +193 -0
- pepa_workers/apps/pepa-prep/extract/split.py +152 -0
- pepa_workers/apps/pepa-prep/extract/tables.py +87 -0
- pepa_workers/apps/pepa-prep/extract/text.py +466 -0
- pepa_workers/apps/pepa-prep/extract/toc.py +510 -0
- pepa_workers/apps/pepa-prep/extract/validate.py +133 -0
- pepa_workers/apps/pepa-prep/extract/workers.py +215 -0
- pepa_workers/apps/pepa-prep/manage.py +120 -0
- pepa_workers/apps/pepa-prep/paper_names.py +59 -0
- pepa_workers/apps/pepa-prep/pyproject.toml +7 -0
- pepa_workers/apps/pepa-prep/refine/__init__.py +0 -0
- pepa_workers/apps/pepa-prep/refine/engine.py +457 -0
- pepa_workers/apps/pepa-prep/refine/headings.py +94 -0
- pepa_workers/apps/pepa-prep/refine/seams.py +85 -0
- pepa_workers/apps/pepa-prep/refine/signals.py +154 -0
- pepa_workers/apps/pepa-prep/refine/toc_text.py +171 -0
- pepa_workers/apps/pepa-prep/refine/zones.py +69 -0
- pepa_workers/apps/pepa-prep/requirements.txt +5 -0
- pepa_workers/apps/pepa-read/README.md +46 -0
- pepa_workers/apps/pepa-read/cli/__init__.py +0 -0
- pepa_workers/apps/pepa-read/cli/install.py +53 -0
- pepa_workers/apps/pepa-read/cli/ui.py +202 -0
- pepa_workers/apps/pepa-read/config.py +22 -0
- pepa_workers/apps/pepa-read/index/__init__.py +0 -0
- pepa_workers/apps/pepa-read/index/build.py +245 -0
- pepa_workers/apps/pepa-read/index/files.py +23 -0
- pepa_workers/apps/pepa-read/index/lists.py +126 -0
- pepa_workers/apps/pepa-read/index/scan.py +123 -0
- pepa_workers/apps/pepa-read/index/schema.py +83 -0
- pepa_workers/apps/pepa-read/manage.py +240 -0
- pepa_workers/apps/pepa-read/paper_names.py +59 -0
- pepa_workers/apps/pepa-read/pyproject.toml +6 -0
- pepa_workers/apps/pepa-read/requirements.txt +3 -0
- pepa_workers/apps/pepa-read/search/__init__.py +0 -0
- pepa_workers/apps/pepa-read/search/query.py +257 -0
- pepa_workers/apps/pepa-read/web/__init__.py +0 -0
- pepa_workers/apps/pepa-read/web/app.py +69 -0
- pepa_workers/apps/pepa-read/web/routes.py +309 -0
- pepa_workers/apps/pepa-read/web/static/search.js +303 -0
- pepa_workers/apps/pepa-read/web/static/style.css +342 -0
- pepa_workers/apps/pepa-read/web/static/theme.js +26 -0
- pepa_workers/apps/pepa-read/web/static/view.js +16 -0
- pepa_workers/apps/pepa-read/web/templates/search.html +77 -0
- pepa_workers/apps/pepa-review/README.md +49 -0
- pepa_workers/apps/pepa-review/backends/__init__.py +0 -0
- pepa_workers/apps/pepa-review/backends/anthropic_client.py +184 -0
- pepa_workers/apps/pepa-review/backends/llm.py +24 -0
- pepa_workers/apps/pepa-review/backends/openai_client.py +195 -0
- pepa_workers/apps/pepa-review/backends/prompt.py +277 -0
- pepa_workers/apps/pepa-review/biblio/__init__.py +0 -0
- pepa_workers/apps/pepa-review/biblio/export.py +91 -0
- pepa_workers/apps/pepa-review/biblio/fetch.py +570 -0
- pepa_workers/apps/pepa-review/biblio/ingest.py +166 -0
- pepa_workers/apps/pepa-review/biblio/network.py +130 -0
- pepa_workers/apps/pepa-review/biblio/references.py +192 -0
- pepa_workers/apps/pepa-review/biblio/schema.py +60 -0
- pepa_workers/apps/pepa-review/biblio/sources.py +118 -0
- pepa_workers/apps/pepa-review/biblio/store.py +159 -0
- pepa_workers/apps/pepa-review/biblio/zotero.py +87 -0
- pepa_workers/apps/pepa-review/cli/__init__.py +0 -0
- pepa_workers/apps/pepa-review/cli/ask.py +178 -0
- pepa_workers/apps/pepa-review/cli/biblio_cmd.py +203 -0
- pepa_workers/apps/pepa-review/cli/costs.py +183 -0
- pepa_workers/apps/pepa-review/cli/explore.py +296 -0
- pepa_workers/apps/pepa-review/cli/gaps.py +360 -0
- pepa_workers/apps/pepa-review/cli/index_cmd.py +78 -0
- pepa_workers/apps/pepa-review/cli/install.py +81 -0
- pepa_workers/apps/pepa-review/cli/items.py +30 -0
- pepa_workers/apps/pepa-review/cli/map.py +484 -0
- pepa_workers/apps/pepa-review/cli/menu.py +71 -0
- pepa_workers/apps/pepa-review/cli/place.py +68 -0
- pepa_workers/apps/pepa-review/cli/progress.py +49 -0
- pepa_workers/apps/pepa-review/cli/review.py +697 -0
- pepa_workers/apps/pepa-review/cli/show_config.py +124 -0
- pepa_workers/apps/pepa-review/cli/similar.py +149 -0
- pepa_workers/apps/pepa-review/cli/thread_map.py +177 -0
- pepa_workers/apps/pepa-review/cli/ui.py +202 -0
- pepa_workers/apps/pepa-review/config.py +257 -0
- pepa_workers/apps/pepa-review/corpus/__init__.py +0 -0
- pepa_workers/apps/pepa-review/corpus/load.py +57 -0
- pepa_workers/apps/pepa-review/corpus/metadata.py +38 -0
- pepa_workers/apps/pepa-review/corpus/parse_sum.py +65 -0
- pepa_workers/apps/pepa-review/corpus/read_parts.py +188 -0
- pepa_workers/apps/pepa-review/index/__init__.py +0 -0
- pepa_workers/apps/pepa-review/index/cluster.py +477 -0
- pepa_workers/apps/pepa-review/index/embeddings.py +99 -0
- pepa_workers/apps/pepa-review/index/store.py +335 -0
- pepa_workers/apps/pepa-review/lib/bindings/utils.js +189 -0
- pepa_workers/apps/pepa-review/lib/tom-select/tom-select.complete.min.js +356 -0
- pepa_workers/apps/pepa-review/lib/tom-select/tom-select.css +334 -0
- pepa_workers/apps/pepa-review/lib/vis-9.1.2/vis-network.css +1 -0
- pepa_workers/apps/pepa-review/lib/vis-9.1.2/vis-network.min.js +27 -0
- pepa_workers/apps/pepa-review/manage.py +250 -0
- pepa_workers/apps/pepa-review/paper_names.py +59 -0
- pepa_workers/apps/pepa-review/pyproject.toml +6 -0
- pepa_workers/apps/pepa-review/requirements.txt +8 -0
- pepa_workers/apps/pepa-review/secrets.example.yaml +49 -0
- pepa_workers/apps/pepa-sum/README.md +46 -0
- pepa_workers/apps/pepa-sum/backends/__init__.py +20 -0
- pepa_workers/apps/pepa-sum/backends/anthropic_client.py +377 -0
- pepa_workers/apps/pepa-sum/backends/llm.py +68 -0
- pepa_workers/apps/pepa-sum/backends/openai_client.py +368 -0
- pepa_workers/apps/pepa-sum/backends/prompt.py +87 -0
- pepa_workers/apps/pepa-sum/cli/__init__.py +2 -0
- pepa_workers/apps/pepa-sum/cli/batches.py +268 -0
- pepa_workers/apps/pepa-sum/cli/cleanup.py +68 -0
- pepa_workers/apps/pepa-sum/cli/install.py +107 -0
- pepa_workers/apps/pepa-sum/cli/items.py +18 -0
- pepa_workers/apps/pepa-sum/cli/menu.py +21 -0
- pepa_workers/apps/pepa-sum/cli/progress.py +141 -0
- pepa_workers/apps/pepa-sum/cli/settings.py +64 -0
- pepa_workers/apps/pepa-sum/cli/show_config.py +55 -0
- pepa_workers/apps/pepa-sum/cli/summarize.py +1285 -0
- pepa_workers/apps/pepa-sum/cli/ui.py +216 -0
- pepa_workers/apps/pepa-sum/config.py +521 -0
- pepa_workers/apps/pepa-sum/documents/__init__.py +10 -0
- pepa_workers/apps/pepa-sum/documents/quotes.py +13 -0
- pepa_workers/apps/pepa-sum/documents/rundown.py +92 -0
- pepa_workers/apps/pepa-sum/documents/summary.py +55 -0
- pepa_workers/apps/pepa-sum/env.yaml.example +56 -0
- pepa_workers/apps/pepa-sum/extract/__init__.py +9 -0
- pepa_workers/apps/pepa-sum/extract/paragraphs.py +93 -0
- pepa_workers/apps/pepa-sum/extract/passages.py +113 -0
- pepa_workers/apps/pepa-sum/extract/read_pdf.py +174 -0
- pepa_workers/apps/pepa-sum/extract/read_source.py +19 -0
- pepa_workers/apps/pepa-sum/extract/signals.py +173 -0
- pepa_workers/apps/pepa-sum/manage.py +100 -0
- pepa_workers/apps/pepa-sum/paper_names.py +59 -0
- pepa_workers/apps/pepa-sum/pyproject.toml +7 -0
- pepa_workers/apps/pepa-sum/render/__init__.py +4 -0
- pepa_workers/apps/pepa-sum/render/markdown.py +30 -0
- pepa_workers/apps/pepa-sum/requirements.txt +8 -0
- pepa_workers/launch.py +63 -0
- pepa_workers-0.9.0.dist-info/METADATA +77 -0
- pepa_workers-0.9.0.dist-info/RECORD +288 -0
- pepa_workers-0.9.0.dist-info/WHEEL +5 -0
- pepa_workers-0.9.0.dist-info/entry_points.txt +7 -0
- pepa_workers-0.9.0.dist-info/licenses/LICENSE +21 -0
- pepa_workers-0.9.0.dist-info/top_level.txt +1 -0
pepa_workers/__init__.py
ADDED
|
File without changes
|
pepa_workers/__main__.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# pepa-console
|
|
2
|
+
|
|
3
|
+
One local web page for all the pepa workers. Pick a worker, fill in a form, and watch it run;
|
|
4
|
+
keys and folders are set once and handed to every worker. It runs each worker through its own
|
|
5
|
+
`manage.py` and answers only on this machine.
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
```mermaid
|
|
10
|
+
flowchart TD
|
|
11
|
+
USER["Web console"] -->|"run a command"| JOB["Job"]
|
|
12
|
+
KEYS[("Keys and folders<br/>in the user profile")] -->|"environment variables"| JOB
|
|
13
|
+
JOB --> CHILD[("Worker's manage.py<br/>in its own folder")]
|
|
14
|
+
CHILD -->|"live output"| USER
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
| Page | What it does |
|
|
18
|
+
|---|---|
|
|
19
|
+
| Library | The items and how far each stage has got; drop PDFs on it to add them, tick items to ask about them, add them to a list or process only those, and press Process items to run the stages in order |
|
|
20
|
+
| Search | Find papers, in the whole library or one list, by their words, their meaning or a whole text of your own; read a paper with its connections beside it, and keep literature lists |
|
|
21
|
+
| Map | Sort the papers into themes, by who cites whom, or both, with each paper drawn as a dot beside the papers closest to it |
|
|
22
|
+
| Ask | Chat with papers you pick; put a question to the closest papers, a list or a theme of a map; or get notes on your points, an outline of your idea, or a check of your draft. Each result shows what it was made from and can be renamed or deleted |
|
|
23
|
+
| Jobs | Every run, kept for as long as chosen there; the chip at the bottom left shows the runs of the moment on every page |
|
|
24
|
+
| Settings | Folders: the project folder, and where each worker reads and writes. Models: the keys, and the models every form offers. Workers: one page per worker, each command as a form with its live log, its settings, and every file it reads or writes. References: Zotero or an export file for looking up citations |
|
|
25
|
+
| Guide | How to start, and what each worker does |
|
|
26
|
+
|
|
27
|
+
## Setup
|
|
28
|
+
|
|
29
|
+
```powershell
|
|
30
|
+
pip install -r requirements.txt
|
|
31
|
+
python manage.py install
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Commands
|
|
35
|
+
|
|
36
|
+
| Action | Command |
|
|
37
|
+
|---|---|
|
|
38
|
+
| Open the web console | `python manage.py` |
|
|
39
|
+
| Open any worker's own menu from one list | `python manage.py --cli` |
|
|
40
|
+
| List every worker and its commands | `python manage.py status` |
|
|
41
|
+
| Run one worker command | `python manage.py run <app> <command>` |
|
|
42
|
+
| Check dependencies | `python manage.py install` |
|
|
File without changes
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"""Terminal UI helpers: status lines, prompts and menus go to stderr, tables to stdout.
|
|
2
|
+
Colour and unicode degrade off a terminal or when NO_COLOR is set.
|
|
3
|
+
"""
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
RESET = "\033[0m"
|
|
8
|
+
BOLD = "\033[1m"
|
|
9
|
+
DIM = "\033[2m"
|
|
10
|
+
RED = "\033[31m"
|
|
11
|
+
GREEN = "\033[32m"
|
|
12
|
+
YELLOW = "\033[33m"
|
|
13
|
+
BLUE = "\033[34m"
|
|
14
|
+
|
|
15
|
+
WIDTH = 64
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _supports_color():
|
|
19
|
+
if os.environ.get("NO_COLOR"):
|
|
20
|
+
return False
|
|
21
|
+
if not sys.stdout.isatty() or not sys.stderr.isatty():
|
|
22
|
+
return False
|
|
23
|
+
if os.name == "nt":
|
|
24
|
+
# Enable ANSI (Virtual Terminal) processing on the Windows console.
|
|
25
|
+
try:
|
|
26
|
+
import ctypes
|
|
27
|
+
k = ctypes.windll.kernel32
|
|
28
|
+
k.SetConsoleMode(k.GetStdHandle(-11), 7) # ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
|
29
|
+
except Exception:
|
|
30
|
+
return False
|
|
31
|
+
return True
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# Try to render unicode symbols even on legacy Windows code pages.
|
|
35
|
+
try:
|
|
36
|
+
sys.stdout.reconfigure(encoding="utf-8")
|
|
37
|
+
sys.stderr.reconfigure(encoding="utf-8")
|
|
38
|
+
except Exception:
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
_COLOR = _supports_color()
|
|
42
|
+
_UNICODE = True
|
|
43
|
+
try:
|
|
44
|
+
"▶✓⚠✗·".encode(sys.stderr.encoding or "utf-8")
|
|
45
|
+
except Exception:
|
|
46
|
+
_UNICODE = False
|
|
47
|
+
|
|
48
|
+
_SYM = {
|
|
49
|
+
"step": "▶" if _UNICODE else ">",
|
|
50
|
+
"ok": "✓" if _UNICODE else "+",
|
|
51
|
+
"warn": "⚠" if _UNICODE else "!",
|
|
52
|
+
"err": "✗" if _UNICODE else "x",
|
|
53
|
+
"info": "·" if _UNICODE else "-",
|
|
54
|
+
"rule": "─" if _UNICODE else "-",
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _c(code, text):
|
|
59
|
+
return f"{code}{text}{RESET}" if _COLOR else text
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def header(text):
|
|
63
|
+
rule = _SYM["rule"] * WIDTH
|
|
64
|
+
print(file=sys.stderr)
|
|
65
|
+
print(_c(BLUE, rule), file=sys.stderr)
|
|
66
|
+
print(_c(BOLD + BLUE, f" {text}"), file=sys.stderr)
|
|
67
|
+
print(_c(BLUE, rule), file=sys.stderr)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def rule():
|
|
71
|
+
print(_c(DIM, _SYM["rule"] * WIDTH), file=sys.stderr)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def step(text):
|
|
75
|
+
print(file=sys.stderr)
|
|
76
|
+
print(_c(BOLD + BLUE, f"{_SYM['step']} {text}"), file=sys.stderr)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def ok(text):
|
|
80
|
+
print(f" {_c(GREEN, _SYM['ok'])} {text}", file=sys.stderr)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def warn(text):
|
|
84
|
+
print(f" {_c(YELLOW, _SYM['warn'])} {text}", file=sys.stderr)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def info(text):
|
|
88
|
+
print(f" {_c(DIM, _SYM['info'])} {text}", file=sys.stderr)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def error(text):
|
|
92
|
+
print(f" {_c(RED, _SYM['err'])} {text}", file=sys.stderr)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def abort(text, code=1):
|
|
96
|
+
error(text)
|
|
97
|
+
sys.exit(code)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def table(rows, columns):
|
|
101
|
+
"""Print a list of dictionaries as an aligned table, one row per unit of work.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
rows: Dictionaries sharing the same keys, one per item processed.
|
|
105
|
+
columns: Keys to show, in the order they should appear.
|
|
106
|
+
"""
|
|
107
|
+
widths = [len(name) for name in columns]
|
|
108
|
+
for row in rows:
|
|
109
|
+
for position, name in enumerate(columns):
|
|
110
|
+
widths[position] = max(widths[position], len(str(row.get(name, ""))))
|
|
111
|
+
|
|
112
|
+
heading = " ".join(name.ljust(widths[position]) for position, name in enumerate(columns))
|
|
113
|
+
print(f" {_c(BOLD, heading)}")
|
|
114
|
+
for row in rows:
|
|
115
|
+
cells = []
|
|
116
|
+
for position, name in enumerate(columns):
|
|
117
|
+
cells.append(str(row.get(name, "")).ljust(widths[position]))
|
|
118
|
+
print(" " + " ".join(cells))
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def ask(prompt, default=None):
|
|
122
|
+
suffix = f" [{default}]" if default is not None else ""
|
|
123
|
+
try:
|
|
124
|
+
sys.stderr.write(_c(BOLD, f" {prompt}{suffix}: "))
|
|
125
|
+
sys.stderr.flush()
|
|
126
|
+
raw = input().lstrip("").strip()
|
|
127
|
+
except (EOFError, KeyboardInterrupt):
|
|
128
|
+
print(file=sys.stderr)
|
|
129
|
+
return default
|
|
130
|
+
return raw or default
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def ask_choice(prompt, choices, default=None):
|
|
134
|
+
low = [c.lower() for c in choices]
|
|
135
|
+
while True:
|
|
136
|
+
raw = ask(prompt, default)
|
|
137
|
+
if raw is None:
|
|
138
|
+
return default
|
|
139
|
+
r = raw.strip().lower()
|
|
140
|
+
if r in low:
|
|
141
|
+
return choices[low.index(r)]
|
|
142
|
+
warn(f"choose one of: {', '.join(choices)}")
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def confirm(question, default_yes=True):
|
|
146
|
+
hint = "Y/n" if default_yes else "y/N"
|
|
147
|
+
raw = ask(f"{question} [{hint}]")
|
|
148
|
+
if not raw:
|
|
149
|
+
return default_yes
|
|
150
|
+
return raw.strip().lower() in ("y", "yes")
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def menu(title, options):
|
|
154
|
+
"""Print a numbered menu and return a 0-based index, or None to close it.
|
|
155
|
+
|
|
156
|
+
None means the user chose [0], typed q/quit/exit, submitted an empty line, or
|
|
157
|
+
pressed Ctrl-C; every caller treats it as "close this menu level".
|
|
158
|
+
|
|
159
|
+
Args:
|
|
160
|
+
title: Heading printed above the entries.
|
|
161
|
+
options: (label, description) tuples or plain strings.
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
0-based index of the chosen option, or None to close the menu.
|
|
165
|
+
"""
|
|
166
|
+
print(file=sys.stderr)
|
|
167
|
+
rule()
|
|
168
|
+
print(_c(BOLD, f" {title}"), file=sys.stderr)
|
|
169
|
+
width = max((len(o[0]) if isinstance(o, tuple) else len(o)) for o in options)
|
|
170
|
+
for i, o in enumerate(options, 1):
|
|
171
|
+
if isinstance(o, tuple):
|
|
172
|
+
label, desc = o
|
|
173
|
+
print(f" {_c(BLUE, f'[{i}]')} {label.ljust(width)} {_c(DIM, desc)}", file=sys.stderr)
|
|
174
|
+
else:
|
|
175
|
+
print(f" {_c(BLUE, f'[{i}]')} {o}", file=sys.stderr)
|
|
176
|
+
print(f" {_c(BLUE, '[0]')} Back", file=sys.stderr)
|
|
177
|
+
while True:
|
|
178
|
+
raw = ask("Choose")
|
|
179
|
+
if raw in (None, "0", "q", "quit", "exit"):
|
|
180
|
+
return None
|
|
181
|
+
if raw.isdigit() and 1 <= int(raw) <= len(options):
|
|
182
|
+
return int(raw) - 1
|
|
183
|
+
warn("invalid choice")
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def run_action(action, *args, **kwargs):
|
|
187
|
+
"""Run a menu action so a failure returns to the menu instead of the shell.
|
|
188
|
+
|
|
189
|
+
Args:
|
|
190
|
+
action: Callable invoked with *args/**kwargs.
|
|
191
|
+
|
|
192
|
+
Returns:
|
|
193
|
+
Whatever `action` returns, or None if it failed or was interrupted.
|
|
194
|
+
"""
|
|
195
|
+
try:
|
|
196
|
+
return action(*args, **kwargs)
|
|
197
|
+
except SystemExit as e:
|
|
198
|
+
if isinstance(e.code, str):
|
|
199
|
+
error(e.code)
|
|
200
|
+
except KeyboardInterrupt:
|
|
201
|
+
warn("interrupted")
|
|
202
|
+
return None
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Show every worker in one terminal menu and open the chosen worker's own menu with the console's folders, models and keys.
|
|
2
|
+
`pepa-console --cli` starts it.
|
|
3
|
+
"""
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
from cli import ui
|
|
8
|
+
from registry import APPS
|
|
9
|
+
from runner import job_environment
|
|
10
|
+
|
|
11
|
+
CONSOLE = "pepa-console"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def open_worker(app):
|
|
15
|
+
"""Run one worker's own menu in its folder, as its own command would, and come back when it closes."""
|
|
16
|
+
ui.info(f"Opening {app.name}; an empty line closes its menu and brings you back here.")
|
|
17
|
+
subprocess.run([sys.executable, "manage.py"], cwd=app.path, env=job_environment(app.name))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def show():
|
|
21
|
+
"""The menu of workers, shown again after each one closes, until an empty line closes it."""
|
|
22
|
+
workers = [app for app in APPS if app.name != CONSOLE and app.path.exists()]
|
|
23
|
+
ui.header("pepa-workers")
|
|
24
|
+
ui.info("Each worker is also its own command, such as pepa-sum. The web console is pepa-console.")
|
|
25
|
+
while True:
|
|
26
|
+
choice = ui.menu("Choose a worker", [(app.name, app.blurb) for app in workers])
|
|
27
|
+
if choice is None:
|
|
28
|
+
return 0
|
|
29
|
+
ui.run_action(open_worker, workers[choice])
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Getting started
|
|
2
|
+
|
|
3
|
+
pepa is a set of workers for academic reading and writing. Each one does one job: prepare PDFs,
|
|
4
|
+
summarise papers, search what has been read, map a field, ask about the literature, or outline an
|
|
5
|
+
argument. Each works on its own, so use only the ones you need.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
With Python 3.10 or newer installed, open PowerShell (a terminal on macOS or Linux) and run:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
pip install pepa-workers
|
|
13
|
+
pepa-console
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The console opens in your browser. Closing the PowerShell window stops it, and `pepa-console`
|
|
17
|
+
starts it again.
|
|
18
|
+
|
|
19
|
+
## Where your files live
|
|
20
|
+
|
|
21
|
+
Every worker keeps its files in one project folder, `pepa-workers` in your home folder. The
|
|
22
|
+
**Folders** page shows each worker's folders and changes any of them, including the project
|
|
23
|
+
folder itself. A folder of papers you already have can be linked there; pepa only ever reads it.
|
|
24
|
+
|
|
25
|
+
## Keys
|
|
26
|
+
|
|
27
|
+
Summaries, chats, notes, outlines and checks call a language model: Claude or OpenAI, which need an
|
|
28
|
+
API key, or a model on this computer, which needs none. Preparing PDFs
|
|
29
|
+
and searching call no model. Choose the model on the **Models** page; a key added there reaches
|
|
30
|
+
every worker that needs it. Steps marked **API costs** are billed to that key and show their cost
|
|
31
|
+
before they run.
|
|
32
|
+
|
|
33
|
+
## Models
|
|
34
|
+
|
|
35
|
+
Every worker writes with the model chosen on the **Models** page: Claude, OpenAI, or one running
|
|
36
|
+
on this computer. [Models](models.md) explains the choices.
|
|
37
|
+
|
|
38
|
+
## A first run
|
|
39
|
+
|
|
40
|
+
1. On **Library**, drop some PDFs on the page, or press **Copy PDFs in** and choose them.
|
|
41
|
+
2. **Process items** opens for the new papers. Press **Run**: they are prepared, summarised and
|
|
42
|
+
indexed for search, and each paper shows its progress.
|
|
43
|
+
3. Click a finished paper's name to read its brief, its paragraph rundown and its quotes.
|
|
44
|
+
4. **Search** finds papers by their words, their meaning or a whole text of yours, in the whole
|
|
45
|
+
library or in one list.
|
|
46
|
+
5. **Map** sorts the papers into themes, by who cites whom, or both, and draws each paper as a dot
|
|
47
|
+
beside the papers closest to it.
|
|
48
|
+
6. **Ask** chats with papers you pick, puts a question to the literature (the closest papers, a
|
|
49
|
+
list, or a theme of a map), or works on your own text: notes on your points, an outline of your
|
|
50
|
+
idea, or a check of your draft.
|
|
51
|
+
|
|
52
|
+
Wherever papers are listed, tick them (Shift-click ticks a range) to ask about them, add them to a
|
|
53
|
+
list or find papers like them. Every chat, set of notes, map, outline and check can be renamed or
|
|
54
|
+
deleted from its page, and so can an item from the Library; Undo brings it back. Every run shows in
|
|
55
|
+
the chip at the bottom left, on every page.
|
|
56
|
+
|
|
57
|
+
## The workers
|
|
58
|
+
|
|
59
|
+
| Worker | What it does |
|
|
60
|
+
|---|---|
|
|
61
|
+
| [pepa-prep](pepa-prep.md) | Turns PDFs into clean text |
|
|
62
|
+
| [pepa-sum](pepa-sum.md) | Summarises each paper: a brief, a paragraph rundown and checked quotes |
|
|
63
|
+
| [pepa-read](pepa-read.md) | Searches everything prepared and summarised; keeps literature lists |
|
|
64
|
+
| [pepa-review](pepa-review.md) | Maps a field into themes, answers questions about it, gathers literature notes, finds gaps in a text, looks up citations |
|
|
65
|
+
| [pepa-plan](pepa-plan.md) | Outlines a paper idea paragraph by paragraph |
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Models
|
|
2
|
+
|
|
3
|
+
Summaries, chats, notes, outlines and checks are written by a language model from Anthropic (Claude),
|
|
4
|
+
OpenAI, or a server running on this computer.
|
|
5
|
+
|
|
6
|
+
## Choosing a model
|
|
7
|
+
|
|
8
|
+
1. On **Models**, paste the key for Anthropic or OpenAI, or give the address of the server on this
|
|
9
|
+
computer.
|
|
10
|
+
2. **Show models** lists the models that key or server offers. Tick the ones to offer, then **Save**.
|
|
11
|
+
3. Every form that calls a model has a **Model** menu of the ticked models, and remembers the last
|
|
12
|
+
choice. Pick a different one for any run, a follow-up question included.
|
|
13
|
+
|
|
14
|
+
pepa-review and pepa-plan use two models in some runs: one for the many short steps, such as
|
|
15
|
+
labelling every paragraph, and one for the writing.
|
|
16
|
+
|
|
17
|
+
Batch mode halves the price of a large run. It works with Claude and with OpenAI; a model on
|
|
18
|
+
another server runs without it.
|
|
19
|
+
|
|
20
|
+
## A model on this computer
|
|
21
|
+
|
|
22
|
+
With [Ollama](https://ollama.com) installed, `ollama pull qwen3:8b` fetches a model. Its address is
|
|
23
|
+
`http://localhost:11434/v1` and its name `qwen3:8b`, and nothing leaves the computer.
|
|
24
|
+
|
|
25
|
+
pepa-sum sends each paper whole when it fits the model's context window, the number given on
|
|
26
|
+
**Models** as "Longest text its models read" (usually 32,768 tokens). Ollama drops whatever goes past
|
|
27
|
+
its own context length, so start it with `OLLAMA_CONTEXT_LENGTH` set to the same number.
|
|
28
|
+
|
|
29
|
+
## Thinking
|
|
30
|
+
|
|
31
|
+
Some models think before they answer. Each worker's page under **Settings › Workers** has "How much the model thinks":
|
|
32
|
+
as little as the model allows, its usual amount, or more. A model on this computer never thinks.
|
|
33
|
+
|
|
34
|
+
## Embeddings
|
|
35
|
+
|
|
36
|
+
pepa-review's index compares texts by their embeddings, a list of numbers for each text. It uses
|
|
37
|
+
Gemini unless the Models page names OpenAI or a model on this
|
|
38
|
+
computer (`ollama pull bge-m3`). A hosted provider's key goes in the **Embeddings** card on **Models**.
|
|
39
|
+
|
|
40
|
+
The index records the model that built it and refuses any other. After a change, rebuild it: run
|
|
41
|
+
pepa-review's index command with **Rebuild from scratch** ticked.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# pepa-plan
|
|
2
|
+
|
|
3
|
+
Turns a paper idea into an outline, paragraph by paragraph. It needs a model, chosen on the **Models** page.
|
|
4
|
+
|
|
5
|
+
## How it works
|
|
6
|
+
|
|
7
|
+
A language model plans the idea paragraph by paragraph and labels each paragraph with the move it
|
|
8
|
+
makes (background, method, finding and so on). The structure is the model's own, or follows a
|
|
9
|
+
template written by hand.
|
|
10
|
+
|
|
11
|
+
## Use it
|
|
12
|
+
|
|
13
|
+
1. On **Ask**, choose **Work on your own text**, then **An outline of your idea**. Write or drop your
|
|
14
|
+
idea, choose notes or a chat to lean on, and a structure: **Let the model choose** or **Follow a
|
|
15
|
+
template**. Notes and chats also offer **Outline an argument** beside them, with themselves
|
|
16
|
+
filled in.
|
|
17
|
+
2. Open an outline to change it with a sentence of feedback; the changed outline is kept beside the
|
|
18
|
+
first.
|
|
19
|
+
3. **A check of your draft**, with **The argument** ticked, says how an idea or a text builds its
|
|
20
|
+
argument.
|
|
21
|
+
|
|
22
|
+
On its app page, **outline**, **review** and **template** do the same from files in
|
|
23
|
+
**Ideas and drafts**.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# pepa-prep
|
|
2
|
+
|
|
3
|
+
Turns PDFs into clean text that the other workers can read: papers and scanned volumes. It runs on
|
|
4
|
+
your computer and calls no model.
|
|
5
|
+
|
|
6
|
+
## How it works
|
|
7
|
+
|
|
8
|
+
Each PDF becomes one text file. A scan is read with Tesseract first. Headers, footers, page numbers
|
|
9
|
+
and reference lists are removed. Every document is also kept whole, every page included, in the
|
|
10
|
+
**complete** folder under **Prepared text**.
|
|
11
|
+
|
|
12
|
+
## Use it
|
|
13
|
+
|
|
14
|
+
1. Put PDFs in its **PDFs to prepare** folder: **Copy files here** on its page, or **Copy PDFs in**
|
|
15
|
+
on **Library**.
|
|
16
|
+
2. Run **extract**.
|
|
17
|
+
3. The results are under **Prepared text**. Open any file to read it.
|
|
18
|
+
|
|
19
|
+
Scanned PDFs need Tesseract. On Windows, install it with `winget install UB-Mannheim.TesseractOCR`.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# pepa-read
|
|
2
|
+
|
|
3
|
+
Searches every paper pepa-prep has prepared and pepa-sum has summarised, and keeps literature
|
|
4
|
+
lists for pepa-review. Nothing leaves your computer.
|
|
5
|
+
|
|
6
|
+
## How it works
|
|
7
|
+
|
|
8
|
+
pepa-read builds a search index of titles, authors and every section of each brief, and ranks
|
|
9
|
+
matches by relevance. A search can target one section: `methods:interviews author:smith` finds
|
|
10
|
+
papers by Smith that used interviews. Plain words also search each paper's prepared text, so a
|
|
11
|
+
paper without a brief is found too; it follows the papers whose brief matches.
|
|
12
|
+
|
|
13
|
+
## Use it
|
|
14
|
+
|
|
15
|
+
1. Run **index** after new papers are prepared or summarised. **Process papers** on **Library** does this too.
|
|
16
|
+
2. Open **Search** and search.
|
|
17
|
+
3. Open a result to read it, or tick results and add them to a literature list. pepa-review reads the same lists.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# pepa-review
|
|
2
|
+
|
|
3
|
+
Works with the papers pepa-sum has summarised: finds papers by meaning, maps how a field falls into
|
|
4
|
+
themes, answers questions about chosen papers, gathers notes on what they say about your points,
|
|
5
|
+
finds work a text is missing, and looks up each paper's citation details. It needs a model, and an
|
|
6
|
+
embedding model for the index, both chosen on **Models**.
|
|
7
|
+
|
|
8
|
+
## How it works
|
|
9
|
+
|
|
10
|
+
Every brief is turned into a vector that captures its meaning, and stored in an index. A question
|
|
11
|
+
about papers you pick reads those papers, every one of them, in the parts you tick: the brief, the
|
|
12
|
+
paragraph rundown, the quotes or the full text. Only a question to the closest papers in the
|
|
13
|
+
library searches the index for them. A language model then answers, writes the notes, names each theme
|
|
14
|
+
or explains each gap, and cites each paper by its authors and year. Every result is kept, and shows
|
|
15
|
+
its cost and size before it runs.
|
|
16
|
+
|
|
17
|
+
## Use it
|
|
18
|
+
|
|
19
|
+
1. **Update review index** on **Library** builds the index; run it again after new papers are
|
|
20
|
+
summarised.
|
|
21
|
+
2. **Search**, by meaning or by a whole text of yours, lists the closest papers.
|
|
22
|
+
3. **Map** sorts every paper, or one list's papers, into themes, by who cites whom, or by both, and
|
|
23
|
+
draws each paper as a dot. Open a theme for what it discusses, its papers and the themes beside
|
|
24
|
+
it; a theme of six or more papers can be mapped in detail.
|
|
25
|
+
4. **Ask** works three ways. **Chat with papers** talks to papers you pick by name or from a list;
|
|
26
|
+
more can be added during the chat. **Ask the literature** puts a question to the closest papers
|
|
27
|
+
in the library, a list, or a theme of a map. **Work on your own text** writes notes with one
|
|
28
|
+
section per point you give. Tick what is read of each paper; when it is too much for the model,
|
|
29
|
+
the size line says so, and **Read only the passages closest to each question** keeps the
|
|
30
|
+
passages that share the most words with it. Follow-up questions can change the papers and the
|
|
31
|
+
model. **Ask** on any paper's row or page starts a chat with that paper.
|
|
32
|
+
5. **Look up citations** on **Library** asks only the places you tick, in the order you set: your
|
|
33
|
+
Zotero library (the running app, or an export kept in **Settings › References**), the DOI printed
|
|
34
|
+
in the paper, a Crossref title search, OpenAlex by DOI, OpenCitations, and a paid OpenAlex title search with its
|
|
35
|
+
key. Who cites whom comes from OpenAlex and OpenCitations, where ticked. The step shows whether Zotero is connected before it runs. A service that reaches its limit
|
|
36
|
+
is skipped for the rest of the run and named in the log. The Library's **Cited by** column sorts
|
|
37
|
+
papers by how often they are cited. **Export references**, wherever papers are listed, writes
|
|
38
|
+
BibTeX unless **Settings › References** names RIS or a formatted list in APA style.
|
|
39
|
+
6. **A check of your draft**, under **Ask**, lists the papers in the library a draft should engage.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# pepa-sum
|
|
2
|
+
|
|
3
|
+
Summarises each paper into three documents: a **brief** with the same fields for every paper, a
|
|
4
|
+
**rundown** of the paper paragraph by paragraph, and **quotes** checked word for word against the
|
|
5
|
+
source. It needs a model, chosen on the **Models** page.
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
The paper is read on your computer, its reference list removed, and its key phrases, names and
|
|
10
|
+
claims picked out. A language model writes the brief and the rundown from that, and chooses quotes
|
|
11
|
+
from passages found locally. A quote that does not appear in the paper exactly is dropped.
|
|
12
|
+
|
|
13
|
+
Every brief has the same fields: question and context, empirical context, literature drawn on,
|
|
14
|
+
methods, arguments, key conclusions, and discussion items.
|
|
15
|
+
|
|
16
|
+
## Use it
|
|
17
|
+
|
|
18
|
+
1. **Papers to summarise** is pepa-prep's prepared text, so prepare the PDFs first. **Folders** can
|
|
19
|
+
point it at any folder of PDFs, markdown or text instead.
|
|
20
|
+
2. Run **summarize**. Papers already summarised are skipped unless **force** is ticked or their text has changed since.
|
|
21
|
+
3. Open a file under **Summaries**. The buttons above it switch between the paper's brief,
|
|
22
|
+
rundown, quotes and prepared text.
|
|
23
|
+
|
|
24
|
+
**clean** lists summaries that failed, so they can be redone.
|
|
25
|
+
|
|
26
|
+
In batch mode, at about half the price, the papers go to Anthropic or OpenAI as one batch and the run ends.
|
|
27
|
+
**batches** writes the summaries once the provider has answered, which can take up to a day; on
|
|
28
|
+
**Library** this happens by itself.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Orchestrate the pepa-* child apps from one place. No arguments opens the web console, --cli a terminal menu of every worker.
|
|
3
|
+
"""
|
|
4
|
+
import argparse
|
|
5
|
+
import json
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from cli import ui
|
|
10
|
+
from registry import APPS, KIND_SYMBOL, get_command
|
|
11
|
+
|
|
12
|
+
INSTALLED = Path(__file__).resolve().parent.parent.name == "apps"
|
|
13
|
+
COMMAND = "pepa-console" if INSTALLED else "python manage.py"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def cmd_status(as_json: bool = False) -> int:
|
|
17
|
+
if as_json:
|
|
18
|
+
apps = []
|
|
19
|
+
for app in APPS:
|
|
20
|
+
commands = [{"name": c.name, "kind": c.kind, "help": c.help} for c in app.commands]
|
|
21
|
+
apps.append({"name": app.name, "blurb": app.blurb, "path": str(app.path), "commands": commands})
|
|
22
|
+
print(json.dumps({"apps": apps}))
|
|
23
|
+
return 0
|
|
24
|
+
for app in APPS:
|
|
25
|
+
print(f"{app.name} : {app.blurb}")
|
|
26
|
+
for c in app.commands:
|
|
27
|
+
mark = KIND_SYMBOL[c.kind]
|
|
28
|
+
flags = " ".join(c.default_flags)
|
|
29
|
+
tail = f" ({flags})" if flags else ""
|
|
30
|
+
print(f" {mark} {c.name:<14} {c.kind:<11} {c.help}{tail}")
|
|
31
|
+
print()
|
|
32
|
+
return 0
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def cmd_config(as_json: bool = False) -> int:
|
|
36
|
+
from registry import ROOT
|
|
37
|
+
interactive = 0
|
|
38
|
+
for app in APPS:
|
|
39
|
+
for command in app.commands:
|
|
40
|
+
if command.kind in ("interactive", "terminal"):
|
|
41
|
+
interactive += 1
|
|
42
|
+
if as_json:
|
|
43
|
+
print(json.dumps({"root": str(ROOT), "apps": len(APPS), "commands": sum(len(a.commands) for a in APPS), "interactive": interactive}))
|
|
44
|
+
return 0
|
|
45
|
+
print(f"root {ROOT}")
|
|
46
|
+
print(f"apps {len(APPS)}")
|
|
47
|
+
print(f"commands {sum(len(a.commands) for a in APPS)}")
|
|
48
|
+
print(f"interactive {interactive} (run in a terminal)")
|
|
49
|
+
return 0
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def cmd_install() -> int:
|
|
53
|
+
ui.step("Checking pepa-console")
|
|
54
|
+
missing = []
|
|
55
|
+
for module in ("flask",):
|
|
56
|
+
try:
|
|
57
|
+
__import__(module)
|
|
58
|
+
ui.ok(f"{module} is installed")
|
|
59
|
+
except ImportError:
|
|
60
|
+
missing.append(module)
|
|
61
|
+
if missing:
|
|
62
|
+
ui.error(f"{', '.join(missing)} missing, run: pip install -r requirements.txt")
|
|
63
|
+
return 1
|
|
64
|
+
for a in APPS:
|
|
65
|
+
found = a.path.exists()
|
|
66
|
+
(ui.ok if found else ui.warn)(f"{a.name} {'found' if found else 'not found'}")
|
|
67
|
+
return 0
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def cmd_cli() -> int:
|
|
71
|
+
if not sys.stdin.isatty():
|
|
72
|
+
raise SystemExit(f"The menu of workers needs a terminal; run a worker's own command instead, see: {COMMAND} status")
|
|
73
|
+
from cli.workers_menu import show
|
|
74
|
+
return show()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def cmd_environment(app_name: str) -> int:
|
|
78
|
+
"""Print, as JSON, the variables the console gives a job of this app; each app's own command reads them."""
|
|
79
|
+
from registry import get_app
|
|
80
|
+
if get_app(app_name) is None:
|
|
81
|
+
raise SystemExit(f"unknown app: {app_name}, see: {COMMAND} status")
|
|
82
|
+
from runner import chosen_environment
|
|
83
|
+
from web import models
|
|
84
|
+
print(json.dumps(models.keys_for_their_servers(app_name, chosen_environment(app_name))))
|
|
85
|
+
return 0
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def cmd_run(app: str, command: str, extra: list[str]) -> int:
|
|
89
|
+
if get_command(app, command) is None:
|
|
90
|
+
raise SystemExit(f"unknown command: {app} {command}, see: {COMMAND} status")
|
|
91
|
+
from runner import run_blocking
|
|
92
|
+
return run_blocking(app, command, extra)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def main() -> int:
|
|
96
|
+
parser = argparse.ArgumentParser(prog=COMMAND, description="Orchestrate the pepa-* child apps.")
|
|
97
|
+
parser.add_argument("--cli", action="store_true", help="Show every worker in one terminal menu and open the one you choose")
|
|
98
|
+
sub = parser.add_subparsers(dest="command")
|
|
99
|
+
|
|
100
|
+
r = sub.add_parser("run", help="Run a child command headlessly and stream its output")
|
|
101
|
+
r.add_argument("app", help="Child app, e.g. pepa-sum")
|
|
102
|
+
r.add_argument("cmd", help="Subcommand, e.g. config")
|
|
103
|
+
r.add_argument("extra", nargs=argparse.REMAINDER, help="Extra flags passed to the child")
|
|
104
|
+
|
|
105
|
+
w = sub.add_parser("web", help="Open the web console in the browser (the default)")
|
|
106
|
+
w.add_argument("--port", type=int, default=None, metavar="N", help="Port (default: 5190)")
|
|
107
|
+
w.add_argument("--no-browser", action="store_true", help="Do not open a browser tab")
|
|
108
|
+
|
|
109
|
+
st = sub.add_parser("status", help="List apps and their commands")
|
|
110
|
+
st.add_argument("--json", action="store_true", help="Print the apps and commands as one JSON line")
|
|
111
|
+
cf = sub.add_parser("config", help="Show effective configuration")
|
|
112
|
+
cf.add_argument("--json", action="store_true", help="Print the configuration as one JSON line")
|
|
113
|
+
sub.add_parser("install", help="Check dependencies and discover apps")
|
|
114
|
+
en = sub.add_parser("environment", help="Print as JSON the folders, models, settings and keys chosen here for one app, keys included")
|
|
115
|
+
en.add_argument("app", help="Child app, e.g. pepa-sum")
|
|
116
|
+
|
|
117
|
+
args = parser.parse_args()
|
|
118
|
+
|
|
119
|
+
if args.cli:
|
|
120
|
+
return cmd_cli()
|
|
121
|
+
if args.command is None:
|
|
122
|
+
from web.app import run as run_web
|
|
123
|
+
run_web(None, open_browser=True)
|
|
124
|
+
return 0
|
|
125
|
+
if args.command == "web":
|
|
126
|
+
from web.app import run as run_web
|
|
127
|
+
run_web(args.port, open_browser=not args.no_browser)
|
|
128
|
+
return 0
|
|
129
|
+
if args.command == "status":
|
|
130
|
+
return cmd_status(as_json=args.json)
|
|
131
|
+
if args.command == "config":
|
|
132
|
+
return cmd_config(as_json=args.json)
|
|
133
|
+
if args.command == "install":
|
|
134
|
+
return cmd_install()
|
|
135
|
+
if args.command == "run":
|
|
136
|
+
return cmd_run(args.app, args.cmd, args.extra)
|
|
137
|
+
if args.command == "environment":
|
|
138
|
+
return cmd_environment(args.app)
|
|
139
|
+
return 0
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
if __name__ == "__main__":
|
|
143
|
+
try:
|
|
144
|
+
sys.exit(main() or 0)
|
|
145
|
+
except KeyboardInterrupt:
|
|
146
|
+
print("\n\n Interrupted.", file=sys.stderr)
|
|
147
|
+
sys.exit(0)
|
|
148
|
+
except SystemExit as e:
|
|
149
|
+
if isinstance(e.code, str):
|
|
150
|
+
ui.error(e.code)
|
|
151
|
+
sys.exit(1)
|
|
152
|
+
raise
|