Jump to content
IGNORED

ChatGPT and the atari 8 bit. help me debug this and get it working


Atarick420

Recommended Posts

10 REM Atari BASIC program for OpenAI chatbot using FujiNet interface
20 REM -------------------------------------------------------------
30 REM Set up FujiNet interface
40 DIM HOST$(255)
50 HOST$="api.openai.com"
60 PORT$="443"
70 OPEN #1,8,0,"SSL:"+HOST$+":"+PORT$
80 REM Authenticate API request with API key
90 DIM API_KEY$(100)
100 INPUT "Enter your OpenAI API key: ", API_KEY$
110 PRINT #1,"POST /v1/engines/davinci-codex/completions HTTP/1.1"+CHR$(13)
120 PRINT #1,"Authorization: Bearer "+API_KEY$+CHR$(13)
130 PRINT #1,"Content-Type: application/json"+CHR$(13)
140 REM Send API request to start a chat session
150 PRINT #1,"Content-Length: 50"+CHR$(13)
160 PRINT #1,""+CHR$(13)
170 PRINT #1,"{""prompt"":""Hello, I'm looking to chat.""}"+CHR$(13)
180 DIM RESPONSE$(255)
190 DIM BUFFER$(1)
200 I = 1
210 REM Wait for API response
220 REPEAT
230 INPUT #1, BUFFER$
240 IF BUFFER$ <> CHR$(13) THEN RESPONSE$(I) = BUFFER$: I = I+1
250 UNTIL BUFFER$ = CHR$(13)
260 REM Display chat prompt
270 FOR J = 1 TO I-1
280 PRINT RESPONSE$(J)
290 NEXT J
300 REM Loop to send messages to chatbot
310 DIM MESSAGE$(255)
320 DIM CONVERSATION_ID$(255)
330 CONVERSATION_ID$ = MID$(RESPONSE$(12),22,64)
340 REPEAT
350 REM Prompt user for message to send
360 INPUT "You: ", MESSAGE$
370 REM Send message to chatbot API
380 PRINT #1,"POST /v1/engines/davinci-codex/completions HTTP/1.1"+CHR$(13)
390 PRINT #1,"Authorization: Bearer "+API_KEY$+CHR$(13)
400 PRINT #1,"Content-Type: application/json"+CHR$(13)
410 PRINT #1,"Content-Length: 166"+CHR$(13)
420 PRINT #1,""+CHR$(13)
430 PRINT #1,"{""prompt"":"""+MESSAGE$+" \nAI: "",""temperature"":0,""max_tokens"":256,""stop"":""\n""}"
440 REM Wait for chatbot response
450 DIM RESPONSE$(255)
460 DIM BUFFER$(1)
470 I = 1
480 REPEAT
490 INPUT #1, BUFFER$
500 IF BUFFER$ <> CHR$(13) THEN RESPONSE$(I) = BUFFER$: I = I+1
510 UNTIL BUFFER$ = CHR$(13)
520 REM Display chatbot response
530 FOR J = 1 TO I-1
540 PRINT RESPONSE$(J)
550 NEXT J
560 UNTIL MESSAGE$ = "bye"
570 REM Close FujiNet connection
580 CLOSE #1
590 END
 

  • Thanks 1
Link to comment
Share on other sites

refined code version 2 

with print and disl saving of buffer

10 REM Atari BASIC program for OpenAI chatbot using FujiNet interface
20 REM -------------------------------------------------------------
30 REM Set up FujiNet interface
40 DIM HOST$(255)
50 HOST$="api.openai.com"
60 PORT$="443"
70 OPEN #1,8,0,"SSL:"+HOST$+":"+PORT$
80 REM Authenticate API request with API key
90 DIM API_KEY$(100)
100 INPUT "Enter your OpenAI API key: ", API_KEY$
110 PRINT #1,"POST /v1/engines/davinci-codex/completions HTTP/1.1"+CHR$(13)
120 PRINT #1,"Authorization: Bearer "+API_KEY$+CHR$(13)
130 PRINT #1,"Content-Type: application/json"+CHR$(13)
140 REM Send API request to start a chat session
150 PRINT #1,"Content-Length: 50"+CHR$(13)
160 PRINT #1,""+CHR$(13)
170 PRINT #1,"{""prompt"":""Hello, I'm looking to chat.""}"+CHR$(13)
180 DIM RESPONSE$(255)
190 DIM BUFFER$(1)
200 I = 1
210 REM Wait for API response
220 REPEAT
230 INPUT #1, BUFFER$
240 IF BUFFER$ <> CHR$(13) THEN RESPONSE$(I) = BUFFER$: I = I+1
250 UNTIL BUFFER$ = CHR$(13)
260 REM Set screen colors to black background with green text
270 GRAPHICS 0
280 COLOR 0,1,0
290 REM Print chat prompt
300 FOR J = 1 TO I-1
310 PRINT RESPONSE$(J)
320 PRINT #6, RESPONSE$(J)  :REM print to screen
330 NEXT J
340 REM Loop to send messages to chatbot
350 DIM MESSAGE$(255)
360 DIM CONVERSATION_ID$(255)
370 CONVERSATION_ID$ = MID$(RESPONSE$(12),22,64)
380 REM Open file for saving chat buffer
390 PRINT #1,"ATTR DISK1:chat.txt"
400 PRINT #1,"OPEN #3:chr$(8):""chat.txt"":chr$(8):""O"""
410 REM Main chat loop
420 REPEAT
430 REM Prompt user for message to send
440 INPUT "You: ", MESSAGE$
450 REM Send message to chatbot API
460 PRINT #1,"POST /v1/engines/davinci-codex/completions HTTP/1.1"+CHR$(13)
470 PRINT #1,"Authorization: Bearer "+API_KEY$+CHR$(13)
480 PRINT #1,"Content-Type: application/json"+CHR$(13)
490 PRINT #1,"Content-Length: 166"+CHR$(13)
500 PRINT #1,""+CHR$(13)
510 PRINT #1,"{""prompt"":"""+MESSAGE$+" \nAI: "",""temperature"":0,""max_tokens"":256,""stop"":""\n""}"
520 REM Wait for chatbot response
530 DIM RESPONSE$(255)
540 DIM BUFFER$(1)
550 I = 1
560 REPEAT
570 INPUT #1, BUFFER$
580 IF BUFFER$ <> CHR$(13) THEN RESPONSE$(I) = BUFFER$: I = I+1
590 UNTIL BUFFER$ = CHR$(13)
600 REM Print chatbot response
610 FOR J = 1 TO I-1
620 PRINT RESPONSE$(J)
630 PRINT #6, RESPONSE$(J) :REM print to screen
640 PRINT
 

Link to comment
Share on other sites

There's no MID$ in Atari BASIC

also

270 FOR J = 1 TO I-1
280 PRINT RESPONSE$(J)
290 NEXT J

would print everything from position 'J' to the end of the string , not what I think was intended

so this is certainly anther BASIC version other than Atari BASIC

 

Don't think TBXL either as it doesn't support adding strings this way

 

70 OPEN #1,8,0,"SSL:"+HOST$+":"+PORT$

 

and it doesn't support undimmed strings i.e.

60 PORT$="443"

used without a DIM

Edited by TGB1718
Link to comment
Share on other sites

Here is a non-exhaustive list of issues here.

 

Are you looking to program this in Atari BASIC or another dialect of BASIC?

 

Presuming you want to program in plain Atari BASIC, 'REPEAT' and 'UNTIL' cannot be used as this is not valid syntax for Atari BASIC. You can rewrite this using a 'for' loop or if's with GOTO statements.

 

You cannot concatenate strings with + symbols. 

 

COLOR 0,1,0 is not correct syntax. Use 'SETCOLOR' instead.

 

You need to DIM the PORT$ variable before using it.

 

Do not use underscores in variable names.

 

MID$ is not an available command in Atari BASIC. Directly reference the characters in the string instead.

 

  • Like 2
Link to comment
Share on other sites

1 hour ago, snicklin said:

Here is a non-exhaustive list of issues here.

 

Are you looking to program this in Atari BASIC or another dialect of BASIC?

 

Presuming you want to program in plain Atari BASIC, 'REPEAT' and 'UNTIL' cannot be used as this is not valid syntax for Atari BASIC. You can rewrite this using a 'for' loop or if's with GOTO statements.

 

You cannot concatenate strings with + symbols. 

 

COLOR 0,1,0 is not correct syntax. Use 'SETCOLOR' instead.

 

You need to DIM the PORT$ variable before using it.

 

Do not use underscores in variable names.

 

MID$ is not an available command in Atari BASIC. Directly reference the characters in the string instead.

 

@snicklin summed it up quite well. To me, it looks like it is M$ Basic to Atari Basic port. 

Link to comment
Share on other sites

Have 0 experience with chatGPT, but I really do think foft has a point. Think about it - if chatGPT had been asked to 'write an atari basic program to communicate with itself', then it could appear as above, sort of a close-but-not-quite-right deal. ChatGPT, as I understand, was trained on huge amounts of stuff on the internet. Given the way that works, you kind of expect that it would have some dialect drift since it's seen hundreds of BASIC variants, and what you would get back out is sort of an averaged mish-mash syntactically.

 

