Merge branch 'python_custom_node_component' of github.com:logspace-ai/langflow into python_custom_node_component
This commit is contained in:
commit
ae2707d7c3
5 changed files with 10 additions and 30 deletions
|
|
@ -147,10 +147,10 @@ class CustomComponent(Component, extra=Extra.allow):
|
|||
raise ValueError(f"Flow {flow_id} not found")
|
||||
return build_sorted_vertices_with_caching(data_graph)
|
||||
|
||||
def list_flow_names(self):
|
||||
def list_flows(self):
|
||||
with session_getter() as session:
|
||||
flows = session.query(Flow).all()
|
||||
return [flow.name for flow in flows]
|
||||
return flows
|
||||
|
||||
def build(self):
|
||||
raise NotImplementedError
|
||||
|
|
|
|||
|
|
@ -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