✨ feat(custom_components.py): add CustomComponentFrontendNode class to create a custom component
The CustomComponentFrontendNode class is added to the custom_components.py file. This class represents a custom component in the frontend of the application. It has properties such as name, display_name, template, description, and base_classes. The template property defines the structure of the custom component, including a code field with default value. The to_dict() method is also implemented to convert the class instance to a dictionary. This allows the custom component to be serialized and used in other parts of the application.
This commit is contained in:
parent
93dbf552f0
commit
790d8b5669
1 changed files with 30 additions and 0 deletions
|
|
@ -0,0 +1,30 @@
|
|||
from langflow.template.field.base import TemplateField
|
||||
from langflow.template.frontend_node.base import FrontendNode
|
||||
from langflow.template.template.base import Template
|
||||
from langflow.utils.constants import DEFAULT_CUSTOM_COMPONENT_CODE
|
||||
|
||||
|
||||
class CustomComponentFrontendNode(FrontendNode):
|
||||
name: str = "CustomComponent"
|
||||
display_name: str = "Custom Component"
|
||||
template: Template = Template(
|
||||
type_name="CustomComponent",
|
||||
fields=[
|
||||
TemplateField(
|
||||
field_type="code",
|
||||
required=True,
|
||||
placeholder="",
|
||||
is_list=False,
|
||||
show=True,
|
||||
value=DEFAULT_CUSTOM_COMPONENT_CODE,
|
||||
name="code",
|
||||
advanced=False,
|
||||
dynamic=True,
|
||||
)
|
||||
],
|
||||
)
|
||||
description: str = "Create any custom component you want!"
|
||||
base_classes: list[str] = []
|
||||
|
||||
def to_dict(self):
|
||||
return super().to_dict()
|
||||
Loading…
Add table
Add a link
Reference in a new issue