"""出厂默认配置。结构 = spec §5.1 的 9 个配置组。 本阶段 brand/wall 的默认值由 Task 4 从 jc 代码提取填充。""" import copy DEFAULT_CONFIG: dict = { "brand": { "title": "AI Support", "color": "#066fc0", "avatar": "/static/kefu-small.png", "welcome": "", "topics": [], "placeholder": "", "whatsapp": "", "email": "", "privacy_url": "", }, "wall": {}, # Task 4 填充 "contact": {"cc_completion": True, "email_light_ask": True, "template_languages": ["en", "zh", "es"]}, "email": {"smtp": None, "sender_name": "", "notify_emails": []}, "push": {"enabled": False, "url": "", "api_key": "", "prefix": "", "timeout": 10, "max_attempts": 3, "retry_backoff_base": 1.0}, "ai": {"provider": "glm", "api_key": None, "base_url": None, "model": "glm-4-flash"}, "engine": {"context_seed_keys": {}, "rate_limit_per_hour": 30}, "misc": {"name_to_region_extras": {}}, } def deep_merge(base: dict, override: dict) -> dict: """override 逐层覆盖 base;dict 递归合并,其余类型整体替换。不修改入参。""" out = copy.deepcopy(base) for k, v in (override or {}).items(): if isinstance(v, dict) and isinstance(out.get(k), dict): out[k] = deep_merge(out[k], v) else: out[k] = copy.deepcopy(v) return out