Artificial Intelligence (AI) is getting good, real good. Kevin Kelly, the futurist, has introduced the idea of AI as a universal personal intern (UPI) because its current capability is at the level of a competent intern – good enough to do the initial legwork but that work needs to be checked.
I’ve been making good use of generative AI like ChatGPT to solve real problems in my life. I’ve always enjoyed reading Twitter threads on how people use ChatGPT in an innovative way (the one that asks it to make as much money as possible is by far the most entertaining).
In the same spirit, I’ve decided to start a series of blog posts to share how I’m using AI. ChatGPT has suggested that I call this series “How I Used AI Interns to Improve My Life” for maximum clicks.
In this inaugural post of the series, I’ll show you how I used ChatGPT for a coding task. The task would have taken me a couple of hours but was completed in minutes with the help of my trusty AI intern.
I used to run this blog on Movable Type, a content management system (CMS). The CMS publishes pages with absolute links instead of relative links.
When I relaunched the blog, I moved the old pages to a different directory but the CMS no longer works so I couldn’t republish the pages with updated links.
Long story short, I have pages with broken links. I need a script that will fix these broken links.
ChatGPT prompts and responses
In 8 prompts, ChatGPT provides an elegant solution. The complete prompts and responses are at the bottom of the page. Here is a walkthrough:
- I give ChatGPT a brief outline of what I aim to achieve.
- Despite the half-ass prompt, the first solution is very good but the explanation on modifying my absolute link is not clear. I provide my absolute link and ask ChatGPT to please amend the script. My good manners will hopefully be well remembered and appreciated when AI rises against humankind.
- I run the script but there is an error. I ask ChatGPT to debug. I mention the environment I’m running the code in case it’s environment-specific. ChatGPT pinpoints the issue immediately. I ask ChatGPT to kindly update the script to deal with the encoding specific to my HTML files.
- The amended script does not contain the absolute link I have provided earlier. It looks like ChatGPT has selective memory. I could insert the absolute link manually myself but I’ve been told to learn to delegate. I provide the absolute link again, and eschew my politeness as AI has proven to have terrible memory – it is unlikely to remember my good manners and therefore will not look kindly upon me when it takes over.
- The script runs successfully but I’m seeing absolute links to images. In a momentary lapse in memory on my part, I’ve forgotten the correct HTML terminology so I give a relatively vague prompt. ChatGPT proves more competent than I am and passive-aggressively mentions that I’m referring to HTML element attributes.
- I rerun the amended script but I’m still seeing broken links. I realise that I’ve been a dumbass and have not accounted for subdirectory depth – the basics when it comes to relative links. I instruct ChatGPT to make the change, without acknowledging my mistake for I have embarrassed humankind. I can only hope that ChatGPT doesn’t call me a dumbass behind my back.
- The script runs successfully and fixes all 637 HTML files in less than a second.