tosin2013 commited on
Commit
beeaade
1 Parent(s): 0c0ed04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -26,10 +26,10 @@ def answer_question(model_name, file, question, status):
26
  if file is not None:
27
  file_name = file.name
28
  if file_name.endswith(".pdf"):
29
- pdf_reader = PyPDF2.PdfFileReader(file)
30
  context = ""
31
- for page_num in range(pdf_reader.numPages):
32
- context += pdf_reader.getPage(page_num).extract_text()
33
  elif file_name.endswith(".md"):
34
  context = file.read().decode('utf-8')
35
  context = markdown.markdown(context)
@@ -89,4 +89,4 @@ with gr.Blocks() as interface:
89
  )
90
 
91
  if __name__ == "__main__":
92
- interface.launch()
 
26
  if file is not None:
27
  file_name = file.name
28
  if file_name.endswith(".pdf"):
29
+ pdf_reader = PyPDF2.PdfReader(file)
30
  context = ""
31
+ for page_num in range(len(pdf_reader.pages)):
32
+ context += pdf_reader.pages[page_num].extract_text()
33
  elif file_name.endswith(".md"):
34
  context = file.read().decode('utf-8')
35
  context = markdown.markdown(context)
 
89
  )
90
 
91
  if __name__ == "__main__":
92
+ interface.launch(share=True)