From 8a75315249ee834038da0cc25268a6939b8a1fba Mon Sep 17 00:00:00 2001 From: ogabrielluiz Date: Wed, 12 Jun 2024 23:27:21 -0300 Subject: [PATCH] refactor: Update CustomComponent to use StrInput and Output classes Update the CustomComponent class in CustomComponent.py to use the StrInput and Output classes from the langflow library. This change ensures compatibility with the latest langflow updates and improves the clarity and consistency of the code. --- .../components/helpers/CustomComponent.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/backend/base/langflow/components/helpers/CustomComponent.py b/src/backend/base/langflow/components/helpers/CustomComponent.py index 98dcf3934..8da9b0004 100644 --- a/src/backend/base/langflow/components/helpers/CustomComponent.py +++ b/src/backend/base/langflow/components/helpers/CustomComponent.py @@ -1,16 +1,25 @@ # from langflow.field_typing import Data -from langflow.custom import CustomComponent +from langflow.custom import Component +from langflow.inputs import StrInput from langflow.schema import Data +from langflow.template import Output -class Component(CustomComponent): +class CustomComponent(Component): display_name = "Custom Component" description = "Use as a template to create your own component." documentation: str = "http://docs.langflow.org/components/custom" icon = "custom_components" - def build_config(self): - return {"param": {"display_name": "Parameter"}} + inputs = [ + StrInput(name="input_value", display_name="Input Value", value="Hello, World!"), + ] - def build(self, param: str) -> Data: - return Data(data=param) + outputs = [ + Output(display_name="Output", name="output", method="build_output"), + ] + + def build_output(self) -> Data: + data = Data(value=self.input_value) + self.status = data + return data