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

feat: Add suggestion message to API exception response #3149

Merged
merged 32 commits into from
Aug 7, 2024
Merged

Conversation

anovazzi1
Copy link
Contributor

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.

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.
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 1, 2024
@dosubot dosubot bot added the enhancement New feature or request label Aug 1, 2024
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-3149.dmtpw4p5recq1.amplifyapp.com

src/backend/base/langflow/exceptions/api.py Outdated Show resolved Hide resolved
src/backend/base/langflow/exceptions/api.py Outdated Show resolved Hide resolved
src/backend/base/langflow/api/utils.py Outdated Show resolved Hide resolved
src/backend/base/langflow/exceptions/api.py Show resolved Hide resolved
anovazzi1 and others added 5 commits August 1, 2024 17:16
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
super().__init__(status_code=status_code, detail=body.model_dump_json())

@staticmethod
def from_exc_and_flow(exc: str | list[str], flow: Flow) -> ExceptionBody:
Copy link
Contributor

@ogabrielluiz ogabrielluiz Aug 5, 2024

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

Suggested change
def from_exc_and_flow(exc: str | list[str], flow: Flow) -> ExceptionBody:
def build_exception_body(exc: str | list[str], flow: Flow | None) -> ExceptionBody:

Comment on lines 24 to 25
if flow is None:
body = ExceptionBody(message=str(exception))
Copy link
Contributor

@ogabrielluiz ogabrielluiz Aug 5, 2024

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

Suggested change
if flow is None:
body = ExceptionBody(message=str(exception))

Copy link
Contributor

@ogabrielluiz ogabrielluiz left a 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?

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Aug 5, 2024
Copy link
Contributor

@ogabrielluiz ogabrielluiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 6, 2024
@anovazzi1 anovazzi1 enabled auto-merge (squash) August 7, 2024 15:01
@anovazzi1 anovazzi1 merged commit 48ffdbf into main Aug 7, 2024
52 checks passed
@anovazzi1 anovazzi1 deleted the alertApi branch August 7, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants