Skip to content
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

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

whiterabbit1983
Copy link
Contributor

@whiterabbit1983 whiterabbit1983 commented Jul 10, 2024

🚀 This description was created by Ellipsis for commit cf5ced2

Summary:

Added exception handler for litellm.exceptions.APIError in agents-api/agents_api/web.py to return a 502 Bad Gateway error with the error message.

Key points:

  • Added litellm.exceptions.APIError exception handler in agents-api/agents_api/web.py.
  • Returns a 502 Bad Gateway error with the error message when APIError is raised.

Generated with ❤️ by ellipsis.dev

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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 in 1 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)
Copy link
Contributor

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.

@app.exception_handler(APIError)
async def litellm_api_error(request: Request, exc: APIError):
return JSONResponse(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
Copy link
Contributor

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

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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 in 1 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.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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 in 1 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.

@creatorrr creatorrr merged commit c703332 into dev Jul 12, 2024
9 checks passed
@creatorrr creatorrr deleted the x/apierror-exc-handler branch July 12, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants