refactor: Ensure data_input is always a list in RecursiveCharacterTextSplitterComponent

To prevent potential errors, this refactor ensures that the `data_input` attribute in the `RecursiveCharacterTextSplitterComponent` class is always a list. If it is not already a list, it is converted to a list before processing. This change improves the reliability and consistency of the code.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-06-19 10:54:08 -03:00
commit 4f7d453abc

View file

@ -73,6 +73,8 @@ class RecursiveCharacterTextSplitterComponent(Component):
chunk_overlap=self.chunk_overlap,
)
documents = []
if not isinstance(self.data_input, list):
self.data_input = [self.data_input]
for _input in self.data_input:
if isinstance(_input, Data):
documents.append(_input.to_lc_document())