fix: strict anti-hallucination default prompt

- Replace creative/warm tone with factual summarization
- Explicitly forbid invention, assumption, or hallucination
- Model must ONLY use information from provided entries
- Acknowledge gaps rather than fill them
This commit is contained in:
lotherk
2026-03-26 20:29:40 +00:00
parent a4e7132244
commit 37871271cc
9 changed files with 120 additions and 37 deletions

View File

@@ -579,8 +579,61 @@ app.onError((err, c) => {
return c.json({ data: null, error: { code: 'INTERNAL_ERROR', message: 'Internal server error' } }, 500);
});
async function createDefaultUser() {
const defaultEmail = envVars.DEFAULT_USER_EMAIL;
const defaultPassword = envVars.DEFAULT_USER_PASSWORD;
if (!defaultEmail || !defaultPassword) {
console.log('No default user configured (set DEFAULT_USER_EMAIL and DEFAULT_USER_PASSWORD)');
return;
}
try {
const existing = await prisma.user.findUnique({ where: { email: defaultEmail } });
if (existing) {
console.log(`Default user '${defaultEmail}' already exists`);
const hasKey = await prisma.apiKey.findFirst({ where: { userId: existing.id } });
if (!hasKey) {
const apiKey = randomBytes(32).toString('hex');
const keyHash = createHash('sha256').update(apiKey).digest('hex');
await prisma.apiKey.create({
data: { userId: existing.id, keyHash, name: 'Default' }
});
console.log(`Created API key for default user`);
console.log(`API Key: ${apiKey}`);
}
return;
}
const passwordHash = await bcrypt.hash(defaultPassword, 12);
const user = await prisma.user.create({
data: {
email: defaultEmail,
passwordHash,
settings: { create: {} }
}
});
const apiKey = randomBytes(32).toString('hex');
const keyHash = createHash('sha256').update(apiKey).digest('hex');
await prisma.apiKey.create({
data: { userId: user.id, keyHash, name: 'Default' }
});
console.log(`Created default user: ${defaultEmail}`);
console.log(`API Key: ${apiKey}`);
} catch (err) {
console.error('Failed to create default user:', err);
}
}
const port = parseInt(envVars.PORT || '3000', 10);
console.log(`Starting TotalRecall API on port ${port}`);
console.log(`Starting DearDiary API on port ${port}`);
createDefaultUser().then(() => {
console.log('Server ready');
});
export default {
port,