-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[QUERY] How to properly handle errors on OpenAI client (azure-ai-openai)? #40466
Comments
@mssfang could you please follow up with @leandrodvd? Is this something that should be covered in the README or TROUBLESHOOT guide |
@leandrodvd I created a TROUBLESHOOT.md guideline to help explain how to handle errors. Hope it helps |
Hi, yeah, the documentation looks like a good start, but it's kinda shallow, only shows what exception to catch, could have more details on the exception content. For instance I learned that the A better solution (and maybe a separate issue) would be to have the error mapped to some model class that I can use. That's in fact the solution I implemented, I created an I implemented this Error class on my side but I believe this should be part of the SDK
|
Query/Question
How to properly handle errors on OpenAI client ?
I'm using
OpenAIClient.getChatCompletions()
. I noticed that different types of errors will generate HttpResponseException. I`m trying to understand what is the best approach to properly parse/handle those errors.For instance, the same HttpResponseException is thrown when the request exceeds the model length and when the requests is filtered by the open ai content filter. I have very different approaches for those errors. For model length limit I want to retry the request with a different model, for content filter I want to reply a polite message to my user.
How can I differentiate what is the actual error causing the exception ? Is there anything on the SDK that can help me parse the error ?
Maybe some sample code with error handling would help
Why is this not a Bug or a feature Request?
Not a bug, just need to guidance on how to handle errors properly.
Setup (please complete the following information if applicable):
The text was updated successfully, but these errors were encountered: