Kogann commited on
Commit
a091974
Β·
verified Β·
1 Parent(s): 6dd105c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -382,13 +382,19 @@ def run_quickstart(name):
382
  tbl[c] = pd.to_numeric(tbl[c], errors="coerce")
383
  return _prettify(tbl), entry["rationale"]
384
 
 
 
 
 
 
385
  # ---------------------------------------------------------------------------
386
  # UI
387
  # ---------------------------------------------------------------------------
388
  with gr.Blocks(title="StockMatch AI", theme=gr.themes.Soft()) as demo:
389
  gr.Markdown(
390
  "# πŸ“ˆ StockMatch AI\n"
391
- "**Matching everyday savers to stocks that help protect against inflation.**\n\n"
 
392
  "Answer six questions, or click a preset profile. Matches come from a FAISS "
393
  "search over 12,500 synthetic stocks embedded with `BAAI/bge-small-en-v1.5`; "
394
  "the written explanation is generated by `SmolLM2-1.7B-Instruct`.\n\n"
@@ -421,13 +427,17 @@ with gr.Blocks(title="StockMatch AI", theme=gr.themes.Soft()) as demo:
421
  label="5. Stock type preference")
422
  q6 = gr.CheckboxGroup(["Small", "Medium", "Large"], value=[],
423
  label="6. Company size")
424
- go = gr.Button("πŸ” Find my stocks", variant="primary", size="lg")
 
 
 
425
 
426
  gr.Markdown("### Results")
427
  table = gr.Dataframe(label="Your matches", interactive=False, wrap=True)
428
  text = gr.Markdown()
429
 
430
  go.click(run_custom, [q1, q2, q3, q4, q5, q6], [table, text])
 
431
  b1.click(lambda: run_quickstart("Cautious Retiree"), None, [table, text])
432
  b2.click(lambda: run_quickstart("Balanced Professional"), None, [table, text])
433
  b3.click(lambda: run_quickstart("Young Growth Seeker"), None, [table, text])
 
382
  tbl[c] = pd.to_numeric(tbl[c], errors="coerce")
383
  return _prettify(tbl), entry["rationale"]
384
 
385
+ def reset_form():
386
+ """Return every question to its unanswered state. The order must match the
387
+ output list on the reset click handler."""
388
+ return [], None, [], [], None, []
389
+
390
  # ---------------------------------------------------------------------------
391
  # UI
392
  # ---------------------------------------------------------------------------
393
  with gr.Blocks(title="StockMatch AI", theme=gr.themes.Soft()) as demo:
394
  gr.Markdown(
395
  "# πŸ“ˆ StockMatch AI\n"
396
+ "**Money sitting in a savings account loses value every year. "
397
+ "Find stocks matched to your risk tolerance, budget and goals.**\n\n"
398
  "Answer six questions, or click a preset profile. Matches come from a FAISS "
399
  "search over 12,500 synthetic stocks embedded with `BAAI/bge-small-en-v1.5`; "
400
  "the written explanation is generated by `SmolLM2-1.7B-Instruct`.\n\n"
 
427
  label="5. Stock type preference")
428
  q6 = gr.CheckboxGroup(["Small", "Medium", "Large"], value=[],
429
  label="6. Company size")
430
+
431
+ with gr.Row():
432
+ go = gr.Button("πŸ” Find my stocks", variant="primary", size="lg", scale=4)
433
+ reset = gr.Button("β†Ί Reset", variant="secondary", size="lg", scale=1)
434
 
435
  gr.Markdown("### Results")
436
  table = gr.Dataframe(label="Your matches", interactive=False, wrap=True)
437
  text = gr.Markdown()
438
 
439
  go.click(run_custom, [q1, q2, q3, q4, q5, q6], [table, text])
440
+ reset.click(reset_form, None, [q1, q2, q3, q4, q5, q6])
441
  b1.click(lambda: run_quickstart("Cautious Retiree"), None, [table, text])
442
  b2.click(lambda: run_quickstart("Balanced Professional"), None, [table, text])
443
  b3.click(lambda: run_quickstart("Young Growth Seeker"), None, [table, text])