fix: 默认关闭 A_Memorix 运行时#1623
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
概览通过修改配置架构和宿主服务,实现了 A_Memorix 的禁用功能。配置默认值变更为禁用状态,服务层添加了启用状态检查逻辑,防止禁用时的初始化和内核操作。 变更A_Memorix 启用/禁用功能
序列图sequenceDiagram
actor Client
participant Service as AMemorixHostService
participant Config as Config
participant Kernel as Kernel
Client->>Service: invoke(component)
activate Service
Service->>Service: is_enabled()
Service->>Config: 检查 plugin.enabled
Config-->>Service: false (禁用)
Service->>Service: _disabled_response(component)
Service-->>Client: {"status": "disabled", ...}
deactivate Service
预估代码审查工作量🎯 3 (中等复杂度) | ⏱️ ~25 分钟 ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
Pull request overview
该 PR 旨在让 A_Memorix 长期记忆运行时在默认情况下保持关闭,并在配置未启用时避免初始化与调用内核,从而降低首次使用/未配置 embedding 时的启动与运行成本。
Changes:
- 在运行时启动、重载与调用入口处增加“未启用则跳过/短路返回”的逻辑
- 新增统一的
is_enabled()/_is_enabled_config()开关判定与禁用态响应 - 将
config_schema.json中plugin.enabled默认值改为false,并补充 UI 提示
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/A_memorix/host_service.py |
增加启用开关判断、禁用态短路与返回结构,避免在未启用时初始化 kernel |
src/A_memorix/config_schema.json |
将 A_Memorix 启用开关默认值改为关闭,并更新提示文案 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return True | ||
| return bool(plugin_config.get("enabled", True)) |
| if component_name == "memory_stats": | ||
| return { | ||
| "success": True, | ||
| "enabled": False, | ||
| "disabled": True, | ||
| "reason": reason, | ||
| "message": message, | ||
| "paragraph_count": 0, | ||
| "relation_count": 0, | ||
| "episode_count": 0, | ||
| } |
| "disabled": True, | ||
| "reason": reason, | ||
| "stored_ids": [], | ||
| "skipped_ids": [reason], |
| @@ -57,9 +60,13 @@ async def stop(self) -> None: | |||
| async def reload(self) -> None: | |||
| async with self._lock: | |||
| await self._shutdown_locked() | |||
| self._config_cache = self._read_config() | |||
| self._config_cache = None | |||
| config = self._read_config() | |||
|
|
|||
| await self._ensure_kernel() | |||
| if self._is_enabled_config(config): | |||
| await self._ensure_kernel() | |||
| else: | |||
| logger.info("A_Memorix 配置为未启用,运行时保持关闭") | |||
zh-CN目标翻译作为常规 GitHub 编辑面;常规翻译以 Crowdin ->l10n_*PR 回流为准,详见docs/i18n.md请填写以下内容
(删除掉中括号内的空格,并替换为小写的x)
main分支 禁止修改,请确认本次提交的分支 不是main分支src/A_memorix,我确认已阅读src/A_memorix/MODIFICATION_POLICY.md,不涉及则无需勾选其他信息
Summary by CodeRabbit
配置变更
改进