aikacl commited on
Commit
fb1d2b9
·
verified ·
1 Parent(s): a231b39

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -57,12 +57,14 @@ def remove_doc(count: int):
57
  return _make_vis_updates(count) + [count]
58
 
59
 
60
- def load_example(example_idx):
61
- if example_idx is None:
62
  query_upd = gr.update(value="")
63
  doc_upds = [gr.update(value="") for _ in range(MAX_DOCS)]
64
  return [query_upd] + doc_upds + [INIT_DOCS]
65
- ex = EXAMPLES[example_idx]
 
 
66
  docs = ex["docs"]
67
  count = len(docs)
68
  query_upd = gr.update(value=ex["query"])
 
57
  return _make_vis_updates(count) + [count]
58
 
59
 
60
+ def load_example(example_label):
61
+ if example_label is None:
62
  query_upd = gr.update(value="")
63
  doc_upds = [gr.update(value="") for _ in range(MAX_DOCS)]
64
  return [query_upd] + doc_upds + [INIT_DOCS]
65
+ ex = next((e for e in EXAMPLES if e["label"] == example_label), None)
66
+ if ex is None:
67
+ return [gr.update()] + [gr.update() for _ in range(MAX_DOCS)] + [INIT_DOCS]
68
  docs = ex["docs"]
69
  count = len(docs)
70
  query_upd = gr.update(value=ex["query"])