code: from llama_index.schema import Document
  from llmsherpa.readers import LayoutPDFReader
  
  import pandas as pd
  
  llmsherpa_api_url = "https://readers.llmsherpa.com/api/document/developer/parseDocument?renderFormat=all"
  
  
  def parse_source_item(item):
      documents = []
  
      if item['type'] == 'csv':
          data = pd.read_csv(item['path'])
  
          questions = data[data.columns[0]].tolist()
          answers = data[data.columns[1]].tolist()
  
          for index, question in enumerate(questions):
              text = question + " " + answers[index]
  
              documents.append(Document(text=text, id_=f"{item['_id']}_{index}"))
  
      if item['type'] == 'pdf':
          pdf_reader = LayoutPDFReader(llmsherpa_api_url)
  
          doc = pdf_reader.read_pdf(item['path'])
  
          for index, chunk in enumerate(doc.chunks()):
              documents.append(Document(text=chunk.to_context_text(), id_=f"{item['_id']}_{index}"))
  
      if item['type'] == 'qa':
          text = item['question'] + " " + item['answer']
  
          documents.append(Document(text=text, id_=f"{item['_id']}"))
  
      return documents
  
  
  def parse_items_to_delete(item):
      documents_to_delete = []
  
      if item['type'] == 'csv':
          data = pd.read_csv(item['path'])
  
          questions = data[data.columns[0]].tolist()
  
          for index in enumerate(questions):
              documents_to_delete.append(f"{item['_id']}_{index}")
  
      if item['type'] == 'pdf':
          pdf_reader = LayoutPDFReader(llmsherpa_api_url)
      
          doc = pdf_reader.read_pdf(item['path'])
  
          for index in enumerate(doc.chunks()):
              documents_to_delete.append(f"{item['_id']}_{index}")
  
      if item['type'] == 'qa':
          documents_to_delete.append(f"{item['_id']}")
  
      return documents_to_delete
  
apis: llama_index.schema.Document
extract_api: [((310, 335), 'pandas.read_csv', 'pd.read_csv', (["item['path']"], {}), "(item['path'])\n", (321, 335), True, 'import pandas as pd\n'), ((675, 709), 'llmsherpa.readers.LayoutPDFReader', 'LayoutPDFReader', (['llmsherpa_api_url'], {}), '(llmsherpa_api_url)\n', (690, 709), False, 'from llmsherpa.readers import LayoutPDFReader\n'), ((1198, 1223), 'pandas.read_csv', 'pd.read_csv', (["item['path']"], {}), "(item['path'])\n", (1209, 1223), True, 'import pandas as pd\n'), ((1437, 1471), 'llmsherpa.readers.LayoutPDFReader', 'LayoutPDFReader', (['llmsherpa_api_url'], {}), '(llmsherpa_api_url)\n', (1452, 1471), False, 'from llmsherpa.readers import LayoutPDFReader\n'), ((1023, 1064), 'llama_index.schema.Document', 'Document', ([], {'text': 'text', 'id_': 'f"""{item[\'_id\']}"""'}), '(text=text, id_=f"{item[\'_id\']}")\n', (1031, 1064), False, 'from llama_index.schema import Document\n'), ((572, 621), 'llama_index.schema.Document', 'Document', ([], {'text': 'text', 'id_': 'f"""{item[\'_id\']}_{index}"""'}), '(text=text, id_=f"{item[\'_id\']}_{index}")\n', (580, 621), False, 'from llama_index.schema import Document\n')]