Refactor TextInput and TextOutput to use TextComponent

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-01 09:19:10 -03:00
commit fd16f136b1
3 changed files with 27 additions and 18 deletions

View file

@ -1,19 +1,12 @@
from typing import Optional
from langflow import CustomComponent
from langflow.components.io.base.text import TextComponent
from langflow.field_typing import Text
class TextInput(CustomComponent):
class TextInput(TextComponent):
display_name = "Text Input"
description = "Used to pass text input to the next component."
field_config = {
"input_value": {"display_name": "Value", "multiline": True},
}
def build(self, input_value: Optional[str] = "") -> Text:
self.status = input_value
if not input_value:
input_value = ""
return input_value
return super().build(input_value=input_value)

View file

@ -1,19 +1,16 @@
from typing import Optional
from langflow import CustomComponent
from langflow.components.io.base.text import TextComponent
from langflow.field_typing import Text
class TextOutput(CustomComponent):
class TextOutput(TextComponent):
display_name = "Text Output"
description = "Used to pass text output to the next component."
field_config = {
"value": {"display_name": "Value"},
"input_value": {"display_name": "Value"},
}
def build(self, value: Optional[str] = "") -> Text:
self.status = value
if not value:
value = ""
return value
def build(self, input_value: Optional[Text] = "") -> Text:
return super().build(input_value=input_value)

View file

@ -0,0 +1,19 @@
from typing import Optional
from langflow import CustomComponent
from langflow.field_typing import Text
class TextComponent(CustomComponent):
display_name = "Text Component"
description = "Used to pass text to the next component."
field_config = {
"input_value": {"display_name": "Value", "multiline": True},
}
def build(self, input_value: Optional[str] = "") -> Text:
self.status = input_value
if not input_value:
input_value = ""
return input_value