fix(sos-stream): nickname-Injektion in systemPrompt
Lyra halluzinierte Namen wie 'Max' im SOS-Stream weil systemPrompt
keinen Nicknamen-Anker hatte. message.post.ts hatte das Pattern schon,
aber beim Cutover ins backend/-Layout war's nur dort, nicht in
sos-stream.{get,post}.ts.
Fix: getProfile(user.id) + Inject 'NUTZER-NAME: ...' wie in message.post.ts.
Non-blocking (catch), Memory-Pattern preserved.
This commit is contained in:
parent
431ae6a75d
commit
4e5f8e6c93
@ -22,6 +22,7 @@
|
||||
import { COACH_SYSTEM_PROMPT } from "./message.post";
|
||||
import { getMemoriesForUser, markReferenced } from "../../db/lyraMemory";
|
||||
import { extractAndStoreMemories } from "../../utils/lyraMemoryExtract";
|
||||
import { getProfile } from "../../db/profile";
|
||||
|
||||
const SOS_INSTRUCTION = `\n\nDU BEFINDEST DICH IN EINEM AKUTEN SOS-MOMENT. WICHTIGE REGELN:
|
||||
- Antworte als REINER TEXT, KEINE JSON-Wrapper, KEIN Markdown, KEINE Aufzählungen.
|
||||
@ -127,7 +128,20 @@ export default defineEventHandler(async (event) => {
|
||||
console.error("[lyra-memory] load error (non-fatal):", e);
|
||||
}
|
||||
|
||||
const systemPrompt = `${memoryBlock}${lang}\n\n${COACH_SYSTEM_PROMPT.replace("{{PLAN_DETAILS}}", "")}${SOS_INSTRUCTION}`;
|
||||
// Nickname-Injektion (Pattern aus message.post.ts) — sonst halluziniert Lyra
|
||||
// Namen wie "Max" weil sie keinen Anker hat.
|
||||
let nicknamePrefix = "";
|
||||
try {
|
||||
const profile = await getProfile(user.id);
|
||||
const nickname = profile?.nickname || profile?.username;
|
||||
if (nickname) {
|
||||
nicknamePrefix = `NUTZER-NAME: Der Nutzer heißt "${nickname}" – nenne ihn gelegentlich bei seinem Namen wenn es natürlich passt.\n\n`;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("[sos-stream] profile load (non-fatal):", e);
|
||||
}
|
||||
|
||||
const systemPrompt = `${nicknamePrefix}${memoryBlock}${lang}\n\n${COACH_SYSTEM_PROMPT.replace("{{PLAN_DETAILS}}", "")}${SOS_INSTRUCTION}`;
|
||||
|
||||
// Erste Nachricht muss user sein
|
||||
const firstUserIdx = messages.findIndex((m) => m.role === "user");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user