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
|
- ALL
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
|
environment:
|
||||||
|
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user