From f8c9ac328930db5519b35f67a4f600d138a1407a Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Fri, 29 Nov 2024 13:45:30 -0300 Subject: [PATCH] Refactor: Update Data class to handle different types of text inputs (#4938) The Data class in the langflow schema has been updated to handle different types of text inputs. Previously, the page_content attribute was expected to be a string, but now it can also accept other types. If the input is already a string, it is used as is. Otherwise, it is converted to a string before being assigned to the page_content attribute of the Document object. This change improves the flexibility and robustness of the Data class, allowing it to handle a wider range of input types. --- src/backend/base/langflow/schema/data.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/base/langflow/schema/data.py b/src/backend/base/langflow/schema/data.py index e8a52a565..0750192df 100644 --- a/src/backend/base/langflow/schema/data.py +++ b/src/backend/base/langflow/schema/data.py @@ -130,7 +130,9 @@ class Data(BaseModel): """ data_copy = self.data.copy() text = data_copy.pop(self.text_key, self.default_value) - return Document(page_content=text, metadata=data_copy) + if isinstance(text, str): + return Document(page_content=text, metadata=data_copy) + return Document(page_content=str(text), metadata=data_copy) def to_lc_message( self,