From 4f7d453abcb602e128b44b69d6da3f4bd5c48f15 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 19 Jun 2024 10:54:08 -0300 Subject: [PATCH] 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. --- .../components/textsplitters/RecursiveCharacterTextSplitter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend/base/langflow/components/textsplitters/RecursiveCharacterTextSplitter.py b/src/backend/base/langflow/components/textsplitters/RecursiveCharacterTextSplitter.py index 66ce042a4..fc5057409 100644 --- a/src/backend/base/langflow/components/textsplitters/RecursiveCharacterTextSplitter.py +++ b/src/backend/base/langflow/components/textsplitters/RecursiveCharacterTextSplitter.py @@ -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())