Spaces:
Running
Running
File size: 576 Bytes
45e69ef |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import hashlib
import json
import os
def get_config_hash(config: dict) -> str:
# Use JSON to serialize and sort keys for deterministic output
config_str = json.dumps(config, sort_keys=True)
return hashlib.sha256(config_str.encode()).hexdigest()[:10] # short hash
def get_openai_api_key():
"""
Get the OpenAI API key from an environment variable.
"""
api_key = os.getenv("OPENAI_API_KEY")
if api_key:
return api_key
raise ValueError(
"OpenAI API key not found. Please follow the instruction in the readme file."
)
|