From 617be2809f54cac0ee8f836c74b6f29caf813352 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 29 Mar 2024 22:29:47 -0300 Subject: [PATCH] Refactor code to use get_text() method instead of accessing the 'text' attribute directly. --- src/backend/base/langflow/base/prompts/utils.py | 2 +- src/backend/base/langflow/graph/vertex/types.py | 2 +- .../interface/custom/custom_component/custom_component.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/base/langflow/base/prompts/utils.py b/src/backend/base/langflow/base/prompts/utils.py index 561d8256a..ff4cf5079 100644 --- a/src/backend/base/langflow/base/prompts/utils.py +++ b/src/backend/base/langflow/base/prompts/utils.py @@ -45,7 +45,7 @@ def record_to_string(record: Record) -> str: Returns: str: The record as a string. """ - return record.text + return record.get_text() def document_to_string(document: Document) -> str: diff --git a/src/backend/base/langflow/graph/vertex/types.py b/src/backend/base/langflow/graph/vertex/types.py index 538b2860d..ef3286d79 100644 --- a/src/backend/base/langflow/graph/vertex/types.py +++ b/src/backend/base/langflow/graph/vertex/types.py @@ -125,7 +125,7 @@ class DocumentLoaderVertex(Vertex): # show how many documents are in the list? if not isinstance(self._built_object, UnbuiltObject): - avg_length = sum(len(record.text) for record in self._built_object if hasattr(record, "text")) / len( + avg_length = sum(len(record.get_text()) for record in self._built_object if hasattr(record, "text")) / len( self._built_object ) return f"""{self.display_name}({len(self._built_object)} records) diff --git a/src/backend/base/langflow/interface/custom/custom_component/custom_component.py b/src/backend/base/langflow/interface/custom/custom_component/custom_component.py index 409693681..e6f0c4652 100644 --- a/src/backend/base/langflow/interface/custom/custom_component/custom_component.py +++ b/src/backend/base/langflow/interface/custom/custom_component/custom_component.py @@ -249,7 +249,7 @@ class CustomComponent(Component): return "" markdown_string = "---\n" for record in records: - markdown_string += f"- Text: {record.text}" + markdown_string += f"- Text: {record.get_text()}" if include_data: markdown_string += f" Data: {record.data}" markdown_string += "\n"