Punderful is a #BuildInPublic project that collects puns from everyone and helps them find them ones that make the chuckle.
It was built with 🧡 on the Cloudflare Stack. Most importantly, this code focusses heavy on the new kid on the block Workflows.
You should be able to create all of this on the free tier. Let me know if you run into any problems
This uses a D1 database, so you need to create one
npx wrangler d1 create punderful
Copy and Paste the returned value and replace it in wrangler.toml
Dev mode
npx wrangler d1 migrations apply punderful
Production
npx wrangler d1 migrations apply punderful --remote
Create the index with the settings of embedding model we are going to use
npx wrangler@beta vectorize create punderful --preset "@cf/baai/bge-large-en-v1.5"
(This is already in wrangler.toml)
Create the namespace
npx wrangler@workflows kv namespace create LEADERBOARD
Copy and Paste the returned value and replace it in wrangler.toml
The Workers AI calls that I do in this app pass through an AI Gateway named punderful
. This let's me log and monitor of all AI usage.
Here is a link to your AI Gateway in dashboard.
Or head over to Dash > Your Account > AI > AI Gateway
Click the ➕ sign to create a new Gateway and name it punderful
.
Moderation is available using the free OpenAI the PublishWorkflow. You will need an OpenAI API Key to use it.
npx wrangler secret put OPENAI_API_KEY
You can develop locally, mostly.
npm run dev
But you probably really should deploy it.
npm run deploy