yannsay's picture
Deploy clean to build-small-hackathon org (32B Qwen, step-3 table)
aa1d0aa verified
Raw
History Blame Contribute Delete
2 kB
from __future__ import annotations
import gradio as gr
from core.ontology import axis_options
from core.route import Step1Result
PATH_MESSAGE = "Describe your question"
PATH_CHIPS = "Select from framework"
def make_path_radio() -> gr.Radio:
return gr.Radio(
choices=[PATH_MESSAGE, PATH_CHIPS],
value=PATH_MESSAGE,
label="How do you want to start?",
)
def _labels(axis: str, in_scope_only: bool = False) -> list[str]:
items = axis_options()[axis]
return [o["label"] for o in items if (o["in_scope"] or not in_scope_only)]
def make_sector_group() -> gr.CheckboxGroup:
return gr.CheckboxGroup(
choices=_labels("sectors", in_scope_only=True),
label="Sectors β€” indicator catalog available",
)
def make_sector_group_no_catalog() -> gr.CheckboxGroup:
oos = [o["label"] for o in axis_options()["sectors"] if not o["in_scope"]]
return gr.CheckboxGroup(
choices=oos,
label="Other sectors β€” no indicator catalog (Step 2 finds nothing)",
)
def make_lens_group() -> gr.CheckboxGroup:
return gr.CheckboxGroup(choices=_labels("lens"), label="Lens (2D pillar) β€” optional")
def make_type_group() -> gr.CheckboxGroup:
return gr.CheckboxGroup(choices=_labels("type"), label="Type (1D pillar) β€” optional")
def render_route_summary(res: Step1Result) -> str:
"""Pure markdown render of a resolved Step-1 route."""
all_sectors = res.in_scope + res.out_of_scope
lines = ["### Step 1 β€” Route", ""]
lines.append("**Sectors:** " + (", ".join(all_sectors) or "β€”"))
lines.append("**Lens:** " + (", ".join(res.route.lens) or "β€”"))
lines.append("**Type:** " + (", ".join(res.route.type) or "β€”"))
if res.out_of_scope:
lines += [
"",
"> ℹ️ Outside catalog (WASH / Food Security / Shelter): "
+ ", ".join(res.out_of_scope)
+ " β€” Step 2 will show no indicators for these.",
]
return "\n".join(lines)