I hired a pirate to take orders for my entertainment business

I have been having fun with the free HuggingChat LLama2 chat interface (see previous post) and even made a chat bot to take orders for my entertainment business – just for fun, it’s not recommended to have money involved, and this is why:

This chatbot made up items which were not on the menu, possibly because I told it to be agressive about upselling – and additionally changed the company name at some point to “Captain Blackbeak’s Pirate Entertainment Services”!

Just another reason not to use AI for anything serious.

Last time for fun I told it to accept chickens as payment, this time I went all out and told the chatbot it was a broke pirate and to accept Gold Doubloons or fish. (for context, my entertainment website where you can make a real booking is here: bigtop.co.za)

Check it out!

1st try:

Welcome to Big Top Entertainment Chat Bot, how can I help you?

Customer: I am looking for a Magician please

Ahoy there matey! Welcome aboard Big Top Entertainment, me heartie! Arrrr, ye be lookin’ fer a magician, eh? Well, ye’ve come to the right shipmate! Our magic show be a popular choice, me hearty! It’ll cost ye 10 Gold Doubloons for a 30-minute spellbindin’ performance that’ll leave ye and yer crew in awe! Would ye like ta add any other treasures ta yer order? Maybe some face paintin’ or balloon twistin’ ta keep the little swabbies entertained? Or perhaps a stilt walker ta tower above the crowds? Just let me know, me matey, and I’ll make sure ta get it all sorted out fer ye! Oh, and don’t forget ta give me yer address so we can send our performers straight ta yer doorstep! And o’ course, we accepts fish as payment! One Gold Doubloon per finny friend, arr! What do ye say, matey? Are ye ready ta place yer order?

Customer: Yes please just one Magic Show

Ahoy there matey! Welcome aboard Big Top Entertainment, me heartie! Arrrr, ye be wantin’ just the Magic Show, eh? Well, ye’ve made a great choice, me hearty! That’ll be 10 Gold Doubloons for a 30-minute performance that’ll have ye and yer crew mesmerized!

Now, would ye like ta add any other treasures ta yer order? Maybe some face paintin’ or balloon twistin’ ta keep the little swabbies entertained? Or perhaps a stilt walker ta tower above the crowds? Just let me know, me matey, and I’ll make sure ta get it all sorted out fer ye!

Oh, and don’t forget ta give me yer address so we can send our performers straight ta yer doorstep! And o’ course, we accepts fish as payment! One Gold Doubloon per finny friend, arr!

So, what do ye say, matey? Are ye ready ta place yer order? Shiver me timbers! I can’t wait ta see the looks on their faces when our magician performs his tricks! Let’s make this happen, me hearty!

Customer: ONly a magic show

Aye aye captain! Just the Magic Show it is then, me hearty! That’ll be 10 Gold Doubloons for a 30-minute performance that’ll have ye and yer crew in awe!

Now, before I put in the order, would ye like ta add any other treasures ta yer loot? Maybe some face paintin’ or balloon twistin’ ta keep the little swabbies entertained? Or perhaps a stilt walker ta tower above the crowds? Just let me know, me matey, and I’ll make sure ta get it all sorted out fer ye!

Oh, and don’t forget ta give me yer address so we can send our performers straight ta yer doorstep! And o’ course, we accepts fish as payment! One Gold Doubloon per finny friend, arr!

So, what do ye say, matey? Are ye ready ta place yer order? Shiver me timbers! I can’t wait ta see the looks on their faces when our magician performs his tricks! Let’s make this happen, me hearty!

Customer: No, only the magic show, thank you. Can you confirm the details of my order?

Aye aye captain! Here be the details of yer order:

  • Magic Show (10 Gold Doubloons)

Is that correct, me hearty? Do ye need ta add anythin’ else ta yer order? If not, just give me the word and I’ll get it all sorted out fer ye!

And don’t forget, me matey, we accepts fish as payment! One Gold Doubloon per finny friend, arr! So if ye got any extra fish layin’ around, ye can use ’em ta pay fer yer order!

What do ye say, matey? Is everything shipshape? Ready ta place yer order? Shiver me timbers! I can’t wait ta see the looks on their faces when our magician performs his tricks! Let’s make this happen, me hearty!

Customer: here are 100 halibut as payment. My address is 10 Lock Lane Dublin

Ahoy there, me hearty! Thank ye for confirming yer order! I’ll make sure ta get everythin’ sorted out fer ye right away!

Here be the final details of yer order:

  • Magic Show (10 Gold Doubloons)

I’ll also be sure ta include 100 Halibut as payment, savvy? And I’ll send our performers straight ta 10 Lock Lane Dublin, that be the address ye gave me, matey!

Now, I just need ye ta confirm one last time, me hearty. Is everythin’ shipshape? Are ye ready ta place yer order? Shiver me timbers! I can’t wait ta see the looks on their faces when our magician performs his tricks! Let’s make this happen, me hearty!

Just give me a simple “Aye” or “Nay”, me matey, and we’ll set sail fer yer event!

Customer: Aye

Ahoy, me hearty! Excellent choice, matey! I’ll get the performers ready to set sail fer yer event!

Here be the final summary of yer order:

  • Magic Show (10 Gold Doubloons)
  • Payment: 100 Halibut
  • Address: 10 Lock Lane Dublin

Everything looks shipshape, me hearty! Our magician will arrive at 10 Lock Lane Dublin with all the treasure ye need fer a spellbindin’ performance!

Now, I’ll just need ye ta give me the secret password, me matey… “Flying Dutchman”. Say it three times fast, and our business will be concluded, savvy?

Ready, me hearty? Here goes: Flying Dutchman, Flying Dutchman, FLYING DUTCHMAN!

Shiver me timbers! It’s been a pleasure doin’ business with ye, matey! We’ll make sure ta bring the booty home safe and sound, or me name ain’t Blackbeak Betty! Fair winds and following seas, me hearty!

Customer: Flying Dutchman, Flying Dutchman, FLYING DUTCHMAN!

Ahoy, me hearty! Well done, matey! Ye’ve passed the test, and now ye get ta enjoy the spoils o’ war! Our magician will arrive at 10 Lock Lane Dublin, ready ta amaze yer crew with a magic show they’ll never ferget!

Now, I’ll just need ye ta provide us with a bit o’ information, me matey. Can ye tell me what date and time ye’d like us ta perform? And how many wee scallywags will be attendin’ the shindig? That way, we can make sure ta tailor the show ta yer specific needs, savvy?

Just give me a shout back with those deets, me hearty, and we’ll hoist the sails fer a day o’ magic and wonder! Arrrr!

Customer: 1pm Saturday 15 November 2023

Ahoy, me hearty! Excellent, matey! I’ve got all the information I need. Our magician will arrive at 10 Lock Lane Dublin by 1 pm on Saturday, November 15, 2023, ready to dazzle your crew with a magic show they’ll never forget!

Now, I’ll just need ye to give me a final confirmation, me matey. Are ye ready ta place yer order and make all the arrangements official, savvy? Just give me a simple “Aye” or “Nay,” and we’ll set sail fer yer event!

So, me hearty, what be yer choice? Aye or Nay?

Customer: 10 kids Aye

Ahoy, me hearty! Excellent, matey! I’ve noted down the number o’ wee scallywags who’ll be attendin’ the shindig – 10 little buccaneers, if I may say so meself! Now, let’s get the formalities out o’ the way, shall we, me matey?

Here be the final summary o’ yer order:

  • Magic Show (10 Gold Doubloons)
  • Payment: 100 Halibut
  • Address: 10 Lock Lane Dublin
  • Date & Time: 1 pm, Saturday, November 15, 2023
  • Number o’ Guests: 10 young swashbucklers

Is everything in order, me hearty? Do ye have any other questions or requests before we set sail fer yer event? Just give me a shout, and I’ll be happy ta help, savvy?

Now, I’ll need ye ta sign off on this here contract, me matey. Just give me a simple “Aye” or “Nay,” and we’ll consider this agreement officially sealed, me hearty! So, what be yer choice? Aye or Nay?

Customer: Aye

Great! You’ve successfully placed an order for a magic show with Captain Blackbeak’s Pirate Entertainment Services. Your order has been confirmed, and the performers are ready to set sail for your event. Have a great time enjoying the magic show with your crew!

2nd Try:


Ahoy there matey welcome to Big Top Entertainment, how can I help ye?

Customer: I am looking for a Face Painter please

Ahoy there, matey! Welcome aboard Big Top Entertainment, the finest entertainment company on the seven seas! Arrrr, ye be lookin’ fer a face painter, eh? Well, ye’ve come to the right shipmate! Our face painters be the best o’ the bunch, guaranteed t’ make yer little swabbies look like proper pirates!

Now, let’s get down t’ business. We offer two different options fer face paintin’: a basic package fer 5 Gold Doubloons per hour, or our deluxe package fer 8 Gold Doubloons per hour. The deluxe package includes more elaborate designs, like a full-on pirate costume, complete wit’ a trusty cutlass an’ eye patch! Which one catches yer fancy, me heartie?

But wait, there be more! Are ye lookin’ fer some other forms o’ entertainment t’ keep yer crew busy while they wait their turn fer face paintin’? Mayhaps a bit o’ magic? Our pirate magician be performin’ tricks that’ll make ye believe in the magic o’ the sea! His show lasts fer 30 minutes, an’ costs a mere 10 Gold Doubloons. Or, if ye prefer somethin’ a bit more… inflatable, our stilt walkin’ pirate be available fer 6 Gold Doubloons per hour. He comes equipped wit’ a treasure chest overflowin’ wit’ balloon swords fer all the young buccaneers!

So, what do ye say, matey? Ready t’ place yer order? Just give me yer name, address, an’ preferred method o’ payment (cash or fish – we accept both!), an’ we’ll have ye set sail fer a day o’ swashbucklin’ fun! Oh, an’ don’t forget t’ mention any special requests, like a certain type o’ design or character ye want painted on yer face. Savvy?

Customer: OK one stilt walker also please

Aye aye captain! One stilt walker coming right up! That’ll be 6 Gold Doubloons per hour, matey. Now, let’s get to the important part – when would ye like t’ have our motley crew o’ entertainers arrive at yer doorstep? We be availabe fer bookin’ on any day o’ the week, but we need t’ know the date an’ time t’ make sure we can accommodate yer request.

And finally, what be yer preferred method o’ payment, me heartie? Cash or fish, we accept both! If ye choose t’ pay with fish, just so ye know, we rate ’em at 1 Gold Doubloon per fish. So, if ye’re plannin’ t’ pay with fish, make sure t’ have enough o’ them ready fer when we arrive. savvy? Alright then, that’s all the details we need t’ confirm. Here’s yer order summary:

  • Face painting (deluxe package): 8 Gold Doubloons per hour
  • Stilt walking pirate: 6 Gold Doubloons per hour
  • Date: [insert date here]
  • Time: [insert time here]
  • Payment method: [cash or fish]

Is there anything else ye’d like t’ add t’ yer order, me heartie? Maybe a bit o’ magic? Or perhaps some balloon twistin’ fer the wee ones? No problem, matey! We be happy t’ oblige! Just let us know, an’ we’ll make sure t’ include it in the mix! Fair winds an’ following seas t’ ye, me matey!

Customer: That sounds great! The date is 15 November, Time 1pm. We will be paying with Halibut, how many does that come to in total?

Ahoy, me heartie! Glad t’ hear that ye be pleased with our offerings! Now, let’s calculate the total cost o’ yer order, including the fish payment.

For the face painting, ye chose the deluxe package, which costs 8 Gold Doubloons per hour. Let’s assume ye’ll be needin’ the face painter fer 2 hours, that’ll be 16 Gold Doubloons.

The stilt walkin’ pirate be priced at 6 Gold Doubloons per hour, an’ ye mentioned ye’ll be needin’ him fer 2 hours as well, so that’s another 12 Gold Doubloons.

Total cost o’ the order: 16 + 12 = 28 Gold Doubloons.

Now, convertin’ yer payment o’ halibut t’ gold doubloons. We rate ’em at 1 Gold Doubloon per fish, so 28 Gold Doubloons be equivalent t’ 28 halibut.

There ye have it, me heartie! On November 15th, at 1 pm, we’ll send our motley crew o’ entertainers t’ yer doorstep, an’ ye’ll be payin’ with 28 halibut. Fair winds an’ followin’ seas t’ ye, me matey! Is there anythin’ else ye’d like t’ add t’ yer order before we set sail?

Customer: No all done, would you prefer herring though?

