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:
@@ -18,4 +18,5 @@ services:
|
||||
- ALL
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
|
||||
environment:
|
||||
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
|
||||
|
||||
@@ -21,9 +21,7 @@ WELCOME_FILENAME = "welcome.html"
|
||||
# -------------------------------------------------
|
||||
|
||||
def get_openai_client():
|
||||
"""Initialisiert den OpenAI-Client mit dem API-Key.
|
||||
Der Key ist aktuell direkt im Code hinterlegt – sollte in env var ausgelagert werden."""
|
||||
api_key = "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"
|
||||
api_key = os.environ.get("OPENAI_API_KEY")
|
||||
if not api_key:
|
||||
raise ValueError("OPENAI_API_KEY environment variable not set")
|
||||
return OpenAI(api_key=api_key)
|
||||
|
||||
Reference in New Issue
Block a user