fix(#170): PM-Body literal \\n → echte Newlines

Beobachtung beim ersten Pressereferent-Output: qwen-max liefert
manchmal literale Backslash-n Sequenzen (2 chars: \\ + n) statt echter
Newline-Bytes im JSON-Body. Auch mit response_format=json_object aktiv.

Post-Process im PM-Generator: \\n / \\r / \\t Sequenzen durch echte
Newlines / CR / Tab ersetzen. Konservativ (nur diese drei).
Macht das Modal richtig formatiert mit Paragraphen-Breaks.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dotty Dotter 2026-05-06 01:55:58 +02:00
parent a0559333e8
commit 39ef248a66

View File

@ -314,6 +314,10 @@ async def generate_draft(
titel = (result.get("titel") or "").strip()[:200]
body = (result.get("body") or "").strip()
# Post-Process: qwen-max liefert manchmal literal-escapte Sequenzen
# ('\\n' als 2 chars statt echtem Newline). UI braucht echte Newlines
# fuer korrekte Paragraphen-Trennung. Konservativ: nur \\n / \\r / \\t.
body = body.replace("\\n", "\n").replace("\\r", "\r").replace("\\t", "\t")
if not titel or not body:
raise ValueError("LLM-Response unvollständig (titel oder body leer)")