fix:maibot内部配置字段在amem中过滤
This commit is contained in:
@@ -20,6 +20,8 @@ if TYPE_CHECKING:
|
||||
|
||||
logger = get_logger("a_memorix.host_service")
|
||||
|
||||
_INTERNAL_CONFIG_FIELDS = {"field_docs", "_validate_any", "suppress_any_warning"}
|
||||
|
||||
|
||||
def _get_config_manager():
|
||||
from src.config.config import config_manager
|
||||
@@ -47,6 +49,18 @@ def _to_builtin_data(obj: Any) -> Any:
|
||||
return obj
|
||||
|
||||
|
||||
def _strip_internal_config_fields(obj: Any) -> Any:
|
||||
if isinstance(obj, dict):
|
||||
return {
|
||||
str(key): _strip_internal_config_fields(value)
|
||||
for key, value in obj.items()
|
||||
if str(key) not in _INTERNAL_CONFIG_FIELDS
|
||||
}
|
||||
if isinstance(obj, list):
|
||||
return [_strip_internal_config_fields(value) for value in obj]
|
||||
return obj
|
||||
|
||||
|
||||
def _backup_config_file(path: Path) -> Optional[Path]:
|
||||
if not path.exists():
|
||||
return None
|
||||
@@ -309,13 +323,15 @@ class AMemorixHostService:
|
||||
web_config = payload.get("web")
|
||||
if isinstance(web_config, dict) and "import_config" in web_config:
|
||||
web_config["import"] = web_config.pop("import_config")
|
||||
return _to_builtin_data(payload) if isinstance(payload, dict) else {}
|
||||
payload = _to_builtin_data(payload) if isinstance(payload, dict) else {}
|
||||
return _strip_internal_config_fields(payload) if isinstance(payload, dict) else {}
|
||||
|
||||
@staticmethod
|
||||
def _runtime_dict_to_bot_config_dict(config: Dict[str, Any]) -> Dict[str, Any]:
|
||||
payload = _to_builtin_data(config)
|
||||
if not isinstance(payload, dict):
|
||||
return {}
|
||||
payload = _strip_internal_config_fields(payload)
|
||||
web_config = payload.get("web")
|
||||
if isinstance(web_config, dict) and "import_config" in web_config and "import" not in web_config:
|
||||
web_config["import"] = web_config.pop("import_config")
|
||||
|
||||
Reference in New Issue
Block a user