diff --git a/llama-index-integrations/readers/llama-index-readers-file/llama_index/readers/file/rtf/base.py b/llama-index-integrations/readers/llama-index-readers-file/llama_index/readers/file/rtf/base.py index b2acff7d5173f..d4985bda82c14 100644 --- a/llama-index-integrations/readers/llama-index-readers-file/llama_index/readers/file/rtf/base.py +++ b/llama-index-integrations/readers/llama-index-readers-file/llama_index/readers/file/rtf/base.py @@ -1,7 +1,6 @@ """RTF (Rich Text Format) reader.""" -import os.path from pathlib import Path -from typing import List, Union +from typing import List, Union, Any, Dict from llama_index.core.readers.base import BaseReader from llama_index.core.schema import Document @@ -10,11 +9,12 @@ class RTFReader(BaseReader): """RTF (Rich Text Format) Reader. Reads rtf file and convert to Document.""" - def load_data(self, file: Union[Path, str]) -> List[Document]: + def load_data(self, input_file: Union[Path, str], extra_info=Dict[str, Any], **load_kwargs: Any) -> List[Document]: """Load data from RTF file. Args: - file (Path | str): Path for the RTF file. + input_file (Path | str): Path for the RTF file. + extra_info (Dict[str, Any]): Path for the RTF file. Returns: List[Document]: List of documents. @@ -24,8 +24,6 @@ def load_data(self, file: Union[Path, str]) -> List[Document]: except ImportError: raise ImportError("striprtf is required to read RTF files.") - with open(str(file), "r") as f: + with open(str(input_file), "r") as f: text = rtf_to_text(f.read()) - file_name = os.path.basename(file) - - return [Document(text=text.strip(), metadata={"filename": file_name, 'file_path': str(file)})] + return [Document(text=text.strip())]