Package: manubot-ai-editor
Manubot AI EditorThis package provides classes and functions for automated, AI-assisted revision of manuscripts written usingManubot.
Check out themanuscriptfor more information.UsageThe Manubot AI Editor can be used from the GitHub repository of a Manubot-based manuscript, from the command line, or from Python code.Manubot-based manuscript repositoryYou first need to follow the steps tosetup a Manubot-based manuscript.
Then, followthese instructionsto setup a workflow in GitHub Actions that will allow you to quickly trigger a job to revise your manuscript.Command lineTo use the tool from the command line, you first need to install Manubot in a Python environment:pipinstall--upgrademanubot[ai-rev]You also need to export an environment variable with the OpenAI's API key:exportOPENAI_API_KEY=<your-api-key>You can also provide other options that will change the behavior of the tool (such as revising certain files only).This filedocuments the list of supported environment variables that can be used.
For example, to change the temperature parameter of OpenAI models, you can export the following environment variable:export AI_EDITOR_TEMPERATURE=0.50Then, within the root directory of your Manubot-based manuscript, run the following commands (IMPORTANT:this will overwrite your original manuscript!):manubotai-revision--content-directorycontent/The tool will revise each paragraph of your manuscript and write back the revised files in the same directory.
Finally, you can select which changes you want to keep or discard.Python APIThere is also a Python API that you can use to revise your manuscript.
In this case, you don't need to also install Manubot but only this package:pipinstall-Umanubot-ai-editorThe Python code below shows how to use the API:importshutilfrompathlibimportPathfrommanubot_ai_editor.editorimportManuscriptEditorfrommanubot_ai_editor.modelsimportGPT3CompletionModel# create a manuscript editor object# here content_dir points to the "content" directory of the Manubot-based# manuscript, where Markdown files (*.md) are locatedme=ManuscriptEditor(content_dir="content",)# create a model to revise the manuscriptmodel=GPT3CompletionModel(title=me.title,keywords=me.keywords,)# create a temporary directory to store the revised manuscriptoutput_folder=(Path("tmp")/"manubot-ai-editor-output").resolve()shutil.rmtree(output_folder,ignore_errors=True)output_folder.mkdir(parents=True,exist_ok=True)# then revise the manuscriptme.revise_manuscript(output_folder,model)# the revised manuscript is now in the folder pointed by `output_folder`# uncomment the following code if you want to write back the revised manuscript to# the content folder# **CAUTION**: this will overwrite the original manuscript# for f in output_folder.glob("*"):#     f.rename(me.content_dir / f.name)## # remove output folder# output_folder.rmdir()Thecli_processfunction inthis filealso provides an example of how to use the API.Current support for large language modelsWe currently support the following OpenAI endpoints:CompletionEditsChatCompletionNote:this endpoint is not fully implemented yet.
The current implementation uses the chat completion endpoint in a similar way as we use the completion endpoint (each paragraph is revised independently in a query).
This is because new models such asgpt-3.5-turboorgpt-4are only available through the chat completion endpoint.