Refactor format_template field in FrontendNode
This commit is contained in:
parent
cb39d77667
commit
debf495cf9
2 changed files with 3 additions and 5 deletions
|
|
@ -40,7 +40,7 @@ class FieldFormatters(BaseModel):
|
|||
|
||||
|
||||
class FrontendNode(BaseModel):
|
||||
format_template: bool = Field(default=True, exclude=True)
|
||||
_format_template: bool = True
|
||||
template: Template
|
||||
description: Optional[str] = None
|
||||
base_classes: List[str]
|
||||
|
|
@ -81,7 +81,7 @@ class FrontendNode(BaseModel):
|
|||
def serialize_model(self, handler):
|
||||
result = handler(self)
|
||||
if hasattr(self, "template") and hasattr(self.template, "to_dict"):
|
||||
format_func = self.format_field if self.format_template else None
|
||||
format_func = self.format_field if self._format_template else None
|
||||
result["template"] = self.template.to_dict(format_func)
|
||||
name = result.pop("name")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
from typing import Optional
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from langflow.template.field.base import TemplateField
|
||||
from langflow.template.frontend_node.base import FrontendNode
|
||||
from langflow.template.template.base import Template
|
||||
|
|
@ -47,7 +45,7 @@ class Component(CustomComponent):
|
|||
|
||||
|
||||
class CustomComponentFrontendNode(FrontendNode):
|
||||
format_template: bool = Field(default=False, exclude=True)
|
||||
_format_template: bool = False
|
||||
name: str = "CustomComponent"
|
||||
display_name: Optional[str] = "CustomComponent"
|
||||
beta: bool = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue