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.
This commit is contained in:
ogabrielluiz 2024-06-12 23:27:21 -03:00
commit 8a75315249

View file

@ -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