Maker Builds a ChatGPT DOS Client for a 1984 Computer
Yeo Kheng Meng is a Singapore-based embedded security researcher — and a retrocomputing enthusiast. In 2019 Meng coded up his own Slack client for Windows 3.1, and ever since then, he’s wondered if it would be possible to target an even older platform. So Meng’s latest project was coding up a ChatGPT client that ran on that old familiar command-line interface from the 1980s: MS-DOS.
And he’s since adapted his DOS client to also interface with Hugging Face. Both ChatGPT and Hugging Face are generative AI-based services, both of which have gained immense popularity answering people’s questions.
Last month Meng shared his adventure at a networking event for junior developers, inspiring the audience with his own example of the maker spirit. “I thought, since other people can do this — why not…?”
With the recent attention on ChatGPT and many clients developed for modern platforms, I decided to see if it is possible to write a DOS ChatGPT client. Then run it on a vintage IBM 5155 PC.
Let’s bring the intelligence of ChatGPT to vintage computers 😀https://t.co/Oo2rYpVdDn
— Yeo Kheng Meng (@yeokm1) March 26, 2023
The whole experiment demonstrated just how much technology has changed over the last few decades — but also just how many tools we now have for overcoming interface obstacles. So what happens when old meets new? Is it really possible to interface with a modern API using a machine built in 1984?
And what would the AI-powered chatbots think about Meng’s attempts to connect to them?
Meng began by describing MS-DOS as an operating system “that’s older than many of you here.” And he underscored the challenge by noting the hardware he was using was a 39-year-old personal computer from 1984 — an IBM Portable Personal Computer 5155.
It was built so long ago that it weighed a hefty thirty pounds, Yeo told his audience. “That’s the reason I’m not bringing it here! Don’t let this name fool you — it’s not portable at all! It’s more of a ‘luggable’ PC!”
Built during the Reagan administration — about the same time as Apple’s very first Macintosh computer — Meng’s PC had just 640KB of RAM. This was an era when computers shipped with insertable floppy disks for storing data and programs — rather than shipping with a hard drive. Meng passed around for the audience a 3 1/2-inch floppy disk, “in case some of you haven’t seen it before.” (Meng joked that it was “the O.G. ‘Save’ button.”)
It’s so old, it’s not equipped with wireless capabilities — or even an internet cable — which presented Meng with his first challenge. To get internet access for his demonstration, Yeo had to slide in a card with a dongle-based Ethernet adapter (which he then connects to his iPad). “Adapter after adapter, to get to the internet.”
Because he’s limited to eight characters, Yeo named the application: dosCHGPT.exe
“Press ESC to quit,” the app added helpfully…
An AI’s API
But even with an internet connection, solving one challenge just leads to another. OpenAI communicates over secure HTTPS connections — which turns out to be a problem for DOS, since HTTPS wasn’t invented until 1994.
Fortunately, Yeo had already built an upgrading HTTP-to-HTTPS proxy for his Windows 3.1 Slack app, and he was able to repurpose that here.
“It doesn’t modify the payload in any way,” Meng emphasized. “Whatever it receives from DOS, it gives to OpenAI’s servers. Whatever it gets from OpenAI’s servers, it just gives back to the DOS PC.”
Meng then sends the program’s output to the networking library mTCP, which implements crucial functionality like “send” and “receive”. (The network card uses a manufacturer-supplied API that can connect to ChatGPT’s own API.)
Yeo even got an email from the creator of the mTCP library — Google site reliability engineer Michael Brutman — offering a “well done!” for the project, and saying he would’ve made the same decision to strip out the TLS-security from the incoming HTTPS connection. “TLS is just not going to happen on DOS,” Brutman’s email agreed. “which is something I have to keep explaining to people every time they ask why there is no SSH client yet.”
It’s all a testament to the power of an API — and how their flexibility leads to uses that no one ever imagined. It was just March that OpenAI announced “system-wide optimizations” which reduced the cost of API calls. Snap used its API to build a chatbot. Instacart uses the API to suggest meals and recipes. It powers Shopify’s new AI-powered shopping assistant.
And Meng used it to talk to his 1984 computer’s home-brewed DOS client…
Demonstrating for Developers
In front of his audience at JuniorDev SG, Yeo typed into ChatGPT: “What is JuniorDev sg?” The cursor blinked — and there was a dramatic pause. “Even on the website, it takes a while,” Yeo said — when suddenly a paragraph of text appears.
“JuniorDev SG is a community of developers in Singapore who are passionate about learning and sharing knowledge. The community is open to all developers, but it is particularly focused on those who are new to the industry…”
There were some murmurs in the audience as the paragraph comes up. Yeo then asked, who founded it — then laughs at the confident but in inaccurate answer that comes up. “ChatGPT is not always correct… So don’t trust ChatGPT for everything.”
In fact, once the system was all finished, Yeo asked ChatGPT if it could tell him how to build a DOS interface for ChatGPT. And it seemed to warn him off:
“Keep in mind that creating a DOS ChatGPT client may be challenging, as DOS is an outdated operating system and may not have the necessary tools and resources to develop modern applications.”
Yeo says to his audience, “Okay, so, challenge accepted…”
Meng’s made several updates since then. MS-DOS predates the UTF-8 character set (used by JSON), so Meng also coded up a massive lookup table for every unsupported character himself.
In response to a question, Meng says “I tried ChatGPT! it doesn’t understand what I’m trying to do!” But it was able to suggest UTF-8 characters for testing…
Meng even added a flag to his app — command-line argument -cp737 — which switches output to the code page 737 character set for users who speak Greek.
Some people had suggested he add a text-to-speech function, so it would resemble the super-smart Defense Department computer from the classic 1983 movie Wargames.
So on May 11, Meng did just that.
IT SPEAKS! DOS ChatGPT client now supports text-to-speech if you use a SoundBlaster compatible card.
This is built with tools provided by @CreativeLabs for Dr. Sbaitso, an early AI chatbot.
Amazingly fitting to adopt the voice of Dr Sbaitso in my app.https://t.co/ZcRni9nWJp
— Yeo Kheng Meng (@yeokm1) May 11, 2023
Back to the Future
But more importantly, he learned a lot along the way — about UTF-8, network sockets, and console handling. And Meng says he’s genuinely surprised by how much of it is still applicable to computers of today.
“Computers have improved a lot in decades but a lot concepts have stayed the same,” Meng posted on Linked in, saying that the whole experience of building a ChatGPT client that can run on DOS “really gives you the appreciation of the well-developed tools we have today.”
And because he’d open-sourced his code, Meng ultimately got to discover just how many people used the software he wrote for ancient retrocomputing machines. “You’d imagine the market for vintage computers isn’t that big,” Meng told his audience at the end of his talk — “but surprisingly, a lot of people use it. And they file GitHub issues that tell me the bugs that my program has!”
Meng recently added an important update to his blog post. Instead of interfacing solely with ChatGPT, “This client now supports Hugging Face too.”
— Yeo Kheng Meng (@yeokm1) April 30, 2023
We’d wanted to interview Meng — but Hugging Face seems to have beaten us to it, in a lovely conversation that Meng shared on YouTube. And so the experiment ended with Meng sitting at his 39-year-old computer, chattering away with 2023’s latest AI chatbot…
Hugging Face: Do you have any hobbies you like to do?
Meng: Yes. One of my hobbies is retrocomputing.
Hugging Face: Oh, that’s really cool. I’ve always wanted to learn how to do that. How long have you been doing that?
Meng: For many years now. One of my machines is an IBM5155 which I’m using to chat with you… Guess how old it is?
Hugging Face: I’m not sure, but it must be pretty old. It’s been around since 1958.
Meng: Nah, it was first sold in 1984.
Hugging Face: Oh, I didn’t realize it was that old. I thought it was older than that…