Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 47b6cf6

Browse filesBrowse files
authored
AI revision workflow based on GPT-3 models
merges #484
1 parent 7b10343 commit 47b6cf6
Copy full SHA for 47b6cf6

3 files changed

+101-1Lines changed: 101 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/ai-revision.yaml‎

Copy file name to clipboard
+66Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: ai-revision
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
branch:
6+
description: 'Branch to revise'
7+
required: true
8+
type: string
9+
default: 'main'
10+
file_names:
11+
description: 'File names to revise'
12+
required: false
13+
type: string
14+
default: ''
15+
model:
16+
description: 'Language model'
17+
required: true
18+
type: string
19+
default: 'text-davinci-003'
20+
branch_name:
21+
description: 'Output branch'
22+
required: true
23+
type: string
24+
default: 'ai-revision-davinci'
25+
26+
jobs:
27+
ai-revise:
28+
name: AI Revise
29+
runs-on: ubuntu-latest
30+
defaults:
31+
run:
32+
shell: bash --login {0}
33+
steps:
34+
- name: Checkout Repo
35+
uses: actions/checkout@v3
36+
with:
37+
ref: ${{ inputs.branch }}
38+
- name: Install environment
39+
uses: actions/setup-python@v4
40+
with:
41+
python-version: '3.11'
42+
- name: Install Manubot AI revision dependencies
43+
run: |
44+
# install using the same URL used for manubot in build/environment.yml
45+
manubot_line=$(grep "github.com/manubot/manubot" build/environment.yml)
46+
manubot_url=$(echo "$manubot_line" | awk -F"- " '{print $2}')
47+
48+
pip install ${manubot_url}#egg=manubot[ai-rev]
49+
- name: Revise manuscript
50+
env:
51+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
52+
AI_EDITOR_LANGUAGE_MODEL: ${{ inputs.model }}
53+
AI_EDITOR_FILENAMES_TO_REVISE: ${{ inputs.file_names }}
54+
# More variables can be specified to control the behavior of the model:
55+
# https://github.com/manubot/manubot-ai-editor/blob/main/libs/manubot_ai_editor/env_vars.py
56+
run: manubot ai-revision --content-directory content/
57+
- name: Create Pull Request
58+
uses: peter-evans/create-pull-request@v4
59+
with:
60+
commit-message: 'revise using AI model\n\nUsing the OpenAI model ${{ inputs.model }}'
61+
title: 'AI-based revision using ${{ inputs.model }}'
62+
author: OpenAI model ${{ inputs.model }} <support@openai.com>
63+
add-paths: |
64+
content/*.md
65+
branch: ${{ inputs.branch_name }}
66+
draft: true
Collapse file

‎USAGE.md‎

Copy file name to clipboardExpand all lines: USAGE.md
+34Lines changed: 34 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,32 @@ Potential spelling errors will be printed in the continuous integration log alon
329329
Words in `build/assets/custom-dictionary.txt` are ignored during spellchecking.
330330
Spellchecking is currently only supported for English language manuscripts.
331331

332+
## AI-assisted authoring
333+
334+
The workflow [`ai-revision`](.github/workflows/ai-revision.yaml) is available to assist authors in writing their manuscripts.
335+
It uses large language models to revise the manuscript text, fixing spelling and grammar errors, and improving the sentence structure and the writing style with section-specific prompts.
336+
It is manually triggered by the user (it never runs automatically), and it generates a pull request with suggested revisions.
337+
Then the user can review these changes and merge the pull request if they are acceptable.
338+
More information about this tool is available in [this manuscript](https://greenelab.github.io/manubot-gpt-manuscript/).
339+
340+
You need to change your repository settings to 1) provide a secret with name `OPENAI_API_KEY` containing your OpenAI API token, and 2) allow workflows to create pull requests.
341+
For 1), go to the settings page and, within "Secrets and variables," select "Actions."
342+
Next, create a repository secret with the name `OPENAI_API_KEY` and the value of the API token (you can also do this using "Organization secrets" if available).
343+
For 2), go to "Actions", "General", "Workflow permissions", and activate the checkbox "Allow GitHub Actions to create and approve pull requests."
344+
345+
By default, the tool uses the model `text-davinci-003`.
346+
Make sure to check the [pricing](https://openai.com/api/pricing/) of the OpenAI API.
347+
With $0.02 per 1000 tokens using the most powerful AI models, the cost for a revision of a standard manuscript (around 35 paragraphs) should be around $0.50.
348+
The workflow allows specifying the branch and file names (in the `content/` directory) to revise, the language model to use, and the output branch name.
349+
Internally, the workflow uses the tool [Manubot AI Editor](https://github.com/manubot/manubot-ai-editor) to revise the manuscript.
350+
For more advanced users, the behavior of the Manubot AI Editor or the parameters used for the language model can be changed using environment variables.
351+
These variables can be changed in the workflow file (`ai-revision.yaml`).
352+
353+
It is important to note that using language models in scientific writing is a matter of debate among researchers and journal editors.
354+
Therefore, it's advisable to follow the guidelines that journals and the research community propose.
355+
For example, the *Nature* journal has published [rules about using language models in scholarly writing](https://www.nature.com/articles/d41586-023-00191-1), such as not listing the tools as authors and documenting how they were used.
356+
Since a Manubot-based manuscript uses GitHub, one approach consists of linking the AI-generated pull request, which will transparently show the changes suggested by the AI tool.
357+
332358
## Manubot feedback
333359

334360
If you experience any issues with the Manubot or would like to contribute to its source code, please visit [`manubot/manubot`](https://github.com/manubot/manubot) or [`manubot/rootstock`](https://github.com/manubot/rootstock).
@@ -344,6 +370,14 @@ DOI: [10.1371/journal.pcbi.1007128](https://doi.org/10.1371/journal.pcbi.1007128
344370

345371
The Manubot version of this manuscript is available at <https://greenelab.github.io/meta-review/>.
346372

373+
To cite the Manubot AI Editor or for more information on its design, see `@doi:10.1101/2023.01.21.525030`:
374+
375+
> **A publishing infrastructure for AI-assisted academic authoring**<br>
376+
Milton Pividori, Casey S. Greene<br>
377+
*bioRxiv* (2023) <https://doi.org/grpf8m><br>
378+
DOI: [10.1101/2023.01.21.525030](https://doi.org/10.1101/2023.01.21.525030)
379+
380+
347381
## Acknowledgments
348382

349383
We would like to thank the contributors and funders whose support makes the Manubot project possible.
Collapse file

‎build/environment.yml‎

Copy file name to clipboardExpand all lines: build/environment.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020
- pip:
2121
- cffi==1.15.0
2222
- errorhandler==2.0.1
23-
- git+https://github.com/manubot/manubot@82f25cb8d698a12d69e533686867a8a4afd35c4c
23+
- git+https://github.com/manubot/manubot@d4242ffa4194e4a13a68c5f6466feff559d3f9d5
2424
- isbnlib==3.10.10
2525
- opentimestamps-client==0.7.1
2626
- opentimestamps==0.4.3

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.