From 6a732afab45599a2e69d8da7a27e8ff363c76b9c Mon Sep 17 00:00:00 2001 From: Floke Date: Tue, 1 Jul 2025 14:24:54 +0000 Subject: [PATCH] Fix Global Variable Scope in Prompt Generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - FIX: Kritischer Fehler im Prompt für die Branchen-Evaluation behoben. Die Funktion `evaluate_branche_chatgpt` verwendet nun korrekt das dynamisch geladene Branchenschema, anstatt auf einen veralteten Default-Wert zurückzufallen. - REFACTOR: Redundante Importe innerhalb von Funktionen entfernt, um Scope-Konflikte zu vermeiden. --- helpers.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/helpers.py b/helpers.py index e047b026..c0f3586d 100644 --- a/helpers.py +++ b/helpers.py @@ -36,7 +36,10 @@ from bs4 import BeautifulSoup import pandas as pd import openai from openai.error import AuthenticationError, OpenAIError, RateLimitError, APIError, Timeout, InvalidRequestError, ServiceUnavailableError -from config import Config, BRANCH_MAPPING_FILE, URL_CHECK_MARKER, USER_AGENTS, LOG_DIR +from config import (Config, BRANCH_MAPPING_FILE, URL_CHECK_MARKER, + USER_AGENTS, LOG_DIR, TARGET_SCHEMA_STRING, + ALLOWED_TARGET_BRANCHES, FOCUS_TARGET_BRANCHES, + FOCUS_BRANCHES_PROMPT_PART) # Optionale Bibliotheken try: @@ -901,8 +904,12 @@ def evaluate_branche_chatgpt(crm_branche, beschreibung, wiki_branche, wiki_kateg NUTZT DIE BEWÄHRTE PARSING-LOGIK AUS v1.7.9. """ logger = logging.getLogger(__name__) - from config import TARGET_SCHEMA_STRING, FOCUS_BRANCHES_PROMPT_PART, ALLOWED_TARGET_BRANCHES + # HINWEIS: Die globalen Variablen TARGET_SCHEMA_STRING, FOCUS_BRANCHES_PROMPT_PART + # und ALLOWED_TARGET_BRANCHES werden auf Modulebene importiert und von + # initialize_target_schema() modifiziert. Wir dürfen sie hier nicht erneut importieren. + + # Lazy Loading des Branchenschemas if not ALLOWED_TARGET_BRANCHES: logger.warning("Branchenschema nicht geladen. Versuche es jetzt zu laden...") if not initialize_target_schema():