chansung commited on
Commit
ffff3d1
β€’
1 Parent(s): 1c5a53b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -14
app.py CHANGED
@@ -53,6 +53,10 @@ STYLE = """
53
  #search_input > label > span {
54
  display: none;
55
  }
 
 
 
 
56
  """
57
 
58
  dataset_repo_id = "chansung/auto-paper-qa2"
@@ -146,10 +150,19 @@ def set_paper(date, paper_title):
146
  gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['2_additional_breath_q:answers:expert']}"),
147
  )
148
 
149
- def dumb(title):
150
- if len(title) > 10:
151
- return f"{title[:10]}..."
152
- return title
 
 
 
 
 
 
 
 
 
153
 
154
  def search(search_in, max_results=3):
155
  results = []
@@ -272,55 +285,59 @@ with gr.Blocks(css=STYLE) as demo:
272
  title = gr.Markdown(f"# {selected_paper['title']}")
273
  summary = gr.Markdown(f"{selected_paper['summary']}", elem_classes=["small-font"])
274
 
275
- gr.Markdown("## Auto generated Questions & Answers")
 
 
 
 
276
 
277
  # 1
278
  with gr.Column(elem_classes=["group"], visible=True) as q_0:
279
  basic_q_0 = gr.Markdown(f"## πŸ™‹ {selected_paper['0_question']}")
280
  basic_q_eli5_0 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['0_answers:eli5']}", elem_classes=["small-font"])
281
- basic_q_expert_0 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['0_answers:expert']}", elem_classes=["small-font"])
282
 
283
  with gr.Accordion("Additional question #1", open=False, elem_classes=["accordion"]) as aq_0_0:
284
  depth_q_0 = gr.Markdown(f"## πŸ™‹πŸ™‹ {selected_paper['0_additional_depth_q:follow up question']}")
285
  depth_q_eli5_0 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['0_additional_depth_q:answers:eli5']}", elem_classes=["small-font"])
286
- depth_q_expert_0 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['0_additional_depth_q:answers:expert']}", elem_classes=["small-font"])
287
 
288
  with gr.Accordion("Additional question #2", open=False, elem_classes=["accordion"]) as aq_0_1:
289
  breath_q_0 = gr.Markdown(f"## πŸ™‹πŸ™‹ {selected_paper['0_additional_breath_q:follow up question']}")
290
  breath_q_eli5_0 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['0_additional_breath_q:answers:eli5']}", elem_classes=["small-font"])
291
- breath_q_expert_0 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['0_additional_breath_q:answers:expert']}", elem_classes=["small-font"])
292
 
293
  # 2
294
  with gr.Column(elem_classes=["group"], visible=True) as q_1:
295
  basic_q_1 = gr.Markdown(f"## πŸ™‹ {selected_paper['1_question']}")
296
  basic_q_eli5_1 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['1_answers:eli5']}", elem_classes=["small-font"])
297
- basic_q_expert_1 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['1_answers:expert']}", elem_classes=["small-font"])
298
 
299
  with gr.Accordion("Additional question #1", open=False, elem_classes=["accordion"]) as aq_1_0:
300
  depth_q_1 = gr.Markdown(f"## πŸ™‹πŸ™‹ {selected_paper['1_additional_depth_q:follow up question']}")
301
  depth_q_eli5_1 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['1_additional_depth_q:answers:eli5']}", elem_classes=["small-font"])
302
- depth_q_expert_1 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['1_additional_depth_q:answers:expert']}", elem_classes=["small-font"])
303
 
304
  with gr.Accordion("Additional question #2", open=False, elem_classes=["accordion"]) as aq_1_1:
305
  breath_q_1 = gr.Markdown(f"## πŸ™‹πŸ™‹ {selected_paper['1_additional_breath_q:follow up question']}")
306
  breath_q_eli5_1 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['1_additional_breath_q:answers:eli5']}", elem_classes=["small-font"])
307
- breath_q_expert_1 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['1_additional_breath_q:answers:expert']}", elem_classes=["small-font"])
308
 
309
  # 3
310
  with gr.Column(elem_classes=["group"], visible=True) as q_2:
311
  basic_q_2 = gr.Markdown(f"## πŸ™‹ {selected_paper['2_question']}")
312
  basic_q_eli5_2 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['2_answers:eli5']}", elem_classes=["small-font"])
313
- basic_q_expert_2 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['2_answers:expert']}", elem_classes=["small-font"])
314
 
