Closed Enrico68 closed 6 months ago
For a request that fails, could you run the following (using M-x eval-expression
or equivalent):
(gptel-curl--get-args (gptel--create-prompt) "abcdefgh")
(You would run this instead of gptel-send
)
And paste the result here? We can look at the HTTP payload that is sent to ChatGPT.
Important: This data will contain your API key -- please remove/obfuscate it before pasting.
This is the response:
("--location" "--silent" "--compressed" "--disable" "-XPOST" "-w(abcdefgh . %{size_header})" "-m300" "-D-" "-d{\"model\":\"gpt-3.5-turbo\",\"messages\":[{\"role\":\"system\",\"content\":\"You are a large language model living in Emacs and a helpful assistant. Respond concisely.\"},{\"role\":\"user\",\"content\":\"(gptel-curl--get-args (gptel--create-prompt) \\\"abcdefgh\\\")\"}],\"stream\":true,\"temperature\":1.0}" "-HContent-Type: application/json" "-HAuthorization: Bearer ------------------
I got the same error. For me it was because I retrieved the api key from gnu pass which appended a newline to the key. So the error about the JSON formatting was quite misleading in my case.
This is the response:
("--location" "--silent" "--compressed" "--disable" "-XPOST" "-w(abcdefgh . %{size_header})" "-m300" "-D-" "-d{\"model\":\"gpt-3.5-turbo\",\"messages\":[{\"role\":\"system\",\"content\":\"You are a large language model living in Emacs and a helpful assistant. Respond concisely.\"},{\"role\":\"user\",\"content\":\"(gptel-curl--get-args (gptel--create-prompt) \\\"abcdefgh\\\")\"}],\"stream\":true,\"temperature\":1.0}" "-HContent-Type: application/json" "-HAuthorization: Bearer ------------------
Why is the content being sent to ChatGPT the elisp command I suggested to run?
The problem was related to the API key. Initially, I encountered an error while attempting to retrieve the key from the authpass
file. Due to my own oversight, I didn't thoroughly search for a solution. However, setting the API key directly as a variable resolved the issue entirely. If you concur with this approach, I will proceed to close the issue.
Hello,
My program was running smoothly until today when I encountered the following error. Here's the backtrace:
Is this error related to OpenAI or the package itself? Could be that the response indicates a failure to parse the JSON body of the request, suggesting a potential issue with how the HTTP library is used?
Enrico