ChatGPT: something to play with over Christmas

Post

Posted
Rating:
#1 (In Topic #965)
Avatar
Regular
stevedee is in the usergroup ‘Regular’
ChatGPT is an AI chatbot. Basically you can ask it questions and it will (hopefully) come back with sensible answers.

For example, I asked: "How to cook rice" and this was its reply:-
There are many ways to cook rice, but one of the most basic methods is as follows:

    Rinse the rice in a fine mesh strainer under cold running water. This removes excess starch and dirt from the grains.

    Measure the rice and water. For most types of rice, you will need 1 1/2 to 2 cups of water for every cup of rice.

    Place the rice and water in a pot with a tight-fitting lid. Bring the mixture to a boil over high heat.

    Once the water is boiling, reduce the heat to low and cover the pot with the lid.

    Let the rice simmer for 18-20 minutes or until it is tender and the water has been absorbed. Do not lift the lid or stir the rice during this time.

    When the rice is finished cooking, remove the pot from the heat and let it sit, covered, for an additional 5 minutes. This allows the rice to steam and become fluffier.

    Fluff the rice with a fork and serve.

Note: Some types of rice, such as basmati and jasmine, may require a different water-to-rice ratio and cooking time. Consult the package instructions for specific recommendations.

But its not just a cooking app. Try asking it a coding question: "Write Gambas code to sort list of names"

Image

(Click to enlarge)


The full code output looks like this:-

Code (gambas)

  1. ' Declare an array of strings
  2. DIM names(10) AS STRING
  3.  
  4. ' Initialize the array with some values
  5. names(0) = "Alice"
  6. names(1) = "Bob"
  7. names(2) = "Charlie"
  8. names(3) = "David"
  9. names(4) = "Eve"
  10. names(5) = "Frank"
  11. names(6) = "Greta"
  12. names(7) = "Henry"
  13. names(8) = "Ida"
  14. names(9) = "Jack"
  15.  
  16. ' Perform bubble sort on the array
  17. FOR i = 0 TO LEN(names) - 2
  18.   FOR j = 0 TO LEN(names) - i - 2
  19.     IF names(j) > names(j+1) THEN
  20.       ' Swap the values
  21.       DIM temp AS STRING
  22.       temp = names(j)
  23.       names(j) = names(j+1)
  24.       names(j+1) = temp
  25.     END IF
  26.   NEXT
  27.  
  28. ' Print the sorted array
  29. FOR i = 0 TO LEN(names) - 1
  30.   PRINT names(i)
  31.  
  32.  

Perhaps you want to see what this code would look like in PHP:-
"Rewrite this code in PHP"

…I'll leave you to imagine the possibilities for finding coding solutions, improving your coding skills and converting existing code to other languages.


Once you have registered, use https://chat.openai.com/chat to start asking questions.

Happy Christmas!
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
Looks interesting, i wonder how it works.
Gambas help looks kinda like a VB conversion and doesn't even work.
As i'd more simply sort an array like this..

Code (gambas)

  1. ' Declare an array of strings
  2. Dim names AS String[] = ["Alice", "Bob", "Charlie", "David", "Eve", "Frank", "Greta", "Henry", "Ida", "Jack"]
  3.  
  4. ' Print the sorted array
  5. Print names.Sort(gb.Natural + gb.IgnoreCase).Join("\n")
  6.  

I tried
Dim aStr(5) As String
as i thought this was a method i didn't know about but i got "Syntax error" lol
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Regular
stevedee is in the usergroup ‘Regular’

BruceSteers said

Looks interesting, i wonder how it works…
…I tried
Dim aStr(5) As String
as i thought this was a method i didn't know about but i got "Syntax error" lol

Yes it is interesting.
This ChatBOT is very young and still has plenty to learn.

I started to chat to it earlier;

steve: do you understand gambas arrays
bot: Yes, I am familiar with arrays in Gambas. An array is a data structure that stores a collection of values that are all of the same data type…
steve: write gambas code to sort a list of names
bot:

