Refactor code to use get_text() method instead of accessing the 'text' attribute directly.
This commit is contained in:
parent
0788951ba4
commit
617be2809f
3 changed files with 3 additions and 3 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue