Spaces:
Sleeping
fix(#63): header premium pill is the TYPICAL cohort range, labelled as such
Browse filesThe header pill showed a bare '₹X–₹Y/yr' while the LIVE PREMIUM panel
showed a different (often higher) per-plan number — read as 'random
different numbers'. Per estimate_premium_band's KI-278 contract this is
DELIBERATE: the pill is the p25-p75 typical-cohort band; the panel is
ONE specific plan's estimate (may sit outside the typical band — expected,
not a contradiction). NO pricing math changed (so #44's 0-violation
engine is untouched — gate rc=0). Fix is purely clarity:
- PredictedPremiumBandResponse now surfaces sum_insured_used (the model
was silently dropping the value the contract already returns)
- api.ts type + page.tsx: pill reads 'Typically ₹X–₹Y/yr'; tooltip
explains it's the typical range similar buyers pay (at ₹N cover) and
that a specific plan's live premium can sit above/below it — expected.
Backend import OK; full pytest rc=0; tsc/build green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- backend/main.py +7 -0
- frontend/src/app/page.tsx +4 -2
- frontend/src/lib/api.ts +1 -0
|
@@ -4243,6 +4243,12 @@ class PredictedPremiumBandResponse(BaseModel):
|
|
| 4243 |
max_inr: int
|
| 4244 |
sample_size: int
|
| 4245 |
assumed: bool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4246 |
|
| 4247 |
|
| 4248 |
@app.get(
|
|
@@ -4260,6 +4266,7 @@ async def predicted_premium_band(session_id: Optional[str] = None):
|
|
| 4260 |
if not session_id:
|
| 4261 |
return PredictedPremiumBandResponse(
|
| 4262 |
min_inr=0, median_inr=0, max_inr=0, sample_size=0, assumed=True,
|
|
|
|
| 4263 |
)
|
| 4264 |
|
| 4265 |
sess = get_session(session_id)
|
|
|
|
| 4243 |
max_inr: int
|
| 4244 |
sample_size: int
|
| 4245 |
assumed: bool
|
| 4246 |
+
# #63 — the SI the band was priced at. estimate_premium_band's KI-278
|
| 4247 |
+
# contract already returns this; the model dropped it, so the pill
|
| 4248 |
+
# couldn't tell the user the band is the TYPICAL cohort range at this
|
| 4249 |
+
# cover (vs the per-plan LIVE PREMIUM, which is one specific plan and
|
| 4250 |
+
# may sit outside the typical band — expected, not a contradiction).
|
| 4251 |
+
sum_insured_used: int = 0
|
| 4252 |
|
| 4253 |
|
| 4254 |
@app.get(
|
|
|
|
| 4266 |
if not session_id:
|
| 4267 |
return PredictedPremiumBandResponse(
|
| 4268 |
min_inr=0, median_inr=0, max_inr=0, sample_size=0, assumed=True,
|
| 4269 |
+
sum_insured_used=0,
|
| 4270 |
)
|
| 4271 |
|
| 4272 |
sess = get_session(session_id)
|
|
@@ -1635,7 +1635,9 @@ export default function Page() {
|
|
| 1635 |
className={`chip-tile group relative overflow-hidden rounded-xl shadow-sm transition-all hover:shadow-md ${
|
| 1636 |
showProfile ? "ring-2 ring-[var(--primary)]" : ""
|
| 1637 |
}`}
|
| 1638 |
-
title={uiLang === "hi"
|
|
|
|
|
|
|
| 1639 |
>
|
| 1640 |
<div className="relative flex items-stretch text-white">
|
| 1641 |
{/* Profile segment */}
|
|
@@ -1671,7 +1673,7 @@ export default function Page() {
|
|
| 1671 |
</div>
|
| 1672 |
<div className="text-[12px] leading-tight whitespace-nowrap opacity-90 mt-1">
|
| 1673 |
{hasMeaningfulBand
|
| 1674 |
-
? `₹${premiumBand!.min_inr.toLocaleString("en-IN")}–₹${premiumBand!.max_inr.toLocaleString("en-IN")}/yr`
|
| 1675 |
: (uiLang === "hi" ? "अनुमान देखें" : "Tap to estimate")}
|
| 1676 |
</div>
|
| 1677 |
</div>
|
|
|
|
| 1635 |
className={`chip-tile group relative overflow-hidden rounded-xl shadow-sm transition-all hover:shadow-md ${
|
| 1636 |
showProfile ? "ring-2 ring-[var(--primary)]" : ""
|
| 1637 |
}`}
|
| 1638 |
+
title={uiLang === "hi"
|
| 1639 |
+
? `आपकी profile + similar buyers जो typically pay करते हैं वो range${premiumBand?.sum_insured_used ? ` (₹${premiumBand.sum_insured_used.toLocaleString("en-IN")} cover पर)` : ""}. किसी एक specific plan का live premium इस typical range से ऊपर/नीचे हो सकता है — ये सामान्य है।`
|
| 1640 |
+
: `Your profile + the TYPICAL range similar buyers pay${premiumBand?.sum_insured_used ? ` (priced at ₹${premiumBand.sum_insured_used.toLocaleString("en-IN")} cover)` : ""}. A specific plan's live premium can sit above or below this typical range — that's expected, not a contradiction.`}
|
| 1641 |
>
|
| 1642 |
<div className="relative flex items-stretch text-white">
|
| 1643 |
{/* Profile segment */}
|
|
|
|
| 1673 |
</div>
|
| 1674 |
<div className="text-[12px] leading-tight whitespace-nowrap opacity-90 mt-1">
|
| 1675 |
{hasMeaningfulBand
|
| 1676 |
+
? `${uiLang === "hi" ? "आम तौर पर" : "Typically"} ₹${premiumBand!.min_inr.toLocaleString("en-IN")}–₹${premiumBand!.max_inr.toLocaleString("en-IN")}/yr`
|
| 1677 |
: (uiLang === "hi" ? "अनुमान देखें" : "Tap to estimate")}
|
| 1678 |
</div>
|
| 1679 |
</div>
|
|
@@ -521,6 +521,7 @@ export type PredictedPremiumBandResponse = {
|
|
| 521 |
max_inr: number;
|
| 522 |
sample_size: number;
|
| 523 |
assumed: boolean;
|
|
|
|
| 524 |
};
|
| 525 |
|
| 526 |
export async function getPredictedPremiumBand(
|
|
|
|
| 521 |
max_inr: number;
|
| 522 |
sample_size: number;
|
| 523 |
assumed: boolean;
|
| 524 |
+
sum_insured_used?: number; // #63 — SI the typical-cohort band priced at
|
| 525 |
};
|
| 526 |
|
| 527 |
export async function getPredictedPremiumBand(
|