elibrowne commited on
Commit
81eb5b7
1 Parent(s): 6ee07a7
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -259,7 +259,7 @@ with gr.Blocks(theme = theme) as user_eval:
259
  btn_g = gr.Button("Next")
260
 
261
  def next_p(e0, e1, e2, e3, cur_step, mode, cr, cq):
262
- step = cur_step + 1
263
  # Add user data to the current response
264
  print(cr)
265
  print(cr.values())
@@ -267,7 +267,7 @@ with gr.Blocks(theme = theme) as user_eval:
267
  print(cr)
268
  print(cr.values())
269
  # Next item
270
- if step >= len(cq["top10_e5"]): # should always be 10 (DEBUG: >= to avoid out of bounds)
271
  # Step 10: all sources
272
  collapsible_string = "<h2> Set of Passages </h2>\n"
273
  for i, passage in enumerate(cq["top10_e5"]):
@@ -283,7 +283,7 @@ with gr.Blocks(theme = theme) as user_eval:
283
  eval_1: gr.Slider(value = 3),
284
  eval_2: gr.Slider(value = 3),
285
  eval_3: gr.Slider(value = 0),
286
- step: step,
287
  mode: 1,
288
  current_response: cr
289
  }
@@ -291,20 +291,20 @@ with gr.Blocks(theme = theme) as user_eval:
291
  return {
292
  selection: gr.HTML("""
293
  <h2> Retrieved Passage </h2>
294
- <p> """ + cq["top10_e5"][step] + "</p>"),
295
  eval_0: gr.Radio(value = None),
296
  eval_1: gr.Slider(value = 3),
297
  eval_2: gr.Slider(value = 3),
298
  eval_3: gr.Slider(value = 0),
299
- step: step,
300
  mode: 1,
301
  current_response: cr
302
  }
303
 
304
  def next_g(e_h, e_s, cur_step, mode, ud, cr, cq):
305
- step = cur_step + 1
306
 
307
- if step == 11:
308
  # Step 11: guaranteed to be generation
309
  # Add user data to the current response as SET evaluation, which comes before the generation
310
  # CHANGED FROM user_data["modes"][user_data["current"]] + "_set", as are all direct references to top10_e5
@@ -315,13 +315,13 @@ with gr.Blocks(theme = theme) as user_eval:
315
  <p>""" + markdown(cq["generation_e5"]) + "</p>"),
316
  eval_helps: gr.Slider(value = 0),
317
  eval_satisfied: gr.Slider(value = 3),
318
- step: step,
319
  mode: mode,
320
  user_data: ud,
321
  current_response: cr
322
  }
323
  # Steps 12 and 13 are gold passage + gold passage generation IF it is applicable
324
- if step > 11: # and not current_question["top10_contains_gold_passage"]
325
  # When mode is 0 -> reset with mode = 1
326
  """
327
  if mode == 0:
@@ -337,7 +337,7 @@ with gr.Blocks(theme = theme) as user_eval:
337
  }
