now uses name of discord user

This commit is contained in:
Luna
2026-03-03 20:59:23 +01:00
parent 931f222979
commit 55b5e88acb
2 changed files with 14 additions and 0 deletions

View File

@@ -94,9 +94,15 @@ export async function buildPrompt(userId, incomingText, options = {}) {
searchOutage = null,
context: providedContext = null,
useGlobalMemories = false,
userName = null,
} = options;
const context =
providedContext || (await prepareContext(userId, incomingText, { includeAllUsers: useGlobalMemories }));
if (userName) {
context.userName = userName;
} else if (context.userName === undefined) {
context.userName = null;
}
const memoryLines = context.memories.length
? context.memories
.map((m) =>
@@ -121,6 +127,11 @@ export async function buildPrompt(userId, incomingText, options = {}) {
' Adjust emoji usage, sarcasm, response length, and overall energy accordingly.',
);
}
if (context.userName) {
systemPromptParts.push(`System: You are currently chatting with ${context.userName}. Anchor each reply to them.`);
} else {
systemPromptParts.push(`System: You are currently chatting with Discord user ${userId}. Keep that connection in mind.`);
}
systemPromptParts.push(STATIC_SYSTEM_PROMPT);
if (searchOutage) {
systemPromptParts.push('System: Google search is currently offline; be transparent about the outage and continue without searching until it returns.');