Posts

ChatGPT Meets de Bono: A Powerful Combo

I'm struggling to make a decision at the moment, so I've enlisted the help of ChatGPT. I am experimenting a lot with some of the new AI tools, and it's a bit like playing whack-a-mole at the moment; as soon as I get to grips with one bit of software, another appears and demands my attention. A lot of what I'm doing is based on OpenAI's ChatGPT. I'm concerned that I'll spend too much on paid services, so I am actively looking at Open Source alternatives that I could run locally. Alas, many Large Language Models (LLMs) are too resource-hungry to run on my workstation, and I've been thinking of trying out a Jetson Xavier which I'm not using at the moment. Worth the time? I know I'll need to spend a few days getting to the point where I know whether I can use it for the projects I have in mind. Should I invest the time? I decide to take a Judo approach and use ChatGPT to help me make the decision. I used a prompt that's worked well for me before ...

Finding the Best Solution with ChatGPT: A Personal Experience

When you're developing software for technically savvy users, you'll often encounter an annoying problem: users provide their preferred solution instead of their requirements. This issue is even more pronounced when you are both developer and user. In such situations, you're likely to choose the first solution that seems to meet your needs, even though there might be better alternatives. Pair programming can help, as your partner can spot what's going on and suggest other ideas. But what if you're programming on your own? That's where ChatGPT comes in handy. ChatGPT to the Rescue I've recently been working on an application that downloads interesting arXiv PDFs, and I wanted to access them remotely. I could think of a couple of ways to do that, but I decided to ask ChatGPT for advice. I used a prompt that had been helpful before: " Suggest three ways I could accomplish that, with the pros, cons, and interesting features of each approach. " I present...

Pair Programming with ChatGPT

  Earlier today I started work on a small admin project to help me organise my excessive collection of repositories on GitHub. I wanted a list of my repositories, showing the name, url, description, stars and forks. I decided to get ChatGPT to write the code for me. In the conversation that follows, you can imagine an embodied ChatBot sitting next to me as we pair program. I'm the customer, ChatGPT is the programmer. If I'm not happy with the results, I ask my pair to change the code. My part is in italics. Everything else came from ChatGPT. As you'll see, there are a couple of wrinkles I didn't anticipate, but ChatGPT fixed them. This took less time than I'd have taken to write the code, and it was much more fun. I recommend it. Here's the session. Write python to find the names of all my repositories on GitHub, My username is romilly. You can use the GitHub API to retrieve the names of all your repositories. Here is the Python code to achieve that: i...

Can ChatGPT code like a pro?

I've been experimenting with the code generation capabilities of ChatGPT, and I'm blown away. As a test of its capabilities I decided to ask it to write a generic version of some code I've used, over and over, in slightly different forms, in real applications. The Problem The code implements a Throttler - a class that wraps something that makes requests and makes sure that requests are not made too often. Lots of APIs apply rate limits to requests, and this code makes it easy to enforce those limits within your application. A coding session with ChatGPT Here'es the session I had with ChatGPT. My instructions are in italics . Everything else - code, comments, and explanations - was written by ChatGPT in response. Write Python to create an Abstract Class called Requester. It should have a single abstract method called request that takes an argument called command. Add docstring comments. Here is the Python code to create an Abstract Class called Requester with a single ...

Will ChatGPT save your job - or take it over?

Wondering whether ChatGPT will make you more effective, or do your job so well that you are no longer needed? ChatGPT is one of the new generation of AI tools. You can ask it for help and it can turn its hand to a huge range of tasks. ChatGPT as a Python coder Today I used it to write a very simple but useful computer application. The task would have taken me half an hour or so. ChatGPT did the job in a few seconds, and the code it write was well-structured, readable and well commented. So far so good - but what about other tasks? I decided to make a short video about what I'd done. (Watch this space to see it when it's ready).  I knew that my first step would be to write a script. Could I ask ChatGPT to help me do that? Sure. Here's what happened next. ChatGPT as scriptwriter Here's what I typed: Earlier today I got ChatGPT to write a simple application for me. Now I want to make a video showing the process and the result. I'd also like to explain why the automatio...

Complex Network Analysis

Image
 I've recently been working on two fascinating, challenging projects. One is a guide to the Pimoroni Explorer Base. That's going to take a while, and I'll report on progress as i go. The other is a tool to help me keep track of published papers on some of the AI areas the interest me. Therese's so much published that it's a real challenge to keep up. I rely heavily on the wonderful service provided by Semantic Scholar; that helps me keep track of new papers that cite older papers that I've identified as interesting. Here's the citation  network for one of the papers that interest me: I've done quite a bit of work on networks with Python, but I've recently been reading  Complex Network Analysis in Python by Dmitry Zinoviev. It's well-written, broad in coverage, and has plenty of useful sample code. I love it. 

How to write reliable tests for Python MQTT applications

More and more IoT applications use MQTT. It's a simple and very useful messaging framework which runs on small boards like the Raspberry Pi Pico as well as systems running under Linux, MacOS and Windows. I recently decided to add some extra functionality to Lazydoro using MQTT. The code seemed to work when run manually but I had a lot of trouble getting my automated tests working. It took quite a while to understand the problem, but the fix was simple. Intermittently failing tests are bad In the end-to-end test that was causing the problem, the code simulated the start of a pomodoro session and then checked that the correct MQTT message had been  sent. The test usually failed but sometimes passed. When I manually ran a separate client that subscribed to the message stream I could see that the right messages were being sent. Intermittently failing (or passing) tests are a nuisance. They do nothing to build confidence that the application under test is working reliably, and they are ...