You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
return`Autism screening biomarkers for child (age: ${age}): ${JSON.stringify(biomarkers)}
141
+
142
+
Return ONLY valid JSON (no markdown, no explanation):
143
+
{"severityLevel":"mild|moderate|significant","criterionA_interpretation":"1-2 sentences mapping gaze/vocalization/face scores to DSM-5 A.1/A.2/A.3","criterionB_interpretation":"1-2 sentences mapping motor/behavior patterns to DSM-5 B.1/B.2/B.4","clinicalImpression":"2-3 sentence overall clinical impression","priorityRecommendations":["2-3 specific recommendations for this child"],"differentialConsiderations":"1 sentence on differential diagnosis considerations"}`;
@@ -170,43 +228,15 @@ export async function POST(req: NextRequest) {
170
228
171
229
const{ biomarkers, childAge }=body;
172
230
173
-
constageContext=childAge
174
-
? `The child is ${Math.floor(childAge/12)} years and ${childAge%12} months old.`
175
-
: "The child's age was not specified.";
176
-
177
-
constprompt=`You are a clinical report generator for an autism screening platform. Generate a comprehensive DSM-5 aligned clinical screening report based on the following biomarker data.
178
-
179
-
${ageContext}
180
-
181
-
Biomarker Data:
182
-
${JSON.stringify(biomarkers,null,2)}
183
-
184
-
Structure the report with these EXACT section headers:
185
-
186
-
CRITERION A -- SOCIAL COMMUNICATION & INTERACTION
187
-
Analyze social gaze patterns (avgGazeScore), vocalization quality (avgVocalizationScore), facial affect (dominantFaceBehavior if available), and their mapping to DSM-5 Criterion A sub-criteria (A.1 social-emotional reciprocity, A.2 nonverbal communication, A.3 relationships).
188
-
189
-
CRITERION B -- RESTRICTED & REPETITIVE BEHAVIOURS
190
-
Analyze motor patterns (avgMotorScore), response latency, body behavior classification (dominantBodyBehavior, behaviorClassDistribution if available), and mapping to DSM-5 Criterion B sub-criteria (B.1 stereotyped movements, B.2 insistence on sameness, B.3 restricted interests, B.4 sensory reactivity).
191
-
192
-
MOTOR DEVELOPMENT ASSESSMENT
193
-
Provide a focused motor development analysis based on the motor score and any detected body behavior patterns. Note co-occurring motor differences common in ASD.
194
-
195
-
RECOMMENDATIONS
196
-
Provide actionable next steps based on the screening results: referral recommendations, suggested interventions, monitoring frequency. Include a disclaimer that this is a screening tool, not a diagnostic instrument.
197
-
198
-
Guidelines:
199
-
- Use clinical but accessible language
200
-
- Reference specific DSM-5 criteria codes where appropriate
201
-
- Include specific scores and thresholds in your analysis
202
-
- Be factual and evidence-based, avoid speculation
203
-
- End with a clear disclaimer about the screening nature of this tool`;
231
+
// Always generate the deterministic template first
| ONNX Runtime (on-device) | 4 models in `public/models/`| app/lib/inference/ (13 files), workers/inference.worker.ts | Active, working |
13
13
@@ -36,6 +36,6 @@
36
36
1.**AI voice conversation with child** (Step 7 screening + kid chat) — app/api/chat/conversation/route.ts — Nova Lite generates adaptive multi-turn questions across social/cognitive/language/motor domains
37
37
2.**Dynamic word/sentence generation** (speech stages) — app/api/chat/generate-words/route.ts — Nova Lite generates age-appropriate vocabulary
38
38
3.**Parent-friendly summary** (end of screening) — app/api/report/summary/route.ts — Nova Lite translates biomarker scores to plain language
39
-
4.**DSM-5 clinical report** (end of screening) — app/api/report/clinical/route.ts — Command R+ generates full Criterion A/B/Motor/Recommendations report
39
+
4.**DSM-5 clinical report** (end of screening) — app/api/report/clinical/route.ts — Nova Pro returns structured JSON insights merged with deterministic template (hybrid approach, ~85% fewer tokens)
40
40
41
41
All 4 Bedrock routes have comprehensive mock fallbacks, so the app is fully functional even with your current quota=0 situation. The on-device ONNX inference (the core screening AI) needs zero cloud — it runs entirely in the browser.
- Replaced full-prose LLM prompt with hybrid template + AI insights approach
1012
+
- Deterministic template (`buildMockReport`) generates the complete report with scores, thresholds, flags, and disclaimers
1013
+
- Nova Pro now returns only a small structured JSON with clinical interpretations (severity level, DSM-5 criterion mappings, clinical impression, priority recommendations, differential considerations)
1014
+
-`mergeAiInsights()` enriches the template sections with AI clinical depth
1015
+
-~85% token reduction per clinical report (~400 tokens vs ~2700 previously)
1016
+
-`maxTokens` reduced from 2048 to 512
1017
+
- Fallback preserved: if Bedrock fails or JSON unparseable, returns template-only report
1018
+
1019
+
**Bedrock Model Updates:**
1020
+
- Replaced Cohere Command R+ with Amazon Nova Pro for clinical reports (v2.3.0)
1021
+
- Fixed `maxNewTokens` → `maxTokens` in generate-words route (v2.3.0)
1022
+
- Updated all documentation references from Cohere to Nova Pro
0 commit comments