per-campaign settings, default campaign folders, custom prompt fix
All checks were successful
Build and Push / build (push) Successful in 12m10s
All checks were successful
Build and Push / build (push) Successful in 12m10s
This commit is contained in:
@@ -6,27 +6,10 @@ from .. import database as db, config
|
||||
|
||||
router = APIRouter(prefix="/api/settings", tags=["settings"])
|
||||
|
||||
# Settings are stored as flat key/value rows (see database.py / config.DEFAULT_SETTINGS).
|
||||
# This router is a thin pass-through over that table - it must not invent its own
|
||||
# schema, or the Settings/Setup pages will silently stop affecting the actual
|
||||
# transcription/summarization pipeline, which reads these same flat keys.
|
||||
# Only global (GLOBAL_SETTINGS) keys live here; campaign settings are under /api/campaigns/{id}/settings.
|
||||
|
||||
# Env var overrides — set these in docker-compose.yml to prefill the setup wizard
|
||||
_ENV_OVERRIDES = {
|
||||
"onboarding_completed": "NAT20_ONBOARDING_COMPLETED",
|
||||
"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",
|
||||
}
|
||||
|
||||
_BOOL_KEYS = {"onboarding_completed"}
|
||||
@@ -39,15 +22,15 @@ def _coerce(key: str, value: str):
|
||||
|
||||
|
||||
def _merge_with_env(raw: dict) -> dict:
|
||||
"""Priority: explicit user DB saves (non-default) > env vars > DEFAULT_SETTINGS."""
|
||||
merged = {**config.DEFAULT_SETTINGS}
|
||||
"""Priority: explicit user DB saves (non-default) > env vars > GLOBAL_SETTINGS."""
|
||||
merged = {**config.GLOBAL_SETTINGS}
|
||||
for key, env_name in _ENV_OVERRIDES.items():
|
||||
val = os.environ.get(env_name)
|
||||
if val is not None:
|
||||
merged[key] = val
|
||||
for key, val in raw.items():
|
||||
db_val = val.strip()
|
||||
if db_val and db_val != config.DEFAULT_SETTINGS.get(key, ""):
|
||||
if db_val and db_val != config.GLOBAL_SETTINGS.get(key, ""):
|
||||
merged[key] = db_val
|
||||
return merged
|
||||
|
||||
@@ -61,7 +44,7 @@ async def get_settings():
|
||||
|
||||
@router.post("")
|
||||
async def update_settings(patch: dict):
|
||||
clean = {k: str(v) for k, v in patch.items() if k in config.DEFAULT_SETTINGS}
|
||||
clean = {k: str(v) for k, v in patch.items() if k in config.GLOBAL_SETTINGS}
|
||||
db.update_settings(clean)
|
||||
raw = db.get_settings()
|
||||
merged = _merge_with_env(raw)
|
||||
|
||||
Reference in New Issue
Block a user