Spaces:
Sleeping
Sleeping
Commit History
-
feat: uploaded-PDF parity with catalogued 148 (ADR-044)
User-uploaded PDFs now go through the IDENTICAL pipeline as the 148 catalogued policies — same LLM extractor, same scorecard, same review data flow, same card UI. No "user-upload" carve-outs. CHANGES ───────────────────────────────────────────────────────────────────── A. Insurer detection (backend/uploaded_docs.py) detect_insurer_slug() scans the first ~6000 chars of PDF text for the legal name of any of the 21 insurers we have reviews data for (Acko, Bajaj Allianz, HDFC ERGO, ICICI Lombard, ManipalCigna, Niva Bupa, Star Health, Tata AIG, …). On a match, the persisted record + chunk metadata + Chroma metadata are stamped with the REAL insurer_slug → the scorecard's Claim Experience sub-score reads 40-data/reviews/<slug>.json and gets real claim-ratio + complaint-volume + NPS data, same as a catalogued card. Fail-closed: no match ⇒ insurer_slug stays "user-upload". B. LLM-assisted extraction on upload (backend/uploaded_docs.py + backend/main.py) New …4bb66dd
-
#33: add "?" help affordance to every policy-calculation control
Shared HelpTip component (createPortal body-root popover, desktop hover/focus + touch tap-toggle, Esc/outside/scroll dismiss, a11y labelled) driven by one CALC_HELP_COPY map. Wired next to every calc control across all 3 surfaces: - ProfileBuilder sliders (sum insured / existing cover / co-pay / budget) - PerPolicyPremiumEstimator (sum insured / co-pay) - PolicyPremiumWidget (sum insured / tenure / deductible) Deductible tip auto-absent where unsupported (sits inside the #29 supportsDeductible gate). Copy is purely qualitative — zero digits/%/₹ (no-invented-numbers). Verified: tsc 0, eslint 0-new vs baseline, static build OK, copy-map digit scan clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>deefe3a -
feat(#31): deterministic profile-aware {strengths,caveat} policy summary on all 3 surfaces
Replaces the generic grade one-liner with a per-(profile×policy) ProfileSummary{strengths[], caveat} computed on the SAME pass as the marketplace grade (scorecard.build_profile_summary): deterministic, no LLM, no fabricated numbers, no /100 or A/B in prose; ~4-5 most-material strengths for THIS profile + the one honest grade-capping caveat; fallback to one_liner when facts-sparse/insufficient-data. Rendered at the TOP of CitedPolicyCards, PolicyDetailModal, marketplace PolicyCard, and PolicyScorecardWidget. §4c: /api/policies/{id}/scorecard now takes session_id and resolves the profile via brain_tools.union_snapshot identically to /api/policies/all; single-endpoint defers to the catalogue (single source of truth) so profile_summary+grade are byte-identical across surfaces for all 148 (new parity test). Verified: full pytest suite exit 0 (no regression); test_profile_ summary + parity + endpoint_catalogue 21/21 (incl. 148×6-profile invariants, deductible-gate, non-fabrication, caveat-t…d486a56 -
fix: deductible gating (#29), existing-cover steering + dangling-turn guard (#30), compare-modal full reviews (#32)
#29 — deductible selector/discount was applied to all 148 though only 2 truly offer a voluntary deductible. New premium_calculator.policy_ deductible_support() (deductible_amount>0 AND not top-up → exactly bajaj-allianz__health-guard, star-health__star-assure); estimate + bulk gate the discount (defense-in-depth); PremiumEstimateResponse echoes supports_voluntary_deductible/allowed_deductibles; widget renders the deductible row only when supported. tests/test_deductible_ eligibility.py sweeps all 148. #30 — existing_cover_inr drove neither ranking, retrieval phrasing, nor framing; bot promised 're-evaluate' then stopped; re-eval recycled 2/3. Decisive fix B1-c: +22 existing-cover term in _fit_score for top-ups + seed out-of-window top-ups in _quality_seed_candidates. B1-a: RULE 2 mandatory existing-cover phrasing + Worked example C + RULE 2.6 framing mandate. B2: RULE 3.7 never-promise + _is_promissory_ no_action + one-shot loop guard that forces the promised tool call. B3: RULE 3 mat…3fcae97
-
fix(batch): voice interim, TTS truncation, RULE2.5 re-ask, faithfulness regression, markdown, compare-reviews, policy-name
Eight user-reported defects fixed together (all root-caused, all verified): #17 page.tsx PTT live transcript: separate inline SpeechRecognition had continuous=false + no-op onend (died after first pause, never restarted) + replace-not-accumulate. Added cross-session final accumulator, want-gated onend restart + 3s heartbeat, trailing flush. #19 sarvam_tts.py: bulbul:v2 silently voices only the first sentence of an over-real-limit single request; hard-coded 1500 ceiling meant the chunker never engaged for 370-720-char replies. Ceiling 1500->500, dropped undocumented enable_preprocessing, added a WAV-duration truncation guard (fail-loud). RED->GREEN proven. #18 single_brain.py: _profile_to_snapshot never exported smoker/ copay_pct/family_medical_history/parents_age_max, so the model couldn't know they were captured -> RULE 2.5 re-asked them. Snapshot widened + RULE 2.5 'omit captured items' directive. #23 single_brain.py: get_policy_facts policies now regis…8828a2e -
fix(#66): enrich the sparse POLICY DETAILS expander
The expander showed only policy name + insurer + PDF link (user: 'what is the point of this'). PolicyDetails now takes the resolved marketplacePolicy and renders the key decision facts when present: Cover, Grade, No-claim bonus, Pre-existing wait, Initial wait, Room rent, Co-pay, Network hospitals, Max entry age — each row only shown when the value exists (no fabricated/empty rows). citation-only fallback unchanged when no marketplace row resolves. tsc clean; frontend build green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>bb734ab -
fix(#76): show the customer's chosen cover, not 'As per policy schedule'
When a plan publishes no fixed SI tiers the premium IS already priced at the customer's desired_sum_insured_inr, but the Cover-amount row still rendered the dismissive 'As per policy schedule' placeholder — looking like the customer's stated cover was ignored. SnapProfile now carries desired_sum_insured_inr (the live profile already provides it; build green) and buildSnapshot overrides the placeholder with '₹X (your chosen cover)' ONLY when the plan has no published SI AND the customer gave one — otherwise unchanged. fmtSumInsured signature untouched (used elsewhere). tsc clean; frontend build Compiled successfully. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1e171b7 -
fix(#57+#58+#59): canonical-resolve compare-card marketplace lookup
One root cause, three symptoms on the HDFC ERGO Optima Restore compare card. page.tsx policyById was keyed ONLY by exact marketplace policy_id; the compare modal resolves the marketplace row by the CITED policy_id. A recommendation can cite a doctype/variant/alias id that is not byte-equal to the marketplace card's id (same canonical-identity class #40 solved for grades) → policyById[id] undefined → the card silently degraded: - #58 no network_list_url → 'Hospitals list' link missing - #57 no rationalised SI → Cover amount fell back to 'As per policy schedule' - #59 fewer populated fields → shorter/asymmetric vs Niva Bupa & Star Fix: build a canonical-resolving index (exact policy_id wins, plus doctype-stripped product_key + normalised policy_name + aliases, never overwriting a real id hit) and a _resolvePolicy(id,name) fallback chain; PolicyCompareModal now passes c.policy_name as the canonical fallback. Niva Bupa & Star already matched exactly so they were unaffected; HDFC now resol…e525764
-
fix(pricing+scoring): rebuild premium engine to 0 logical violations + classification, faithfulness, links, writing
Claude Code +1: Claude Opus 4.7 (1M context)Pricing: rebuilt sample→premium as median-of-normalized-bases (monotone by construction) + real-fact product-type classifier + age-bucket-key fix + type-aware abs/low caps + P7 capped vs cheapest real comprehensive + Sanjeevani rel-cap. Exhaustive harness 3,316→0 (P1-P8=0, 104,760 checks); 5 monotonicity + 4 strict all-148 seeds clean. Deep-research harvest (6 agents, integrity-gated): 93/148 now real-quote-anchored, rest type×profile-modelled w/ honest provenance labels. Classification: fixed Health Guard/Star Assure (voluntary-deductible comprehensive mislabelled topup → ded≥₹2L threshold), Criti Care/Medicare→disease, Energy→comprehensive, Health Protector Plus→topup. Scoring: parity-by-construction (_scorecard_signal mirrors marketplace doctype-rank + merge); harness S3=0, test_scorecard_parity green. Reviews source-map + 148 confirm. Weighted-avg math audited PASS. Faithfulness: _verify_prose_grounding — UINs in reply prose must be retrieved-grounded (faithfulness_passed now co…f266901 -
fix(reco): cap 3, exclude non-extracted policies, unify premium, ask PED
Claude Code +1: Claude Opus 4.7 (1M context)Five live recommendation-card defects, fixed at source: - #28 hard ≤3 cap in _build_recommendation_citations + prompt 2-3 + compare modal ≤3 (>3 collapsed the layout to 1 char/line) - #29 _has_extraction renderability gate: non-extracted policies excluded from _quality_seed_candidates AND the citation gate (was rendering raw slug / N/A / 'No extraction available' / 'Data not indexed') - #30 'Your share & the limits' always renders both rows with 'Not specified' fallback (was omitting nulls -> different field per card) - #31 removed Path C NonCuratedPricingNotice (dead component+styles deleted); estimate_premium_band now p25-p75 interquartile not raw min-max (was identical 30x-wide band on every non-curated card) - #32 SYSTEM_PROMPT now mandates the explicit pre-existing-conditions question before retrieve_policies Tests: rewrote no-cap + band-superset guards to the new contracts, added tests/test_extraction_gate.py + tests/conftest.py renderable-stub; full pytest gate green; frontend…61980e6
-
recovery: integrate stalled-session work + de-stale/cleanup (pytest 215 green) [build-fix]
Resumes the session whose 3 background agents stalled on the 600s watchdog; captures the prior session's uncommitted #42–#110 work + data exercise plus this session's verified recovery changes. (Rebuilt from the first attempt to store frontend/public/insurer-logos/*.png via Git LFS — HF Spaces' pre-receive hook requires it; .gitattributes updated, tools/.pdf_text_cache gitignored.) Prior-session work captured (was uncommitted, behaviourally live-tested): - single_brain rewrite, full frontend rebuild, compare/scorecard/premium UI, ~77 40-data/policy_facts sourced-data edits, new tests/tools, render.yaml drop. This session's recovery (surgical, verified, behaviour-preserving): - Fix app-wide HTTP 500: a `*/` inside a CSS comment killed the stylesheet. - Remove dead get_judge_llm everywhere (judge retired in single-brain rewrite). - eval/run.py: repair imports + hard-guard against stale results.json. - Centralize ~13 hardcoded "40-data" literals to one settings.DATA_DIR (resolves id…b87bd2d -
deploy#2: unified reco-fit gate + session-privacy fix + profile-completeness + full UI rebuild
- Reco-fit gate (absorbs #10/#26): product-type + hard-eligibility(entry-age) + required-feature(maternity) + fit-rank + UIN dedup; new policy_identity.py; fixes overall_score rank-inversion. 7-persona audit failures resolved. - Profile session-persistence privacy leak closed (name-keyed directory scan removed; recall now staged + confirmation-gated, fails closed) + single_brain "Are you <name>? yes/no" confirm-prompt. - Profile-form completeness: + desired_sum_insured_inr/smoker/copay_pct/ family_medical_history; ProfileUpdateRequest silent-drop closed. - Full premium UI rebuild (front-page design system): profile panel, chat/AI replies, cited cards, marketplace, compare modal, scorecard/premium widgets; Live(BETA) real warning modal; front-page prose→bullets. - 117 backend tests pass; frontend production build clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>b134f5b
-
fix(pricing): KI-277 — F6 Option B+ curated vs non-curated premium UI
User clarified: per-policy pricing is only real for the 26 curated policies in illustrative_premiums.json. For the other ~124 policies in the corpus we have NO quote data — the flat heuristic just reuses the same buyer math across them, giving false per-policy precision. Implementation of Option B+: - Curated policy (base_sample_used=true): existing slider widget renders unchanged — real quote-anchored estimate with SI/tenure/deductible sliders + ±15% range + methodology footnote. (Removed the now-redundant "Estimate" badge since this branch is curated-only.) - Non-curated policy (base_sample_used=false): NEW NonCuratedPricingNotice sub-component renders instead. Blue-accented info card. Reads: "We don't have a verified quote for [Policy Name] yet, so we can't show a plan-specific estimate. Based on your profile, plans in this category typically cost: ₹X-Y/year." + median sub-line + sample size + footnote pointing to PolicyBazaar / InsuranceDekho for an exact…fc6581d -
feat(profile+pricing+voice): KI-275 — F-bundle: smoker + recap-verify + premium scope + price consolidation
F2 — Smoker slot end-to-end (KI-275): - needs_finder.Profile: smoker: Optional[bool] field - brain_tools._ACCEPTED_FIELDS + SLOT_UNION extended (now 16 slots). _coerce_smoker accepts yes/true/smoker/tobacco→True, no/non-smoker→False, empty/unclear→None. - single_brain SYSTEM_PROMPT RULE 2.5 item 7: ask "Do you smoke or use tobacco?" Save smoker: save_profile_field(field="smoker", value="yes"/"no"). - premium_calculator bulk_estimate threads smoker_mult (1.4× when True) through both curated-anchor + flat-base paths. Surfaces smoker_loading_x + smoker_loading_reason in breakdown when !=1.0. - Premium delta: 35yo metro 10L SI no-PED → ₹11,500 → ₹14,300 (+24% via curated 1.35×) / ₹9,000 → ₹12,600 (+40% flat fallback). F3 — Recap-vs-reality fix: - single_brain RULE 4 new "RECAP VERIFY" sub-section: forbids recapping slots not actually saved via save_profile_field. Worked example for the diabetes/family_medical_history split (don't conflate them). - main.py post-turn confirm…a7d8209 -
refactor: KI-268 — Path B cleanup: -5,219 LOC legacy + nim_fallback + chain collapse + modal wiring
CLEAN1 — nim_fallback replaces legacy orchestrator fallback (+190 LOC, NEW): - backend/nim_fallback.py: handle_turn_fallback(session, user_text, chat_history) picks NIM via llm_health.get_primary("brain") with BRAIN_CHAIN[0] last-resort. One NvidiaNimLLM.chat call with 15s timeout. Never raises — graceful TurnResult on timeout/exception. - main.py: removed `from backend.orchestrator import handle_turn`. Both fallback branches (SingleBrainError non-sticky + USE_SINGLE_BRAIN=False) now call nim_fallback.handle_turn_fallback. Sticky-graceful-retry preserved. CLEAN2 — Port _normalize_dependents into brain_tools, delete 9 legacy modules: - brain_tools._coerce_dependents now uses ported _normalize_dependents_inline + _CANONICAL_VALUES tuple. Zero imports from sales_brain_normalizer. - DELETED (5,219 LOC total): * orchestrator.py (1,832) * sales_brain_normalizer.py (855) * sales_brain.py (819) * faithfulness.py (616) * providers/tiered_brain_llm.py (257) * persona.py …55fb938 -
feat(profile+pricing): KI-259..KI-266 — B-bundle (compare modal + per-policy + scorecard + premium band + budget/SI + union + persistence + recall)
B1 — Structured recommendation cards + Compare modal - NEW frontend/src/components/PolicyCompareModal.tsx: side-by-side compare for up to 3 cited policies. Each column = insurer logo + policy name + premium-calc slot + scorecard slot + policy details expandable + PDF. - page.tsx Message renderer now uses CitedPolicyCards (replaces flat PolicyChipsFromCitations). "Compare all" pill opens the modal when >=2 cited policies present. Removed dead PolicyChipsFromCitations (-67 LOC). B2 — Per-policy premium widget with sliders + profile defaults - NEW frontend/src/components/PolicyPremiumWidget.tsx: SI/tenure/deductible sliders, 300ms debounced fetch, AbortController cleanup, profile-summary line, "Estimate" badge when assumed=true, breakdown bullets. - backend/premium_calculator.py + main.py /api/premium/bulk: multiplicative model (base x SI x age-band x location x family x tenure x deductible). Anchors to illustrative_premiums.json when available (assumed=false); flat heu…f6901d8