File size: 1,234 Bytes
f935214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# clarifier.py
from __future__ import annotations
from typing import Dict, Any, List

def missing_inputs_questions(plan: Dict[str,Any], binding: Dict[str,Dict[str,Any]]) -> List[str]:
    """
    For each required input in plan['requires'], if binding[name]['match'] is None or score too low,
    produce a specific question asking for the exact data or where it lives.
    """
    reqs = [r.get("input") or r.get("name") or "" for r in (plan.get("requires") or [])]
    out: List[str] = []
    for r in reqs:
        b = binding.get(r, {})
        if (not b) or (b.get("match") is None) or (float(b.get("score", 0.0)) < 0.46):
            out.append(f"Where can I find **{r}** in your files (exact column name), or please provide its value?")
    # Always end with planning constraints
    if out:
        out.append("Any constraints (time windows, cohorts, or routing/scheduling rules) I should apply?")
    return out

def render_phase1_markdown(questions: List[str]) -> str:
    if not questions:
        return "**Clarification Questions**\n- No data gaps detected. Please confirm to proceed with analysis."
    out = ["**Clarification Questions**"]
    for q in questions:
        out.append(f"- {q}")
    return "\n".join(out)