🐛 fix(base.py): exclude format_template field from serialization to prevent it from being included in the serialized output
✨ feat(base.py): add format_template field to FrontendNode class to control whether the template should be formatted or not during serialization 🐛 fix(custom_components.py): exclude format_template field from serialization to prevent it from being included in the serialized output ✨ feat(custom_components.py): add format_template field to CustomComponentFrontendNode class to control whether the template should be formatted or not during serialization
This commit is contained in:
parent
2ae11c335c
commit
0e7a1e75e4
2 changed files with 6 additions and 1 deletions
|
|
@ -40,6 +40,7 @@ class FieldFormatters(BaseModel):
|
||||||
|
|
||||||
|
|
||||||
class FrontendNode(BaseModel):
|
class FrontendNode(BaseModel):
|
||||||
|
format_template: bool = Field(default=True, exclude=True)
|
||||||
template: Template
|
template: Template
|
||||||
description: Optional[str] = None
|
description: Optional[str] = None
|
||||||
base_classes: List[str]
|
base_classes: List[str]
|
||||||
|
|
@ -80,7 +81,8 @@ class FrontendNode(BaseModel):
|
||||||
def serialize_model(self, handler):
|
def serialize_model(self, handler):
|
||||||
result = handler(self)
|
result = handler(self)
|
||||||
if hasattr(self, "template") and hasattr(self.template, "to_dict"):
|
if hasattr(self, "template") and hasattr(self.template, "to_dict"):
|
||||||
result["template"] = self.template.to_dict(self.format_field)
|
format_func = self.format_field if self.format_template else None
|
||||||
|
result["template"] = self.template.to_dict(format_func)
|
||||||
name = result.pop("name")
|
name = result.pop("name")
|
||||||
|
|
||||||
return {name: result}
|
return {name: result}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
from pydantic import Field
|
||||||
|
|
||||||
from langflow.template.field.base import TemplateField
|
from langflow.template.field.base import TemplateField
|
||||||
from langflow.template.frontend_node.base import FrontendNode
|
from langflow.template.frontend_node.base import FrontendNode
|
||||||
from langflow.template.template.base import Template
|
from langflow.template.template.base import Template
|
||||||
|
|
@ -45,6 +47,7 @@ class Component(CustomComponent):
|
||||||
|
|
||||||
|
|
||||||
class CustomComponentFrontendNode(FrontendNode):
|
class CustomComponentFrontendNode(FrontendNode):
|
||||||
|
format_template: bool = Field(default=False, exclude=True)
|
||||||
name: str = "CustomComponent"
|
name: str = "CustomComponent"
|
||||||
display_name: Optional[str] = "CustomComponent"
|
display_name: Optional[str] = "CustomComponent"
|
||||||
beta: bool = True
|
beta: bool = True
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue