From 7402590969bafbd8f4bd4e75b9dcd8b221f190ec Mon Sep 17 00:00:00 2001 From: saridsa2 Date: Sat, 18 Apr 2026 17:47:13 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20always=20include=20Health=20Packages=20s?= =?UTF-8?q?ection=20in=20KB=20=E2=80=94=20empty=20state=20says=20"not=20co?= =?UTF-8?q?nfigured"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When zero active packages exist, the KB silently omitted the section. AI then responded "I couldn't find that" for package queries. Now always includes the section header with explicit "not configured" guidance. Also removed contradicting rule 8 (bullet points) — conflicts with the structured output format that requires plain text sentences. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/ai/ai-chat.controller.ts | 4 +++- src/config/ai.defaults.ts | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ai/ai-chat.controller.ts b/src/ai/ai-chat.controller.ts index 9b4fce3..1436888 100644 --- a/src/ai/ai-chat.controller.ts +++ b/src/ai/ai-chat.controller.ts @@ -773,8 +773,8 @@ export class AiChatController { undefined, auth, ); const packages = pkgData.healthPackages.edges.map((e: any) => e.node); + sections.push('\n## Health Packages'); if (packages.length) { - sections.push('\n## Health Packages'); for (const p of packages) { const price = p.price ? `₹${p.price.amountMicros / 1_000_000}` : ''; const disc = p.discountedPrice?.amountMicros ? ` (discounted: ₹${p.discountedPrice.amountMicros / 1_000_000})` : ''; @@ -791,6 +791,8 @@ export class AiChatController { sections.push(` Includes: ${p.inclusions}`); } } + } else { + sections.push('No packages available.'); } } catch (err) { this.logger.warn(`Failed to fetch health packages: ${err}`); diff --git a/src/config/ai.defaults.ts b/src/config/ai.defaults.ts index 6a9ad8d..537ce2a 100644 --- a/src/config/ai.defaults.ts +++ b/src/config/ai.defaults.ts @@ -123,7 +123,6 @@ RULES: 5. For clinic info, timings, packages, insurance → answer directly from the knowledge base below. If the knowledge base is empty for that section (e.g. no packages configured), say the feature isn't set up yet instead of "I couldn't find that". 6. Be concise — agents are on live calls. Under 100 words unless asked for detail. 7. NEVER give medical advice, diagnosis, or treatment recommendations. -8. Format with bullet points for easy scanning. RESPONSE FORMAT (STRICT): You MUST respond with valid JSON in this exact format — no markdown fences, no extra text, just raw JSON: