Added helpful error message telling user to use ChatCompletion #258
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Many users (including me) are trying to call the "gpt-3.5-turbo" from the
Completion
class. See #250.Which returns a confusing error message, telling the user to use a different endpoint.
Proposal
Given this is a library that wraps the API, it'd be more helpful to tell the user to use the
ChatCompletion
class instead. My pull requests wraps the error and displays the following.Approach
My initial thought was to add some sort of kwarg checking in
Completion
but it looks like this is a lean wrapper class. Searching further it looks likehandle_error_response
is a good spot to put this since it already does something similar for internal errors.Caveats
This approach is fairly tightly coupled to the OpenAI API error response message, I'm not sure how stable these messages are. With that said if the error message does change, this will not affect any other functionality.