KalooAI commited on
Commit
48b5a8d
·
verified ·
1 Parent(s): d6113ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -161,21 +161,22 @@ def answer_question(question, state):
161
  # ============================================================
162
 
163
  with gr.Blocks(title="Granite PDF QA") as demo:
164
- gr.Markdown("## 📄🔍 PDF Q&A using IBM Granite\nUpload a PDF and ask questions about its content.")
165
 
166
  state = gr.State({"chunks": None, "index": None})
167
 
168
- with gr.Row():
169
- with gr.Column(scale=1):
170
- pdf_input = gr.File(label="Upload PDF", file_types=[".pdf"])
171
- pdf_status = gr.Textbox(label="Status", interactive=False)
172
 
173
- with gr.Column(scale=2):
174
- question = gr.Textbox(label="Your question", lines=2)
175
- answer = gr.Textbox(label="Answer", lines=8)
 
176
 
177
- pdf_input.upload(load_pdf, inputs=[pdf_input, state], outputs=[pdf_status, state])
178
- question.submit(answer_question, inputs=[question, state], outputs=answer)
179
 
180
  if __name__ == "__main__":
181
  demo.launch()
 
161
  # ============================================================
162
 
163
  with gr.Blocks(title="Granite PDF QA") as demo:
164
+ gr.Markdown("## PDF Q&A using IBM Granite\nUpload a PDF and ask questions about its content.")
165
 
166
  state = gr.State({"chunks": None, "index": None})
167
 
168
+ with gr.Row():
169
+ with gr.Column(scale=1):
170
+ pdf_input = gr.File(label="Upload PDF", file_types=[".pdf"])
171
+ pdf_status = gr.Textbox(label="Status", interactive=False)
172
 
173
+ with gr.Column(scale=2):
174
+ question = gr.Textbox(label="Your question", lines=2)
175
+ answer = gr.Textbox(label="Answer", lines=8)
176
+ ask_button = gr.Button("Ask")
177
 
178
+ pdf_input.upload(load_pdf, inputs=[pdf_input, state], outputs=[pdf_status, state])
179
+ ask_button.click(answer_question, inputs=[question, state], outputs=answer)
180
 
181
  if __name__ == "__main__":
182
  demo.launch()