c-ttpfx/chatgpt-java-wx

偶尔出现invalid_request_error

Opened this issue · 3 comments

在调用gpt的接口过程中,openai偶尔返回这样的报错
"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
}
并且不能稳定复现,如果再次进行同样的对话,就不会出现了

我也遇见过,查资料发现官方有请求速率的限制,请求过快就会出现这个

我也遇见过,查资料发现官方有请求速率的限制,请求过快就会出现这个

我感觉应该不是官方速率问题,我在另一个项目用其他语言,同样的聊天基本不会出现报错,因为不太精通java一直排查不到原因

我也很奇怪,明明速率还没有达到阈值 帮助文档查看 就可能出现上面的问题,我debug代码看了请求体,就是标准的json格式,如果问题请求慢一点那么就没有问题

image

然后我又使用同步方式请求,在连续多次请求后控制台提示如下信息

    "error": {
        "message": "Rate limit reached for default-gpt-3.5-turbo in organization org-iybBoCbpsPhaymZWS3t2JTGT on requests per min. Limit: 3 / min. Please try again in 20s. Contact us through our help center at help.openai.com if you continue to have issues. Please add a payment method to your account to increase your rate limit. Visit https://platform.openai.com/account/billing to add a payment method.",
        "type": "requests",
        "param": null,
        "code": null

大概意思就是速率限制为每分钟3次,我又去官方里面查看,结果发现了以下内容

image

问题应该就是官方的速率限制导致的