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:
parent
0240315020
commit
f8c9ac3289
1 changed files with 3 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue