🔧 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:
parent
2f4426d49f
commit
109283b6d0
1 changed files with 11 additions and 0 deletions
|
|
@ -8,6 +8,8 @@ from langflow.template.field.base import TemplateField
|
||||||
from langflow.template.template.base import Template
|
from langflow.template.template.base import Template
|
||||||
from langflow.utils import constants
|
from langflow.utils import constants
|
||||||
|
|
||||||
|
CLASSES_TO_REMOVE = ["Serializable", "BaseModel"]
|
||||||
|
|
||||||
|
|
||||||
class FrontendNode(BaseModel):
|
class FrontendNode(BaseModel):
|
||||||
template: Template
|
template: Template
|
||||||
|
|
@ -17,7 +19,16 @@ class FrontendNode(BaseModel):
|
||||||
display_name: str = ""
|
display_name: str = ""
|
||||||
custom_fields: List[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:
|
def to_dict(self) -> dict:
|
||||||
|
self.process_base_classes()
|
||||||
return {
|
return {
|
||||||
self.name: {
|
self.name: {
|
||||||
"template": self.template.to_dict(self.format_field),
|
"template": self.template.to_dict(self.format_field),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue