diff --git a/helpers.py b/helpers.py index 045fe407..80f6aa82 100644 --- a/helpers.py +++ b/helpers.py @@ -1008,11 +1008,11 @@ for line in lines: if result["justification"]: result["justification"] += " " + justification_text else: result["justification"] = justification_text - if not parsed_branch or not suggested_branch or suggested_branch.lower() in ["k.a.", "n/a"]: - logger.error(f"Fehler in evaluate_branche_chatgpt: Konnte 'Branche:' nicht oder nur leer/k.A. aus Antwort parsen: {chat_response[:500]}...") - crm_short_branch_for_fallback = "k.A." - if crm_branche and isinstance(crm_branche, str) and crm_branche.strip().lower() != "k.a.": - crm_short_branch_for_fallback = crm_branche.strip() + if not parsed_branch or not suggested_branch or suggested_branch.lower() in ["k.a.", "n/a"]: + logger.error(f"Fehler in evaluate_branche_chatgpt: Konnte 'Branche:' nicht oder nur leer/k.A. aus Antwort parsen: {chat_response[:500]}...") + crm_short_branch_for_fallback = "k.A." + if crm_branche and isinstance(crm_branche, str) and crm_branche.strip().lower() != "k.a.": + crm_short_branch_for_fallback = crm_branche.strip() return { "branch": crm_short_branch_for_fallback if crm_short_branch_for_fallback.lower() != "k.a." else "FEHLER PARSING",