Automatically generate books with GPT-4 🤖✍️
AutoBook is an application that automatically creates books given a prompt describing the book. It generates chapters, topics for each chapter, and detailed bullet points for each topic. After creating this outline, the application generates text for every topic. Ultimately, this results in a book with approximately 15-20k words. The cost for creating one book is around $5. Examples of books created from this application can be seen on Amazon 🛒 here, here and here.
- OpenAI Python library
Ensure you have a valid OpenAI API key, as the application uses OpenAI's GPT-4 model to generate the book content.
- Clone the repository:
https://github.com/yachty66/AutoBook.git
- Install the required Python packages:
pip install openai
- Within the script, set the OpenAI API key by replacing
"api_key"
with your OpenAI API key:openai.api_key = "YOUR_OPENAI_API_KEY"
- Ensure you have a file named
prompt.md
in the same directory as the script. This file should contain the initial content or prompts that will be used to guide the AI in generating the book content.
- Run the script:
python book.py
- The script will automatically create chapters, topics, and detailed bullet points for each topic 📝.
- The application generates two files: a metadata file (
title_metadata.md
) and a content file (title.txt
), where "title" is the title of the book defined inprompt.md
. Both files will be saved in the same directory as the script 📁.
book.py
: The main Python script file that contains all the code.prompt.md
: A markdown file with the initial prompts for the book. Adjust this file according to your needs depending on the kind of book you want to generate. This file must be in the same directory as the script.title_metadata.md
: A markdown file that contains metadata and an outline of the book.title.txt
: A text file that contains the generated content of the book.
- Fork the repository.
- Create your feature branch:
git checkout -b feature/my-new-feature
. - Commit your changes:
git commit -am 'Add some feature'
. - Push to the branch:
git push origin feature/my-new-feature
. - Submit a pull request.
This application uses OpenAI's GPT-4 to generate content. The generated content may not always meet your expectations or be error-free. Always review the content carefully.