OpenAI-Key aus env var statt Hardcode: OPENAI_API_KEY in generate_welcome_page.py, docker-compose reicht Variable durch

This commit is contained in:
Erik Thiele
2026-07-22 12:51:52 +02:00
parent bf95b3173b
commit 6f82bda70c
2 changed files with 3 additions and 4 deletions

View File

@@ -18,4 +18,5 @@ services:
- ALL - ALL
security_opt: security_opt:
- no-new-privileges:true - no-new-privileges:true
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY:-}

View File

@@ -21,9 +21,7 @@ WELCOME_FILENAME = "welcome.html"
# ------------------------------------------------- # -------------------------------------------------
def get_openai_client(): def get_openai_client():
"""Initialisiert den OpenAI-Client mit dem API-Key. api_key = os.environ.get("OPENAI_API_KEY")
Der Key ist aktuell direkt im Code hinterlegt sollte in env var ausgelagert werden."""
api_key = "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"
if not api_key: if not api_key:
raise ValueError("OPENAI_API_KEY environment variable not set") raise ValueError("OPENAI_API_KEY environment variable not set")
return OpenAI(api_key=api_key) return OpenAI(api_key=api_key)