| """Runtime configuration for the GameMaster Design Copilot.""" |
|
|
| from __future__ import annotations |
|
|
| import os |
| from dataclasses import dataclass |
| from pathlib import Path |
|
|
|
|
| ROOT_DIR = Path(__file__).resolve().parents[1] |
|
|
| MODES = { |
| "brainstorm": "Generate several usable design directions, then recommend one.", |
| "critique": "Identify weaknesses, missing constraints, and concrete fixes.", |
| "balance": "Analyze incentives, exploits, progression curves, and tuning levers.", |
| "level_design": "Focus on spatial flow, onboarding, pacing, affordances, and readability.", |
| "gm_session": "Prioritize table-ready content, pacing, rulings, NPCs, scenes, and improvisation.", |
| } |
|
|
| DEFAULT_EMBEDDING_MODEL = "sentence-transformers/all-MiniLM-L6-v2" |
| DEFAULT_LLM_REPO = "mistralai/Ministral-3-3B-Instruct-2512-GGUF" |
| DEFAULT_LLM_FILE = "Ministral-3-3B-Instruct-2512-Q4_K_M.gguf" |
|
|
|
|
| def _bool_env(name: str, default: bool = False) -> bool: |
| value = os.getenv(name) |
| if value is None: |
| return default |
| return value.strip().lower() in {"1", "true", "yes", "on"} |
|
|
|
|
| def _int_env(name: str, default: int) -> int: |
| value = os.getenv(name) |
| if value is None: |
| return default |
| try: |
| return int(value) |
| except ValueError: |
| return default |
|
|
|
|
| @dataclass(frozen=True) |
| class Settings: |
| """Environment-backed settings with CPU-safe defaults.""" |
|
|
| root_dir: Path = ROOT_DIR |
| sources_path: Path = Path(os.getenv("GMC_SOURCES_PATH", str(ROOT_DIR / "sources.yaml"))) |
| index_dir: Path = Path(os.getenv("GMC_INDEX_DIR", str(ROOT_DIR / "data" / "index"))) |
| embedding_backend: str = os.getenv("GMC_EMBEDDING_BACKEND", "auto") |
| embedding_model: str = os.getenv("GMC_EMBEDDING_MODEL", DEFAULT_EMBEDDING_MODEL) |
| embedding_dimensions: int = _int_env("GMC_EMBEDDING_DIMENSIONS", 384) |
| llm_provider: str = os.getenv("GMC_LLM_PROVIDER", "auto") |
| enable_local_llm: bool = _bool_env("GMC_ENABLE_LOCAL_LLM", False) |
| llm_model_repo: str = os.getenv("GMC_LLM_MODEL_REPO", DEFAULT_LLM_REPO) |
| llm_model_file: str = os.getenv("GMC_LLM_MODEL_FILE", DEFAULT_LLM_FILE) |
| llm_model_path: str = os.getenv("GMC_LLM_MODEL_PATH", "") |
| llm_context_window: int = _int_env("GMC_LLM_CONTEXT_WINDOW", 4096) |
| llm_max_tokens: int = _int_env("GMC_LLM_MAX_TOKENS", 768) |
| retrieval_min_score: float = float(os.getenv("GMC_RETRIEVAL_MIN_SCORE", "0.08")) |
|
|
|
|
| def get_settings() -> Settings: |
| """Return current process settings.""" |
|
|
| return Settings() |
|
|
|
|