Return the ExInfo for a given exception instance
(self, ex)
| 78 | return tuple(self.exceptions) |
| 79 | |
| 80 | def get_ex_info(self, ex): |
| 81 | """Return the ExInfo for a given exception instance""" |
| 82 | import litellm |
| 83 | |
| 84 | if ex.__class__ is litellm.APIConnectionError: |
| 85 | if "boto3" in str(ex): |
| 86 | return ExInfo("APIConnectionError", False, "You need to: pip install boto3") |
| 87 | if "OpenrouterException" in str(ex) and "'choices'" in str(ex): |
| 88 | return ExInfo( |
| 89 | "APIConnectionError", |
| 90 | True, |
| 91 | ( |
| 92 | "OpenRouter or the upstream API provider is down, overloaded or rate" |
| 93 | " limiting your requests." |
| 94 | ), |
| 95 | ) |
| 96 | |
| 97 | # Check for specific non-retryable APIError cases like insufficient credits |
| 98 | if ex.__class__ is litellm.APIError: |
| 99 | err_str = str(ex).lower() |
| 100 | if "insufficient credits" in err_str and '"code":402' in err_str: |
| 101 | return ExInfo( |
| 102 | "APIError", |
| 103 | False, |
| 104 | "Insufficient credits with the API provider. Please add credits.", |
| 105 | ) |
| 106 | # Fall through to default APIError handling if not the specific credits error |
| 107 | |
| 108 | return self.exceptions.get(ex.__class__, ExInfo(None, None, None)) |