epochs-demos commited on
Commit
71de0be
·
1 Parent(s): 8917285

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -6
app.py CHANGED
@@ -19,7 +19,7 @@ class GUI:
19
  return self.session.question(question)
20
 
21
 
22
- with gr.Blocks() as demo:
23
  with open("./logo.png", "rb") as f:
24
  image_data = f.read()
25
  image_base64 = base64.b64encode(image_data).decode("utf-8")
@@ -65,8 +65,17 @@ with gr.Blocks() as demo:
65
 
66
 
67
  app = GUI()
68
- gr.Interface(fn=app.analyse, inputs=[api_input, pdf_input], outputs=result,title=title,description=description)
69
- ask_button.click(app.ask_question, inputs=question_input, outputs=answer)
70
-
71
- if __name__ == "__main__":
72
- demo.launch() # add "share=True" to share CHATGPT-PAPER-READER app on Internet. an app on hugging face
 
 
 
 
 
 
 
 
 
 
19
  return self.session.question(question)
20
 
21
 
22
+
23
  with open("./logo.png", "rb") as f:
24
  image_data = f.read()
25
  image_base64 = base64.b64encode(image_data).decode("utf-8")
 
65
 
66
 
67
  app = GUI()
68
+ def start_analyse(api_key, pdf_file):
69
+ return app.analyse(api_key, pdf_file)
70
+
71
+ def start_ask(question):
72
+ return app.ask_question(question)
73
+
74
+ iface = gr.Interface(fn=start_analyse,inputs=["text", "file"],outputs="text",title=title,description=description)
75
+ upload_button = iface.get_widget("file")
76
+ upload_button.label = "Upload PDF File"
77
+ question_input = gr.inputs.Textbox(label="Your Question", placeholder="Authors of this paper?")
78
+ ask_button = gr.Button("Ask")
79
+ iface.add_input(question_input)
80
+ iface.add_output(ask_button)
81
+ iface.launch()