Refactor TextInput and TextOutput to use TextComponent
This commit is contained in:
parent
90569d73c8
commit
fd16f136b1
3 changed files with 27 additions and 18 deletions
|
|
@ -1,19 +1,12 @@
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from langflow import CustomComponent
|
from langflow.components.io.base.text import TextComponent
|
||||||
from langflow.field_typing import Text
|
from langflow.field_typing import Text
|
||||||
|
|
||||||
|
|
||||||
class TextInput(CustomComponent):
|
class TextInput(TextComponent):
|
||||||
display_name = "Text Input"
|
display_name = "Text Input"
|
||||||
description = "Used to pass text input to the next component."
|
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:
|
def build(self, input_value: Optional[str] = "") -> Text:
|
||||||
self.status = input_value
|
return super().build(input_value=input_value)
|
||||||
if not input_value:
|
|
||||||
input_value = ""
|
|
||||||
return input_value
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from langflow import CustomComponent
|
from langflow.components.io.base.text import TextComponent
|
||||||
from langflow.field_typing import Text
|
from langflow.field_typing import Text
|
||||||
|
|
||||||
|
|
||||||
class TextOutput(CustomComponent):
|
class TextOutput(TextComponent):
|
||||||
display_name = "Text Output"
|
display_name = "Text Output"
|
||||||
description = "Used to pass text output to the next component."
|
description = "Used to pass text output to the next component."
|
||||||
|
|
||||||
field_config = {
|
field_config = {
|
||||||
"value": {"display_name": "Value"},
|
"input_value": {"display_name": "Value"},
|
||||||
}
|
}
|
||||||
|
|
||||||
def build(self, value: Optional[str] = "") -> Text:
|
def build(self, input_value: Optional[Text] = "") -> Text:
|
||||||
self.status = value
|
return super().build(input_value=input_value)
|
||||||
if not value:
|
|
||||||
value = ""
|
|
||||||
return value
|
|
||||||
|
|
|
||||||
19
src/backend/langflow/components/io/base/text.py
Normal file
19
src/backend/langflow/components/io/base/text.py
Normal 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue