Jofthomas commited on
Commit
5fb2898
·
1 Parent(s): cf79bd4

reset Gradio textbox on_next round

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -970,7 +970,7 @@ with gr.Blocks(css=APP_CSS, title="LLM GeoGuessr") as demo:
970
  validate_btn.click(on_validate, inputs=[round_id_box, lat_box, lng_box, user_profile], outputs=[popup_html, ai_chat])
971
 
972
  def on_next(r_state: list, idx: int, profile: dict, request: gr.Request):
973
- if not profile: return idx, gr.update(), gr.update(), gr.update()
974
  username = profile["name"]
975
  idx += 1
976
  sess = user_sessions.get(username)
@@ -997,12 +997,12 @@ with gr.Blocks(css=APP_CSS, title="LLM GeoGuessr") as demo:
997
  <h3>{winner_message}</h3>
998
  </div>
999
  """
1000
- return idx, gr.update(value=summary_html), gr.update(value=""), gr.update(value="")
1001
  r = sess['rounds'][idx]
1002
  s_html = build_street_html(r['image_url'])
1003
- return idx, gr.update(value=s_html), gr.update(value=r['id']), gr.update(value="")
1004
 
1005
- next_btn.click(on_next, inputs=[rounds_state, idx_state, user_profile], outputs=[idx_state, street_html, round_id_box, popup_html])
1006
 
1007
  # Inject boot JS using load(js=callable) compatible format
1008
  demo.load(fn=lambda: None, inputs=None, outputs=None, js=APP_BOOT_JS)
 
970
  validate_btn.click(on_validate, inputs=[round_id_box, lat_box, lng_box, user_profile], outputs=[popup_html, ai_chat])
971
 
972
  def on_next(r_state: list, idx: int, profile: dict, request: gr.Request):
973
+ if not profile: return idx, gr.update(), gr.update(), gr.update(), gr.update()
974
  username = profile["name"]
975
  idx += 1
976
  sess = user_sessions.get(username)
 
997
  <h3>{winner_message}</h3>
998
  </div>
999
  """
1000
+ return idx, gr.update(value=summary_html), gr.update(value=""), gr.update(value=""), gr.update(value="")
1001
  r = sess['rounds'][idx]
1002
  s_html = build_street_html(r['image_url'])
1003
+ return idx, gr.update(value=s_html), gr.update(value=r['id']), gr.update(value=""), gr.update(value="")
1004
 
1005
+ next_btn.click(on_next, inputs=[rounds_state, idx_state, user_profile], outputs=[idx_state, street_html, round_id_box, popup_html, ai_chat])
1006
 
1007
  # Inject boot JS using load(js=callable) compatible format
1008
  demo.load(fn=lambda: None, inputs=None, outputs=None, js=APP_BOOT_JS)