Simone's Blog (no JS mode)

Joshua & AI frenzie

It was a sunny June in 2015, GitHub just released Atom, an incredibly revolutionary (for some people bloated) text editor highly customizable and based on JavaScript. They even announced it with an amazing 60s TV-Ad-like video, which I found freaking hilarious. That same month, Telegram also releases their new set of APIs for making chatbots and so, with a new text editor to try out and some APIs to play around with, I started working on a bot named Joshua. Yes, it's a reference to WarGames; I'm sure there are probably hundreds more bots with the same name.

joshua bot logo

Getting inspired by this IRC chatbot originally made by Lindsey Bieda, Joshua_bot was a simple chatbot capable of loading user made plugins invoked with specific commands. The main reason I developed this bot was to control my Raspberry Pi remotely and read various sensors attached to it. This hobby project helped me so much on my path to learning Ruby, working with threads and in general organizing code.

Joshua_bot was initially deployed on an old Asus Eee PC that I had lying around in my college dorm room. Then after I got my first Raspberry Pi (Zero W) in 2017, I ported all the code and plugins to work specifically on this hardware.

As mentioned earlier, the only way I could interact with the bot was through commands e.g. /lyrics to find lyrics of songs, /temperature to get the temperature of the room, /takephoto to get a photo with Pi Camera Module. It was all pretty straightforward, but as soon as I wanted to amaze my friends by adding this bot to groups and doing some special stuff like recognizing words and launching games without direct commands, that nasty cyclomatic complexity increased exponentially. Lots of regexps everywhere and custom logic tailored to my pals' specific inside jokes!
Pretty much:

Artificial Intelligence = IF X THEN Y ELSIF Z ELSIF ... ∞

Large language models slowly emerged in 2018 to solve these kinds of issues, but frankly these solutions were so pricey and impractical that it would have never worked for a poorly performant Raspberry Pi Zero.

Then this month ChatGPT APIs were released - small pause - and oh boy, do they just work...

For the last couple of weeks, I've been experimenting with an integration of OpenAI APIs with this small personal Telegram bot, and on more than one occasion I was just stumped by how smoothly this worked. You can notice this by the tone of my overly excited toots. As someone who has never studied or worked with LLMs this was just magical; with the power of a prompt I could talk to an AI impersonating Joshua_bot, that chatbot I wrote almost eight years ago. Now by simply writing plain English (or sometimes even Italian) I can invoke plugins and execute commands on my Raspberry Pi, It feels like having your own personal Siri that executes and triggers pieces of code at will.

Under the hood, the AI handler works so that it generates a text-davinci-003 prompt to learn and convert plain text to programmatic commands for each loaded plugin. Otherwise, in case no commands are matching, it uses a new prompt in gpt-3.5-turbo for a more "human like" conversation.

This is an example of a generated prompt for teaching how to recognize plugins commands:

Joshua is a chatbot capable of translating text to a programmatic command, for example:
You: return a random number from 1 to 6
Joshua: /diceroll
You: return a random number from 1 to 10
Joshua: /diceroll 10
You: get a random fortune cookie
Joshua: /fortune
You: search for a lyrics of a song
Joshua: /lyrics
You: play rock paper scissors
Joshua: /morra
You: return issue number 6 of xkcd comic
Joshua: /xkcd 6
You: list all commands available for plugins, features or in general what the bot is capable of doing
Joshua: /help

You can notice that by simply giving two examples for /diceroll and /diceroll 10 (one with parameter and one without), the model automatically understands it should replace that number 10 with any number given by the user. I was blown away when I discovered this!

I understand that this use case is so minuscule in comparison to what this tech can be used for, but personally, I would refrain myself from calling ChatGPT just a fad (yet). I can certainly see the dark aspects of this tech: we will see a myriad of AI generated blog posts full of ads on how to use React hooks because SEO algorithms are just too dumb; or even smarter scammy Tinder bots; maybe films and TV shows co-written by LLMs?

asking ChatGPT to generate a star wars name

Overall, I found this experience very inspiring and eye-opening. It motivated me to dig more into LLMs and neural networks, which is a topic I've always ignored. Who knows, maybe the next season of Andor will even feature Vexor Rell.

Article written by human not by AI (maybe?)