8a16a2959b
- characterization:显式 None 整体替换且兄弟键保留默认(Task 9 回退契约依赖);列表整体替换不与默认拼接 - DEFAULT_CONFIG 与 TenantConfig.data/Site.brand 补只读约定注释 - platform 包依赖章程改明确:defaults/tenant_config 为叶子模块供 engine 反向消费,registry 组装层可 import app/engine Co-Authored-By: Claude Code <noreply@anthropic.com>
32 lines
1.4 KiB
Python
32 lines
1.4 KiB
Python
"""出厂默认配置。结构 = spec §5.1 的 9 个配置组。
|
|
本阶段 brand/wall 的默认值由 Task 4 从 jc 代码提取填充。
|
|
只读约定:消费者不得修改本 dict,需要定制走 deep_merge 拷贝。"""
|
|
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
|