deepmage121 commited on
Commit
41c437b
·
1 Parent(s): 1682cec

update search function to use key_up and unifiying search

Browse files
Files changed (1) hide show
  1. app.py +13 -21
app.py CHANGED
@@ -10,7 +10,6 @@ from data_loader import (
10
  build_leaderboard_table,
11
  clear_cache,
12
  search_model_across_leaderboards,
13
- get_all_model_names,
14
  DATA_DIR
15
  )
16
  from ui_components import (
@@ -123,7 +122,8 @@ def compare_models(selected_models):
123
  """, None
124
 
125
 
126
- def get_model_suggestions(query):
 
127
  if not query or len(query) < 2:
128
  return gr.update(choices=[])
129
 
@@ -289,26 +289,20 @@ with gr.Blocks(title="Every Eval Ever", theme=get_theme(), css=get_custom_css())
289
  default_compare_html = """
290
  <div class="no-results">
291
  <h3>Search for models to compare</h3>
292
- <p>Type in the dropdown above, then click a model to add it</p>
293
  </div>
294
  """
295
 
296
- model_search_box = gr.Textbox(
297
- label="Type to search for models",
298
- placeholder="Start typing model name (e.g., gpt, llama, claude)...",
299
- interactive=True,
300
- )
301
-
302
  with gr.Row(elem_classes="controls-bar"):
303
  with gr.Column(scale=4):
304
  model_dropdown = gr.Dropdown(
305
  choices=[],
306
- label="Select from search results",
307
  interactive=True,
308
- allow_custom_value=False,
309
  )
310
- with gr.Column(scale=1, min_width=100):
311
- clear_models_btn = gr.Button("Clear All", variant="secondary", size="sm")
312
 
313
  selected_models_group = gr.CheckboxGroup(
314
  choices=[],
@@ -418,7 +412,6 @@ Submit via GitHub Pull Request:
418
  comparison_html, plot = compare_models(current_selected) if current_selected else (default_compare_html, None)
419
  return (
420
  current_selected,
421
- gr.update(value=""),
422
  gr.update(value=None, choices=[]),
423
  gr.update(choices=current_selected, value=current_selected),
424
  comparison_html,
@@ -432,7 +425,6 @@ Submit via GitHub Pull Request:
432
 
433
  return (
434
  current_selected,
435
- gr.update(value=""),
436
  gr.update(value=None, choices=[]),
437
  gr.update(choices=current_selected, value=current_selected),
438
  comparison_html,
@@ -446,23 +438,23 @@ Submit via GitHub Pull Request:
446
  def clear_all_models():
447
  return (
448
  [],
449
- gr.update(value=""),
450
  gr.update(value=None, choices=[]),
451
  gr.update(choices=[], value=[]),
452
  default_compare_html,
453
  None
454
  )
455
 
456
- model_search_box.input(
457
  fn=get_model_suggestions,
458
- inputs=[model_search_box],
459
- outputs=[model_dropdown]
 
460
  )
461
 
462
  model_dropdown.select(
463
  fn=add_model_and_compare,
464
  inputs=[model_dropdown, selected_models_state],
465
- outputs=[selected_models_state, model_search_box, model_dropdown, selected_models_group, model_card_view, radar_view]
466
  )
467
 
468
  selected_models_group.change(
@@ -473,7 +465,7 @@ Submit via GitHub Pull Request:
473
 
474
  clear_models_btn.click(
475
  fn=clear_all_models,
476
- outputs=[selected_models_state, model_search_box, model_dropdown, selected_models_group, model_card_view, radar_view]
477
  )
478
 
479
  export_comparison_btn.click(
 
10
  build_leaderboard_table,
11
  clear_cache,
12
  search_model_across_leaderboards,
 
13
  DATA_DIR
14
  )
15
  from ui_components import (
 
122
  """, None
123
 
124
 
125
+ def get_model_suggestions(key_up_data: gr.KeyUpData):
126
+ query = key_up_data.input_value if key_up_data else ""
127
  if not query or len(query) < 2:
128
  return gr.update(choices=[])
129
 
 
289
  default_compare_html = """
290
  <div class="no-results">
291
  <h3>Search for models to compare</h3>
292
+ <p>Type in the dropdown to search, then select a model to add it</p>
293
  </div>
294
  """
295
 
 
 
 
 
 
 
296
  with gr.Row(elem_classes="controls-bar"):
297
  with gr.Column(scale=4):
298
  model_dropdown = gr.Dropdown(
299
  choices=[],
300
+ label="Search and select models",
301
  interactive=True,
302
+ allow_custom_value=True,
303
  )
304
+ with gr.Column(scale=1, min_width=80):
305
+ clear_models_btn = gr.Button("Clear", variant="secondary", size="sm")
306
 
307
  selected_models_group = gr.CheckboxGroup(
308
  choices=[],
 
412
  comparison_html, plot = compare_models(current_selected) if current_selected else (default_compare_html, None)
413
  return (
414
  current_selected,
 
415
  gr.update(value=None, choices=[]),
416
  gr.update(choices=current_selected, value=current_selected),
417
  comparison_html,
 
425
 
426
  return (
427
  current_selected,
 
428
  gr.update(value=None, choices=[]),
429
  gr.update(choices=current_selected, value=current_selected),
430
  comparison_html,
 
438
  def clear_all_models():
439
  return (
440
  [],
 
441
  gr.update(value=None, choices=[]),
442
  gr.update(choices=[], value=[]),
443
  default_compare_html,
444
  None
445
  )
446
 
447
+ model_dropdown.key_up(
448
  fn=get_model_suggestions,
449
+ inputs=[],
450
+ outputs=[model_dropdown],
451
+ show_progress="hidden"
452
  )
453
 
454
  model_dropdown.select(
455
  fn=add_model_and_compare,
456
  inputs=[model_dropdown, selected_models_state],
457
+ outputs=[selected_models_state, model_dropdown, selected_models_group, model_card_view, radar_view]
458
  )
459
 
460
  selected_models_group.change(
 
465
 
466
  clear_models_btn.click(
467
  fn=clear_all_models,
468
+ outputs=[selected_models_state, model_dropdown, selected_models_group, model_card_view, radar_view]
469
  )
470
 
471
  export_comparison_btn.click(