🐛 fix(base.py): fix typo in "successfully" in the built object representation message

🐛 fix(custom_component.py): add support for custom representation of repr_value if it is a dictionary by using yaml.dump() function
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-04 13:49:19 -03:00
commit bb3be161bd
2 changed files with 8 additions and 1 deletions

View file

@ -269,4 +269,8 @@ class Vertex:
def _built_object_repr(self):
# Add a message with an emoji, stars for sucess,
return "Built sucessfully ✨" if self._built_object else "Failed to build 😵‍💫"
return (
"Built sucessfully ✨"
if self._built_object is not None
else "Failed to build 😵‍💫"
)

View file

@ -9,6 +9,7 @@ from langflow.utils import validate
from langflow.database.base import session_getter
from langflow.database.models.flow import Flow
from pydantic import Extra
import yaml
class CustomComponent(Component, extra=Extra.allow):
@ -24,6 +25,8 @@ class CustomComponent(Component, extra=Extra.allow):
super().__init__(**data)
def custom_repr(self):
if isinstance(self.repr_value, dict):
return yaml.dump(self.repr_value)
if isinstance(self.repr_value, str):
return self.repr_value
return str(self.repr_value)