refactor: Update TextInput to handle Message input
Update the TextInput component in TextInput.py to handle Message input. If the input value is an instance of the Message class, extract the text attribute and use it as the input value. This change ensures compatibility with the langflow schema and improves the flexibility of the component.
This commit is contained in:
parent
7b09d1cc51
commit
00c83d4b9b
1 changed files with 7 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ from langflow.base.io.text import TextComponent
|
|||
from langflow.field_typing import Text
|
||||
from langflow.inputs import StrInput
|
||||
from langflow.template import Output
|
||||
from langflow.schema.message import Message
|
||||
|
||||
|
||||
class TextInput(TextComponent):
|
||||
|
|
@ -31,4 +32,9 @@ class TextInput(TextComponent):
|
|||
]
|
||||
|
||||
def text_response(self) -> Text:
|
||||
return self.build(input_value=self.input_value, data_template=self.data_template)
|
||||
if isinstance(self.input_value, Message):
|
||||
text = self.input_value.text
|
||||
else:
|
||||
text = self.input_value
|
||||
|
||||
return self.build(input_value=text, data_template=self.data_template)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue