Arri98 commited on
Commit
893514c
·
1 Parent(s): 16713da

New logo, disable send until vote

Browse files
Files changed (2) hide show
  1. app.py +20 -11
  2. static/logo.png +0 -0
app.py CHANGED
@@ -39,7 +39,7 @@ def change_vote( _id:str, backdown: bool,) -> Tuple[bool, bool]:
39
  )
40
 
41
  def record_vote(prompt: str, left_chat: List, right_chat: List,
42
- left_model: str, right_model: str, energy, moreConsuming, request: gr.Request, vote_type: int ) -> Tuple[str, bool, bool, bool, bool, bool]:
43
  """Record a vote for either the left or right model"""
44
  vote_message = "Is a tie!"
45
  if vote_type == 0:
@@ -71,11 +71,12 @@ def record_vote(prompt: str, left_chat: List, right_chat: List,
71
  gr.update(interactive=False), # tie_btn interactive
72
  gr.update(visible=True), # model_names_row visible
73
  gr.update(visible=changeVisible), # backdown_row visible
74
- _id
 
75
  )
76
 
77
 
78
- def send_prompt(prompt: str) -> Tuple[List, List, str, str, bool, bool, bool, bool, str]:
79
  response = requests.post(url + "/v2/query", json={"prompt": prompt})
80
  jsonResponse = response.json()
81
  print(jsonResponse)
@@ -90,14 +91,22 @@ def send_prompt(prompt: str) -> Tuple[List, List, str, str, bool, bool, bool, bo
90
  gr.update(interactive=True, visible=True),
91
  gr.update(interactive=True, visible=True),
92
  gr.update(visible=False),
93
- moreConsuming
 
94
  )
95
  css = """
96
  .logo {max-width: 200px !important; widht: 300px;}
97
  """
98
 
 
 
 
 
 
 
 
99
  # Initialize Gradio Blocks
100
- with gr.Blocks(css=css) as demo:
101
  _id = gr.State("")
102
  moreConsuming = gr.State("")
103
  with gr.Column(visible=True) as landing:
@@ -179,7 +188,7 @@ with gr.Blocks(css=css) as demo:
179
  with gr.Row(equal_height=True):
180
  textbox = gr.Textbox(
181
  show_label=False,
182
- placeholder="👉 Introduce tu prompt y presiona Enter",
183
  elem_id="input_box",
184
  #submit_btn=True,
185
  )
@@ -198,25 +207,25 @@ with gr.Blocks(css=css) as demo:
198
  send_btn.click(fn=lambda *args: send_prompt(*args),
199
  inputs=[textbox],
200
  outputs=[chatbot[0], chatbot[1], left_model, right_model,
201
- buttons[0], buttons[1], tievote_btn, model_names_row, moreConsuming
202
  ])
203
 
204
  buttons[0].click(
205
  record_vote_0,
206
  inputs=[textbox, chatbot[0], chatbot[1], left_model, right_model, gr.State(value=False), moreConsuming],
207
- outputs=[result,buttons[0], buttons[1], tievote_btn, model_names_row, backdown_row, _id]
208
  )
209
 
210
  buttons[1].click(
211
  record_vote_1,
212
  inputs=[textbox, chatbot[0], chatbot[1], left_model, right_model, gr.State(value=False), moreConsuming],
213
- outputs=[result,buttons[0], buttons[1], tievote_btn, model_names_row, backdown_row, _id]
214
  )
215
 
216
  tievote_btn.click(
217
  record_vote_2,
218
  inputs=[textbox, chatbot[0], chatbot[1], left_model, right_model, gr.State(value=False), moreConsuming],
219
- outputs=[result,buttons[0], buttons[1], tievote_btn, model_names_row, backdown_row, _id]
220
  )