Code (gambas)

  1. [i]Here is an example of a bubble sort algorithm implemented in Gambas that can be used to sort a list of names:[/i]
  2.  
  3. ' Declare an array of strings
  4. Dim names As String[] = \{"John", "Paul", "George", "Ringo"}
  5.  
  6. ' Perform the bubble sort
  7. For i As Integer = 0 To names.Ubound
  8.     For j As Integer = 0 To names.Ubound - i - 1
  9.         If names[j] > names[j + 1] Then
  10.             ' Swap the names
  11.             Dim temp As String = names[j]
  12.             names[j] = names[j + 1]
  13.             names[j + 1] = temp
  14.         Endif
  15.     Next
  16.  
  17. ' Print the sorted array
  18. For Each name As String In names
  19.     Print name

Obviously this code still does not work, so the chat continued;
steve: that does not work because the {} should be []
bot: You are correct that the curly braces {} should be replaced with square brackets [] when declaring and initializing an array in Gambas. Here is the corrected version of the code that sorts a list of names using a bubble sort algorithm…

…still problems with the new code, the chat continues;
steve: I don't think Gambas uses UBound(), I think it uses Bounds()
bot: You are correct that in Gambas, the Bounds() function is used to get the lower and upper bounds of an array. Here is the corrected version of the code that sorts a list of names using a bubble sort algorithm…

…more problems, more chat;
steve: please recheck as I think the format is names.Bounds.Count
bot: I apologize for the errors in my previous responses. You are correct that in Gambas, you can use the Bounds() function to get the lower and upper bounds of an array, and you can then access the Count property of the Bounds object to get the number of elements in the array…

I assume that if anyone asks the exact question that I asked at the start of this chat, they should get a code example with these problems corrected if the AI bot is really learning from experience.
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
Technopeasant is in the usergroup ‘Regular’
Funny.  :lol:
Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
PartierSP is in the usergroup ‘Regular’
Looks like The Retro Hack Shack tried out your idea Steve, but on a Commodore 64 (video link).

I started to watch it last night before falling asleep.  Yes I have a bad habit of watching tech in bed.  (Now I'm going to have to try and finish watching it tonight  :lol: ).
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Regular
stevedee is in the usergroup ‘Regular’
The AI race is on: Enter The Bard!

Google are about to release "Bard" as their AI Chatbot alternative, and it looks like Microsoft will shortly be rolling out ChatGPT on Bing: Bard: Google launches ChatGPT rival - BBC News
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Guru
cogier is in the usergroup ‘Guru’
I now have access to the Bing AI. Here is my first question and the answer. The code works without modification!

<IMG src="https://www.cogier.com/gambas/Bing_AI_1.png"> </IMG>

This is the code: -

Code (gambas)

  1. Public Sub Button1_Click()
  2.  
  3.  
  4.   s = ""
  5.  
  6.   For i = Asc("A") To Asc("Z")
  7.     s &= Chr(i) & " = " & Str(i) & "\n"
  8.   Next
  9.  
  10.   TextArea1.Text = s
  11.  
  12.  
Online now: No Back to the top

Post

Posted
Rating:
#8
Trainee
Agreed, ChatGPT makes learning and exploring various subject matters really fun and interactive, like having a smart assistant at your disposal. It's incredible how it can explain how to cook a basic meal or translate a code snippet into a different language. I've used it to brush up on a few programming languages, and it elaborates complex procedures into simple instructions. The possibilities are endless and indeed make for a fantastic learning pastime.

I've been giving Special Character AI a go recently. This free AI tool has simplified working with special characters in my projects. It's especially useful when dealing with strings and needing specific character sets. Just thought it might be worth mentioning as another neat AI-powered tool to try out.
Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Regular
cage is in the usergroup ‘Regular’
 So when are we going to get AI on the board.  Just think you won't have to have any human interaction or have to even learn how to program in Gambas. AI will be able to do it all. Have a problem with your program, or have a question AI will do it all for you.
Online now: No Back to the top

Post

Posted
Rating:
#10
Trainee

stevedee said

I assume that if anyone asks the exact question that I asked at the start of this chat, they should get a code example with these problems corrected if the AI bot is really learning from experience.

Interestingly, ChatGPT doesn't learn from past interactions with others:

Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#11
Trainee

cogier said

I now have access to the Bing AI. Here is my first question and the answer. The code works without modification!

I bet we are all wondering what the question was…
Online now: No Back to the top

Post

Posted
Rating:
#12
Avatar
Guru
cogier is in the usergroup ‘Guru’
It was a simple request to see if Bing could create Gambas code. I asked for Gambas code to display ASCII characters.
Online now: No Back to the top
1 guest and 0 members have just viewed this.