Day 17 of the Anvil Advent Calendar

Build a web app every day until Christmas, with nothing but Python!

Send yourself a mystery Christmas card with GPT-J

So far this Advent, we have taught our programs to send physical mail, and we have used frankly scary text-generation models to create remarkably plausible Christmas greetings. Now that our computers can write persuasively and drive the postal system, this cannot end well.

Let us take another jaunty step towards the robot apocalypse, by combining GPT-J and the Handwrytten API to send ourselves a random AI-generated Christmas card – sight unseen!

Here’s how the app looks:

Just hit Send, wait a few days, and see what you he gets.

Just hit Send, wait a few days, and see what you he gets.

It looks rather similar to our app from the other day – but this time, there’s no box to enter a message!

Instead, when you click Send, we use the GPT-J model to generate a festive message (thanks to the Hugging Face Inference API). Then we post the message, and your address, to the Handwrytten API, where robots hand-write a card and send it to you by post!

Source code

This app is open source, so you can run it yourself – but you’ll need your own API tokens for Handwrytten and Hugging Face. Once you open the app, open up the App Secrets and set new values for handwrytten_username, handwrytten_password, and huggingface_token.

(I wanted to put this online as a hosted service, and use Anvil’s Stripe integration to collect the postage fees, but I got a migraine just thinking about the VAT consequences. Sorry. Clone the app and try it yourself!)

Give the Gift of Python

Share this post: