diff --git a/backend/services/maintenance.py b/backend/services/maintenance.py index cce73c1..995f507 100644 --- a/backend/services/maintenance.py +++ b/backend/services/maintenance.py @@ -382,12 +382,23 @@ def _summarize_hermes_commits(commits: list[dict]) -> str: ) try: r = httpx.post(f"{LLAMA_SWAP_URL}/v1/chat/completions", timeout=90.0, json={ - "model": "fast", "max_tokens": 380, "temperature": 0.2, + "model": "fast", "max_tokens": 550, "temperature": 0.2, "chat_template_kwargs": {"enable_thinking": False}, "messages": [{"role": "user", "content": prompt}], }) r.raise_for_status() - summary = ((r.json().get("choices") or [{}])[0].get("message", {}).get("content") or "").strip() + resp = r.json() + choice = (resp.get("choices") or [{}])[0] + summary = (choice.get("message") or {}).get("content") or "" + finish_reason = choice.get("finish_reason") or "" + summary = summary.strip() + + # finish_reason == "length" → Antwort wurde wegen Token-Limits abgeschnitten → + # letzten (unvollständigen) Stichpunkt entfernen. + # Bei "stop" oder None → Antwort ist vollständig → unverändert lassen. + if finish_reason == "length" and summary: + lines = summary.rsplit("\n", 1) + summary = lines[0] if len(lines) > 1 else "" if summary: _relnotes_cache.update(key=key, summary=summary) return summary