Skip to content

Commit

Permalink
Minor fix for SimpleLoadDirectory integration
Browse files Browse the repository at this point in the history
  • Loading branch information
FunkyOz committed Feb 28, 2024
1 parent 315a9e3 commit 4536984
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand All @@ -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())]

0 comments on commit 4536984

Please sign in to comment.