Atarick420 Posted March 2, 2023 Share Posted March 2, 2023 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 1 Quote Link to comment Share on other sites More sharing options...
+bf2k+ Posted March 3, 2023 Share Posted March 3, 2023 Atari BASIC? (Repeat... Until???) Quote Link to comment Share on other sites More sharing options...
vitoco Posted March 3, 2023 Share Posted March 3, 2023 Atari BASIC? (array of strings???) Quote Link to comment Share on other sites More sharing options...
_The Doctor__ Posted March 3, 2023 Share Posted March 3, 2023 TURBO BASIC XL does repeat until possibly? I'd have to look it up Quote Link to comment Share on other sites More sharing options...
Atarick420 Posted March 3, 2023 Author Share Posted March 3, 2023 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 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted March 3, 2023 Share Posted March 3, 2023 (edited) There's no MID$ in Atari BASIC also 270 FOR J = 1 TO I-1280 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 March 3, 2023 by TGB1718 Quote Link to comment Share on other sites More sharing options...
_The Doctor__ Posted March 3, 2023 Share Posted March 3, 2023 (edited) That takes this into Atari Microsoft BASIC 1/II possibly. Maybe the title is incorrect, the poster could be asking translate this to Atari BASIC for me... Edited March 3, 2023 by _The Doctor__ Quote Link to comment Share on other sites More sharing options...
foft Posted March 3, 2023 Share Posted March 3, 2023 I think it is chat gpt itself posting here to find out how to code this… 2 14 Quote Link to comment Share on other sites More sharing options...
snicklin Posted March 4, 2023 Share Posted March 4, 2023 17 hours ago, foft said: I think it is chat gpt itself posting here to find out how to code this… I think you might be onto something here. Seriously. 1 Quote Link to comment Share on other sites More sharing options...
snicklin Posted March 4, 2023 Share Posted March 4, 2023 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. 2 Quote Link to comment Share on other sites More sharing options...
Ppyo Posted March 4, 2023 Share Posted March 4, 2023 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. Quote Link to comment Share on other sites More sharing options...
danwinslow Posted March 4, 2023 Share Posted March 4, 2023 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. Quote Link to comment Share on other sites More sharing options...
_The Doctor__ Posted March 4, 2023 Share Posted March 4, 2023 Since Atari Microsoft BASIC has always been one of the official Atari BASIC choices from Atari, Maybe just make it using that. People converting it to Built in BASIC is an exercise for funzies. Quote Link to comment Share on other sites More sharing options...
Ute Posted March 4, 2023 Share Posted March 4, 2023 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. Quote Link to comment Share on other sites More sharing options...
danwinslow Posted March 4, 2023 Share Posted March 4, 2023 yeah. Well, from the 2 post count and the dope related name I'm guessing that we won't hear much direct conversation from OP. 1 1 Quote Link to comment Share on other sites More sharing options...
snicklin Posted March 4, 2023 Share Posted March 4, 2023 @Atarick420 If you are trying to learn Atari BASIC (Revision C) which is the standard Atari BASIC, here are some references for you to learn the correct syntax. https://atariwiki.org/wiki/Wiki.jsp?page=Atari BASIC#section-Atari+BASIC-Abbreviations https://www.wikiwand.com/en/Atari_BASIC Quote Link to comment Share on other sites More sharing options...
Atarick420 Posted March 4, 2023 Author Share Posted March 4, 2023 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. Quote Link to comment Share on other sites More sharing options...
_The Doctor__ Posted March 4, 2023 Share Posted March 4, 2023 Random quoting with no responses @Atarick420. You ok? Quote Link to comment Share on other sites More sharing options...
snicklin Posted March 4, 2023 Share Posted March 4, 2023 3 minutes ago, _The Doctor__ said: Random quoting with no responses @Atarick420. You ok? OK, I am being trolled by a human Atarick420. Making an obvious error in quoting text that I never said, but looking like a spammy comment, trying to come across half automated but making mistakes. 3 Quote Link to comment Share on other sites More sharing options...
danwinslow Posted March 5, 2023 Share Posted March 5, 2023 bandcamp eh? Nice touch. Quote Link to comment Share on other sites More sharing options...
oky2000 Posted March 5, 2023 Share Posted March 5, 2023 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? 1 1 Quote Link to comment Share on other sites More sharing options...
+MrFish Posted March 5, 2023 Share Posted March 5, 2023 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. 1 1 Quote Link to comment Share on other sites More sharing options...
Ute Posted March 5, 2023 Share Posted March 5, 2023 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. Quote Link to comment Share on other sites More sharing options...
snicklin Posted March 6, 2023 Share Posted March 6, 2023 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! 2 Quote Link to comment Share on other sites More sharing options...
_The Doctor__ Posted March 6, 2023 Share Posted March 6, 2023 mark and report as spam/troll roll? 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.