🔧 chore(base.py): add method to remove unwanted base classes from the list of base classes

The `process_base_classes` method is added to the `FrontendNode` class. This method removes unwanted base classes specified in the `CLASSES_TO_REMOVE` list from the `base_classes` list. This ensures that only the desired base classes are included in the `base_classes` list. The method is then called in the `to_dict` method to ensure that the processed `base_classes` list is used when converting the `FrontendNode` instance to a dictionary.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-30 18:09:02 -03:00
commit 109283b6d0

View file

@ -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),