Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get response data when the status is not in 200-300 #54

Open
noobnooc opened this issue Mar 9, 2023 · 3 comments
Open

Get response data when the status is not in 200-300 #54

noobnooc opened this issue Mar 9, 2023 · 3 comments

Comments

@noobnooc
Copy link

noobnooc commented Mar 9, 2023

I used this package to access the OpenAI API. However, when the response has a status code outside of the range 200-300, an error occurs. The UnsuccessfulResponseError object only includes a responseStatus field, but OpenAI responded with a JSON error message like the following:

{
  "error": {
    "param": null,
    "message": "Rate limit reached for default-gpt-3.5-turbo in organization org-xxx on requests per minute. Limit: 20 / min. Current: 30 / min. Contact [email protected] 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.",
    "code": null,
    "type": "requests"
  }
}

I would like to retrieve the message from this error response, but I couldn't find a way to do it. Is it possible to do so with the current version? If not, could you please add this functionality in a future release?

@keelerm84
Copy link
Member

👋 Hi @noobnooc

There is not a way to retrieve the body of the failed response with the way the library currently operates. I have filed your request to add support for it as sc-192056.

I will check with the team today about whether or not this is something we can support and when we might have a timeline for completion. I will keep you updated as I know more.

Thanks!

@DerJacques
Copy link

I'm in the same boat, and having access to the error response would be very helpful.
I very much appreciate the work you have put into this already. The library has been working great for me this far!

@DerJacques
Copy link

And to be clear: The error response would only need to be available in the onError callback. At least in my scenario, I do not need need the error to be streamed to the onMessage method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants