bugfix
This commit is contained in:
@@ -1408,9 +1408,10 @@ class WikipediaScraper:
|
|||||||
def evaluate_branche_chatgpt(crm_branche, beschreibung, wiki_branche, wiki_kategorien, website_summary):
|
def evaluate_branche_chatgpt(crm_branche, beschreibung, wiki_branche, wiki_kategorien, website_summary):
|
||||||
def load_target_branches():
|
def load_target_branches():
|
||||||
try:
|
try:
|
||||||
with open("ziel_Branchenschema.csv", "r", encoding="utf-8") as csvfile:
|
# Mit "utf-8-sig" werden BOM-Zeichen automatisch entfernt.
|
||||||
|
with open("ziel_Branchenschema.csv", "r", encoding="utf-8-sig") as csvfile:
|
||||||
reader = csv.reader(csvfile)
|
reader = csv.reader(csvfile)
|
||||||
# Filtere mögliche Header (z. B. "Branche") aus
|
# Filtern: Nur Zeilen, deren erster Eintrag (nach Strip) nicht exakt "branche" (unabhängig von Groß-/Kleinschreibung) ist.
|
||||||
branches = [row[0].strip() for row in reader if row and row[0].strip().lower() != "branche"]
|
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:
|
||||||
@@ -1444,7 +1445,6 @@ 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, 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
|
||||||
@@ -1495,13 +1495,12 @@ 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: Wurde kein gültiger Branch von ChatGPT zurückgegeben?
|
# Fallback-Logik: Falls der von ChatGPT vorgeschlagene Branch nicht im Ziel-Branchenschema enthalten ist,
|
||||||
# Prüfe, ob der vorgeschlagene Branch in target_branches enthalten ist.
|
# wird geprüft, ob der in CRM angegebene Branch vorhanden und gültig ist; andernfalls der erste Eintrag.
|
||||||
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.strip()
|
fallback = crm_branche.strip()
|
||||||
elif target_branches:
|
elif target_branches:
|
||||||
@@ -1516,6 +1515,7 @@ def evaluate_branche_chatgpt(crm_branche, beschreibung, wiki_branche, wiki_kateg
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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