My name is Lee. I'm a former Stack Overflow taught dev now Solutions Architect2 which is cool and all but in my spare time I still like to play around with different ideas. Usually I play around with AR and game dev3 or get roped into random freebie app dev projects for family/friends4 to keep my skills sharp.
Recently,5 I've been playing around with ChatGPT and MidJourney. While there may be a day when they can replace devs, creatives, writers, politicians6, doctors, hotdog vendors7, etc., I don't think we are there yet. I mean even these little 500 word stories cost me $0.028 a day to generate!9
Anyway, this whole idea started with a CostCo hotdog.10 See, their was a discussion in the work Slack channel that ended up on the topic of Costco hotdogs.10 We nerdy lock folk have been taking topics and letting ChatGPT do it's magic to create hilarity, from suggestions of how to stop eating them to scientific explanations of why they are so good.
Well,11 one thing led to another and I asked ChatGPT to write a Post-Apocalyptic story about a world where CostCo hotdogs were currency.12 The story was so good I decided to get MidJourney to generate some supporting art, 15 minutes in Photoshop later,13 a few obligatory co-worker +1's in the Slack channel14 an idea was born...a daily AI story generator.
The frontend side of this is dead simple,16 plain ol' HTML and JS with the awesome Skeleton handling the CSS columnar fanciness.
Where it gets cool is in the backend. I'm a huge fan of the standard AWS Serverless stack17 and have been using it for well over a decade now so figured that'd help me move fast18 and OpenAI19 has a great API that fronts the AI hardness20 for the natural language stuff, code gen stuff, and DALL-E image stuff for you all within some handy SDKs.
The Story Gen Lambda is triggered by a daily EventBridge Schedule around 2a.m. EST.21 That Lambda first does some quick date calculations to get everything formatted for the frontend and uses the day of the year to grab the genre of the day from an array of 36622 random genre names. Then it takes that genre name and makes three calls to the OpenAI API completions endpoint to generate the prompt, title, and story23 only setting model, prompt, and max_tokens values and letting everything else default.
{
model: "text-davinci-003",
prompt: `Generate a unique and interesting writing prompt for a ${genre} short story`,
max_tokens: 200,
}
{
model: "text-davinci-003",
prompt: `Write a story title for the prompt: '${prompt}'`,
max_tokens: 200,
}
{
model: "text-davinci-003",
prompt: `Write a long detailed fictional story (with a minimum length of 1000 words) in the ${genre} style based on the prompt: '${prompt}'`,
max_tokens: 4000,
}
Once those return26 and are cleaned up,27 the page templates for the site and the email are just string literals in an imported module28 so it makes quick work of doing the replacements. Those are then pushed over to S3, an invalidation is sent to Cloudfront and a few seconds later the site is ready for the day.29 Other than that it's just boring ol' serverless stuff30 to serve the static site and hit you up daily with annoying emails.31
Anyway,34 enjoy the ride as we see what the robot overlords35 come up with over the next year. I don't plan on spending any more time on this18 unless something changes with the API or it super breaks. I'll be sure to update if any other crazy ideas come along so stay tuned, otherwise enjoy the show!36
*Footnotes on mobile.
1According to Google and the Latin classes I took in high school 20 years ago.
2The nerd in a tech business meeting who has to pretend like they didn't just Google a bunch of stuff to come up with a smart answer.
3Awesome, btw.
4Not as awesome.
5Like everyone else on the planet.
6Best case.
7Worst case.
8Bs. 48,690.06 (Venezulan bolĂvar)
9Bye, bye hotdog fund.
10Don't they all?
11I really love a discourse marker, don't I?
12Bs. 3651773.26
14Bit of a narcissist, me.
15If you are just here for the banter and stories click here
16Inspect the page, I'll wait.
17S3, Lambda, API Gateway, Dynamo, Cloudfront, etc., told you I know AWS.
18If my boss is reading this, fast because I only did this after hours. If my family is reading this, fast because I did it all in one Saturday morning while you were asleep.
19The engine behind ChatGPT.
20Technical term.
21Around because I'm rubbish at CRON and EST because that's where I am and time math is hard.
22Because society's stupid and didn't listen to Moses B. Cotsworth.
23I know it's possible to get title and story in one response by formatting the prompt correctly18
24Sorry if these code blocks look bad on your browser, I refuse to get a whole CSS framework just for that.
25The 1000 word thing does not work, I spent a Costco Hot Dog's worth12 of credits trying to get it to and gave up.
26It takes well over 30 seconds for all 3 typically so be warned.
27The OpenAI responses have a ton of rnadom linebreaks in them that I'm sure if I just read the docs I'd understand why but I can't be bothered.18
28Written in Node because I was a web dev first.
29Or night.
30Trying to sound cool here, serverless is not boring!
31Promise I'll get the unsubscribe link working soon...don't tell AWS mods
32Any fail notifies me and doesn't retry because I'm cheap and don't want to run up charges on AWS or OpenAI!
33I promise.
34Told you I love a discourse marker.
35I hate that phrase but all the cool kids are using it.
36A bit redundant, but I'm tired.
All stories and images generated by AI and not reviewed by humans so YMMV and no copywright claimed.
Site built by Lee/AI.