CreatorPhan commited on
Commit
ac628ef
β€’
1 Parent(s): d26e120

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -7
app.py CHANGED
@@ -19,9 +19,18 @@ with gr.Blocks() as demo:
19
  msg = gr.Textbox(label='Your prompt')
20
 
21
  with gr.Column(scale=0.3, min_width=500):
22
- for i in range(args.choices):
23
  with gr.Accordion(f"Answer {i+1}", open=False) as answer_area:
 
 
 
24
  context_area = gr.Markdown(f"Context {i+1}")
 
 
 
 
 
 
25
  RLHF.append(answer_area)
26
  RLHF.append(context_area)
27
  clear_chat = gr.Button("Clear history")
@@ -45,24 +54,24 @@ with gr.Blocks() as demo:
45
 
46
  def bot(history):
47
  question = history[-1][0]
48
- print('User mess:', question)
49
  answers = chatbot.asking(question)
50
 
51
 
52
  print(answers)
53
  history[-1][1] = ""
54
- for character in answers[0]:
55
  history[-1][1] += character
56
  time.sleep(0.01)
57
  yield history
58
 
59
  def fill_feedback(prompt):
60
- contexts, answers = chatbot.temp
61
  outptus = []
62
- for i in range(args.choices):
63
  if i < chatbot.choices:
64
- outptus.append(RLHF[2*i].update(label=answers[i], visible=True))
65
- outptus.append(contexts[i]['context'])
 
66
  else:
67
  outptus.append(RLHF[2*i].update(visible=False))
68
  outptus.append("No context")
 
19
  msg = gr.Textbox(label='Your prompt')
20
 
21
  with gr.Column(scale=0.3, min_width=500):
22
+ for i in range(args.show_c):
23
  with gr.Accordion(f"Answer {i+1}", open=False) as answer_area:
24
+ with gr.Row():
25
+ gr.Button('πŸ‘ Answer').style(size='sm', full_width=False)
26
+ gr.Button('πŸ‘ŽπŸ» Answer').style(size='sm', full_width=False)
27
  context_area = gr.Markdown(f"Context {i+1}")
28
+ # gr.CheckboxGroup(choices=['Good Answer', 'Bad Answer', 'Good Context', 'Bad Context'])
29
+
30
+ with gr.Row():
31
+ gr.Button('πŸ‘ Context').style(size='sm', full_width=False)
32
+ gr.Button('πŸ‘ŽπŸ» Context').style(size='sm', full_width=False)
33
+
34
  RLHF.append(answer_area)
35
  RLHF.append(context_area)
36
  clear_chat = gr.Button("Clear history")
 
54
 
55
  def bot(history):
56
  question = history[-1][0]
 
57
  answers = chatbot.asking(question)
58
 
59
 
60
  print(answers)
61
  history[-1][1] = ""
62
+ for character in answers:
63
  history[-1][1] += character
64
  time.sleep(0.01)
65
  yield history
66
 
67
  def fill_feedback(prompt):
68
+ results = chatbot.temp
69
  outptus = []
70
+ for i in range(args.show_c):
71
  if i < chatbot.choices:
72
+ answer = f"{results[i]['score']}% | {results[i]['answer']}"
73
+ outptus.append(RLHF[2*i].update(label=answer, visible=True, open=False))
74
+ outptus.append(results[i]['context'])
75
  else:
76
  outptus.append(RLHF[2*i].update(visible=False))
77
  outptus.append("No context")