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.
This commit is contained in:
anovazzi1 2024-11-29 13:45:30 -03:00 committed by GitHub
commit f8c9ac3289
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,