marinarosa commited on
Commit
d55ece1
Β·
1 Parent(s): 2029737

Add Gradio UI wiring checks to the reviewer model

Browse files

Model + space pickers (org spaces fetched live, free text allowed),
instant verdict/checklist/opportunities from the deterministic layer,
then the streamed LLM review.

Files changed (1) hide show
  1. app.py +101 -0
app.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Submit Eval β€” is your Build Small hackathon Space ready to submit?
2
+
3
+ Pick a model, pick a Space in the build-small-hackathon org, and get a
4
+ grounded rule checklist plus model-written recommendations.
5
+ """
6
+
7
+ import gradio as gr
8
+
9
+ import checks
10
+ import llm
11
+ from guide import ORG, DEADLINE
12
+
13
+ VERDICT_STYLE = {
14
+ "READY TO SUBMIT": ("🟒", "All hard rules pass β€” submit it!"),
15
+ "ALMOST READY": ("🟑", "No rule failures, but check the warnings below."),
16
+ "NOT READY": ("πŸ”΄", "At least one entry rule is not met yet."),
17
+ }
18
+
19
+
20
+ def refresh_spaces():
21
+ names = checks.list_org_spaces()
22
+ return gr.Dropdown(choices=names)
23
+
24
+
25
+ def run_checks(space_name: str):
26
+ if not (space_name or "").strip():
27
+ raise gr.Error("Pick or paste a Space first.")
28
+ ev = checks.evaluate_space(space_name)
29
+ if not ev.exists:
30
+ return (
31
+ f"## πŸ”΄ NOT READY\n{ev.error}",
32
+ "",
33
+ "",
34
+ ev.to_dict(),
35
+ )
36
+ icon, blurb = VERDICT_STYLE[ev.verdict]
37
+ verdict_md = f"## {icon} {ev.verdict}\n**`{ev.space_id}`** β€” {blurb}"
38
+ opps = ev.facts.get("opportunities") or []
39
+ opps_md = (
40
+ "### πŸ… Prizes & badges you might be leaving on the table\n"
41
+ + "\n".join(f"- {o}" for o in opps)
42
+ if opps
43
+ else ""
44
+ )
45
+ return verdict_md, checks.checklist_markdown(ev), opps_md, ev.to_dict()
46
+
47
+
48
+ def run_review(model_id: str, ev_dict: dict):
49
+ if not ev_dict or not ev_dict.get("exists"):
50
+ yield "*(No Space evaluated β€” nothing to review.)*"
51
+ return
52
+ yield "*Loading the model β€” the first run of a model can take a few minutes…*"
53
+ yield from llm.generate_review(model_id, ev_dict)
54
+
55
+
56
+ with gr.Blocks(title="Submit Eval β€” Build Small") as demo:
57
+ gr.Markdown(
58
+ f"# πŸ‘ Submit Eval\n"
59
+ f"Checks a Space in the **`{ORG}`** org against the official "
60
+ f"[Build Small field guide](https://build-small-hackathon-field-guide.hf.space/) "
61
+ f"rules β€” track tags, badges, demo video, social post, the 32B model cap β€” "
62
+ f"then a small model (your pick) writes grounded recommendations. "
63
+ f"Deadline: **{DEADLINE}**."
64
+ )
65
+ with gr.Row():
66
+ model_dd = gr.Dropdown(
67
+ choices=[(label, mid) for mid, label in llm.MODELS.items()],
68
+ value=llm.DEFAULT_MODEL,
69
+ label="Reviewer model (all under 32B, of course)",
70
+ scale=2,
71
+ )
72
+ space_dd = gr.Dropdown(
73
+ choices=[],
74
+ label=f"Space in {ORG} (pick, or paste a name/URL)",
75
+ allow_custom_value=True,
76
+ scale=2,
77
+ )
78
+ refresh_btn = gr.Button("πŸ”„", scale=0, min_width=48)
79
+ eval_btn = gr.Button("Evaluate", variant="primary", scale=1)
80
+
81
+ verdict_md = gr.Markdown()
82
+ checklist_md = gr.Markdown()
83
+ opps_md = gr.Markdown()
84
+ ev_state = gr.State()
85
+ gr.Markdown("---")
86
+ review_md = gr.Markdown(label="Model recommendations")
87
+
88
+ demo.load(refresh_spaces, outputs=[space_dd])
89
+ refresh_btn.click(refresh_spaces, outputs=[space_dd])
90
+ eval_btn.click(
91
+ run_checks,
92
+ inputs=[space_dd],
93
+ outputs=[verdict_md, checklist_md, opps_md, ev_state],
94
+ ).then(
95
+ run_review,
96
+ inputs=[model_dd, ev_state],
97
+ outputs=[review_md],
98
+ )
99
+
100
+ if __name__ == "__main__":
101
+ demo.launch()