code: import tempfile, os
  from routers.utils.engine import Engine
  from llama_index import download_loader
  from fastapi import APIRouter, UploadFile, HTTPException
  
  engine = Engine()
  router = APIRouter()
  
  @router.post("/pdf")
  async def file(upload_file: UploadFile, namespace: str):
      """
      Loader: https://llamahub.ai/l/file-pymu_pdf
      """
      file_preview_name, file_extension = os.path.splitext(upload_file.filename)
      if file_extension != '.pdf':
          raise HTTPException(status_code=400, detail="File must be a PDF")
      
      with tempfile.NamedTemporaryFile(delete=True, prefix=file_preview_name + '_', suffix=".pdf") as temp_file:
          content = await upload_file.read()
          temp_file.write(content)
          PyMuPDFReader = download_loader("PyMuPDFReader")
          loader = PyMuPDFReader().load(file_path=temp_file.name, metadata=True)
          engine.load(loader, namespace)
      
      return {'message': 'File uploaded successfully', 'filename': upload_file.filename, "namespace": namespace}
apis: llama_index.download_loader
extract_api: [((167, 175), 'routers.utils.engine.Engine', 'Engine', ([], {}), '()\n', (173, 175), False, 'from routers.utils.engine import Engine\n'), ((185, 196), 'fastapi.APIRouter', 'APIRouter', ([], {}), '()\n', (194, 196), False, 'from fastapi import APIRouter, UploadFile, HTTPException\n'), ((380, 418), 'os.path.splitext', 'os.path.splitext', (['upload_file.filename'], {}), '(upload_file.filename)\n', (396, 418), False, 'import tempfile, os\n'), ((466, 525), 'fastapi.HTTPException', 'HTTPException', ([], {'status_code': '(400)', 'detail': '"""File must be a PDF"""'}), "(status_code=400, detail='File must be a PDF')\n", (479, 525), False, 'from fastapi import APIRouter, UploadFile, HTTPException\n'), ((540, 631), 'tempfile.NamedTemporaryFile', 'tempfile.NamedTemporaryFile', ([], {'delete': '(True)', 'prefix': "(file_preview_name + '_')", 'suffix': '""".pdf"""'}), "(delete=True, prefix=file_preview_name + '_',\n    suffix='.pdf')\n", (567, 631), False, 'import tempfile, os\n'), ((742, 774), 'llama_index.download_loader', 'download_loader', (['"""PyMuPDFReader"""'], {}), "('PyMuPDFReader')\n", (757, 774), False, 'from llama_index import download_loader\n')]