mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 07:13:29 +00:00
feat(insights): verdict-first briefing, richer score cards, grounded opener rotation
Replace the fixed three-beat assessment skeleton with a menu of moves the model orders freely, and reframe the daily briefing from per-signal enumeration to a verdict-first read that weaves the few salient signals into one associative story. Score cards now name both the helped and the hurt contributors, translate the band into a forward read for the day, and close on one grounded nudge; the deterministic fallback gains the same band-meaning sentence so provider-less and demo accounts read as well. Add a hash-seeded opener-archetype rotation (deterministic, testable) so consecutive cards and days no longer open the same way, a day-rotated sampling seed for the period narrative in place of the fixed reference seed, and a shared paragraph formatting contract. Add a score-number grounding gate and extend the briefing grounding allow-set to the glucose, labs, preventive-care and workout aggregate blocks so real figures can be cited without opening the gate. Gate the daily score warm on an input fingerprint so a quiet day skips the model call.
This commit is contained in:
1 parent
e2c6e46f2a
commit
b393527cac
22 files changed
+1089
-78
No files matched your search
@@ -34,7 +34,10 @@ import {
|
||||
buildUserPrompt,
|
||||
type ComparisonSnapshot,
|
||||
} from "@/lib/ai/prompts/insight-system-prompt";
|
||||
import { buildSystemPromptWithReferences } from "@/lib/ai/prompts/insight-generator";
|
||||
import {
|
||||
buildSystemPromptWithReferences,
|
||||
buildBriefingPersonalisationBlock,
|
||||
} from "@/lib/ai/prompts/insight-generator";
|
||||
import {
|
||||
buildAboutMeInsightBlock,
|
||||
getSelfContextTextForUser,
|
||||
@@ -398,6 +401,8 @@ export const POST = apiHandler((request: NextRequest) =>
|
||||
dateOfBirth: true,
|
||||
gender: true,
|
||||
heightCm: true,
|
||||
// v1.22 (W6) — first name for the sparse, hash-gated briefing opener.
|
||||
displayName: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -666,6 +671,14 @@ export const POST = apiHandler((request: NextRequest) =>
|
||||
userPrompt += buildBriefingIllnessCyclePrompt(illnessCycleCtx, locale);
|
||||
}
|
||||
|
||||
// v1.22 (W6) — opener-archetype rotation + sparse first-name personalization
|
||||
// (deterministic per user+day; omitted for unnamed accounts).
|
||||
userPrompt += buildBriefingPersonalisationBlock(
|
||||
userId,
|
||||
dbUser?.displayName ?? null,
|
||||
locale,
|
||||
);
|
||||
|
||||
// v1.12.7 (B5) — inject the curated SOURCES block for the metric sections
|
||||
// this briefing actually carries, so a normative claim can cite a real
|
||||
// `referenceId` the schema + UI footnote already support. Returns the plain
|
||||
@@ -826,6 +839,7 @@ export const POST = apiHandler((request: NextRequest) =>
|
||||
let ungrounded = findUngroundedBriefingNumbers(
|
||||
readBriefingBlock(insights),
|
||||
signals,
|
||||
features,
|
||||
);
|
||||
if (ungrounded.length > 0) {
|
||||
annotate({
|
||||
@@ -855,6 +869,7 @@ export const POST = apiHandler((request: NextRequest) =>
|
||||
ungrounded = findUngroundedBriefingNumbers(
|
||||
readBriefingBlock(retryInsights),
|
||||
signals,
|
||||
features,
|
||||
);
|
||||
if (ungrounded.length === 0) {
|
||||
insights = retryInsights;
|
||||
|
||||
Reference in new issue
Block a user