fix: env var overrides for campaign settings (hf_token, ollama_host etc)
Some checks failed
Build and Push / build (push) Has been cancelled
Some checks failed
Build and Push / build (push) Has been cancelled
This commit is contained in:
@@ -64,3 +64,34 @@ CAMPAIGN_SETTINGS = {
|
||||
"player_recap_style": "story",
|
||||
"player_recap_custom_prompt": "",
|
||||
}
|
||||
|
||||
# Env var names that can override CAMPAIGN_SETTINGS at read time.
|
||||
# Set these in docker-compose.yml to prefill the setup wizard.
|
||||
CAMPAIGN_ENV_OVERRIDES = {
|
||||
"hf_token": "NAT20_HF_TOKEN",
|
||||
"whisper_model": "NAT20_WHISPER_MODEL",
|
||||
"whisper_compute_type": "NAT20_WHISPER_COMPUTE_TYPE",
|
||||
"ollama_host": "NAT20_OLLAMA_HOST",
|
||||
"ollama_model": "NAT20_OLLAMA_MODEL",
|
||||
"api_base_url": "NAT20_API_BASE_URL",
|
||||
"api_key": "NAT20_API_KEY",
|
||||
"api_model": "NAT20_API_MODEL",
|
||||
"chunk_word_target": "NAT20_CHUNK_WORD_TARGET",
|
||||
"world_context": "NAT20_WORLD_CONTEXT",
|
||||
"world_context_path": "NAT20_WORLD_CONTEXT_PATH",
|
||||
"player_recap_style": "NAT20_PLAYER_RECAP_STYLE",
|
||||
"player_recap_custom_prompt": "NAT20_PLAYER_RECAP_CUSTOM_PROMPT",
|
||||
}
|
||||
|
||||
|
||||
def merge_campaign_settings_with_env(raw: dict) -> dict:
|
||||
"""Priority: env var > DB value > CAMPAIGN_SETTINGS default."""
|
||||
merged = {**CAMPAIGN_SETTINGS}
|
||||
for key, val in raw.items():
|
||||
if val and val.strip():
|
||||
merged[key] = val.strip()
|
||||
for key, env_name in CAMPAIGN_ENV_OVERRIDES.items():
|
||||
val = os.environ.get(env_name)
|
||||
if val is not None:
|
||||
merged[key] = val
|
||||
return merged
|
||||
|
||||
Reference in New Issue
Block a user