In Power Automate Desktop, I am looping through similar pdf files and using the GPT-4 API To extract text from them, Some files return status code 200 and some return 400 -bad json. I copied the text out of the ‘bad’ file that gets submitted to the API into the playground and it got processed with no error, Does anyone have any idea of how to troubleshoot. Why would playground process ok but not the API? TIA
I’m not familiar with this exact error (or the environment tbh) but I’d guess it could possibly something related to weird characters/escaping of the input string.
To troubleshoot I’d try to pretty print the relevant part of your request object in the environment you’re working in (something like JSON.stringify(obj, null, 2)
in js) to see what it looks like there and try to understand what’s might be wrong with it.
Why wouldn’t it fail in playground
not sure possibly something related to the way the original environment parses the string, or when it’s copied, or pasted in the playground. Anyway it’s just an idea on how to troubleshoot- looking into the issue in the original environment.
The original environment is power automate desktop. I am copying the string that I input to the playground after it has been parsed by power automate desktop so it doesn’t seem parsing can be the problem. I see that playground may use parameters that I didn’t use, such as top_1, frequency penalty, presence penalty, but I don’t think that should make a difference. I’m going to use postman to see if I can get some insight.
Thank you for your interest and help. In postman, the text was underlined with squiggles indicating it was invalid. By successive truncations I was able to determine that. ‘\” in the string was the culprit.
The playground will quote your input strings for you. When you make JSON yourself, you have to properly quote the string values you put in. Most libraries will also do this for you, but if you formulate the JSON encoding yourself, you have to properly encode special characters yourself.
Thank you. That’s helpful.
Thank you. That’s helpful
Cool and makes sense Happy to hear it was resolved!