Spaces:
Sleeping
fix(api): KI-130 — drop 'regulatory' from /api/coverage marketplace tallies
Browse filesPre-fix: marketplace badge showed '20 INSURERS / 156 POLICIES'. The 20th
'insurer' was actually the 'regulatory' slug — 18 IRDAI / NHA documents
that are not insurance companies. They were leaking into the headline
counts because the ingest pipeline stamps insurer_slug=<parent dir name>
and rag/corpus/regulatory/ is a sibling of the 19 real-insurer dirs.
Post-fix: marketplace badge shows '19 INSURERS / 138 POLICIES' (real
insurance products only). The 'regulatory' bucket is excluded from
total_insurers, total_policies, and the insurers[] response array.
CRITICAL: this is a UI-tally change only. Retrieval / RAG / chat answers
are unaffected — rag/retrieve.py::retrieve() pulls chunks from the Chroma
'policies' collection by vector similarity with no insurer_slug filter,
so IRDAI / NHA chunks are still surfaced and cited when relevant. Verified
in earlier E2E test: 'What does the IRDAI master circular say about
moratorium?' returned a citation to
regulatory__irdai-master-circular-standardisation-health-products-2020
p.107
and the faithfulness gate passed.
Localhost verified after restart:
total_chunks=7296 (unchanged), total_policies=138, total_insurers=19,
has regulatory=False, has profile=False.
Pattern: same fix shape as KI-129 (filter profile chunks from /api/coverage).
The 'profile' and 'regulatory' slugs both live in the policies collection
intentionally (for retrieval boosting), but neither belongs in user-facing
counts.
- backend/main.py +10 -0
|
@@ -145,6 +145,11 @@ class InsurerCoverage(BaseModel):
|
|
| 145 |
class CoverageResponse(BaseModel):
|
| 146 |
total_chunks: int
|
| 147 |
total_policies: int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
total_insurers: int
|
| 149 |
insurers: list[InsurerCoverage]
|
| 150 |
|
|
@@ -578,6 +583,11 @@ async def coverage():
|
|
| 578 |
insurers_out = []
|
| 579 |
total_policies = 0
|
| 580 |
for slug, info in sorted(by_insurer.items()):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 581 |
policy_names = sorted(info["policies"])
|
| 582 |
total_policies += len(policy_names)
|
| 583 |
name, home_url = insurer_meta.get(slug, (slug, ""))
|
|
|
|
| 145 |
class CoverageResponse(BaseModel):
|
| 146 |
total_chunks: int
|
| 147 |
total_policies: int
|
| 148 |
+
# KI-130 (2026-05-15) — totals reflect REAL insurers and their products
|
| 149 |
+
# ONLY. The 'regulatory' slug (18 IRDAI/NHA documents) is excluded from
|
| 150 |
+
# the marketplace surface entirely; those documents are still retrieved
|
| 151 |
+
# and cited inside chat answers, they just don't belong in a "policy
|
| 152 |
+
# marketplace" UI.
|
| 153 |
total_insurers: int
|
| 154 |
insurers: list[InsurerCoverage]
|
| 155 |
|
|
|
|
| 583 |
insurers_out = []
|
| 584 |
total_policies = 0
|
| 585 |
for slug, info in sorted(by_insurer.items()):
|
| 586 |
+
# KI-130 (2026-05-15) — regulatory is not an insurer; drop entirely
|
| 587 |
+
# from the marketplace response. IRDAI/NHA docs are still retrieved
|
| 588 |
+
# and cited in chat answers — they just don't show in the marketplace.
|
| 589 |
+
if slug == "regulatory":
|
| 590 |
+
continue
|
| 591 |
policy_names = sorted(info["policies"])
|
| 592 |
total_policies += len(policy_names)
|
| 593 |
name, home_url = insurer_meta.get(slug, (slug, ""))
|