diff --git a/libs/community/langchain_community/document_loaders/word_document.py b/libs/community/langchain_community/document_loaders/word_document.py index c7c50575cc7ef..bd2c4ae8f57f8 100644 --- a/libs/community/langchain_community/document_loaders/word_document.py +++ b/libs/community/langchain_community/document_loaders/word_document.py @@ -24,6 +24,7 @@ class Docx2txtLoader(BaseLoader, ABC): def __init__(self, file_path: Union[str, Path]): """Initialize with file path.""" self.file_path = str(file_path) + self.original_file_path = self.file_path if "~" in self.file_path: self.file_path = os.path.expanduser(self.file_path) @@ -55,7 +56,7 @@ def load(self) -> List[Document]: return [ Document( page_content=docx2txt.process(self.file_path), - metadata={"source": self.file_path}, + metadata={"source": self.original_file_path}, ) ]