mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-05-18 20:08:19 +00:00
feat: structured JSON output + suggestion rules in AI system prompt
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -105,6 +105,9 @@ export class AiChatController {
|
||||
const callerCtx = await this.callerContext.getOrBuild(ctx.leadId, '', auth);
|
||||
if (callerCtx) {
|
||||
systemPrompt += `\n\n${this.callerContext.renderForPrompt(callerCtx)}`;
|
||||
if (callerCtx.suggestionTriggers?.length) {
|
||||
systemPrompt += this.callerContext.renderSuggestionsForPrompt(callerCtx.suggestionTriggers);
|
||||
}
|
||||
}
|
||||
} else if (ctx?.callerPhone) {
|
||||
systemPrompt += `\n\nCURRENT CONTEXT:\nCaller phone: ${ctx.callerPhone}\nNew caller — no prior records.`;
|
||||
|
||||
@@ -125,6 +125,20 @@ RULES:
|
||||
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:
|
||||
{"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.
|
||||
- "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
|
||||
- priority must be one of: high, medium, low
|
||||
- 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.
|
||||
|
||||
KNOWLEDGE BASE (this is real data from our system):
|
||||
{{knowledgeBase}}`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user