kdalanon / ChatGPT-AutoHotkey-Utility

An AutoHotkey script that uses ChatGPT API to process text.
GNU General Public License v3.0
72 stars 11 forks source link

Status 400 error #14

Closed Avastgard closed 1 month ago

Avastgard commented 1 month ago

I keep getting the following error:

Status 400 { "error": { "message": "We could not parse the JSON body of your request. (HINT: This likely means you aren't using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please contact us through our help center at help.openai.com.)", "type": "invalid_request_error", "param": null, "code": null } } I'm not sure what the steps to reproduce it are, but it appears that when the ChatGPT_Prompt is too long, it always triggers this error.

What could be causing this error? Is there a way around it?

Avastgard commented 1 month ago

Turns out the problem was not the size of copied text, but an illegal character inside it (tab).

I included the line ChatGPT_Prompt := RegExReplace(ChatGPT_Prompt, "\t", "") ; Remove horizontal tabs to remove horizontal tabs from the copied text.

This is particularly useful if you select text from a numbered list in Microsoft Word (my use case most of the time).