mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-05-18 20:08:19 +00:00
fix: AI message formatting — plain text sentences, no markdown/data dump
Schema description reinforced: brief 2-3 sentence natural language only. Prompt template updated with example output and explicit ban on markdown headers, bold, bullet lists, and raw field labels in the message field. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const aiResponseSchema = z.object({
|
||||
message: z.string().describe('Conversational response text for the agent. Plain text, no markdown.'),
|
||||
message: z.string().describe('Brief 2-3 sentence conversational summary for the agent. Plain text only — no markdown, no headers, no bold, no bullet lists. Just natural sentences.'),
|
||||
suggestions: z.array(z.object({
|
||||
id: z.string().describe('Unique suggestion ID like s1, s2'),
|
||||
type: z.enum(['upsell', 'crosssell', 'retention', 'operational']),
|
||||
|
||||
@@ -130,7 +130,7 @@ You MUST respond with valid JSON in this exact format — no markdown fences, no
|
||||
{"message": "your response text here", "suggestions": [{"id": "s1", "type": "upsell", "title": "short title", "script": "2-3 sentence script the agent reads aloud", "priority": "high"}]}
|
||||
|
||||
Response format rules:
|
||||
- "message" contains your conversational response to the agent. Use plain text, no markdown.
|
||||
- "message" MUST be plain text sentences only. NEVER use markdown headers (###), bold (**), bullet lists (-), or field labels (Phone:, Status:). Write natural conversational sentences like you're briefing a colleague: "Priya Sharma is a returning patient interested in IVF. She has an upcoming appointment with Dr. Patel on April 14th. Her last General Medicine appointment was rescheduled."
|
||||
- "suggestions" contains 0-4 contextual suggestions based on the SUGGESTION RULES section below (if present).
|
||||
- Each suggestion needs a personalized "script" using the caller's name, doctor, department from the context.
|
||||
- type must be one of: upsell, crosssell, retention, operational
|
||||
@@ -138,6 +138,7 @@ Response format rules:
|
||||
- On the first response (patient summary), always include suggestions from the rules.
|
||||
- On subsequent responses, update suggestions based on conversation — remove acted-on ones, add new if relevant.
|
||||
- If no suggestion rules are provided, return an empty suggestions array.
|
||||
- Do NOT repeat raw data fields in the message. The summary card already shows name, phone, appointments. Keep the message to insight and context the card doesn't show.
|
||||
|
||||
KNOWLEDGE BASE (this is real data from our system):
|
||||
{{knowledgeBase}}`;
|
||||
|
||||
Reference in New Issue
Block a user