Package: gptauthor
GPT AuthorUnleash your storytelling genius: GPTAuthor is an easy to use command-line tool for writing long form, multi-chapter stories given a story prompt.How It WorksHuman written story description:You describe your story outline, writing style, characters etc in a story prompt (see an example).Run GPTAuthor:As described below, choosing model, temperature, and number of chapters to write.AI generated synopsis:Given the story prompt, GPTAuthor uses ChatGPT to automatically turn this into a synopsis that has chapter summaries for the number of chapters you specify.Human review of synopsis:You are given a chance to review the synopsis and (optionally) make changes, only proceeding to the next step if/when you are happy with it. If it isn't what you want, you can generate another before proceeding.AI generated story:Each chapter is iteratively written by ChatGPT given the common synopsis and previous chapter. (This approach is to keep token count within limits).
The full story is written as Markdown and HTML to an./_output/folder for your reading pleasure.Example GPTAuthor Story OutputsThe Nov 2023 OpenAI leadership crisis-
"In the heart of San Francisco, nestled among the city's tech giants and start-up hopefuls, stood the OpenAI office. A hive of activity, it buzzed with the sound of keyboards clacking, coffee machines hissing, and the occasional drone of a philosophical debate about whether AI could develop a taste for late-night taco runs. It was a typical day, or so everyone thought. Sam Altman, the CEO of OpenAI, was in his office, a space that looked more like a teenager's bedroom than the office of a tech mogul, with posters of space exploration and vintage computers adorning the walls. He was in the middle of explaining to a rubber duck on his desk the intricacies of AI alignment, a method he found surprisingly effective, when his phone buzzed with an email notification."continue reading...Echoes of Atlantis(based on ablogpost) - "In the dimly lit halls of the British Museum, Aria Seaborne's heart raced with anticipation. Her fingers, delicate yet steady, brushed against the surface of an ancient artifact that had long eluded understanding. It was a curious object, seemingly part of a larger mechanism, its origins shrouded in mystery and its purpose lost to time. Aria, with her keen eye for the arcane, noticed an almost imperceptible seam along its side. With a gentle nudge, the artifact sprang open, revealing a compartment that housed a parchment, brittle with age."continue reading...InstallationYou can installgptauthorusing pip, ideally into a Pythonvirtual environment.pipinstallgptauthorAlternatively, checkoutan example notebookthat uses gptauthor and you can run directly in Google Colab.Run GPTAuthorExample Usage and API KeyThis example reads the story prompt from the exampleprompts-openai-drama.yamlfile and writes 3 chapters using thegpt-3.5-turbomodel with a temperature of0.1. Note that you will need to locally set yourOpenAI API Keyenvironment variable.It's recommended to experiment using the defaultgpt-3.5-turbomodel as generating a few chapters will only cost a couple cents (as of Jan 2024). Once you are happy with the results you can try one of the more expensivegpt-4models which will produce better quality results, be slower, and cost more to run. See theOpenAI pricing pagefor more details.Set your OpenAI API Key on MacOS/Linux:exportOPENAI_API_KEY=sk-<yourkey>Or, set your OpenAI API Key on Windows:setxOPENAI_API_KEY"sk-<yourkey>"Then run the gptauthor command:gptauthor--storyprompts-openai-drama--total-chapters3--llm-modelgpt-3.5-turbo--llm-temperature0.1Required Arguments--story TEXT: The name of the yaml file defining the story and promptsOptional Arguments--llm-model TEXT: The model name [default: gpt-3.5-turbo]--llm-temperature FLOAT: LLM temperature value (0 to 2, OpenAI default is 1) [default: 1]--llm-top-p FLOAT: LLM top_p probability value (0 to 2, OpenAI default is 1) [default: 1]--llm-use-localhost INTEGER: LLM use localhost:8081 instead of openai [default: 0]--total-chapters INTEGER: Total chapters to write [default: 3]--allow-user-input / --no-allow-user-input: Allow command line user input [default: allow-user-input]--version: Display gptauthor version--help: Show usage helpProduced Output FilesWhile running the app tells your the input paramers, the progress of the writing, and where the output is written to.In progress and final output is written to the./_output/directory, in the sub-folders./_output/<prompt-file-name>/<model-name>/<datetime>-<parameters>-<book-name>/.There are several files, the main output being a Markdown version of the whole book_whole_book.mdand an HTML version of the same_whole_book.html.Creating Your Own Story PromptsThe prompts for creating your own story are defined in a yaml file, for example see:prompts-openai-drama.yaml.Make a copy, fill in your story details and describe the writing style (while retaining the same structure), and run the app in the same folder as your new yaml file.For example, if your yaml prompt file is calledprompts-my-really-great-story.yaml:exportOPENAI_API_KEY=sk-<yourkey>
gptauthor--storyprompts-my-really-great-story--total-chapters5--llm-modelgpt-3.5-turbo--llm-temperature0.1IssuesThe OpenAI API sometimes returns an error, in which case the app will exit. You can restart it and it will continue from where it left off as responses are cached (assuming same arguments).Continuity. Since each chapter only knows about the common synopsis and the previous chapter, there can be issues of continuity between chapters.Not tested on Windows so there could be path issues here.Cost estimation is based on total token but should treat input and output token counts seperately.The use of AI to write stories is a controversial topic. This is a tool to test the capabilities of ChatGPT and should be used responsibly.ContributingContributions are welcome. Please follow these steps:Fork the repository.Create a new branch for your feature or bug fix.Make your changes and commit them.Create a pull request with a description of your changes.Final notesWhile an effort is made to count tokens and estimate OpenAI API costs for each run, they are just estimated and can be wrong. Check your OpenAI billing page to confirm the actual costs.I'm sure there are bugs, please report them on theGithub issues pageHave fun! And please share your results with me if you can (perhaps as a Githubdocumentation issue), I'd love to see them.This project isMITlicensed.