-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat: Add suggestion message to API exception response #3149
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
Merged
Changes from 13 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
594eaf9
feat: suggest updating outdated components in API exception handling
anovazzi1 bd52891
feat: refactor code
anovazzi1 acd08ff
[autofix.ci] apply automated fixes
autofix-ci[bot] fe1d4ad
Update src/backend/base/langflow/exceptions/api.py
anovazzi1 74b00c5
Update src/backend/base/langflow/api/utils.py
anovazzi1 e6c547d
Update src/backend/base/langflow/exceptions/api.py
anovazzi1 3edbd39
update function name
anovazzi1 d2702bf
[autofix.ci] apply automated fixes
autofix-ci[bot] 80d3c5a
Merge branch 'main' into alertApi
anovazzi1 b2f579c
refactor: fix import casing in langflow.api.utils and langflow.except…
anovazzi1 bdecb06
refactor: remove unused code and update exception handling in langflo…
anovazzi1 8653560
[autofix.ci] apply automated fixes
autofix-ci[bot] 6930307
Merge branch 'main' into alertApi
anovazzi1 ee41d66
refactor: update exception handling and class in langflow.api.utils …
anovazzi1 24eca7e
[autofix.ci] apply automated fixes
autofix-ci[bot] e3cd507
update function name and refactor none flow logic
anovazzi1 bc2e267
[autofix.ci] apply automated fixes
autofix-ci[bot] cc25625
refactor: fix typo in get_suggestion_message function name
anovazzi1 4b03ff6
refactor: improve get_suggestion_message function in langflow.api.utils
anovazzi1 068ca14
refactor: add unit tests for get_suggestion_message and get_outdated_…
anovazzi1 3e1c1c3
refactor: add unit tests for APIException in langflow.exceptions.api
anovazzi1 b3be9f6
refactor: improve test coverage for APIException and related functions
anovazzi1 4b83058
[autofix.ci] apply automated fixes
autofix-ci[bot] 3476418
Merge branch 'main' into alertApi
anovazzi1 5ad2929
update file name
anovazzi1 4d75424
refactor: update build_exception_body method in APIException to handl…
anovazzi1 59596d3
refactor: handle None flow data in get_components_versions
anovazzi1 7001f9e
[autofix.ci] apply automated fixes
autofix-ci[bot] b58400d
refactor: update useDeleteBuilds function signature in _builds API query
anovazzi1 e5218a1
Merge branch 'main' into alertApi
anovazzi1 958121d
Merge branch 'main' into alertApi
anovazzi1 0da7c9f
fix: Fix test changing screen before request ended
anovazzi1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,2 +1,32 @@ | ||||||
from fastapi import HTTPException | ||||||
from langflow.api.utils import get_suggestion_messsage | ||||||
from langflow.services.database.models.flow.model import Flow | ||||||
from langflow.services.database.models.flow.utils import get_outdated_components | ||||||
from pydantic import BaseModel | ||||||
|
||||||
|
||||||
class InvalidChatInputException(Exception): | ||||||
pass | ||||||
|
||||||
|
||||||
# create a pidantic documentation for this class | ||||||
class ExceptionBody(BaseModel): | ||||||
message: str | list[str] | ||||||
traceback: str | list[str] | None = None | ||||||
description: str | list[str] | None = None | ||||||
code: str | None = None | ||||||
suggestion: str | list[str] | None = None | ||||||
|
||||||
anovazzi1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
class APIException(HTTPException): | ||||||
def __init__(self, exception: ExceptionBody, status_code: int = 500): | ||||||
super().__init__(status_code=status_code, detail=exception.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 commentThe reason will be displayed to describe this comment to others. Learn more. The method needs a more descriptive name
Suggested change
|
||||||
body = {"message": str(exc)} | ||||||
outdated_components = get_outdated_components(flow) | ||||||
if outdated_components: | ||||||
body["suggestion"] = get_suggestion_messsage(outdated_components) | ||||||
excep = ExceptionBody(**body) | ||||||
return excep |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.