-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/generategraphscript
- Loading branch information
Showing
68 changed files
with
944 additions
and
848 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,34 @@ | ||
from fastapi import HTTPException | ||
from langflow.api.utils import get_suggestion_message | ||
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 | ||
|
||
|
||
class APIException(HTTPException): | ||
def __init__(self, exception: Exception, flow: Flow | None = None, status_code: int = 500): | ||
body = self.build_exception_body(exception, flow) | ||
super().__init__(status_code=status_code, detail=body.model_dump_json()) | ||
|
||
@staticmethod | ||
def build_exception_body(exc: str | list[str] | Exception, flow: Flow | None) -> ExceptionBody: | ||
body = {"message": str(exc)} | ||
if flow: | ||
outdated_components = get_outdated_components(flow) | ||
if outdated_components: | ||
body["suggestion"] = get_suggestion_message(outdated_components) | ||
excep = ExceptionBody(**body) | ||
return excep |
This file contains 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 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 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 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 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.