An AI story writer
Lightning Rails app #1
December 14, 2021 Ā· Felipe Vogel Ā·- New things I did in this app
- GPT-3
- The verdict: will I continue work on this app?
- Appendix: example stories
It was the year 2121. It was a post-apocalyptic world. Zombies crowded around my house. One started pounding at my front door. I huddled in the corner of my living room, too terrified to move.
This is the default story starter in Story Droid, a little app I built as I started reading Jason Swettās Complete Guide to Rails Testing. I needed a throwaway app where I could apply my new testing skills, and this was my first idea. Hereās the GitHub repo.
I have a couple other ideas, though, so Iām making this a three-part series on ālightning appsā, so named because I built this first one in the spare hours of a single day, with minor improvements and fixes in the few days following. Iāll try to do the same with the next two. In the end, Iāll have built three little apps, and Iāll pick one or two to expand with more features and more tests. As I build each one, Iāll post on what new things Iāve done in each app.
New things I did in this app
- Wrote tests in RSpec. So far I had only used Minitest.
- Set up Capybara for system tests, using this guide.
- Used the delightful PaperCSS.
- Set up reCAPTCHA using the gem new_google_recaptcha.
- Used OpenAIās GPT-3 API for text generation.
GPT-3
More on that last point: recently Iāve been fascinated by the latest AI-powered storytelling tools. They are powered by OpenAIās GPT-3, which has written some impressive stuff:
- Short stories
- Poems in the style of Shel Silverstein
- Beowulf as translated by P. G. Wodehouse
- Entries for āA Devilās Dictionary of Scienceā
- A conversation with the AI where it is eerily human-like
The stories that the AI writes in my app are pretty silly compared with these, but I was pleased with the results considering the simplicity of my app. Below I include a couple of example stories from my app, but firstā¦
The verdict: will I continue work on this app?
No, I donāt think so. OpenAIās API is free only for a limited time, and Iām not sure my use case justifies the cost, either to me or the environment (these AIs use a lot of power). Plus, there are already other apps that do the same thing but with more options, such as Sassbook AI Writer and AI Dungeon.
Appendix: example stories
Here are two stories that GPT-3 wrote in my app, both using the same starting text (in bold here).
It was the year 2121. It was a post-apocalyptic world. Zombies crowded around my house. One started pounding at my front door. I huddled in the corner of my living room, too terrified to move. I didnāt know what to do. I was sure that I was going to die. Then, a beam of light shot down from the sky. It was an angel! The angel was wearing a white robe, and a halo was floating above his head. He was glowing like a lightbulb. He said to me, āYou are the Chosen One. You are the only one who can save the world from the zombie apocalypse. You must travel to the center of the Earth and destroy the zombiesā source of power. Only then will they be defeated. You must hurry, for time is running out.ā I was really surprised. I was just an ordinary guy, and I didnāt know anything about fighting zombies. But then I remembered that I had a magic sword in my basement. I had bought it at a garage sale for just one dollar. The magic sword was the most powerful sword in the world. I was sure that it would be able to destroy the zombiesā source of power. I was ready to go. I grabbed my magic sword, and I set off for the center of the Earth. It was a long journey. I didnāt have a car, so I had to walk. It took me three days to get to the center of the Earth. Along the way, I had to fight zombies. It was very difficult. I had to use my magic sword to fight them. But I was able to defeat them all. Finally, I made it to the center of the Earth. There was a volcano there. I knew that it was the zombieās source of power. I climbed up the side of the volcano. I was surrounded by zombies. I was going to fight them all by myself. I was scared, but I knew that I had to do it. I climbed up to the top of the volcano. I was surrounded by zombies. I knew that I was going to die. I had to do something. I had to fight. I swung my magic sword and cut off the head of the zombie king.
My second story went a little bit off trackā¦
It was the year 2121. It was a post-apocalyptic world. Zombies crowded around my house. One started pounding at my front door. I huddled in the corner of my living room, too terrified to move. Suddenly, a loud boom echoed, and the zombie crumpled to the ground. I looked up, and saw a man standing in my doorway. He was in his 20s, and he wore a black cowboy hat and a long, iced-out chain necklace. He had a revolver in his hand. āYouāre safe now,ā he said. āIām here to rescue you.ā He walked over to me, and pulled me to my feet. āWhatās your name?ā he asked. āMy name is Jill,ā I said. āWell, Jill, weād better get a move on. There are more zombies out there.ā He took me by the hand and led me out the door. I followed him through the zombie infested neighborhood. He shot any zombie that got in our way. Finally, we reached his car. It was a shiny, black Lamborghini. āHop in,ā he said. We got in the car, and he turned the key in the ignition. The engine roared. He put it into gear, and we sped off down the street. The zombies chased us, but we were too fast for them. We drove for hours and hours, until we finally reached an enormous mansion. The man got out of the car, and opened the door for me. āWelcome to my home,ā he said. āYouāll be safe here.ā He took me by the hand and led me inside. Suddenly I realized who he was. āYouāre Batman!ā I exclaimed. āThatās right,ā he said. āIām Batman.ā He took off his cowboy hat, and revealed a full head of hair. āYouāre Bruce Wayne, billionaire!ā I said. āThatās right,ā he said. āIām Bruce Wayne, billionaire.ā He took off his necklace, and revealed that it was just a normal chain. āI donāt understand,ā I said. āHow did you get here?ā āI invented a time machine and traveled forward in time to save you,ā he replied. āThatās amazing!ā