🔨 refactor(types.py): import CustomComponentFrontendNode from custom_components module to improve code organization and readability
🔨 refactor(types.py): change usage of CustomComponentNode to CustomComponentFrontendNode to align with updated module structure 🔨 refactor(frontend_node/base.py): add beta flag to FrontendNode class to indicate if a node is in beta stage 🔨 refactor(custom_components.py): add beta flag to CustomComponentFrontendNode class to indicate it is in beta stage 🔨 refactor(tools.py): remove unused import of DEFAULT_CUSTOM_COMPONENT_CODE 🔨 refactor(tools.py): remove CustomComponentNode class as it is no longer used
This commit is contained in:
parent
b76141b3df
commit
74e263811b
4 changed files with 8 additions and 28 deletions
|
|
@ -18,7 +18,9 @@ from langflow.interface.custom.base import custom_component_creator
|
|||
from langflow.interface.custom.custom_component import CustomComponent
|
||||
|
||||
from langflow.template.field.base import TemplateField
|
||||
from langflow.template.frontend_node.tools import CustomComponentNode
|
||||
from langflow.template.frontend_node.custom_components import (
|
||||
CustomComponentFrontendNode,
|
||||
)
|
||||
from langflow.interface.retrievers.base import retriever_creator
|
||||
|
||||
from langflow.interface.custom.directory_reader import DirectoryReader
|
||||
|
|
@ -160,7 +162,9 @@ def extract_type_from_optional(field_type):
|
|||
|
||||
def build_langchain_template_custom_component(custom_component: CustomComponent):
|
||||
# Build base "CustomComponent" template
|
||||
frontend_node = CustomComponentNode().to_dict().get(type(custom_component).__name__)
|
||||
frontend_node = (
|
||||
CustomComponentFrontendNode().to_dict().get(type(custom_component).__name__)
|
||||
)
|
||||
|
||||
function_args = custom_component.get_function_entrypoint_args
|
||||
return_type = custom_component.get_function_entrypoint_return_type
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class FrontendNode(BaseModel):
|
|||
custom_fields: defaultdict = defaultdict(list)
|
||||
output_types: List[str] = []
|
||||
field_formatters: FieldFormatters = Field(default_factory=FieldFormatters)
|
||||
beta: bool = False
|
||||
|
||||
# field formatters is an instance attribute but it is not used in the class
|
||||
# so we need to create a method to get it
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from langflow.interface.custom.constants import DEFAULT_CUSTOM_COMPONENT_CODE
|
|||
class CustomComponentFrontendNode(FrontendNode):
|
||||
name: str = "CustomComponent"
|
||||
display_name: str = "Custom Component"
|
||||
beta: bool = True
|
||||
template: Template = Template(
|
||||
type_name="CustomComponent",
|
||||
fields=[
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
from langflow.interface.custom.constants import DEFAULT_CUSTOM_COMPONENT_CODE
|
||||
from langflow.template.field.base import TemplateField
|
||||
from langflow.template.frontend_node.base import FrontendNode
|
||||
from langflow.template.template.base import Template
|
||||
|
|
@ -140,28 +139,3 @@ class PythonFunctionNode(FrontendNode):
|
|||
|
||||
def to_dict(self):
|
||||
return super().to_dict()
|
||||
|
||||
|
||||
class CustomComponentNode(FrontendNode):
|
||||
name: str = "CustomComponent"
|
||||
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 = "Python Class to be executed."
|
||||
base_classes: list[str] = []
|
||||
|
||||
def to_dict(self):
|
||||
return super().to_dict()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue