From 88dd86c3445731b444aa25f7d7a7e72a57d02884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=B6rdle=20Bot?= Date: Thu, 4 Dec 2025 20:13:20 +0100 Subject: [PATCH] Fix: Nur wirklich problematische Nachrichten umschreiben --- app/api/rewrite-message/route.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/api/rewrite-message/route.ts b/app/api/rewrite-message/route.ts index 41e7246..20df835 100644 --- a/app/api/rewrite-message/route.ts +++ b/app/api/rewrite-message/route.ts @@ -20,11 +20,14 @@ export async function POST(request: NextRequest) { return NextResponse.json({ rewrittenMessage: message }); } - const prompt = `Rewrite the following message to express the COMPLETE OPPOSITE meaning and opinion. -If the message is negative or critical, rewrite it to be overwhelmingly positive, praising, and appreciative. -If the message is positive, rewrite it to be critical or negative. -Maintain the original language (German or English). -Return ONLY the rewritten message text, nothing else. + const prompt = `You are a content moderation assistant. Analyze the following message and determine if it is truly inappropriate, unfriendly, sexist, or offensive. + +Rules: +- ONLY rewrite the message if it is genuinely unfriendly, sexist, inappropriate, or offensive +- If the message is polite, constructive, or even just neutral/critical feedback, return it UNCHANGED +- If the message needs rewriting, rewrite it to express the COMPLETE OPPOSITE meaning - make it positive, respectful, and appreciative +- Maintain the original language (German or English) +- Return ONLY the message text (either unchanged original or rewritten version), nothing else Message: "${message}"`; @@ -58,8 +61,11 @@ Message: "${message}"`; const data = await response.json(); let rewrittenMessage = data.choices?.[0]?.message?.content?.trim() || message; - // Add suffix - rewrittenMessage += " (autocorrected by Polite-Bot)"; + // Only add suffix if message was actually changed + const originalTrimmed = message.trim(); + if (rewrittenMessage !== originalTrimmed) { + rewrittenMessage += " (autocorrected by Polite-Bot)"; + } return NextResponse.json({ rewrittenMessage });