bugfix
This commit is contained in:
@@ -1410,7 +1410,8 @@ def evaluate_branche_chatgpt(crm_branche, beschreibung, wiki_branche, wiki_kateg
|
|||||||
try:
|
try:
|
||||||
with open("ziel_Branchenschema.csv", "r", encoding="utf-8") as csvfile:
|
with open("ziel_Branchenschema.csv", "r", encoding="utf-8") as csvfile:
|
||||||
reader = csv.reader(csvfile)
|
reader = csv.reader(csvfile)
|
||||||
branches = [row[0] for row in reader if row]
|
# Filtere mögliche Header (z. B. "Branche") aus
|
||||||
|
branches = [row[0].strip() for row in reader if row and row[0].strip().lower() != "branche"]
|
||||||
return branches
|
return branches
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
debug_print(f"Fehler beim Laden des Ziel-Branchenschemas: {e}")
|
debug_print(f"Fehler beim Laden des Ziel-Branchenschemas: {e}")
|
||||||
@@ -1443,7 +1444,7 @@ def evaluate_branche_chatgpt(crm_branche, beschreibung, wiki_branche, wiki_kateg
|
|||||||
return {"branch": "k.A.", "consistency": "k.A.", "justification": "k.A."}
|
return {"branch": "k.A.", "consistency": "k.A.", "justification": "k.A."}
|
||||||
openai.api_key = api_key
|
openai.api_key = api_key
|
||||||
|
|
||||||
# Falls kein Wikipedia-Artikel vorhanden ist, nutzen wir die Website-Zusammenfassung
|
# Falls kein Wikipedia-Artikel vorhanden ist, nutze als Fallback die Website-Zusammenfassung
|
||||||
if wiki_branche.strip().lower() == "k.a.":
|
if wiki_branche.strip().lower() == "k.a.":
|
||||||
debug_print("Kein Wikipedia-Artikel vorhanden – verwende Website-Zusammenfassung als Branchenbeschreibung-Fallback.")
|
debug_print("Kein Wikipedia-Artikel vorhanden – verwende Website-Zusammenfassung als Branchenbeschreibung-Fallback.")
|
||||||
used_description = website_summary
|
used_description = website_summary
|
||||||
@@ -1494,14 +1495,15 @@ def evaluate_branche_chatgpt(crm_branche, beschreibung, wiki_branche, wiki_kateg
|
|||||||
elif line.lower().startswith("begründung:"):
|
elif line.lower().startswith("begründung:"):
|
||||||
justification = line.split(":", 1)[1].strip()
|
justification = line.split(":", 1)[1].strip()
|
||||||
|
|
||||||
# Fallback-Logik: Wenn der vorgeschlagene Branch nicht im Zielschema ist,
|
# Fallback-Logik: Wurde kein gültiger Branch von ChatGPT zurückgegeben?
|
||||||
# dann wähle den in CRM vorliegenden Branch, sofern er gültig ist, sonst verwende den ersten Eintrag im Schema.
|
# Prüfe, ob der vorgeschlagene Branch in target_branches enthalten ist.
|
||||||
target_lower = [tb.lower() for tb in target_branches]
|
target_lower = [tb.lower() for tb in target_branches]
|
||||||
if branch is None or branch.lower() not in target_lower:
|
if branch is None or branch.lower() not in target_lower:
|
||||||
debug_print("Vorgeschlagene Branche entspricht nicht dem Ziel-Branchenschema, Fallback verwenden.")
|
debug_print("Vorgeschlagene Branche entspricht nicht dem Ziel-Branchenschema, Fallback verwenden.")
|
||||||
fallback = None
|
fallback = None
|
||||||
|
# Falls der in CRM angegebene Branch im Zielschema liegt, verwende ihn.
|
||||||
if crm_branche.strip() and crm_branche.lower() in target_lower:
|
if crm_branche.strip() and crm_branche.lower() in target_lower:
|
||||||
fallback = crm_branche
|
fallback = crm_branche.strip()
|
||||||
elif target_branches:
|
elif target_branches:
|
||||||
fallback = target_branches[0]
|
fallback = target_branches[0]
|
||||||
else:
|
else:
|
||||||
@@ -1513,6 +1515,7 @@ def evaluate_branche_chatgpt(crm_branche, beschreibung, wiki_branche, wiki_kateg
|
|||||||
return {"branch": branch, "consistency": consistency, "justification": justification}
|
return {"branch": branch, "consistency": consistency, "justification": justification}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def evaluate_servicetechnicians_estimate(company_name, company_data):
|
def evaluate_servicetechnicians_estimate(company_name, company_data):
|
||||||
try:
|
try:
|
||||||
with open("serpApiKey.txt", "r") as f:
|
with open("serpApiKey.txt", "r") as f:
|
||||||
|
|||||||
Reference in New Issue
Block a user