Skip to content

Commit

Permalink
Merge branch 'mnl/file-system-reader-mixin-standardize' of github.com…
Browse files Browse the repository at this point in the history
…:EmanuelCampos/llama_index into mnl/add-get-methods-filesystemmixin
  • Loading branch information
EmanuelCampos committed Nov 26, 2024
2 parents 9e869d3 + b5e1c14 commit e513251
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions llama-index-core/llama_index/core/readers/file/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,12 @@ async def aload_resource(
**kwargs,
)

def read_file_content(self, input_file: Path, **kwargs: Any) -> bytes:
def read_file_content(self, resource_id: str, **kwargs: Any) -> bytes:
"""Read file content."""
fs: fsspec.AbstractFileSystem = kwargs.get("fs", self.fs)
with fs.open(input_file, errors=self.errors, encoding=self.encoding) as f:
with fs.open(
Path(resource_id), errors=self.errors, encoding=self.encoding
) as f:
return f.read()

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ def list_resources(
recursive=recursive,
userprincipalname=userprincipalname,
)
return [payload.resource_info["file_path"] for payload in payloads]
return [str(payload.resource_info["file_path"]) for payload in payloads]
except Exception as e:
logger.error(
f"An error occurred while listing resources: {e}", exc_info=True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ def list_resources(
sharepoint_folder_id: Optional[str] = None,
sharepoint_site_id: Optional[str] = None,
recursive: bool = True,
) -> List[Path]:
) -> List[str]:
"""
Lists the files in the specified folder in the SharePoint site.
Expand Down Expand Up @@ -738,11 +738,11 @@ def list_resources(
recursive,
os.path.join(sharepoint_site_name, sharepoint_folder_path),
)
file_paths.extend(folder_contents)
file_paths.extend([str(path) for path in folder_contents])
else:
# Fetch drive contents
drive_contents = self._list_drive_contents()
file_paths.extend(drive_contents)
file_paths.extend([str(path) for path in drive_contents])
except Exception as exp:
logger.error("An error occurred while listing files in SharePoint: %s", exp)
raise
Expand Down

0 comments on commit e513251

Please sign in to comment.