asif00 commited on
Commit
f38ab8d
1 Parent(s): 3e51f2e

Update: A few changes in UI

Browse files
Files changed (2) hide show
  1. app.py +12 -6
  2. src/style.css +1 -1
app.py CHANGED
@@ -14,11 +14,13 @@ processing = False
14
 
15
  def load_pdf(pdf_file_path):
16
  global pdf_loaded
 
 
17
  filename = pdf_file_path.name
18
  global brain
19
  brain = Initializer.initialize(AUG_TOKEN, RES_TOKEN, filename)
20
  pdf_loaded = True
21
- return "Processing complete!"
22
 
23
 
24
  def response(query, history):
@@ -49,21 +51,25 @@ def loading():
49
  with gr.Blocks(css=css) as app:
50
  with gr.Column(elem_id="column_container"):
51
  gr.HTML(title_html)
 
52
  with gr.Column():
53
- pdf = gr.File(label="Load your PDF document", file_types=[".pdf"])
 
54
  with gr.Row():
55
- status = gr.Label(label="Status", value="Yet to Process the PDF")
56
  load_pdf_button = gr.Button(value="Process")
57
 
58
- chatbot = gr.Chatbot([], elem_id="chatbot")
 
 
59
  query = gr.Textbox(
60
- label="Ask questions about the PDF",
61
  placeholder="What do you want to know?",
62
  )
63
  clear = gr.ClearButton([query, chatbot])
64
  gr.HTML(bts_html)
65
 
66
- load_pdf_button.click(loading, outputs=[status], queue=True)
67
  load_pdf_button.click(load_pdf, inputs=[pdf], outputs=[status], queue=True)
68
  query.submit(response, [query, chatbot], [query, chatbot], queue=True)
69
 
 
14
 
15
  def load_pdf(pdf_file_path):
16
  global pdf_loaded
17
+ if pdf_file_path is None:
18
+ return "Upload PDF First"
19
  filename = pdf_file_path.name
20
  global brain
21
  brain = Initializer.initialize(AUG_TOKEN, RES_TOKEN, filename)
22
  pdf_loaded = True
23
+ return "Ask Questions Now!"
24
 
25
 
26
  def response(query, history):
 
51
  with gr.Blocks(css=css) as app:
52
  with gr.Column(elem_id="column_container"):
53
  gr.HTML(title_html)
54
+
55
  with gr.Column():
56
+ send = gr.Label(value="UPLOAD your PDF below")
57
+ pdf = gr.File(label="Load your PDF document:", file_types=[".pdf"])
58
  with gr.Row():
59
+ status = gr.Label(label="Status:", value="Process Document!")
60
  load_pdf_button = gr.Button(value="Process")
61
 
62
+ chatbot = gr.Chatbot([])
63
+ with gr.Column():
64
+ send = gr.Label(value="Write your QUESTION bellow and hit ENTER")
65
  query = gr.Textbox(
66
+ label="Type your questions here:",
67
  placeholder="What do you want to know?",
68
  )
69
  clear = gr.ClearButton([query, chatbot])
70
  gr.HTML(bts_html)
71
 
72
+ load_pdf_button.click(loading, outputs=[status], queue=False)
73
  load_pdf_button.click(load_pdf, inputs=[pdf], outputs=[status], queue=True)
74
  query.submit(response, [query, chatbot], [query, chatbot], queue=True)
75
 
src/style.css CHANGED
@@ -51,7 +51,7 @@ li {
51
  }
52
 
53
  button {
54
- background-color: #7af3e575;
55
  color: #000000;
56
  border: none;
57
  border-radius: 8px;
 
51
  }
52
 
53
  button {
54
+ background-color: #7af3e517;
55
  color: #000000;
56
  border: none;
57
  border-radius: 8px;