Now Reading
“TRS-GPT” : ChatGPT from a TRS-80 Mannequin III Pc inbuilt 1981

“TRS-GPT” : ChatGPT from a TRS-80 Mannequin III Pc inbuilt 1981

2023-08-26 14:27:26

If you wish to skip forward, and easily see the ultimate, working challenge, then CLICK HERE

After I was a child, round 1985, I bought an Atari 800XL,

Atari 800XL, image courtesy Wikipedia
 
 

It was essentially the most joyous and addicting toy I had ever skilled, particularly because it had video games like Zork:

Zork II, image courtesy www.atarimania.com
 
 

Pondering again, I typically inform others that I drastically improved my studying and vocabulary expertise whereas taking part in video games comparable to Zork on a CRT tv related to the Atari laptop.
As I performed video games, I grew to become interested by how they have been made, and I found the BASIC programming language.
instance courtesy of https://www.youtube.com/@mmille10

Though solely the fundamentals of the language made sense to me, I bought a kick out of painstakingly, manually typing in lengthy packages that did cool issues from my subscription to Antic Magazine:

My Antic journal, 1986
 
 

However what I actually needed to put in writing was an interactive program like Zork, however the place I might chat with it, and it could be capable of maintain an clever dialog with me. In different phrases, it has at all times been my dream to have artificial general intelligence on my Atari. This purpose was particularly impressed by motion pictures comparable to War Games:

Conflict Video games Film - 1983

Quick ahead about 40 years…

I’m now a middle-aged man with a number of levels, working for NASA JPL. For all of those years, I’ve saved alive the childhood dream of interacting (chatting) with the pc in an clever manner.

This yr, 2023, two issues occurred, that allowed me to “shut the loop” on my childhood dream:

As a child, I bear in mind mates speaking in regards to the TRS-80, referring to it because the “trash 80”. So my expectations weren’t that top, however I noticed that it regarded fairly retro, had about the identical decision as my previous Atari 800XL, and it ran BASIC!

After I opened the field, and fired it up (not less than the factor powered on), I shortly realized that solely about 10% of the keys truly labored.

I proceeded to take aside the pc, and one-by-one de-soldered every key, disassembled the mechanisms in each, cleaned the contacts, put the important thing again collectively, and soldered the entire keyboard again collectively. Because of this great video, I used to be actually about to grasp the method of keyboard restoration.

The TRS-80, opened up

a top-down view of the keyboard

disassembling the keyboard

keys off

cleansing a key

close-up view of a key contact

soldering the keyboard again collectively

After this, I had a working, lovely TRS-80, with fully-functional keys!

shiny, brand-new, restored TRS-80 Mannequin III!

Then I noticed that I didn’t actually have a laborious drive to retailer BASIC packages (or something) on. Ought to I observe down and purchase a TRS-80 floppy drive from somebody on Ebay? No, that is 2023, and I needed to observe a extra fashionable strategy! I did some searches on-line, and located Ian Mavric, the “Australian TRS-80 Recycler”, and discovered I might get a FreHD module, which primarily permits one to plug an exterior board with a microSD card, into the serial ribbon cable enter on the again of the TRS-80, which might emulate a tough drive. Ian was promoting the the “FreHD Clearly Superior Package for M3/4”, which supposedly labored for my wants. It was “clearly superior”, so it needed to be the appropriate selection for me. I ordered the package, and set it up, which additionally concerned changing a sure ROM chip.

FreHD Clearly Superior Package for M3/4!

Ian was actually useful, and after a number of emails with him, and figuring out that my system truly had the wanted 48K of RAM, I hooked it up!
I used to be now capable of play video games like Microchess 1.5 (copyright 1978)
Microchess 1.5 (copyright 1978)

Apple Panic, the sport

Apple Panic, the sport

After which it dawned on me that to attain my purpose of clever dialogue with my laptop, I actually wanted my TRS-80 to hook as much as the web (in order that I might discuss to OpenAI/ChatGPT). Nearly as good because the FreHD Clearly Superior Package was, I apparently wanted one thing a bit extra Superior. I did extra extra web looking out, and located the TRS-IO.
https://github.com/apuder/TRS-IO

See Also

Overview of the TRS-IO, courtesy of [Arno Puder](https://github.com/apuder/TRS-IO)

The TRS-IO promised to be an answer that would offer the aptitude to each retailer packages, and entry the web. I might even take the micro-SD card that I had with my superior system, and and use it right here. So I ordered the TRS-IO from Arno Puder, and swapped it in for my superior package.

Connecting and configuring the TRS-IO to make use of the WiFi

After connecting it, and configuring it to hook up with my Wi-Fi, which took me some time to determine, as a result of, who knew, however I wanted to truly join the antenna, I used to be up and operating, capable of discover some instance packages in BASIC that related to the WHOIS server to make requests. Arno supplied some super useful starter example code for this, that I used to be capable of mess around with to see how issues work:

With a view to go textual content queries entered on the TRS-80 to the OpenAI server, I first got here up with a plan to implement an AWS lambda perform, sitting behind an API Gateway that handed the question to OpenAI, then returned the response again the TRS-80.
my first try on the topology

After getting the lambda working and examined, I used to be very comfortable, till I noticed that API Gateway solely helps HTTPS connections. Netscape Communications created HTTPS in 1994 for its Netscape Navigator internet browser, 13 years after my laptop was constructed! Moreover the TRS-LIB (a part of TRS-IO) didn’t assist safe connections out-of-the-box. So I made a decision to go a bit extra old style, and get as near the implementation of the WHOIS, port 43 protocol as doable, to keep away from messing round within the BASIC language an excessive amount of. So I settled on implementing a easy EC2 server internet hosting a Python server program, listening on the identical port as the unique WHOIS server instance:

closing, working structure

TRSGPT.BAS (the client-side program):

https://github.com/druid77/trs-gpt/blob/main/TRSGPT.BAS
The BASIC consumer program

For the server aspect (AWS EC2 Python Server), I wrote a easy program like this:

https://github.com/druid77/trs-gpt/blob/main/server.py

import socket
import os
import json
import openai

OPENAI_MODEL = "gpt-3.5-turbo"
openai.api_key = "<REDACTED>"
dialog = []

def chat_with_gpt3(messages):
    response = openai.ChatCompletion.create(
        mannequin=OPENAI_MODEL,
        messages=messages
    )
    return response.decisions[0].message['content']


def handle_client(client_socket):
    user_input = client_socket.recv(1024).decode()
    print(f"Obtained information from consumer: {user_input}")

    dialog.append({"function": "consumer", "content material": user_input})

    response = chat_with_gpt3(dialog)

    dialog.append({"function": "assistant", "content material": response})

    client_socket.ship(response.encode())
    client_socket.shut()

def foremost():
    host = '0.0.0.0'
    port = 43

    server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_socket.bind((host, port))
    server_socket.hear(5)

    print(f"Server listening on port {port}")

    whereas True:
        client_socket, client_addr = server_socket.settle for()
        print(f"Accepted connection from {client_addr}")
        handle_client(client_socket)

if __name__ == "__main__":
    foremost()

Quickly, I had my first profitable communication with ChatGPT:
First profitable communication with ChatGPT!

I noticed, I needed to make some extra enhancements/modifications to the BASIC program, to have it:

  1. Setup and open the socket
  2. Immediate consumer for question
  3. Ship question over the socket
  4. Shut and cleanup the socket
  5. Cycle again to step 1

After these modifications, I used to be capable of work together with ChatGPT on my TRS-80!

ChatGPT on the TRS-80!

I hope you loved studying about my journey to get a retro laptop connecting to the trendy world!

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top