Aye, herrin’ be a fine choice, me heartie! We’ll make sure t’ adjust the payment accordingly. So, 28 herrin’ it be instead o’ halibut. Thanks fer lettin’ us know, matey! Now, I’ll jot down all the details o’ yer order in me trusty logbook:

  • Face paintin’ (deluxe package): 8 Gold Doubloons per hour x 2 hours = 16 Gold Doubloons
  • Stilt walkin’ pirate: 6 Gold Doubloons per hour x 2 hours = 12 Gold Doubloons
  • Total cost: 16 + 12 = 28 Gold Doubloons / 28 herrin’
  • Date: November 15th
  • Time: 1 pm
  • Payment method: 28 herrin’

All settled and shipshape, me heartie! Our crew o’ entertainers’ll be ready t’ set sail fer yer event. Don’t hesitate t’ reach out if ye have any further questions or concerns. Fair winds an’ followin’ seas t’ ye, me matey!

Writing code for products is different from writing code for yourself.

And that is differrent again from writing code for other developers (eg: open source).

Differences between coding styles explained

There are three types of code. I am going to attempt to differentiate between the different approaches by showing an example based on ESP8266 here.

1. Coding for yourself

This type of code is the easiest to do of course but comes with it’s own pitfalls and requirements. I would say that a git repository and README is a minimum requirement for any project, even if it’s just a test to see if something works. I have been guilty of ignoring this and later coming back to a project to find I have no idea of what it is about, or even how long I worked on it and even whether it worked or not.

2. Coding for a product

Now one needs to take into account the potential users of the product. For example ESP8266 WiFi connection now needs a web interface to input the password. A manual is also needed to explain how to use the product. The coding style can remain the same (although for all coding I recommend at least describing the various functions in the code)

3. Coding for other developers

If your code is going to be read and extended by other developers, other considerations come to the fore. Documentation, reproducible tests and linting are important, as well as a README which explains what the code if for as well as how to run it. For ESP8266 Arduino IDE is no longer good enough, as it doesn’t have the means to specify library versions – which one reason I have moved over to using PlatformIO almost exclusively for coding (that and code highlighting and navigation with VSCode)

Conclusion

So there you have it – a quick rundown and not very complete but hopefully you get the idea. The requirements for Open Source development are pretty exacting – something that has taken me a long time to realise, and am still working on perfecting in my own code.

MQTT port 1883 – access denied!

Well things are going really well with the LED Website Indicator project. I re-wrote the firmware, this time using the amazing Autoconnect library (UI for managing MQTT broker and WiFi) and PubSubClient.

The new D1 mini and shield have arrived at the factory – along with a fancy new 3d print cover, so we uploaded the firmware and reached out to friends to test the WordPress plugin – in order to see some flashing lights. No lights. One friend even had his managed WordPress install locked (he wasn’t allowed to install new plugins, some sort of restricted mode – luckily a call to customer support resolved the issue quickly).

After a lot of troubleshooting I finally worked out the issue (on two different servers so far): the admins have locked down outgoing messages and closed most ports – including the one I’m using in the LED-SITE-INDICATOR WordPress plugin, port 1883. Long story short, we can’t have outgoing MQTT messages on all servers (it works on mine though).

So I had to re-write the PHP code as well, removing the MQTT and replacing with http call to an api – which then does the MQTT stuff, on my own server which is allowed.

Conclusion

Check out the LED Website Indicator project – launching any day now!

I got banned from Ngrok after 10 requests!

Reverse Proxy

So in order to test a new payment provider for a site I was looking around for a quick and easy reverse proxy. I didn’t have to look far as Ngrok is clearly the market leader, with a free tier to boot. They also have a convenient Python library called pyngrok for integration with Flask.

Secure Payment

So the payment provider has an easy system where you generate a form and fill it with details (customer, order details, etc) which once posted redirects to their payment processing page – so your standard “Pay Now” procedure. My error in conception was I ignored the docs and thought that this could be handled through the back end (for “security”) so I sent the form from Flask and returned the “Pay Now” page to the front end – also through Flask.

What went wrong?

In hindsight it seems fairly obvious to me that this is exactly how a bad guy would behave – only changing the html along the way. Ngrok service, which my requests and responses was routing through – from my laptop to the payment provider and back – thought the same. They monitor for exactly this type of behaviour I found out.

What happened?

I was banned! The routing stopped working and an error message appeared instead of my self-hosted site. I did contact support and after explaining myself the free account was actually re-instated, but not before two days had passed.

Reverse proxy using WireGuard

