forked from phoenix/litellm-mirror
(fix) return 429 error
This commit is contained in:
parent
aaa008ecde
commit
3aeada232e
1 changed files with 10 additions and 4 deletions
|
@ -171,6 +171,15 @@ class ProxyException(Exception):
|
||||||
self.param = param
|
self.param = param
|
||||||
self.code = code
|
self.code = code
|
||||||
|
|
||||||
|
# rules for proxyExceptions
|
||||||
|
# Litellm router.py returns "No healthy deployment available" when there are no deployments available
|
||||||
|
# Should map to 429 errors https://github.com/BerriAI/litellm/issues/2487
|
||||||
|
if (
|
||||||
|
"No healthy deployment available" in self.message
|
||||||
|
or "No deployments available" in self.message
|
||||||
|
):
|
||||||
|
self.code = 429
|
||||||
|
|
||||||
def to_dict(self) -> dict:
|
def to_dict(self) -> dict:
|
||||||
"""Converts the ProxyException instance to a dictionary."""
|
"""Converts the ProxyException instance to a dictionary."""
|
||||||
return {
|
return {
|
||||||
|
@ -2907,10 +2916,7 @@ async def chat_completion(
|
||||||
param=getattr(e, "param", "None"),
|
param=getattr(e, "param", "None"),
|
||||||
code=getattr(e, "status_code", status.HTTP_400_BAD_REQUEST),
|
code=getattr(e, "status_code", status.HTTP_400_BAD_REQUEST),
|
||||||
)
|
)
|
||||||
else:
|
error_msg = f"{str(e)}"
|
||||||
error_traceback = traceback.format_exc()
|
|
||||||
error_msg = f"{str(e)}\n\n{error_traceback}"
|
|
||||||
|
|
||||||
raise ProxyException(
|
raise ProxyException(
|
||||||
message=getattr(e, "message", error_msg),
|
message=getattr(e, "message", error_msg),
|
||||||
type=getattr(e, "type", "None"),
|
type=getattr(e, "type", "None"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue