Skip to content

Commit

Permalink
fix: onedrive reader
Browse files Browse the repository at this point in the history
  • Loading branch information
himself65 committed Nov 7, 2024
1 parent eb57e75 commit 960a06a
Showing 1 changed file with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
import os
import tempfile
import time
from typing import Any, Dict, List, Optional, Union
from typing import Any, Dict, List, Optional
from pathlib import Path

import requests
from llama_index.core.readers import SimpleDirectoryReader
from llama_index.core.readers.base import BaseReader, BasePydanticReader
from typing_extensions import Unpack

from llama_index.core.readers import SimpleDirectoryReader, DirectoryReaderArgs
from llama_index.core.readers.base import BasePydanticReader
from llama_index.core.schema import Document
from llama_index.core.bridge.pydantic import PrivateAttr, Field, BaseModel
from llama_index.core.bridge.pydantic import PrivateAttr, BaseModel
from llama_index.core.readers import FileSystemReaderMixin
from llama_index.core.readers.base import (
BaseReader,
BasePydanticReader,
ResourcesReaderMixin,
)
Expand Down Expand Up @@ -68,10 +69,6 @@ class OneDriveReader(BasePydanticReader, ResourcesReaderMixin, FileSystemReaderM
file_ids: Optional[List[str]] = None
folder_path: Optional[str] = None
file_paths: Optional[List[str]] = None
required_exts: Optional[List[str]] = None
file_extractor: Optional[Dict[str, Union[str, BaseReader]]] = Field(
default=None, exclude=True
)
attach_permission_metadata: bool = False

_is_interactive_auth = PrivateAttr(False)
Expand All @@ -87,10 +84,8 @@ def __init__(
file_ids: Optional[List[str]] = None,
folder_path: Optional[str] = None,
file_paths: Optional[List[str]] = None,
file_extractor: Optional[Dict[str, Union[str, BaseReader]]] = None,
attach_permission_metadata: bool = False,
required_exts: Optional[List[str]] = None,
**kwargs,
**kwargs: Unpack[DirectoryReaderArgs],
) -> None:
super().__init__(
client_id=client_id,
Expand All @@ -101,9 +96,7 @@ def __init__(
file_ids=file_ids,
folder_path=folder_path,
file_paths=file_paths,
file_extractor=file_extractor,
attach_permission_metadata=attach_permission_metadata,
required_exts=required_exts,
**kwargs,
)
self._is_interactive_auth = not client_secret
Expand Down Expand Up @@ -562,10 +555,9 @@ def get_metadata(filename: str) -> Any:

simple_loader = SimpleDirectoryReader(
directory,
file_extractor=self.file_extractor,
required_exts=self.required_exts,
file_metadata=get_metadata,
recursive=recursive,
**self.model_dump(),
)
return simple_loader.load_data()

Expand Down

0 comments on commit 960a06a

Please sign in to comment.