manuelcozar55 commited on
Commit
4695961
·
verified ·
1 Parent(s): efc54b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -19,10 +19,11 @@ def process_input(file, file_type):
19
  reader = PyPDF2.PdfFileReader(file.name)
20
  text = ""
21
  for page in range(reader.numPages):
22
- text += reader.getPage(page).extractText()
23
  return text
24
  elif file_type == 'json':
25
- data = json.load(file)
 
26
  return json.dumps(data, indent=2)
27
  return file
28
 
@@ -54,7 +55,7 @@ gr.ChatInterface(
54
  fn=generate,
55
  inputs=[
56
  gr.Dropdown(label="Mode", choices=["translation", "summary", "explanation"], value="translation"),
57
- gr.File(label="Input File", type="file"),
58
  gr.Radio(label="File Type", choices=["pdf", "json"], value="pdf"),
59
  gr.Textbox(label="Additional Instructions", placeholder="Enter any additional instructions here"),
60
  gr.Chatbot()
 
19
  reader = PyPDF2.PdfFileReader(file.name)
20
  text = ""
21
  for page in range(reader.numPages):
22
+ text += reader.getPage(page).extract_text()
23
  return text
24
  elif file_type == 'json':
25
+ with open(file.name, 'r') as f:
26
+ data = json.load(f)
27
  return json.dumps(data, indent=2)
28
  return file
29
 
 
55
  fn=generate,
56
  inputs=[
57
  gr.Dropdown(label="Mode", choices=["translation", "summary", "explanation"], value="translation"),
58
+ gr.File(label="Input File", type="filepath"),
59
  gr.Radio(label="File Type", choices=["pdf", "json"], value="pdf"),
60
  gr.Textbox(label="Additional Instructions", placeholder="Enter any additional instructions here"),
61
  gr.Chatbot()