From 109283b6d0e6f5f54fd42e129b8472e9b50150aa Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 30 Jun 2023 18:09:02 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore(base.py):=20add=20method?= =?UTF-8?q?=20to=20remove=20unwanted=20base=20classes=20from=20the=20list?= =?UTF-8?q?=20of=20base=20classes=20The=20`process=5Fbase=5Fclasses`=20met?= =?UTF-8?q?hod=20is=20added=20to=20the=20`FrontendNode`=20class.=20This=20?= =?UTF-8?q?method=20removes=20unwanted=20base=20classes=20specified=20in?= =?UTF-8?q?=20the=20`CLASSES=5FTO=5FREMOVE`=20list=20from=20the=20`base=5F?= =?UTF-8?q?classes`=20list.=20This=20ensures=20that=20only=20the=20desired?= =?UTF-8?q?=20base=20classes=20are=20included=20in=20the=20`base=5Fclasses?= =?UTF-8?q?`=20list.=20The=20method=20is=20then=20called=20in=20the=20`to?= =?UTF-8?q?=5Fdict`=20method=20to=20ensure=20that=20the=20processed=20`bas?= =?UTF-8?q?e=5Fclasses`=20list=20is=20used=20when=20converting=20the=20`Fr?= =?UTF-8?q?ontendNode`=20instance=20to=20a=20dictionary.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/template/frontend_node/base.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/backend/langflow/template/frontend_node/base.py b/src/backend/langflow/template/frontend_node/base.py index 2663164e0..47c8c53f6 100644 --- a/src/backend/langflow/template/frontend_node/base.py +++ b/src/backend/langflow/template/frontend_node/base.py @@ -8,6 +8,8 @@ from langflow.template.field.base import TemplateField from langflow.template.template.base import Template from langflow.utils import constants +CLASSES_TO_REMOVE = ["Serializable", "BaseModel"] + class FrontendNode(BaseModel): template: Template @@ -17,7 +19,16 @@ class FrontendNode(BaseModel): display_name: str = "" custom_fields: List[str] = [] + def process_base_classes(self) -> None: + """Removes unwanted base classes from the list of base classes.""" + self.base_classes = [ + base_class + for base_class in self.base_classes + if base_class not in CLASSES_TO_REMOVE + ] + def to_dict(self) -> dict: + self.process_base_classes() return { self.name: { "template": self.template.to_dict(self.format_field),