mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-05-18 20:08:19 +00:00
feat: enforce structured JSON output via AI SDK Output.object
- ai-response-schema.ts: Zod schema for { message, suggestions[] }
- ai-chat.controller.ts: Output.object({ schema }) on streamText
forces the LLM to return valid JSON matching the schema instead
of free-form prose. Supervisor mode excluded (uses tools, not schema).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
14
src/ai/ai-response-schema.ts
Normal file
14
src/ai/ai-response-schema.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const aiResponseSchema = z.object({
|
||||
message: z.string().describe('Conversational response text for the agent. Plain text, no markdown.'),
|
||||
suggestions: z.array(z.object({
|
||||
id: z.string().describe('Unique suggestion ID like s1, s2'),
|
||||
type: z.enum(['upsell', 'crosssell', 'retention', 'operational']),
|
||||
title: z.string().describe('Short title for the suggestion pill'),
|
||||
script: z.string().describe('2-3 sentence script the agent can read aloud to the caller'),
|
||||
priority: z.enum(['high', 'medium', 'low']),
|
||||
})).describe('0-4 contextual suggestions based on business rules. Include on first response, update on subsequent.'),
|
||||
});
|
||||
|
||||
export type AiResponse = z.infer<typeof aiResponseSchema>;
|
||||
Reference in New Issue
Block a user