sync: 鍚屾灞€鍩熺綉鏈€鏂颁唬鐮?(source master @ b69568e4)
This commit is contained in:
1 parent
4f7f07504a
commit
8bc8b0e082
1651 files changed
+278599
-11416
No files matched your search
@@ -12,8 +12,11 @@
|
||||
injection: {...} # 系统提示词注入
|
||||
security: {...} # 内容安全扫描
|
||||
|
||||
两层配置覆盖
|
||||
============
|
||||
运行时总开关与配置覆盖
|
||||
======================
|
||||
管理员维护的 ``system_settings.json -> memory.enabled`` 是权威总开关,默认
|
||||
``false``。关闭时下面所有 provider 参数都不生效。
|
||||
|
||||
``get_effective_memory_config(user_id)`` 按优先级合并 (高 -> 低):
|
||||
1. per-user 覆盖 数据库 ``user_memory_configs`` 表 (经进程内 cache 读取)
|
||||
(有 per-user 记录时自动强制 enabled=True)
|
||||
@@ -32,6 +35,8 @@ from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from deerflow.config.system_settings import get_memory_runtime_settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -126,7 +131,7 @@ class V1MemoryConfig(BaseModel):
|
||||
class MemoryConfig(BaseModel):
|
||||
"""记忆子系统的全局配置 (config.yaml 的 ``memory:`` 段)。"""
|
||||
|
||||
enabled: bool = Field(default=True, description="记忆子系统总开关")
|
||||
enabled: bool = Field(default=False, description="记忆子系统总开关")
|
||||
version: str = Field(
|
||||
default="v2",
|
||||
description="记忆系统版本:v1(原版 DeerFlow,memory.json + LLM 自动提取) 或 v2(USER.md/MEMORY.md)",
|
||||
@@ -253,10 +258,18 @@ def get_recall_budget_from_cache(user_id: str) -> str | None:
|
||||
def get_effective_memory_config(user_id: str) -> MemoryConfig:
|
||||
"""返回某用户的生效记忆配置 (同步,从进程内 cache 读取 per-user 覆盖)。
|
||||
|
||||
优先级 (高 -> 低):per-user DB 覆盖 (经 cache) > config.yaml > 默认值。
|
||||
有 per-user 记录时自动强制 enabled=True。
|
||||
管理员运行时总开关关闭时直接返回 ``enabled=False``;开启后再按
|
||||
per-user DB 覆盖 (经 cache) > config.yaml > 默认值 合并参数。
|
||||
"""
|
||||
# The admin-managed runtime switch is authoritative and defaults to off.
|
||||
# ``config.yaml`` supplies provider parameters only; it cannot silently
|
||||
# turn memory on after a fresh deployment or settings-file reset.
|
||||
runtime_enabled = get_memory_runtime_settings().enabled
|
||||
if not runtime_enabled:
|
||||
return _memory_config.model_copy(update={"enabled": False}, deep=True)
|
||||
|
||||
base = _memory_config.model_dump()
|
||||
base["enabled"] = True
|
||||
recall_budget = _recall_budget_cache.get(user_id)
|
||||
if recall_budget is not None:
|
||||
base.setdefault("hindsight", {})["recall_budget"] = recall_budget
|
||||
|
||||
Reference in new issue
Block a user