Kang Suhyun suhyun.kang commited on
Commit
f00b7ff
1 Parent(s): a089fa0

[#7] Display model names only after voting (#16)

Browse files

* [#7] Display model names only after voting

Changes:
- Displayed model names only after a user has voted for a model.
- Moved the model name section to the bottom of the model responses.

Screenshot: https://screen.yanolja.in/tlwjKwGkIMAeIXuo.png

* fix

---------

Co-authored-by: suhyun.kang <suhyun.kang@yanolja.group>

Files changed (2) hide show
  1. app.py +17 -15
  2. response.py +1 -1
app.py CHANGED
@@ -54,6 +54,7 @@ def vote(vote_button, response_a, response_b, model_a_name, model_b_name,
54
  winner = VoteOptions(vote_button).name.lower()
55
 
56
  deactivated_buttons = [gr.Button(interactive=False) for _ in range(3)]
 
57
 
58
  doc = {
59
  "id": doc_id,
@@ -71,7 +72,7 @@ def vote(vote_button, response_a, response_b, model_a_name, model_b_name,
71
  doc_ref = db.collection("arena-summarizations").document(doc_id)
72
  doc_ref.set(doc)
73
 
74
- return deactivated_buttons
75
 
76
  if category == response.Category.TRANSLATE.value:
77
  if not source_lang or not target_lang:
@@ -82,7 +83,7 @@ def vote(vote_button, response_a, response_b, model_a_name, model_b_name,
82
  doc["target_language"] = target_lang.lower()
83
  doc_ref.set(doc)
84
 
85
- return deactivated_buttons
86
 
87
  raise gr.Error("Please select a response type.")
88
 
@@ -123,9 +124,14 @@ with gr.Blocks(title="Arena") as app:
123
  prompt = gr.TextArea(label="Prompt", lines=4)
124
  submit = gr.Button()
125
 
126
- with gr.Row():
127
- response_boxes[0] = gr.Textbox(label="Model A", interactive=False)
128
- response_boxes[1] = gr.Textbox(label="Model B", interactive=False)
 
 
 
 
 
129
 
130
  # TODO(#5): Display it only after the user submits the prompt.
131
  with gr.Row():
@@ -133,26 +139,22 @@ with gr.Blocks(title="Arena") as app:
133
  option_b = gr.Button(VoteOptions.MODEL_B.value)
134
  tie = gr.Button(VoteOptions.TIE.value)
135
 
136
- # TODO(#7): Hide it until the user votes.
137
- with gr.Accordion("Show models", open=False):
138
- with gr.Row():
139
- model_names[0] = gr.Textbox(label="Model A", interactive=False)
140
- model_names[1] = gr.Textbox(label="Model B", interactive=False)
141
-
142
  vote_buttons = [option_a, option_b, tie]
143
  instruction_state = gr.State("")
144
 
145
  submit.click(
146
  get_responses, [prompt, category_radio, source_language, target_language],
147
- response_boxes + model_names + vote_buttons + [instruction_state])
 
148
 
149
  common_inputs = response_boxes + model_names + [
150
  prompt, instruction_state, category_radio, source_language,
151
  target_language
152
  ]
153
- option_a.click(vote, [option_a] + common_inputs, vote_buttons)
154
- option_b.click(vote, [option_b] + common_inputs, vote_buttons)
155
- tie.click(vote, [tie] + common_inputs, vote_buttons)
 
156
 
157
  build_leaderboard(db)
158
 
 
54
  winner = VoteOptions(vote_button).name.lower()
55
 
56
  deactivated_buttons = [gr.Button(interactive=False) for _ in range(3)]
57
+ outputs = deactivated_buttons + [gr.Row(visible=True)]
58
 
59
  doc = {
60
  "id": doc_id,
 
72
  doc_ref = db.collection("arena-summarizations").document(doc_id)
73
  doc_ref.set(doc)
74
 
75
+ return outputs
76
 
77
  if category == response.Category.TRANSLATE.value:
78
  if not source_lang or not target_lang:
 
83
  doc["target_language"] = target_lang.lower()
84
  doc_ref.set(doc)
85
 
86
+ return outputs
87
 
88
  raise gr.Error("Please select a response type.")
89
 
 
124
  prompt = gr.TextArea(label="Prompt", lines=4)
125
  submit = gr.Button()
126
 
127
+ with gr.Group():
128
+ with gr.Row():
129
+ response_boxes[0] = gr.Textbox(label="Model A", interactive=False)
130
+ response_boxes[1] = gr.Textbox(label="Model B", interactive=False)
131
+
132
+ with gr.Row(visible=False) as model_name_row:
133
+ model_names[0] = gr.Textbox(show_label=False)
134
+ model_names[1] = gr.Textbox(show_label=False)
135
 
136
  # TODO(#5): Display it only after the user submits the prompt.
137
  with gr.Row():
 
139
  option_b = gr.Button(VoteOptions.MODEL_B.value)
140
  tie = gr.Button(VoteOptions.TIE.value)
141
 
 
 
 
 
 
 
142
  vote_buttons = [option_a, option_b, tie]
143
  instruction_state = gr.State("")
144
 
145
  submit.click(
146
  get_responses, [prompt, category_radio, source_language, target_language],
147
+ response_boxes + model_names + vote_buttons +
148
+ [instruction_state, model_name_row])
149
 
150
  common_inputs = response_boxes + model_names + [
151
  prompt, instruction_state, category_radio, source_language,
152
  target_language
153
  ]
154
+ common_outputs = vote_buttons + [model_name_row]
155
+ option_a.click(vote, [option_a] + common_inputs, common_outputs)
156
+ option_b.click(vote, [option_b] + common_inputs, common_outputs)
157
+ tie.click(vote, [tie] + common_inputs, common_outputs)
158
 
159
  build_leaderboard(db)
160
 
response.py CHANGED
@@ -88,7 +88,7 @@ def get_responses(user_prompt, category, source_lang, target_lang):
88
 
89
  yield responses + models + [
90
  gr.Button(interactive=True) for _ in range(3)
91
- ] + [instruction]
92
 
93
  except StopIteration:
94
  pass
 
88
 
89
  yield responses + models + [
90
  gr.Button(interactive=True) for _ in range(3)
91
+ ] + [instruction, gr.Row(visible=False)]
92
 
93
  except StopIteration:
94
  pass