fix(debug): Add version info and API key debugging
- Adds a version and timestamp to the orchestrator's startup logs to verify code deployment. - Introduces extensive debug logging in config.py and helpers.py to trace the API key loading process, including exact file paths and environment variable checks. This will help diagnose the persistent 'API Key missing' error.
This commit is contained in:
@@ -490,6 +490,7 @@ class Config:
|
||||
"""Laedt API-Schluessel aus den definierten Dateien."""
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.info("Lade API-Schluessel...")
|
||||
print(f"DEBUG: Attempting to load API keys. BASE_DIR: {BASE_DIR}") # Debug print
|
||||
cls.API_KEYS['openai'] = cls._load_key_from_file(API_KEY_FILE)
|
||||
cls.API_KEYS['serpapi'] = cls._load_key_from_file(SERP_API_KEY_FILE)
|
||||
cls.API_KEYS['genderize'] = cls._load_key_from_file(GENDERIZE_API_KEY_FILE)
|
||||
|
||||
@@ -20,6 +20,7 @@ LOG_DIR = "Log_from_docker"
|
||||
if not os.path.exists(LOG_DIR):
|
||||
os.makedirs(LOG_DIR)
|
||||
|
||||
ORCHESTRATOR_VERSION = "1.1.0"
|
||||
run_timestamp = datetime.now().strftime("%y-%m-%d_%H-%M-%S")
|
||||
log_file_path = os.path.join(LOG_DIR, f"{run_timestamp}_gtm_orchestrator_run.log")
|
||||
|
||||
@@ -31,7 +32,7 @@ logging.basicConfig(
|
||||
logging.StreamHandler(sys.stdout)
|
||||
]
|
||||
)
|
||||
|
||||
logging.info(f"GTM Architect Orchestrator v{{ORCHESTRATOR_VERSION}} ({{run_timestamp}}) starting...")
|
||||
def log_and_save(project_id, step_name, data_type, content):
|
||||
logging.info(f"Project {project_id} - Step: {step_name} - Type: {data_type}")
|
||||
filename = f"{run_timestamp}_{step_name}_{data_type}.txt"
|
||||
|
||||
@@ -295,13 +295,18 @@ def get_email_address(firstname, lastname, website):
|
||||
def _get_gemini_api_key():
|
||||
"""Retrieves Gemini API Key from Config or Environment."""
|
||||
logger = logging.getLogger(__name__)
|
||||
print("DEBUG: _get_gemini_api_key called.") # Debug print
|
||||
api_key = Config.API_KEYS.get('openai') # Legacy slot
|
||||
print(f"DEBUG: API Key from Config.API_KEYS['openai']: {api_key if api_key else 'None'}") # Debug print
|
||||
|
||||
if not api_key:
|
||||
# Fallback: Versuche Environment Variable, falls Config leer ist
|
||||
api_key = os.environ.get("OPENAI_API_KEY")
|
||||
print(f"DEBUG: API Key from env OPENAI_API_KEY: {api_key if api_key else 'None'}") # Debug print
|
||||
if not api_key:
|
||||
# Fallback 2: Versuche den Gemini Key direkt
|
||||
api_key = os.environ.get("GEMINI_API_KEY") or Config.API_KEYS.get('gemini')
|
||||
print(f"DEBUG: API Key from env GEMINI_API_KEY or Config.API_KEYS['gemini']: {api_key if api_key else 'None'}") # Debug print
|
||||
|
||||
if not api_key:
|
||||
logger.error("Fehler: Kein API Key gefunden (weder als 'openai' noch 'gemini').")
|
||||
|
||||
Reference in New Issue
Block a user