Main v2 errors that ChatGPT makes?

Discuss other useful utilities, general computing tips & tricks, Internet resources, etc.
User avatar
kunkel321
Posts: 1156
Joined: 30 Nov 2015, 21:19

Main v2 errors that ChatGPT makes?

20 May 2024, 15:24

I've started using the awesome ChatGPT AutoHotkey Utility script. Since there are several common errors that GPT makes with AHK v2 code, I thought I'd preemptively correct some of them by embedding the corrections in the prompt. Almost always, the problems are because GPT inserts AHK v1 code and syntax.

I thought I'd start by asking GPT, itself, what it's most likely errors would be... The list it gave me is pretty good. Are there other things that you would add? @RaptorX

Code: Select all

AHK v1 versus v2

Function Call Syntax:
AHK v1: FunctionName param1, param2
AHK v2: FunctionName(param1, param2)

Assignment Operator:
AHK v1: var = value
AHK v2: var := value

Variable Dereferencing:
AHK v1: MsgBox % var
AHK v2: MsgBox(var)

If Statements:
AHK v1: If var = value
AHK v2: If (var = value)

Loop Syntax:
AHK v1:
Loop, 10
{
    MsgBox % A_Index
}
AHK v2:
Loop 10
{
    MsgBox(A_Index)
}

Return Values:
AHK v1: return, value
AHK v2: return value

Expressions:
AHK v1: MsgBox % "Hello " . var
AHK v2: MsgBox("Hello " . var)

Built-in Variables and Functions-Some built-in variables and functions might have been renamed or their behavior changed. For example:
AHK v1: StringLen, OutputVar, InputVar
AHK v2: OutputVar := StrLen(InputVar)

Error Handling:
AHK v1: No specific error handling mechanism.
AHK v2: Use try...catch for error handling.
try {
    ; Code that might cause an error
} catch e {
    MsgBox(e.message)
}

GUI Creation:
AHK v1:
Gui, Add, Text,, Hello
Gui, Show
AHK v2:
Gui := GuiCreate()
Gui.Add("Text", "Hello")
Gui.Show()

Commands vs. Functions:
AHK v1 uses many commands (e.g., MsgBox, Send), while AHK v2 uses functions (e.g., MsgBox(), Send()).
ste(phen|ve) kunkel
User avatar
kunkel321
Posts: 1156
Joined: 30 Nov 2015, 21:19

Re: Main v2 errors that ChatGPT makes?

20 May 2024, 20:12

Well.... I repurposed the first menu item in the menu... The updated parts of the code are below. First I had only the prompt text from my above post, then I gave the ai some instructions for a simple ahk v2 gui. And (of course) there were have a dozen errors. Everytime I fixed an error, I added it to the bottom of the prompt text. Then... I restarted the script and gave it the same instructions. I'm glad to say that it didn't make the same mistakes. It did, however, make all new ones. LOL.

Maybe this can be a group project... We can all add the "corrections" that correspond to errors that GPT makes.

Code: Select all

MenuPopup := Menu()
MenuPopup.Add("&1 - Code", Code) ; <---- changed.
MenuPopup.Add("&2 - Summarize", Summarize)
MenuPopup.Add("&3 - Explain", Explain)
MenuPopup.Add("&4 - Expand", Expand)
MenuPopup.Add()
MenuPopup.Add("&5 - Generate reply", GenerateReply)
MenuPopup.Add("&6 - Find action items", FindActionItems)
MenuPopup.Add("&7 - Translate to Spanish", TranslateToSpanish)

Code(*) {  ; <---- changed.
    ChatGPT_Prompt := "
    (
        AHK v1 versus AHK v2.  Please remember to create AutoHokey v2 code and not AutoHotkey v1 conde.  When generating code, create code the conforms to v2 syntax and rultes--Not v1.  Here are some examples of the difference.  

Function Call Syntax:
AHK v1: FunctionName param1, param2
AHK v2: FunctionName(param1, param2)

Assignment Operator:
AHK v1: var = value
AHK v2: var := value

Variable Dereferencing:
AHK v1: MsgBox % var
AHK v2: MsgBox(var)

If Statements:
AHK v1: If var = value
AHK v2: If (var = value)

Loop Syntax:
AHK v1:
Loop, 10
{
    MsgBox % A_Index
}
AHK v2:
Loop 10
{
    MsgBox(A_Index)
}

Return Values:
AHK v1: return, value
AHK v2: return value

Expressions:
AHK v1: MsgBox % "Hello " . var
AHK v2: MsgBox("Hello " . var)

Built-in Variables and Functions-Some built-in variables and functions might have been renamed or their behavior changed. For example:
AHK v1: StringLen, OutputVar, InputVar
AHK v2: OutputVar := StrLen(InputVar)

Error Handling:
AHK v1: No specific error handling mechanism.
AHK v2: Use try...catch for error handling.
try {
    ; Code that might cause an error
} catch e {
    MsgBox(e.message)
}

GUI Creation:
AHK v1:
Gui, Add, Text,, Hello
Gui, Show
AHK v2:
Gui := GuiCreate()
Gui.Add("Text", "Hello")
Gui.Show()

Commands vs. Functions:
AHK v1 uses many commands (e.g., MsgBox, Send), while AHK v2 uses functions (e.g., MsgBox(), Send()).

With AHK v2, the correct synyax for creating a GUI is:
mainGui := Gui()
It is not: 
mainGui := GuiCreate()

With AHK v2, when using a Fat Arrow function inside an OnEvent, there must be an asterisk, like this:
OnEvent("Close", (*)=>subGui.Destroy())
Not like this:
OnEvent("Close", ()=>subGui.Destroy())

With AHK v2, the second parameter of an OnEvent gui.control.prototype should not have parentheses around it.  And the function that gets called must have an asterisk, like this:
myFunction(*)
Not like this:
myFunction()

With AHK v2, Gui.Show() can only have one parameter.

In AHK v2 scripts, '#NoEnv' is no longer used. 

In AHK v2, an OnEvent command should look like this:
OnEvent("Click", OpenSecondGui)
Not this:
OnEvent("Button", "Default", Func("OpenSecondGui"))
    )"
    Status_Message := "Writing Code..."
    API_Model := "gpt-4"
    ProcessRequest(ChatGPT_Prompt, Status_Message, API_Model, Retry_Status)
}
ste(phen|ve) kunkel
User avatar
andymbody
Posts: 956
Joined: 02 Jul 2017, 23:47

Re: Main v2 errors that ChatGPT makes?

20 May 2024, 20:59

Interesting idea...

I wonder how long this forum will holdout support of AI code. I suspect that one day, ChatGPT type tools will replace this forum entirely, just before it replaces coders entirely.
rockitdontstopit
Posts: 98
Joined: 12 Nov 2022, 15:47

Re: Main v2 errors that ChatGPT makes?

21 May 2024, 16:32

kunkel321 wrote:
20 May 2024, 15:24
I've started using the awesome ChatGPT AutoHotkey Utility script. Since there are several common errors that GPT makes with AHK v2 code, I thought I'd preemptively correct some of them by embedding the corrections in the prompt. Almost always, the problems are because GPT inserts AHK v1 code and syntax.
Have you used Microsoft's CoPilot (https://copilot.microsoft.com) for ahk v1 or v2? I use it for v1 code and am generally pleased. I don't think it's as good at v2 code since there is less training data for v2. How would you compare your utility to CoPilot?

CoPilot uses ChatGpt4 and is trained for coding.
User avatar
kunkel321
Posts: 1156
Joined: 30 Nov 2015, 21:19

Re: Main v2 errors that ChatGPT makes?

22 May 2024, 13:48

