Skip to content

Commit 50171c8

Browse files
committed
Use isinstance() instead of type() == for exception type checking
Replace `type(e) == litellm.exceptions.RateLimitError` with `isinstance(e, litellm.exceptions.RateLimitError)` for proper exception type checking. While technically different behavior (isinstance() supports inheritance while type() == requires exact match), isinstance() is the correct and more robust approach for exception handling. If litellm introduces subclasses of RateLimitError in the future, isinstance() will correctly catch them.
1 parent 0070d75 commit 50171c8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

interpreter/core/respond.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def respond(interpreter):
114114
f"{output}\n\nThere might be an issue with your API key(s).\n\nTo reset your API key (we'll use OPENAI_API_KEY for this example, but you may need to reset your ANTHROPIC_API_KEY, HUGGINGFACE_API_KEY, etc):\n Mac/Linux: 'export OPENAI_API_KEY=your-key-here'. Update your ~/.zshrc on MacOS or ~/.bashrc on Linux with the new key if it has already been persisted there.,\n Windows: 'setx OPENAI_API_KEY your-key-here' then restart terminal.\n\n"
115115
)
116116
elif (
117-
type(e) == litellm.exceptions.RateLimitError
117+
isinstance(e, litellm.exceptions.RateLimitError)
118118
and ("exceeded" in str(e).lower() or
119119
"insufficient_quota" in str(e).lower())
120120
):

0 commit comments

Comments
 (0)