chore: Refactor TextComponent to remove unused code and improve readability
This commit is contained in:
parent
2cecfb009f
commit
7331cb1903
1 changed files with 0 additions and 23 deletions
|
|
@ -1,9 +1,4 @@
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from langflow.custom import Component
|
from langflow.custom import Component
|
||||||
from langflow.field_typing import Text
|
|
||||||
from langflow.helpers.data import data_to_text
|
|
||||||
from langflow.schema import Data
|
|
||||||
|
|
||||||
|
|
||||||
class TextComponent(Component):
|
class TextComponent(Component):
|
||||||
|
|
@ -24,21 +19,3 @@ class TextComponent(Component):
|
||||||
"advanced": True,
|
"advanced": True,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def build(
|
|
||||||
self,
|
|
||||||
input_value: Optional[Text] = "",
|
|
||||||
data_template: Optional[str] = "{text}",
|
|
||||||
) -> Text:
|
|
||||||
if isinstance(input_value, Data):
|
|
||||||
if data_template == "":
|
|
||||||
# it should be dynamically set to the Data's .text_key value
|
|
||||||
# meaning, if text_key = "bacon", then data_template = "{bacon}"
|
|
||||||
data_template = "{" + input_value.text_key + "}"
|
|
||||||
input_value = data_to_text(template=data_template, data=input_value)
|
|
||||||
elif not input_value:
|
|
||||||
input_value = ""
|
|
||||||
self.status = input_value
|
|
||||||
if not input_value:
|
|
||||||
input_value = ""
|
|
||||||
return input_value
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue