A python script for fully automatically creating web articles with images about any user specified topic. The script uses OpenAI's GPT-3 as a content creator. it will first send a request to create a table of contents in a specified xml format and it will then iterate over the table of content and request GPT-3 to write a specific chapter and its subsections. For some chapters it will ask GPT-3 to create a prompt that describes an image related to the article. This prompt is then used to generate illustrations with GPT-3. The result is formatted in HTML and inserted into a user specified web page template.
Content generation works in any Language known to GPT-3 but i only tried german and english.Example results can be found here:
Article examples:
- Convergent Evolution (Created by Version 1.0.2 in the writing style of a National Geographic)
- The History of Space Exploration (Created by Version 1.0.2 in the writing style of a Carl Sagan)
- The Age of Piracy (Created by Version 1.0.2 in the writing style of a drunken pirate)
- The Cambrian Explosion (Created by Version 1.0.1)
- Paleocene–Eocene Thermal Maximum (Created by Version 1.0.1)
- The Late Bronze Age Collapse (Created by Version 1.0.1)
Version 1.0.2 (2023-01-09):
- Added command line option to set writing style.
- fixed a bug that was messing up the created HTML
Version 1.0.1 (2022-12-31):
- Added placeholder for script version number
- OpenAI prompts modified
- added option for verbose mode
- improved output quality with a hardcoded filter that will remove the first paragraph of subsections. This paragraph contained repetetive explanations about the article topic.
Version 1.0.0:
- initial release
In order to use this script you must have an OpenAI API key that is exported in the environment variable OPENAP_API_KEY. To execute the script type in the following command line:
python ./ghostwriter.py -t "The Rise of AI generated Content" -tmpl ./template.html -o ai_content
The command will create a HTML article about the topic "The Rise of AI generated Content". It will build and send the necessary API queries to OpenAI's servers and compile a web page complete with a couple of images.
-t
The topic to write about. Should be written in Quotation marks.
-tmpl
The template file used for output formatting. The layout of a template file is simple. It is a text file that needs to contain the two placeholders {TOPIC}, {CONTENT} and optionally {VERSION}. The {TOPIC} placeholder will be replaced with the article topic and the {CONTENT} placeholder will be replaced with the HTML formatted article. The {VERSION} placeholder will be replaced with the script version.
-o
The output folder. If the folder does not exist it will be created.
-v
Verbose mode. In this mode the prompts will be output to the console.
-s
Writing Style. Set the Writing style. i.e. "National Geographic", "Carl Sagan" or "Drunken Pirate"