rockitdontstopit wrote:
21 May 2024, 16:32
Have you used Microsoft's CoPilot (https://copilot.microsoft.com) for ahk v1 or v2? I use it for v1 code and am generally pleased. I don't think it's as good at v2 code since there is less training data for v2. How would you compare your utility to CoPilot?
CoPilot uses ChatGpt4 and is trained for coding.
I will check it out thanks.
Are you finding that it's buggy today? I can't seem to log in. If I click the log in button, it just refreshes the same page.
ste(phen|ve) kunkel
rockitdontstopit
Posts: 98
Joined: 12 Nov 2022, 15:47

Re: Main v2 errors that ChatGPT makes?

22 May 2024, 14:06

kunkel321 wrote:
22 May 2024, 13:48
Are you finding that it's buggy today? I can't seem to log in. If I click the log in button, it just refreshes the same page.
It's working for me currently. I'm logged into my personal Microsoft account at that url.

Btw, I used to use "more precise" but it's been hallucinating recently. For example it was telling me that variables in ahk were case-sensitive. So I switched to "more creative" to see if I get better results.
User avatar
kunkel321
Posts: 1156
Joined: 30 Nov 2015, 21:19

Re: Main v2 errors that ChatGPT makes?

22 May 2024, 14:09

I was able to access it by opening Edge, then using the search function from there. With a simple search, it seems to have the same problems...
Certainly! Here’s the equivalent AutoHotkey v2 script that displays “Hello, World!” when you press Ctrl + J:
^j:: ; Ctrl + J hotkey
SendInput, My First Script
return
LOL.

I'll keep experimenting. Any tips for getting AHK v2 code from it?
ste(phen|ve) kunkel
rockitdontstopit
Posts: 98
Joined: 12 Nov 2022, 15:47

Re: Main v2 errors that ChatGPT makes?

22 May 2024, 14:20

kunkel321 wrote:
22 May 2024, 14:09
LOL.

I'll keep experimenting. Any tips for getting AHK v2 code from it?
Like I said I think it's not very good at v2. There are more than 10 times the number of forum posts for v1 than v2. Way more material for it to learn from.
User avatar
RaptorX
Posts: 390
Joined: 06 Dec 2014, 14:27
Contact:

Re: Main v2 errors that ChatGPT makes?

27 May 2024, 18:41

I have been playing a LOT with custom GPTs and trying to make them do what we want specially with ahk v2 with very limited success.

I have been providing it with very specific knowledge base of files and it still simply ignores it and gives wrong answers.
I specifically tell it not to do somethings and it promptly ignores me too. haha.

Our best bet is to train a model with a LOT of v2 scripts, I havent done that one yet because I am a bit annoyed with it atm but I think i will try once i finish the OpenAI library that im creating for that :P
rockitdontstopit wrote:
21 May 2024, 16:32
kunkel321 wrote:
20 May 2024, 15:24
I've started using the awesome ChatGPT AutoHotkey Utility script. Since there are several common errors that GPT makes with AHK v2 code, I thought I'd preemptively correct some of them by embedding the corrections in the prompt. Almost always, the problems are because GPT inserts AHK v1 code and syntax.
Have you used Microsoft's CoPilot (https://copilot.microsoft.com) for ahk v1 or v2? I use it for v1 code and am generally pleased. I don't think it's as good at v2 code since there is less training data for v2. How would you compare your utility to CoPilot?

CoPilot uses ChatGpt4 and is trained for coding.
I use it for v2 and is amazingly good after it picks up on your patterns... When you open a new file it will suggest v1 code and then as you keep adding files/code to the project it gets scarily better at predicting your next code including perfectly valid v2 code
Projects:
AHK-ToolKit
User avatar
kunkel321
Posts: 1156
Joined: 30 Nov 2015, 21:19

Re: Main v2 errors that ChatGPT makes?

28 May 2024, 07:34

RaptorX wrote:
27 May 2024, 18:41
Good info. Thanks for the input.
ste(phen|ve) kunkel

Return to “Other Utilities & Resources”

Who is online

Users browsing this forum: No registered users and 10 guests