- C 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| src | ||
| .gitignore | ||
| BUILDING.txt | ||
| README.md | ||
| WMAKE.txt | ||
GPT4DOS
v0.1a — "ELIZA'S REVENGE"
A chat client for MS-DOS that talks to a remote Ollama server, built on mTCP for networking. Runs on real DOS-era hardware — a 386 with a packet driver and 2MB RAM is plenty.
==============================================================
____ ____ ____ ___ ____
| _| | _ \| _ \/ _ \/\___ \ GPT4DOS v0.1a
| | | | |_) | |_) | | | ___ \ "ELIZA'S REVENGE"
| | | | __/| _ <| |_| |___) |
| |_| |_| |_| \_\\___/____/ A 40-year gap, closed
over TCP.
==============================================================
Left: 1987. Right: the future. Connected by TCP/IP.
Why?
Because we can. In 1966, ELIZA pretended to understand you with pattern matching. In 1987, DOS gave PC users their first taste of mainstream computing. In 2026, we let a model running on a Linux server do the actual thinking, and let a 40-year-old machine be the face of the conversation.
Plaintext HTTP only — mTCP has no TLS. Intended for trusted LANs.
What you need
DOS side:
- MS-DOS / PC-DOS / FreeDOS (real HW or DOSBox)
- A network card with a packet driver (e.g.
ne2000.com 0x60 5 0x300) - mTCP configured (
set MTCPCFG=...)
Server side:
- Ollama, listening beyond localhost:
OLLAMA_HOST=0.0.0.0:11434 ollama serve - A model pulled, ideally a small fast one (
llama3.2,qwen2.5:0.5b,smollm)
Build:
- Open Watcom C/C++ —
wcc386,wlink,wmake
Build
# Get mTCP into ./MTCP (adjust to your download)
unzip mTCP_latest.zip -d MTCP
wmake -f WMAKE.TXT # produces GPT4DOS.EXE
Run
Real machine:
C:\> ne2000 0x60 5 0x300
C:\> set MTCPCFG=C:\MTCP\MTCP.CFG
C:\> GPT4DOS.EXE 192.168.1.100 llama3.2
DOSBox (NE2000 emulation, bridged to host NIC):
wmake -f WMAKE.TXT run
Commands in the chat: /quit exits, /clear resets conversation context.
Architecture
src/GPT4MTCP.c— main: chat loop, HTTP request build, mTCP lifecyclesrc/NDJSON.c— streaming response handler: NDJSON line scanner + HTTP chunked de-framing, tolerant of TCP reads that split tokens mid-linesrc/NDJSON.h— interface for the aboveWMAKE.TXT— Open Watcom build file (wmake -f WMAKE.TXT)
Non-streamed replies ("stream": false) land in one 64KB buffer; streamed replies
(NDJSON.c) print tokens live as each NDJSON line arrives.
Caveats / TODO
- Conversation context is kept by appending prior turns into the prompt — crude but cheap. Switching to
/api/chatwith proper message arrays is on the roadmap. - No TLS: run this only on networks you trust.
- Verify mTCP API signatures against your mTCP release (
tcp.h); they have shifted slightly between versions. - Escape sequences decode
\uXXXXto?— CP437 says hi. - Future work: ANSI.SYS output colors, 80-column word wrap, DNS resolution for hostnames.
Credits
- mTCP by Michael Brutman (http://www.brutman.com/mTCP/)
- Ollama by the Ollama team (https://ollama.com)
- Open Watcom maintained by the OW community
GPT4DOS: written in fun, compiled in anger, shipped over TCP.
License
MIT — do what you like, but share your improvements.