code: from pathlib import Path
  from llama_index import download_loader
  
  from llama_index import SimpleDirectoryReader
  PDFReader = download_loader("PDFReader")
  
  def getdocument(filename : str,filetype:str):
      if filetype == "pdf":
          loader = PDFReader()
      elif filetype == "txt":
          loader = SimpleDirectoryReader('./example')
  
  
  
      
      document = loader.load_data(file=Path(filename))
      return document
apis: llama_index.download_loader llama_index.SimpleDirectoryReader
extract_api: [((124, 152), 'llama_index.download_loader', 'download_loader', (['"""PDFReader"""'], {}), "('PDFReader')\n", (139, 152), False, 'from llama_index import download_loader\n'), ((300, 334), 'llama_index.SimpleDirectoryReader', 'SimpleDirectoryReader', (['"""./example"""'], {}), "('./example')\n", (321, 334), False, 'from llama_index import SimpleDirectoryReader\n'), ((380, 394), 'pathlib.Path', 'Path', (['filename'], {}), '(filename)\n', (384, 394), False, 'from pathlib import Path\n')]