Problem running a compiled script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
bobbrennan
Posts: 5
Joined: 26 Jan 2023, 14:34

Problem running a compiled script

07 Mar 2024, 16:29

I've have a script that I use to chat with a LLM running on a LM Studio Local server. It works fine. But If I compile it and run the .exe it always causes an error in JSON.ahk, Here's a snippet of the script (scaled down to bare bonnes) and the error message the executable throws. If anyone has an idea of why the .exe doesn't work, I'd appreciate the help.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance force
#Include <JSON>
http := WinHttpRequest()
url := "http://localhost:1234/v1/chat/completions"
body := {}
body.messages := [{"role":"user", "content":"Hello There"}]
body.max_tokens := -1
headers := {"Content-Type": "application/json"}
response := http.POST(url, JSON.Dump(body), headers, {Object:true})
obj := JSON.Load(response.Text)
text := obj.choices[1].message.content
msgbox, % text
ExitApp
Attachments
1.png
1.png (6.71 KiB) Viewed 178 times
2.png
2.png (51.47 KiB) Viewed 178 times
bobbrennan
Posts: 5
Joined: 26 Jan 2023, 14:34

Re: Problem running a compiled script

07 Mar 2024, 16:44

One additional point. I use a similar script with ChatGPT and the compiled script works fine
geek
Posts: 1052
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: Problem running a compiled script

07 Mar 2024, 17:01

This exception occurs when you have run the JSON library in an unsupported ANSI mode. Please compile using Unicode 32 or 64 bit.
bobbrennan
Posts: 5
Joined: 26 Jan 2023, 14:34

Re: Problem running a compiled script

07 Mar 2024, 19:25

I believe it's compiled using UTF64
User avatar
boiler
Posts: 16989
Joined: 21 Dec 2014, 02:44

Re: Problem running a compiled script

07 Mar 2024, 22:36

Since you apparently don’t know for sure, why wouldn’t you just compile it again and select what geek identified?
geek
Posts: 1052
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: Problem running a compiled script

08 Mar 2024, 08:22

It would also be helpful to know for sure if the response from the HTTP request is correct in the compiled version. What does a MsgBox % response.Text right above obj := JSON.Load(response.Text) say?
bobbrennan
Posts: 5
Joined: 26 Jan 2023, 14:34

Re: Problem running a compiled script

09 Mar 2024, 01:21

Thanks Geek. That helped. Somehow led me down a winding path. Realized that my ChatGPT.exe which always worked, had the same issue. I found a backup copy of both the ChatGPT.ahk script and the .ex from a couple of months ago. I compared the two scripts and they were basically identical. But when I looked at the .exe files, the backup was significantly bigger. I ran that and it worked. I use SciTE4AutoHotkey as my editor, so I recompiled the backup and the resulting .exe was the same size as the smaller one. Then I decided to compile it using Ahk2Exe. Bingo! Everything works now. So it seems that the problem must in SciTE4Auto. It used to always work for me. Not anymore it seems... :lol:
bobbrennan
Posts: 5
Joined: 26 Jan 2023, 14:34

Re: Problem running a compiled script

09 Mar 2024, 01:30

boiler wrote:
07 Mar 2024, 22:36
Since you apparently don’t know for sure, why wouldn’t you just compile it again and select what geek identified?
I did. That's when I found out my ChatGPT.exe wasn't working either

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 66 guests