Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
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(
|
| 61 |
-
if
|
| 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[
|
|
|
|
|
|
|
| 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"])
|