WinGPT logo

WinGPT: AI Assistant for Windows 3.1

Do you use Windows 3.1? Do your friends send you jokes and haikus written by ChatGPT, and make you feel left out? Do you wish you had the sum of all human knowledge at your fingertips? Or wish you had your very own AI chatbot on your trusty 386?

Wish no more! Introducing WinGPT, an AI Assistant for Windows 3.1.

WinGPT helps you:[1]

Screenshot of WinGPT

How was this made?

WinGPT is written in C, using the standard Windows API. I used Open Watcom v2 as the compiler, which is very convenient as it supports cross-compiling to 16-bit Windows from even Windows 11.

WinGPT connects to the OpenAI API server natively with TLS 1.3, so it doesn't require a proxy on a modern machine to terminate TLS. To see how I did this and some of the challenges, take a look at Modern TLS on 16-bit Windows. (As you'll see on that page, this is not a secure implementation).

Screenshot of Wireshark showing WinGPT connecting using TLS

Building the UI

Having been used to building Windows apps like Windle using Delphi previously, I was surprised how primitive the UI building capabilities are with Windows 3.1 if you only use the built-in Windows API.

I built most of the UI in C directly, meaning that each UI component had to be manually constructed in code. Resizing logic manually ensures that each component retains its proper size when the window is resized.

Screenshot of WinGPT GUI code

In particular, I was surprised that the set of standard controls available to use by any program with Windows 3.1 is incredibly limited. You have some controls you'd expect—push buttons, check boxes, radio buttons, edit boxes—but any other control you might need, including those used across the operating system itself, aren't available.

Desktop settings in Windows 3.1
Desktop control panel in Windows 3.1, showing many of the standard controls.

I ran into this problem when I was trying to figure out how to add a status bar to WinGPT. Status bars appear all over Windows 3.1, including in the File Manager and Control Panel. Unfortunately, Microsoft didn't make them widely available to other application developers until Windows 95, alongside a bunch of other useful controls like progress bars, toolbars, and tree views.[2]

As an aside, I asked ChatGPT how I might be able to use a status bar in my program. It replied with a header file that only exists for later versions of Windows, and when I asked it to clarify, it came up with the name of a very enticing (but I'm pretty sure very non-existent) UI library. Luckily, Philip J. Erdelsky still has a status bar implementation from 1997 that is very kindly in the public domain that I was able to use! I modified that code to more closely represent the status bars in Microsoft's programs pixel for pixel.

Screenshot of ChatGPT

Another fun part of building WinGPT was designing the icon in Borland's Image Editor, which is really just a clone of Microsoft Paint that happens to make ICO files instead. Program icons in Windows 3.1 are 32x32, and show up in the Program Manager as well as in the task switcher. I also designed a 16x16 version that shows up on later versions of Windows.

Screenshot of the WinGPT icon being created


Memory is quite limited on Windows 3.1 machines, so I tried to reduce the amount of memory needed for WinGPT, especially in sending and receiving the query and response from the OpenAI API. The JSON responses of modern APIs aren't especially optimized for size, and OpenAI's API is no exception. I've asked the model to be brief in an effort to keep responses as small as possible. I've also chosen not to send the text of previous turns in the API calls, even though this means that the bot won't be able to use prior conversation context.

Screenshot of WinGPT

Try WinGPT

WinGPT is licensed under the GNU General Public License (GPL) v2.

WinGPT will work on any 16-bit or 32-bit version of Windows post-Windows 3.1. It requires an implementation of Winsock (tested with Microsoft TCP/IP-32 3.11b on Windows 3.11 for Workgroups and on stock Windows 2000). It will not work on 64-bit versions of Windows (but does work on Wine—give it a try!)

You'll also need an OpenAI API key to talk to OpenAI. Once you open WinGPT, go to File | Options... to enter your secret key.