315
  with gr.Accordion("Additional question #1", open=False, elem_classes=["accordion"]) as aq_2_0:
316
  depth_q_2 = gr.Markdown(f"## πŸ™‹πŸ™‹ {selected_paper['2_additional_depth_q:follow up question']}")
317
  depth_q_eli5_2 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['2_additional_depth_q:answers:eli5']}", elem_classes=["small-font"])
318
- depth_q_expert_2 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['2_additional_depth_q:answers:expert']}", elem_classes=["small-font"])
319
 
320
  with gr.Accordion("Additional question #2", open=False, elem_classes=["accordion"]) as aq_2_1:
321
  breath_q_2 = gr.Markdown(f"## πŸ™‹πŸ™‹ {selected_paper['2_additional_breath_q:follow up question']}")
322
  breath_q_eli5_2 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['2_additional_breath_q:answers:eli5']}", elem_classes=["small-font"])
323
- breath_q_expert_2 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['2_additional_breath_q:answers:expert']}", elem_classes=["small-font"])
324
 
325
  search_r1.click(
326
  set_date,
@@ -401,4 +418,14 @@ with gr.Blocks(css=STYLE) as demo:
401
  fn=None
402
  )
403
 
 
 
 
 
 
 
 
 
 
 
404
  demo.launch(share=True)
 
53
  #search_input > label > span {
54
  display: none;
55
  }
