From 00c83d4b9b60ed3fefc7741768f7cf5a968b7353 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Thu, 13 Jun 2024 00:03:36 -0300 Subject: [PATCH] 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. --- src/backend/base/langflow/components/inputs/TextInput.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backend/base/langflow/components/inputs/TextInput.py b/src/backend/base/langflow/components/inputs/TextInput.py index 0dd59db42..9db7f0481 100644 --- a/src/backend/base/langflow/components/inputs/TextInput.py +++ b/src/backend/base/langflow/components/inputs/TextInput.py @@ -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)