-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
feat: Add suggestion message to API exception response #3149
Conversation
Suggest updating the outdated components in the API exception handling. This commit adds a suggestion message to the API exception response when there are outdated components in the flow. The suggestion message provides the number of outdated components and recommends updating them. The suggestion is generated based on the list of outdated components obtained from the flow data.
This pull request is automatically being deployed by Amplify Hosting (learn more). |
Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
…ions.api Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
…w.api.utils and langflow.exceptions.api
…nd langflow.exceptions.api
super().__init__(status_code=status_code, detail=body.model_dump_json()) | ||
|
||
@staticmethod | ||
def from_exc_and_flow(exc: str | list[str], flow: Flow) -> ExceptionBody: |
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.
The method needs a more descriptive name
def from_exc_and_flow(exc: str | list[str], flow: Flow) -> ExceptionBody: | |
def build_exception_body(exc: str | list[str], flow: Flow | None) -> ExceptionBody: |
if flow is None: | ||
body = ExceptionBody(message=str(exception)) |
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.
The condition shouldn't be here. It could be inside the method, for example
if flow is None: | |
body = ExceptionBody(message=str(exception)) |
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.
Could you add tests to this?
…components functions
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.
LGTM
This pull request adds a suggestion message to the API exception response when there are outdated components in the flow. The suggestion message provides the number of outdated components and recommends updating them. The suggestion is generated based on the list of outdated components obtained from the flow data. Additionally, the code has been refactored to improve readability and maintainability.