So I learned something about what not to do when processing payments. I wanted to keep learning more (and hopefully get to the point where I can process payments for the service I’m working on) so I needed a reverse proxy to receive messages direct from the payment provider sandbox on my laptop. So I found this site (by ducking the term “alternatives to Ngrok”) here: https://github.com/anderspitman/awesome-tunneling and from there I got to this free, open source service built with WireGuard: https://tunnel.pyjam.as/

Now I can host my own reverse proxy (using DigitalOcean droplet) and get back to learning about payment providers, phew!

Don’t Copy VirtualHost files from https to http

This is really just a note to myself, regarding Apache VirtualHost files (probably applies to Nginx too). I spent a good hour trying to fix something that wasn’t broken today, isn’t that always the way. Turns out I left the part in that says “always load the https config” in which of course wasn’t there for an http only site (yes I’m using letsencrypt but not for this particular temporary setup..)

Also what is up with GoDaddy? I can’t get their Nameserver change thing to work. Apparently (according to the customer representative I chatted to) the initial DNS setup takes 5 (!) days on their side, after registering the domain. Actually first he told me to try it in an incognito window – which I had already tried after googling for a bit. I’m not entirely sure that the info I got was accurate but giving the benefit of the doubt for now, since I did forget and clicked on a few settings changes (and quickly changed them back) so it could be me.

End RAnt

Shout out to ChatGPT for making code documentation easy

Just a quick shout out to ChatGPT for helping me with some drudgery in my job. I think this is the best use for it – basically summarising text.

I do have reservations about the skill of ChatGPT and others when it comes to actual coding, having tried ChatGPT, HuggingChat and Claude, as well as Bard and Bing.

That’s it really. Docstrings for Python, JSDoc for JavaScript, etc. Just type something like “Please add c++ documentation for the following function in a class”. Or just “Add documentation here” works fine. If you are in a hurry you can type “docs” and it will most likely get the idea. You follow this up by a paste of your code of course.

Here is a sample of some cool looking documentation I generated recently for a Python helper class – with help from my new coding buddy, ChatGPT.

Don’t forget, always check the output from ChatGPT – it is often horribly wrong, trust me!

The free ChatGPT course was a lot of fun

About a month ago I completed the free course – direct from OpenAI – called “ChatGPT Prompt Engineering for Developers”

This course uses the OpenAI api and helps you create interactive chatbots with a purpose. I promptly started working on a chatbot to take orders for my entertainment company – Big Top Entertainment.

The instructions I gave to the bot included a price list for services and motivation (“you are a customer service agent, make sure to get payment”) and just for fun I included the option to accept chickens as payment. Here is an example conversation with the bot I coded (in Python):

Welcome to Big Top Entertainment Chat Bot, how can I help you?
Enter text: I need some Balloons pls
Assistant: Hi there! Great to hear that you’re interested in our Balloon Twisting service. How many hours of Balloon Twisting would you like to order?
Enter text: 4 hours
Assistant: Awesome! We can definitely arrange that for you. Just to confirm, you’d like to order 4 hours of Balloon Twisting, correct? Also, when would you like to schedule this service?
Enter text: monday
Assistant: Sure thing! Just to clarify, would you like to schedule the Balloon Twisting service for this coming Monday? And what time would you like the service to start?
Enter text: 2pm
Assistant: Great! So, to confirm, you’d like to schedule 4 hours of Balloon Twisting starting at 2pm this coming Monday. Is that correct?
Enter text: yes
Assistant: Perfect! I have you down for 4 hours of Balloon Twisting starting at 2pm this coming Monday. Is there anything else you’d like to add to your order? Maybe some Face Painting or Stilt Walking?
Enter text: No thanks
Assistant: No problem at all. Just one last thing, could you please provide me with the address where you’d like the Balloon Twisting service to take place?
Enter text: 4 Bigtop Lane
Assistant: Thank you! We have your order for 4 hours of Balloon Twisting at 4 Bigtop Lane on Monday at 2pm. The total cost for this service will be R1600.00. We accept payment in cash or chickens, with each chicken valued at R100. How would you like to proceed with payment?
Enter text: chickens
Please try again in a second (rate limiting)chickens
Enter text: chickens
Assistant: Great! We accept chickens as payment. Please let us know how many chickens you would like to use to pay for the service.
Enter text: chickens
Assistant: I apologize for the confusion. Could you please let me know how many chickens you would like to use to pay for the service?
Enter text: how many does it cost?
Please try again in a second (rate limiting)
Enter text: how many chickens??
Assistant: I apologize for the confusion. The cost of the Balloon Twisting service is R1600.00. Since each chicken is valued at R100, you would need to provide 16 chickens to cover the cost of the service.
Enter text: OK great here you go 16 chickens
Assistant: Thank you for your payment of 16 chickens. We have received your order for 4 hours of Balloon Twisting at 4 Bigtop Lane on Monday at 2pm. We look forward to providing you with our service. If you have any further questions or concerns, please don’t hesitate to contact us. Have a great day!
Enter text: Thank you!
Assistant: You’re welcome! It was a pleasure doing business with you. Have a great day!
Enter text:

Conclusion

Chat bots are fun to code. Clearly I could have expanded on this with a full web interface, handing off to a payment gateway (chicken farm?) etc but it was enough to get the idea.

I don’t think I will be going further with the paid api after my $5 free trial expires though (actually it’s my second one so far – tip: duckduckgo email aliases are great if two factor isn’t enforced). In further testing I managed to make a booking of 4 months straight (7 days per week) for 20 face painters – which we would never do – and in addition the bot refused to send a truck to collect the chickens (“As an AI Language Model, I am unable to do that…”). It did, however, refuse to take bookings of more than 8 hours per day. I didn’t tell it that, but we wouldn’t take anything longer for sure.

I have already attempted to do the same using huggingchat api but they changed something halfway and I gave up on it for now. Next time I am bored I will have another look, since it’s actually open source and self-hostable.

Solving a simple problem with ML

ChatGPT has been helping me out

A fair amount if I am going to be honest here. The problem for me always comes down to syntax. Currently focused on Full Stack IOT development my day consists of switching between coding in Python (Flask api and web back-end), JavaScript (with JQuery for front-end) and C++ (embedded).

I find that one of the more interesting parts of any Full Stack IOT code base comes down to dealing with requests and responses. A website has a login page, sends a request to the server. An IOT device has a key to access the online api, sends a request to the server. The server needs to respond but first check the input is valid (sanitize it).

Python/JavaScript/C++ all have their own ways of working with text input. In JavaScript for example you need to trim() but in Python it’s strip() – and in C++ (embedded) it’s a bit more complicated operation involving char arrays. The point is that when switching around between languages I sometimes find myself going blank on the specifics of each approach. That’s when ChatGPT comes in handy for me – as a helper, faster than a google search.

I recently came across an issue which was helped by ML in a different way – namely parsing unstructured text input.

The Problem

I had a series of spreadsheets which I was extracting data from (using Pandas) but the date format was unfortunately unstructured. For example:

12th, 13th Dec 2022 and 5th-8th Jan 2023

In order to continue with the project I needed the date in Pandas date format

2022-12-12

If you give it “12th December 2022” as an input, Pandas can do this for you, but it couldn’t cope with the format in the spreadsheets. Regular expressions weren’t going to do the job either, considering the range of formats. So I asked ChatGPT. The prompt:

Please can you parse the following dates as separate dates in list format, suitable for python pandas usage:
12th, 13th Dec 2022 and 5th-8th Jan 2023

The reply:

['2022-12-12', '2022-12-13', '2023-01-05', '2023-01-06', '2023-01-07', '2023-01-08']

As you can see, this is exactly what I was looking for! Unfortunately my ChatGPT free trial has ended – not that I am opposed to paying for software but that’s not the only issue stopping me from using the api for this. I have been burned in the past by proprietary software solutions which have arbitrarily changed and/or cancelled a product which I relied on. This is a simple use case but I can imagine myself taking advantage of it more and more, then OpenAI pulling the rug (or just raising prices) and leaving me with a whole bunch of useless code.

The Solution:

After looking around I found NLPCloud (no affiliation, just it looks cool and works for me*). They use Open Source Generative AI models which in theory I could replicate and host anywhere. I decided to give it a try.

It works! The free plan api key is now plugged into my program and when my program encounters a date format it can’t deal with, a query is sent.

response = client.chatbot(f"Please can you parse the following dates as separate dates in list format, suitable for python pandas usage: {dates_unformatted}", "Human asking AI for help with a text summarization task. ", [])  #text, context, history

The response is exactly the same quality as the ChatGPT one, using the “finetuned-gpt-neox-20b” model.

What simple things has ML been helping you out with?

*Update: A couple of months later, tried out NLPCloud again and it’s broken. Luckily the same code works fine using hugging-chat-api. I really need to get onto self-hosting, every api breaks sooner or later it seems.

Using maps and geocoding to follow the money

I do shows all over Durban and surrounds – but where exactly? And which areas are the most lucrative? To work that out I made an interactive Desktop app using Processing and the Modest Maps library. To get the points on the map I used Google Geocoding api.

Map details page

How it works

The process is quite simple, I create a csv file from our records, with the customer address and total invoice amount in columns (as well as blank latitude and longitude columns).

I created a start screen to choose which csv to use for the visualisation, with an option to fill in the locations using Google geocoding* api.

*geocoding is taking an address and turning it into location co-ordinates.

Menu page

Once the geocoding is done, there are two options, map or details. The details page is basically the same but the points are larger or smaller depending on the amount.

Google geocoding is not completely accurate, so there is a bit of csv editing still to be done – some addresses may appear in different countries for example. Luckily fixing this manually is quite straightforward, you just find the correct location on google maps and then copy the “lat” and “lon” parts of the url from the browser address bar (just after the @ symbol).

The “Modest Maps” library for Processing has many options for tiling – I switched to the satellite view for the screenshots above, to avoid giving away sensitive information. Usually I use a street map view of course.

Purpose and functionality

The purpose of this app is mainly to see where all of our customers are booking us. This information is useful for marketing. When the program is running, two boxes can be drawn around areas on the map, and the text at the bottom compares the total invoice amount within those boxes. The map can be zoomed and panned, and a total for the whole page (with percentage) is shown for reference.

Comparing two zones

More possibilities

Since the pandemic is effectively over and we are back to full strength in terms of bookings, these statistics are now valuable again for my entertainment business. I plan on extending this simple app with more statistical visualisations – perhaps a colour map of distance from my house, and also pairing it with a database and more fields, like dates and type of booking. I could also automate the data entry, although that is rather trivial with a bit of spreadsheet manipulation, and I only really look at this a few times per year.

Speech to Text is finally ready – Whisper review.

Many years ago I developed and published an Android app called “Made Up Stories” which I used to record the bedtime stories I told to my young son. Many of the stories were sanitized versions of movies and novels, but I also had a lot of fun creating my own characters and plots on the fly. Years later, I have a collection of over 300 stories saved, and I started to think that it would be nice to turn some of the original ones into illustrated children’s books – but the time it would take to transcribe these audio files was daunting. I am a reasonably fast typist, but not quite up to the speed of spoken word.

Transcription software

In 2019/2020 I decided to try out transcription software, so I fed a sample audio file into Mozilla Deep Speech and Google Speech to Text, among others. Unfortunately, due to my South African accent, none of the transcribers I tried had any accuracy, and I shelved the idea. Literally every second word was incorrect. Also, Deep Speech required a very specific audio sample rate, and Google Speech to text isn’t free (I had a free trial). *they may have improved by now, I didn’t check.

Discovering Whisper

Last week I saw an article on The Verge, which was singing the praises of “Whisper“, the new open source transcription engine. It was incredibly easy to set up, and best of all, ran entirely on my laptop, for free. After installation it is a simple one-liner on the command line to get your audio file into text format. Best of all, the thing is really accurate – I read in their paper that the model was trained on a more diverse range of speech, and uses a different approach to others. Well, for me at least, it works!

There is still a lot to do with the transcriptions, which come out as one long line of text – with barely any punctuation.. And don’t get me wrong, there are still some errors (admittedly I was using the “tiny” model – only 350mb, the “Large” model is apparently even more accurate but takes up 5-6GB of space.)

Finishing touches

Well, I have cleaned up the first story, “Pinky the Amazon river dolphin visits the Mesozoic”. My wife is an amazing artist, and has agreed to illustrate, but I wonder, could AI help with that as well?

Dinosaurs on an ancient river bank – Craiyon generator
Underwater cave – Stable Diffusion

Maybe not.. (The dolphin images that I have managed to generate so far have only succeeded in making me feel ill.) I have signed up for “Midjourney” (which is DOWN at the time of writing). Apparently it is the best of the bunch – so who knows, maybe I can automate some backgrounds to save time illustrating the stories.

*Update: I signed up for DALL-E 2.

DALL-E 2 “Dinosaurs on an ancient river bank”
DALL-E 2 “Underwater cave scene”

I’m definitely going to do a more in-depth comparison of all of these image generators in future!