That said, I find it hard to believe that it would be able to a-priori write the above details about communication with itself using the fujiNet api and the details of atari SIO. Right now I lean towards somebody just screwing with us. I don't think chatGPT actually reasons on it's own much, it's just an extremely well trained and sophisticated natural language machine learning model.

Link to comment
Share on other sites

I was fooling around and I asked ChatGPT to write me an algorithm in 6502 assembly for Atari to display characters on the screen. It returned something mostly correct but had an opcode I didn't recognize. I don't know if it was illegal, but it wasn't standard. I then told ChatGpt that particular opcode was incorrect(It does understand context for the same session). First it apologized and then it re-wrote the code closer to something I would expect.

 

The point is, I think it is mixing and matching code with what it 'thinks' is the best version. Just like with the assembly and as others have guessed, it's trying to build a version from all the little bits of basic it can find and mashing them all together.

 

@Atarick420 I would start over and ask the same question but make it as defined as you can(such as requiring it to be in Atari Standard Basic Version C). Then look at the code and ask follow up questions or place additional constraints and it can re-write the output based on that.

 

And keep in mind it's still a very young technology and may not be able to write something like that for a few more years/decades.

 

 

Link to comment
Share on other sites

10 hours ago, snicklin said:

thank you ill try the changes tonight sorry for the late responce i was in the studio recording all day 😃

http://csmp3.bandcamp.com

 

10 hours ago, snicklin said:

 

Here is a non-exhaustive list of issues here.

 

Are you looking to program this in Atari BASIC or another dialect of BASIC?

 

Presuming you want to program in plain Atari BASIC, 'REPEAT' and 'UNTIL' cannot be used as this is not valid syntax for Atari BASIC. You can rewrite this using a 'for' loop or if's with GOTO statements.

 

You cannot concatenate strings with + symbols. 

 

COLOR 0,1,0 is not correct syntax. Use 'SETCOLOR' instead.

 

You need to DIM the PORT$ variable before using it.

 

Do not use underscores in variable names.

 

MID$ is not an available command in Atari BASIC. Directly reference the characters in the string instead.

 

 

Link to comment
Share on other sites

14 hours ago, snicklin said:

Here is a non-exhaustive list of issues here.

 

Are you looking to program this in Atari BASIC or another dialect of BASIC?

 

Presuming you want to program in plain Atari BASIC, 'REPEAT' and 'UNTIL' cannot be used as this is not valid syntax for Atari BASIC. You can rewrite this using a 'for' loop or if's with GOTO statements.

 

You cannot concatenate strings with + symbols. 

 

COLOR 0,1,0 is not correct syntax. Use 'SETCOLOR' instead.

 

You need to DIM the PORT$ variable before using it.

 

Do not use underscores in variable names.

 

MID$ is not an available command in Atari BASIC. Directly reference the characters in the string instead.

 

79kQ.gif.2dc433559669fc2621397c17aaafac4a.gif

 

  • Like 1
  • Haha 1
Link to comment
Share on other sites

18 hours ago, oky2000 said:

ChatGPT is digital snake oil fooling millennial losers with the IQ of a boiled potato lol why are people of my generation even trying it?

 

 

Ha ha, true for the most part, however....

 

ChatGPT has passed the BAR examination, albeit with a C+ average. As well it has written quite a few PHD thesis'. It has also been writing research papers for high schoolers and undergraduates, which has been very upsetting for the respective teachers and professors. I'm no AI expert but from what I understand, the limits to the potential are 1) the amount of data available and 2) the feedback received from users - compounded by time(And of course the original algorithms used to program the AI).

 

The technology is very young, but it will only get better with time and larger data sets. There is potential there, But it may be decades away.

 

Link to comment
Share on other sites

3 hours ago, Ute said:

Ha ha, true for the most part, however....

 

ChatGPT has passed the BAR examination, albeit with a C+ average. As well it has written quite a few PHD thesis'. It has also been writing research papers for high schoolers and undergraduates, which has been very upsetting for the respective teachers and professors. I'm no AI expert but from what I understand, the limits to the potential are 1) the amount of data available and 2) the feedback received from users - compounded by time(And of course the original algorithms used to program the AI).

 

The technology is very young, but it will only get better with time and larger data sets. There is potential there, But it may be decades away.

 

Interestingly my wife is a teacher. She uses it to create lesson plans and loves it!

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...