221
  backdown_btn.click(
222
  lambda *args: change_vote(*args, True),
@@ -255,7 +264,7 @@ with gr.Blocks(css=css) as demo:
255
  </p>
256
  </div>
257
  """)
258
- start_button = gr.Button(value="Start", visible=True, interactive=True, size= "lg", variant="primary")
259
  start_button.click(
260
  lambda *args: start_app(),
261
  inputs=[],
 
39
  )
40
 
41
  def record_vote(prompt: str, left_chat: List, right_chat: List,
42
+ left_model: str, right_model: str, energy, moreConsuming, request: gr.Request, vote_type: int ) -> Tuple[str, bool, bool, bool, bool, bool, bool]:
43
  """Record a vote for either the left or right model"""
44
  vote_message = "Is a tie!"
45
  if vote_type == 0:
 
71
  gr.update(interactive=False), # tie_btn interactive
72
  gr.update(visible=True), # model_names_row visible
73
  gr.update(visible=changeVisible), # backdown_row visible
74
+ _id,
75
+ gr.update(interactive=True)
76
  )
77
 
78
 
79
+ def send_prompt(prompt: str) -> Tuple[List, List, str, str, bool, bool, bool, bool, str, bool]:
80
  response = requests.post(url + "/v2/query", json={"prompt": prompt})
81
  jsonResponse = response.json()
82
  print(jsonResponse)
 
91
  gr.update(interactive=True, visible=True),
92
  gr.update(interactive=True, visible=True),
93
  gr.update(visible=False),
94
+ moreConsuming,
95
+ gr.update(interactive=False)
96
  )
97
  css = """
98
  .logo {max-width: 200px !important; widht: 300px;}
99
  """
100
 
101
+ js = """
102
+ document.getElementById("start").onclick = function() {
103
+ window.scrollTo(0, 0);
104
+ }
105
+
106
+ """
107
+
108
  # Initialize Gradio Blocks
109
+ with gr.Blocks(css=css, js=js) as demo:
110
  _id = gr.State("")
111
  moreConsuming = gr.State("")
112
  with gr.Column(visible=True) as landing:
 
188
  with gr.Row(equal_height=True):
189
  textbox = gr.Textbox(
190
  show_label=False,
191
+ placeholder="👉 Introduce tu prompt y presiona Enviar",
192
  elem_id="input_box",
193
  #submit_btn=True,
194
  )
 
207
  send_btn.click(fn=lambda *args: send_prompt(*args),
208
  inputs=[textbox],
209
  outputs=[chatbot[0], chatbot[1], left_model, right_model,
210
+ buttons[0], buttons[1], tievote_btn, model_names_row, moreConsuming, send_btn
211
  ])
212
 
213
  buttons[0].click(
214
  record_vote_0,
215
  inputs=[textbox, chatbot[0], chatbot[1], left_model, right_model, gr.State(value=False), moreConsuming],
216
+ outputs=[result,buttons[0], buttons[1], tievote_btn, model_names_row, backdown_row, _id, send_btn]
217
  )
218
 
219
  buttons[1].click(
220
  record_vote_1,
221
  inputs=[textbox, chatbot[0], chatbot[1], left_model, right_model, gr.State(value=False), moreConsuming],
222
+ outputs=[result,buttons[0], buttons[1], tievote_btn, model_names_row, backdown_row, _id, send_btn]
223
  )
224
 
225
  tievote_btn.click(
226
  record_vote_2,
227
  inputs=[textbox, chatbot[0], chatbot[1], left_model, right_model, gr.State(value=False), moreConsuming],
228
+ outputs=[result,buttons[0], buttons[1], tievote_btn, model_names_row, backdown_row, _id, send_btn]
229
  )
230
  backdown_btn.click(
231
  lambda *args: change_vote(*args, True),
 
264
  </p>
265
  </div>
266
  """)
267
+ start_button = gr.Button(value="Start", visible=True, interactive=True, size= "lg",elem_id="start", variant="primary")
268
  start_button.click(
269
  lambda *args: start_app(),
270
  inputs=[],
static/logo.png CHANGED