Creating an AI Book Writing Assistant | Dabble.AI #8
The Dabble.AI Project #8 - Exploring autonomous business models
The dabble.ai project is about exploring business models that could be fully automated by artificial intelligence. The first model I’ve been dabbling with is an AI book publishing business. The idea was that AI could be used automate the process of writing, editing, and publishing (on amazon.com) books with very little human involvment. I’ve invested around 90 hours so far and most of that has been on refining a process for using AI to generate books that don’t read like they were AI generated. I feel like I’ve got that figued out - sort of.
In my last post I said I'd outline the process I'm using for generating books with AI. In this post I'll do that. I've also recorded a video that walks through the process. You will find a link to that in this post as well.
The Problem
When I wrote Exploring GPT-3 it took me 11 months and a little over 1,000 hours to complete. But within a matter of months after it was published, the book was out of date. Of course now, AI can write books in literally a matter of minutes. But when you read those books it's clear they were AI generated. So, I'm trying to find a middle ground. I want to use AI to create the content for a book, but I want to be able to ensure it reads and flows like it was written by an experienced human author. I also don't want to write a single sentence or line of code in the process.
The Solution
What I've come up with is a workflow that essentially lets me read and approve/reject, or ask for revisions on everything that is generated - while the book is being created. So, I don't just let the AI just run through and create an entire book in one shot. Instead, I have it create a list of chapters, then I have it create a list of topics for each chapter, then the content for each topic, and so on.
After each step, I have it get my approval before moving on. This way I can ensure the book flows well, is well written, and accurate while it's being created. The best part is, this process provides incredible results without having to write a single sentence or line of code. So, the book is 100% written by AI, but I'm in full control of the final product.
I walk through the entire workflow in the following video. But I'll also outline the process here in text.
Here's an overview of the high-level steps.
Macro Steps
Generate a book overview
Generate a list of chapters
Save the overview and list of chapters to files named overview.yml and chapters.yaml respectively
Make the overview.yml and chapters.yaml file available to the assistant for reference
Generate topics for each chapter
Generate content for each topic
Save the content for each chapter to a file named chapter-#.yaml
Make each chapter available to the assistant for reference
Have the assistant merge the chapters into a single yaml file named {book-name}-{revision}.yaml
Have the assistant use the final yaml file to generate a PDF or some other format for the book
Prerequisites
I've been mostly using OpenAI assistants for this process. But I've also tested it with ChatGPT and Google's Bard and with minor adjustments they both work as well. That said, I prefer using OpenAI assistants. So, to follow this workflow the way I've outlined it, you'll need an OpenAI Platform account. This isn't the same as a ChatGPT account. Again, you could do this using GPTs, but the video walks through how to do it using the OpenAI Platform.
If you don't have a OpenAI Platform account you can sign up here: OpenAI Platform Account.
Creating a new OpenAI assistant
After you've signed up for an OpenAI Platform account, you'll need to create a new assistant. You can do this by selecting the assistants menu item from the left-hand navigation. Then click the "Create Assistant" button.
Assistant Settings
When creating a new assistant, you'll need to provide some basic information about the assistant. I give my assistants a name that is descriptive of the book I'm working on. For example, I named the assistant I'm using for the game theory book, "Game Theory Book Assistant". You can name it whatever you like, it really doesn't matter. What does matter are the settings you choose for the assistant. Especially the instruction.
Instructions
The instructions are where most of the magic happens. They are the starting prompt that provides the assistant with some context and details about what you want it to do. For my workflow, I update the instruction four times. When I first create the assistant, after I've generated the book overview and chapters, after I've generated the content for each chapter, and before I compile the chapters and generate the final output. Below are the instructions I use for each step.
Initial instructions
The first instruction is to generate an overview of the book. After I approve the overview, I'll have the assistant generate a list of chapters. Here are the instructions I'm using for the first step.
You are a book author who is an expert on game theory. You are working on a book named Winning Alone: Game Theory Essentials for Solopreneurs. Your writing style is no-nonsense, direct, and to the point. You write in short sentences and avoid filler words, fluff, and hype. You begin by generating an introduction for the book that is 4000 characters or less. You ask the user if they are happy with the introduction. If they are happy, you write and run code to save the introduction as a file named overview.yaml. If they are not happy, you ask the user for feedback and then generate a new introduction. You continue this process until the user is happy with the introduction.
After the user is happy with the introduction, you generate a list of suggested chapter titles and numbers. You ask the user if they would like to make any modifications. When the user is happy with the chapter list you write and run code to save the list as a file named chapters.yaml.
After I have the overview and chapters, I'll update the assistant's instructions to have it generate topics for each chapter. Before I do that, I'll save the overview and chapters to files named overview.yaml and chapters.yaml respectively. Then I'll make those files available to the assistant for reference. You can do that by uploading the files to the assistant's knowledge base and saving the changes to the assistant.
Instructions to generate the chapter content
After I've saved the overview and chapters to files and made them available to the assistant, I'll update the assistant's instructions to have it generate topics for each chapter. Here are the instructions I'm using for that step.
You are a book author who is an expert on game theory. You are working on a book named Winning Alone: Game Theory Essentials for Solopreneurs. Your writing style is no-nonsense, direct, and to the point. You write in short sentences and avoid filler words, fluff, and hype. You get a list of the book chapters from your knowledge base. Then you ask the user for the chapter they'd like to work on. After the user provide a chapter number you generate a numbered list of topics for the chapter using your knowledge base to get the chapter number and title. You ask the user to confirm the topics are acceptable or to suggest changes. After the user is happy with the topic list you ask the user if they'd like to start generating content for each topic. After generating the content for topic, you make sure the user is happy with the topic content before moving on to the next topic. When you're done with the content for all the topics, you write and run code to save the content for the chapter as a file named chapter-#.yaml.
After each chapter's content is generated and saved to a file, I'll make the file available to the assistant for reference. When I'm done with all the chapters, I'll update the assistant's instructions to have it merge the chapters into a single yaml file named {book-name}-{revision}.yaml.
Instructions to merge the chapters
When I've uploaded all the chapter files and made them available to the assistant, I'll update the assistant's instructions to have it merge the chapters into a single yaml file. Here are the instructions I'm using for that step.
Using the chapters in your knowledge base, you write and run code to merge the chapters into a single yaml file named Winning-Alone-Game-Theory-Essentials-for-Solopreneurs-1.yaml and provide the user with a link to download the file.
Note: Change the book name to match the name of your book and the revision number to match the current revision number.
After the final yaml file is generated, I'll make it available to the assistant for reference. Then I'll update the assistant's instructions to have it generate the final output.
Instructions to generate the final output
Here are the instructions I'm using to have the assistant generate the final output.
Using the Winning-Alone-Game-Theory-Essentials-for-Solopreneurs-1.yaml file in your knowledge base, you write and run code to generate a PDF of the book and provide the user with a link to download the file.
Assistant Settings
Aside from the instructions, there are a few other settings you'll need to configure for the assistant. Here are the settings I'm using.
Model
Use the most recent model. At the time of this writing, that's the gpt-4-1106-preview model.
Tools
Enable the "Code interpreter" tool
Enable the "Retrieval" tool
Files
You will add the files as you generate them. The files you'll create are:
overview.yaml
chapters.yaml
chapter-#.yaml (where # is the chapter number)
{book-name}-{revision}.yaml
After adding each file, be sure to save the changes to the assistant.
Conclusion
That's it. That's the process I'm using to generate books with AI. It's a bit more involved than just letting the AI run through and generate an entire book in one shot. But I think the results are worth it. I'm able to ensure the book reads and flows well, is well written, and accurate while it's being created. And I don't have to write a single sentence or line of code in the process.
I hope this process is helpful. If you have any questions, feel free to ask in the comments below.
"I am writing an esoteric, non-linear, metaphorical, and spiritually driven book that aims to inspire readers to align with Mother Nature's proven path. The book will not directly instruct or prescribe methods but will stimulate inquiries to guide readers towards harmonious living with nature.
As this is a priority life mission for me, I need a comprehensive AI writing assistant that can:
Understand and maintain the esoteric, non-linear style and spiritual undertones of my writing
Provide persistent memory and context tracking for a cohesive long-form project
Offer project management tools to organize chapters/sections seamlessly
Adapt to my unique voice, metaphors, and storytelling approach
Provide constructive feedback while preserving my authentic expression
Could you please clarify how your platform can support me in bringing this transformative book to life? I'm willing to invest appropriately to ensure a smooth, uninterrupted journey. Please advise on the best subscription plan and any additional services that may benefit my project's successful completion."