338
  """
339
  # When mode is 1 -> display GP and GP generation, then switch
340
- if step == 12:
341
  # The user just evaluated a generation for mode 1
342
  # CHANGE from user_data["modes"][user_data["current"]] + "_generation"
343
  cr["e5_generation"] = [e_h, e_s]
@@ -348,12 +348,12 @@ with gr.Blocks(theme = theme) as user_eval:
348
  forward_btn: gr.Textbox(),
349
  eval_helps: gr.Slider(value = 0),
350
  eval_satisfied: gr.Slider(value = 3),
351
- step: step,
352
  mode: mode,
353
  user_data: ud,
354
  current_response: cr
355
  }
356
- elif step == 13:
357
  # The user just evaluated the gold passage
358
  cr["gold_set"] = [e_h, e_s]
359
  return {
@@ -363,7 +363,7 @@ with gr.Blocks(theme = theme) as user_eval:
363
  forward_btn: gr.Textbox(),
364
  eval_helps: gr.Slider(value = 0),
365
  eval_satisfied: gr.Slider(value = 3),
366
- step: step,
367
  mode: mode,
368
  user_data: ud,
369
  current_response: cr
@@ -380,7 +380,7 @@ with gr.Blocks(theme = theme) as user_eval:
380
  forward_btn: gr.Textbox("changed" + str(user_data["current"])), # current forces event to trigger always
381
  eval_helps: gr.Slider(value = 0),
382
  eval_satisfied: gr.Slider(value = 3),
383
- step: step,
384
  mode: mode,
385
  user_data: ud,
386
  current_response: cr,
 
259
  btn_g = gr.Button("Next")
260
 
261
  def next_p(e0, e1, e2, e3, cur_step, mode, cr, cq):
262
+ cur_step += 1
263
  # Add user data to the current response
264
  print(cr)
265
  print(cr.values())
 
267
  print(cr)
268
  print(cr.values())
269
  # Next item
270
+ if cur_step >= len(cq["top10_e5"]): # should always be 10 (DEBUG: >= to avoid out of bounds)
271
  # Step 10: all sources
272
  collapsible_string = "<h2> Set of Passages </h2>\n"
273
  for i, passage in enumerate(cq["top10_e5"]):
 
283
  eval_1: gr.Slider(value = 3),
284
  eval_2: gr.Slider(value = 3),
285
  eval_3: gr.Slider(value = 0),
286
+ step: cur_step,
287
  mode: 1,
288
  current_response: cr
289
  }
 
291
  return {
292
  selection: gr.HTML("""
293
  <h2> Retrieved Passage </h2>
294
+ <p> """ + cq["top10_e5"][cur_step] + "</p>"),
295
  eval_0: gr.Radio(value = None),
296
  eval_1: gr.Slider(value = 3),
297
  eval_2: gr.Slider(value = 3),
298
  eval_3: gr.Slider(value = 0),
299
+ step: cur_step,
300
  mode: 1,
301
  current_response: cr
302
  }
303
 
304
  def next_g(e_h, e_s, cur_step, mode, ud, cr, cq):
305
+ cur_step += 1
306
 
307
+ if cur_step == 11:
308
  # Step 11: guaranteed to be generation
309
  # Add user data to the current response as SET evaluation, which comes before the generation
310
  # CHANGED FROM user_data["modes"][user_data["current"]] + "_set", as are all direct references to top10_e5
 
315
  <p>""" + markdown(cq["generation_e5"]) + "</p>"),
316
  eval_helps: gr.Slider(value = 0),
317
  eval_satisfied: gr.Slider(value = 3),
318
+ step: cur_step,
319
  mode: mode,
320
  user_data: ud,
321
  current_response: cr
322
  }
323
  # Steps 12 and 13 are gold passage + gold passage generation IF it is applicable
324
+ if cur_step > 11: # and not current_question["top10_contains_gold_passage"]
325
  # When mode is 0 -> reset with mode = 1
326
  """
327
  if mode == 0:
 
337
  }
338
  """
339
  # When mode is 1 -> display GP and GP generation, then switch
340
+ if cur_step == 12:
341
  # The user just evaluated a generation for mode 1
342
  # CHANGE from user_data["modes"][user_data["current"]] + "_generation"
343
  cr["e5_generation"] = [e_h, e_s]
 
348
  forward_btn: gr.Textbox(),
349
  eval_helps: gr.Slider(value = 0),
350
  eval_satisfied: gr.Slider(value = 3),
351
+ step: cur_step,
352
  mode: mode,
353
  user_data: ud,
354
  current_response: cr
355
  }
356
+ elif cur_step == 13:
357
  # The user just evaluated the gold passage
358
  cr["gold_set"] = [e_h, e_s]
359
  return {
 
363
  forward_btn: gr.Textbox(),
364
  eval_helps: gr.Slider(value = 0),
365
  eval_satisfied: gr.Slider(value = 3),
366
+ step: cur_step,
367
  mode: mode,
368
  user_data: ud,
369
  current_response: cr
 
380
  forward_btn: gr.Textbox("changed" + str(user_data["current"])), # current forces event to trigger always
381
  eval_helps: gr.Slider(value = 0),
382
  eval_satisfied: gr.Slider(value = 3),
383
+ step: 0,
384
  mode: mode,
385
  user_data: ud,
386
  current_response: cr,