-
Notifications
You must be signed in to change notification settings - Fork 904
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
fix: Add exception handler for litellm API error #432
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ Changes requested. Reviewed everything up to a82b991 in 35 seconds
More details
- Looked at
28
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
0
drafted comments based on config settings.
Workflow ID: wflow_dH0KeLkRm9ELwAUp
Want Ellipsis to fix these issues? Tag @ellipsis-dev
in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
@@ -120,6 +121,14 @@ async def prompt_too_big_error(request: Request, exc: PromptTooBigError): | |||
) | |||
|
|||
|
|||
@app.exception_handler(APIError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider refining the exception handling for APIError
to provide more appropriate HTTP status codes based on the error specifics, rather than defaulting to 500 Internal Server Error. This can help in accurately reflecting the nature of the error to the clients and aid in better error diagnostics.
agents-api/agents_api/web.py
Outdated
@app.exception_handler(APIError) | ||
async def litellm_api_error(request: Request, exc: APIError): | ||
return JSONResponse( | ||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change this to 502, please
a82b991
to
cf5ced2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Incremental review on cf5ced2 in 46 seconds
More details
- Looked at
27
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. agents-api/agents_api/web.py:127
- Draft comment:
The PR description states that a 500 Internal Server Error should be returned, but the code returns a 502 Bad Gateway. If the intent is to indicate a server-side error, consider changing the status code to 500.
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
- Reason this comment was not posted:
Confidence of 0% on close inspection, compared to threshold of 50%.
Workflow ID: wflow_Nya8cwi39nc4aZdX
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Incremental review on cf5ced2 in 46 seconds
More details
- Looked at
27
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. agents-api/agents_api/web.py:127
- Draft comment:
The PR description states that a 500 Internal Server Error should be returned, but the code returns a 502 Bad Gateway. If the intent is to indicate a server-side error, consider changing the status code to 500.
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
- Reason this comment was not posted:
Confidence of 0% on close inspection, compared to threshold of 50%.
Workflow ID: wflow_Nya8cwi39nc4aZdX
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
Summary:
Added exception handler for
litellm.exceptions.APIError
inagents-api/agents_api/web.py
to return a 502 Bad Gateway error with the error message.Key points:
litellm.exceptions.APIError
exception handler inagents-api/agents_api/web.py
.APIError
is raised.Generated with ❤️ by ellipsis.dev