From 3ced33b6781b93c1d290ce0048f9e0ef802fc008 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 29 Jun 2023 13:07:04 -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=20=F0=9F=90=9B=20fix(base.py):=20call=20?= =?UTF-8?q?the=20method=20to=20remove=20unwanted=20base=20classes=20before?= =?UTF-8?q?=20converting=20the=20frontend=20node=20to=20a=20dict=20The=20`?= =?UTF-8?q?process=5Fbase=5Fclasses`=20method=20is=20added=20to=20the=20`F?= =?UTF-8?q?rontendNode`=20class=20to=20remove=20unwanted=20base=20classes?= =?UTF-8?q?=20from=20the=20list=20of=20base=20classes.=20This=20method=20i?= =?UTF-8?q?terates=20over=20the=20base=20classes=20and=20filters=20out=20a?= =?UTF-8?q?ny=20classes=20that=20are=20present=20in=20the=20`CLASSES=5FTO?= =?UTF-8?q?=5FREMOVE`=20list.=20The=20method=20is=20then=20called=20before?= =?UTF-8?q?=20converting=20the=20frontend=20node=20to=20a=20dictionary=20r?= =?UTF-8?q?epresentation=20in=20the=20`to=5Fdict`=20method=20to=20ensure?= =?UTF-8?q?=20that=20the=20unwanted=20base=20classes=20are=20not=20include?= =?UTF-8?q?d=20in=20the=20final=20output.?= 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 0c0c1e06a..de8c78112 100644 --- a/src/backend/langflow/template/frontend_node/base.py +++ b/src/backend/langflow/template/frontend_node/base.py @@ -9,6 +9,8 @@ from langflow.template.template.base import Template from langflow.utils import constants from langflow.template.frontend_node.formatter import field_formatters +CLASSES_TO_REMOVE = ["Serializable", "BaseModel"] + class FieldFormatters(BaseModel): formatters = { @@ -47,6 +49,14 @@ class FrontendNode(BaseModel): documentation: str = "" field_formatters: FieldFormatters = Field(default_factory=FieldFormatters) + 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 + ] + # field formatters is an instance attribute but it is not used in the class # so we need to create a method to get it @staticmethod @@ -59,6 +69,7 @@ class FrontendNode(BaseModel): def to_dict(self) -> dict: """Returns a dict representation of the frontend node.""" + self.process_base_classes() return { self.name: { "template": self.template.to_dict(self.format_field),