Sitemap
Desiderium Sciendi

David Durant’s personal blog

Coding with ChatGPT 4 : Absolutely unnecessary levels of detail

--

So, my latest home project has been very different from my usual attempts at creating software in two important ways. Firstly, I actually finished it and secondly it works!

The idea was fairly simple. Along with my a small group of co-organisers I run a monthly lecture series in central London / online called .

Our next one is on the Wednesday 26th of March. !

When encouraging people to come to our events we’ve found the best way to get the word out is to have our social media posts on Bluesky reposted by people with large numbers of followers. Up to now we’ve been doing that semi-manually by using the free version of to schedule large numbers of individual posts tagging specific individuals.

There’s two issues with that. The first is that anyone who follows the main gets their timeline spammed with a lot of almost identical posts. The second is that someone (e.g. me) needs to line all those posts up in Buffer which is tedious, time consuming and prone to error.

So, to automate as much of this as possible I created 3 things.

  • A new Bluesky account specifically to do this marketing that only reposts the main account. No-one should subscribe to it.
  • A Google sheet that contain the info of who we want to share our posts.
  • A python script that reads and updates the script and does the posting (I’d normally post the repo here but I was lazy this time and made it private so I didn’t need to store the API keys separately).

The Google sheet looks like this.

From left to right the columns are:

  • The Bluesky Post ID of the post that we want to quote post (I hope that sentence makes sense).
  • The main text we want in the quote post.
  • Who we want to target the quote post at (in this case, me).
  • The date / time we want the quote post to be done.

I used to wake up every 15 minutes and run the script.

It’s a fairly simple script this time which comes in under 150 lines of python. I still heavily used ChatGPT to get info on the various Google and Bluesky API calls but I did a fair bit of restructuring what it suggested myself to make it easier to understand (at least for me).

As has happened many times before when trying to use ChatGPT to write code, I ran into a brick wall when it insisted on trying to use a Bluesky API call that didn’t exist. This time I looked up the right thing myself and told it what to use instead. It then didn’t seem to be able to work out how to fill in the data that that API call needed correctly.

As a quick side-note — at this point I had ChatGPT teach me about (one of the main python data validation libraries) as I needed to understand how that worked to get into why it was trying to fill out the API data wrong. I’ve found ChatGPT often very good at teaching very different things at differing levels of complexity. I thoroughly myself the other night on the topic of quantum mechanics after watching an episode of and learned a huge amount just by asking the AI to explain things with more or less complexity depending on my initial understanding (let’s just say I need a basic refresher in how matrix maths works).

Anyway! I used the python dir function to show ChatGPT where it was going wrong. Specifically : print(dir(models.AppBskyEmbedRecord.Main)). From that the AI say how the data was structured differently to what it expected and fixed the code to use the API properly.

There are two take-aways from completing this project. Firstly, ChatGPT still has a little way to go when writing code. It can still get stuck when it gets something wrong, suggest a fix, see that’s also wrong and then go back to suggesting the first thing again. The second is that with a human in the loop it can be shown the right answer and update itself to not only fix the current issue but to not make the same mistake in the future.

In other words — I taught ChatGPT something new! However small :-).

Anyway — this project will make advertising TGT a lot simpler in the future. Now I can get back to the other, much more complicated, Bluesky projects I was trying to do before!

David Durant
David Durant

Written by David Durant

Ex GDS / GLA / HackIT. Co-organiser of unconferences. Opinionated when awake, often asleep.

No responses yet