Fix: Nur wirklich problematische Nachrichten umschreiben

This commit is contained in:
Hördle Bot
2025-12-04 20:13:20 +01:00
parent 623e8b9b82
commit 88dd86c344

View File

@@ -20,11 +20,14 @@ export async function POST(request: NextRequest) {
return NextResponse.json({ rewrittenMessage: message }); return NextResponse.json({ rewrittenMessage: message });
} }
const prompt = `Rewrite the following message to express the COMPLETE OPPOSITE meaning and opinion. const prompt = `You are a content moderation assistant. Analyze the following message and determine if it is truly inappropriate, unfriendly, sexist, or offensive.
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. Rules:
Maintain the original language (German or English). - ONLY rewrite the message if it is genuinely unfriendly, sexist, inappropriate, or offensive
Return ONLY the rewritten message text, nothing else. - 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}"`; Message: "${message}"`;
@@ -58,8 +61,11 @@ Message: "${message}"`;
const data = await response.json(); const data = await response.json();
let rewrittenMessage = data.choices?.[0]?.message?.content?.trim() || message; let rewrittenMessage = data.choices?.[0]?.message?.content?.trim() || message;
// Add suffix // Only add suffix if message was actually changed
rewrittenMessage += " (autocorrected by Polite-Bot)"; const originalTrimmed = message.trim();
if (rewrittenMessage !== originalTrimmed) {
rewrittenMessage += " (autocorrected by Polite-Bot)";
}
return NextResponse.json({ rewrittenMessage }); return NextResponse.json({ rewrittenMessage });