56
+
57
+ #exp-type > span {
58
+ display: none;
59
+ }
60
  """
61
 
62
  dataset_repo_id = "chansung/auto-paper-qa2"
 
150
  gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['2_additional_breath_q:answers:expert']}"),
151
  )
152
 
153
+ def change_exp_type(exp_type):
154
+ if exp_type == "ELI5":
155
+ return (
156
+ gr.Markdown(visible=True), gr.Markdown(visible=False), gr.Markdown(visible=True), gr.Markdown(visible=False), gr.Markdown(visible=True), gr.Markdown(visible=False),
157
+ gr.Markdown(visible=True), gr.Markdown(visible=False), gr.Markdown(visible=True), gr.Markdown(visible=False), gr.Markdown(visible=True), gr.Markdown(visible=False),
158
+ gr.Markdown(visible=True), gr.Markdown(visible=False), gr.Markdown(visible=True), gr.Markdown(visible=False), gr.Markdown(visible=True), gr.Markdown(visible=False),
159
+ )
160
+ else:
161
+ return (
162
+ gr.Markdown(visible=False), gr.Markdown(visible=True), gr.Markdown(visible=False), gr.Markdown(visible=True), gr.Markdown(visible=False), gr.Markdown(visible=True),
163
+ gr.Markdown(visible=False), gr.Markdown(visible=True), gr.Markdown(visible=False), gr.Markdown(visible=True), gr.Markdown(visible=False), gr.Markdown(visible=True),
164
+ gr.Markdown(visible=False), gr.Markdown(visible=True), gr.Markdown(visible=False), gr.Markdown(visible=True), gr.Markdown(visible=False), gr.Markdown(visible=True),
165
+ )
166
 
167
  def search(search_in, max_results=3):
168
  results = []
 
285
  title = gr.Markdown(f"# {selected_paper['title']}")
286
  summary = gr.Markdown(f"{selected_paper['summary']}", elem_classes=["small-font"])
287
 
288
+ with gr.Row():
289
+ with gr.Column(scale=7):
290
+ gr.Markdown("## Auto generated Questions & Answers")
291
+
292
+ exp_type = gr.Radio(choices=["ELI5", "Technical"], value="ELI5", elem_id="exp-type", scale=3)
293
 
294
  # 1
295
  with gr.Column(elem_classes=["group"], visible=True) as q_0:
296
  basic_q_0 = gr.Markdown(f"## πŸ™‹ {selected_paper['0_question']}")
297
  basic_q_eli5_0 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['0_answers:eli5']}", elem_classes=["small-font"])
298
+ basic_q_expert_0 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['0_answers:expert']}", visible=False, elem_classes=["small-font"])
299
 
300
  with gr.Accordion("Additional question #1", open=False, elem_classes=["accordion"]) as aq_0_0:
301
  depth_q_0 = gr.Markdown(f"## πŸ™‹πŸ™‹ {selected_paper['0_additional_depth_q:follow up question']}")
302
  depth_q_eli5_0 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['0_additional_depth_q:answers:eli5']}", elem_classes=["small-font"])
303
+ depth_q_expert_0 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['0_additional_depth_q:answers:expert']}", visible=False, elem_classes=["small-font"])
304
 
305
  with gr.Accordion("Additional question #2", open=False, elem_classes=["accordion"]) as aq_0_1:
306
  breath_q_0 = gr.Markdown(f"## πŸ™‹πŸ™‹ {selected_paper['0_additional_breath_q:follow up question']}")
307
  breath_q_eli5_0 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['0_additional_breath_q:answers:eli5']}", elem_classes=["small-font"])
308
+ breath_q_expert_0 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['0_additional_breath_q:answers:expert']}", visible=False, elem_classes=["small-font"])
309
 
310
  # 2
311
  with gr.Column(elem_classes=["group"], visible=True) as q_1:
312
  basic_q_1 = gr.Markdown(f"## πŸ™‹ {selected_paper['1_question']}")
313
  basic_q_eli5_1 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['1_answers:eli5']}", elem_classes=["small-font"])
314
+ basic_q_expert_1 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['1_answers:expert']}", visible=False, elem_classes=["small-font"])
315
 
316
  with gr.Accordion("Additional question #1", open=False, elem_classes=["accordion"]) as aq_1_0:
317
  depth_q_1 = gr.Markdown(f"## πŸ™‹πŸ™‹ {selected_paper['1_additional_depth_q:follow up question']}")
318
  depth_q_eli5_1 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['1_additional_depth_q:answers:eli5']}", elem_classes=["small-font"])
319
+ depth_q_expert_1 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['1_additional_depth_q:answers:expert']}", visible=False, elem_classes=["small-font"])
320
 
321
  with gr.Accordion("Additional question #2", open=False, elem_classes=["accordion"]) as aq_1_1:
322
  breath_q_1 = gr.Markdown(f"## πŸ™‹πŸ™‹ {selected_paper['1_additional_breath_q:follow up question']}")
323
  breath_q_eli5_1 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['1_additional_breath_q:answers:eli5']}", elem_classes=["small-font"])
324
+ breath_q_expert_1 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['1_additional_breath_q:answers:expert']}", visible=False, elem_classes=["small-font"])
325
 
326
  # 3
327
  with gr.Column(elem_classes=["group"], visible=True) as q_2:
328
  basic_q_2 = gr.Markdown(f"## πŸ™‹ {selected_paper['2_question']}")
329
  basic_q_eli5_2 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['2_answers:eli5']}", elem_classes=["small-font"])
330
+ basic_q_expert_2 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['2_answers:expert']}", visible=False, elem_classes=["small-font"])
331
 
332
  with gr.Accordion("Additional question #1", open=False, elem_classes=["accordion"]) as aq_2_0:
333
  depth_q_2 = gr.Markdown(f"## πŸ™‹πŸ™‹ {selected_paper['2_additional_depth_q:follow up question']}")
334
  depth_q_eli5_2 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['2_additional_depth_q:answers:eli5']}", elem_classes=["small-font"])
335
+ depth_q_expert_2 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['2_additional_depth_q:answers:expert']}", visible=False, elem_classes=["small-font"])
336
 
337
  with gr.Accordion("Additional question #2", open=False, elem_classes=["accordion"]) as aq_2_1:
338
  breath_q_2 = gr.Markdown(f"## πŸ™‹πŸ™‹ {selected_paper['2_additional_breath_q:follow up question']}")
339
  breath_q_eli5_2 = gr.Markdown(f"β†ͺ **(ELI5)** {selected_paper['2_additional_breath_q:answers:eli5']}", elem_classes=["small-font"])
340
+ breath_q_expert_2 = gr.Markdown(f"β†ͺ **(Technical)** {selected_paper['2_additional_breath_q:answers:expert']}", visible=False, elem_classes=["small-font"])
341
 
342
  search_r1.click(
343
  set_date,
 
418
  fn=None
419
  )
420
 
421
+ exp_type.select(
422
+ change_exp_type,
423
+ exp_type,
424
+ [
425
+ basic_q_eli5_0, basic_q_expert_0, depth_q_eli5_0, depth_q_expert_0, breath_q_eli5_0, breath_q_expert_0,
426
+ basic_q_eli5_1, basic_q_expert_1, depth_q_eli5_1, depth_q_expert_1, breath_q_eli5_1, breath_q_expert_1,
427
+ basic_q_eli5_2, basic_q_expert_2, depth_q_eli5_2, depth_q_expert_2, breath_q_eli5_2, breath_q_expert_2
428
+ ]
429
+ )
430
+
431
  demo.launch(share=True)