Singaporean reverse computing enthusiast Yeo Kheng Meng has released a “doschgpt” ChatGPT client for MS-DOS systems from the 1980s.
At present, the ChatGPT client of this DOS system has successfully run on an IBM 5155 portable PC in 1984. This machine is equipped with an Intel 8088 CPU with a main frequency of 4.77Mhz and an MS-DOS 6.22 system with 640KB memory and CGA ISA graphics.
Brother Yeo is an out-and-out “retro conservative”. As early as 2019, he developed a Slack client for Windows 3.1. This time, he combined the 1981 MS-DOS plain text operating system with the latest ChatGPT Two things that spanned over 40 years come together.
The most interesting thing is the development process of the whole program. Brother Yeo first found an “Open Watcom” C/C++ compiler that can develop 16-bit DOS programs. It itself is a 32-bit program, which means it can run on 64-bit Windows 11 and other modern platforms.
However, 64-bit Windows cannot execute 16-bit DOS programs, and it is not very realistic to run the test on an old computer with 640K memory every time. So Yeo opened a Virtualbox virtual machine running DOS 6.22, and then bridged the virtual machine and the host to the network to facilitate the transfer of files for development and testing. After the test was completed, the binary files were transferred to the actual IBM PC to run.
But here comes another question: How do you handle networking on such an old IBM PC? In this step, Yeo found a Packet Driver API from 1983, and then integrated into the application using the open-source MTCP library to communicate with the Packet Driver to enable network functionality for the client.
To use the ChatGPT API, there must be a Post request, but DOS has no auxiliary functions that can be used, and the entire POST request must be manually constructed in C language:
#define API_CHAT_COMPLETION "POST /v1/chat/completions HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Bearer %s\r\nHost: api.openai.com\r\nContent-Length: %d\r\nConnection: close\r\n\r\n%s"
#define API_BODY "{ \"model\": \"%s\", \"messages\": [{\"role\": \"user\", \"content\": \"%s\"}], \"temperature\": %.1f }"
At this time ChatGPT API will return a JSON output, the value of the “Content” key needs to be parsed. Obviously, there is no ready-made JSON library available in this step, and we can only manually write the parsing code of the key-value pair.
At this time, a new problem came: ChatGPT API is encrypted through HTTPS, but the DOS system does not have native HTTPS, Yeo can only write a go language HTTP to HTTPS proxy (a bit like an intermediate server), and then run this proxy on a modern PC. Act as a transparent middleman. It checks the host field of the HTTP request and forwards the raw socket bytes to OpenAI’s servers as HTTPS.
This step is a bit like cheating, but it is really a helpless move. After all, it is too difficult to run modern TLS encryption algorithms on the Intel 8088 for this heirloom series CPU.
The rest is how to read/write the dialogue content to the console, this step will not be repeated, and interested friends can view the complete development process in Yeo’s blog. The final effect achieved:
Yeo has open-sourced the entire doschgpt client on Github. There are detailed tutorials in it. Interested friends can try it out by themselves (provided that there is an heirloom machine with MS-DOS system at home????…)
In addition, the Tualatin old man has something to say this time, and he still dislikes the configuration of the machine? Processor below 3.0 Ghz can not be used? How can someone run ChatGPT on a 4.77Mhz CPU? It’s not that the ability to do it yourself is too poor! It’s still the same sentence, what’s wrong with something old,It’s not that it can’t be used!
#Computers #run #ChatGPT #News Fast Delivery