From 0bb65db27c632ae0d15cc7ac44cbcc614c0d2a43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=94=AF=20A06?= Date: Sat, 5 Sep 2026 11:07:42 +0800 Subject: [PATCH] =?UTF-8?q?chore(scripts):=20=E8=85=BE=E8=AE=AFdb=E5=BD=BB?= =?UTF-8?q?=E5=BA=95=E9=80=80=E5=BD=B9=20=E2=80=94=20MEMORY=5FRECALL=5FSPE?= =?UTF-8?q?C.md=20=E5=BD=92=E6=A1=A3=20.archive/=EF=BC=8C=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=20memory-system-check/self-upgrade/distill-watchdog/m?= =?UTF-8?q?odel-health=20=E5=85=A8=E9=83=A8=E8=85=BE=E8=AE=AFdb=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E6=AE=8B=E7=95=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/{ => .archive}/MEMORY_RECALL_SPEC.md | 0 scripts/distill-model-watchdog.py | 12 +----- scripts/memory-system-check.sh | 9 ----- scripts/memory-system-self-upgrade.py | 40 +------------------- scripts/model-health.py | 7 +--- 5 files changed, 4 insertions(+), 64 deletions(-) rename scripts/{ => .archive}/MEMORY_RECALL_SPEC.md (100%) diff --git a/scripts/MEMORY_RECALL_SPEC.md b/scripts/.archive/MEMORY_RECALL_SPEC.md similarity index 100% rename from scripts/MEMORY_RECALL_SPEC.md rename to scripts/.archive/MEMORY_RECALL_SPEC.md diff --git a/scripts/distill-model-watchdog.py b/scripts/distill-model-watchdog.py index 0b86df6c..85998bed 100644 --- a/scripts/distill-model-watchdog.py +++ b/scripts/distill-model-watchdog.py @@ -2,7 +2,7 @@ """ distill-model-watchdog.py — 蒸馏模型看门狗(30min 轻量探针) ============================================================ -守护对象: 织忆 distill (zhiyid.service LLM_MODEL) + TencentDB L1 (tdai-gateway.yaml model) +守护对象: 织忆 distill (zhiyid.service LLM_MODEL) 为什么需要: - model-health.py 每 6h 才跑,免费模型挂了要等半天 @@ -43,7 +43,6 @@ for _l in open(os.path.expanduser("~/.hermes/.env"), encoding="utf-8"): if _l.startswith("SENSENOVA_API_KEY=") and not _l.startswith("#"): SENSENOVA_KEY = _l.strip().split("=", 1)[1] ZHIYID_SERVICE = os.path.expanduser("~/.config/systemd/user/zhiyid.service") -TDDB_CONFIG = os.path.expanduser("~/.memory-tencentdb/memory-tdai/tdai-gateway.yaml") FEISHU_WEBHOOK = "https://open.feishu.cn/open-apis/bot/v2/hook/446db983-e392-4d2c-bfb8-f9060e5df3ad" # 候选池(优先级降序,2026-08-29 更新:本地 7B 首选,云 API 兜底) @@ -189,10 +188,6 @@ def _update_zhiyid(model: str) -> bool: print(f" ❌ 更新 zhiyid.service 失败: {e}") return False -def _update_tddb(model: str) -> bool: - """TencentDB 已退役(2026-09-05),tdai-gateway 停用,永不更新。""" - return False - def _feishu_alert(title: str, content: str): """飞书告警卡片""" try: @@ -261,15 +256,12 @@ def main(): print(msg) return - # 3. 更新两处配置 + # 3. 更新配置 z_ok = _update_zhiyid(replacement) - t_ok = _update_tddb(replacement) changed_parts = [] if z_ok: changed_parts.append("zhiyid.service") - if t_ok: - changed_parts.append("tdai-gateway.yaml") msg = f"**🔄 蒸馏模型已自动切换**\n\n⏰ {ts}\n`{current}` → `{replacement}`\n更新: {', '.join(changed_parts) if changed_parts else '无(配置已是最新)'}\n\n原因: 原模型 JSON 输出失败(免费模型挂了)" _feishu_alert("🔄 蒸馏模型自动切换", msg) diff --git a/scripts/memory-system-check.sh b/scripts/memory-system-check.sh index 147729ae..f7d7e209 100755 --- a/scripts/memory-system-check.sh +++ b/scripts/memory-system-check.sh @@ -130,14 +130,6 @@ for c in d.get('cares', []): fi } -# ── L3/L4 TencentDB(已退役 2026-09-05,跳过)───────────── -check_tddb() { - # 2026-09-05 TencentDB 退役:tdai-gateway disabled、8420 释放、数据归档 .memory-tencentdb.archive-20260905 - # daemon.py TDDB_ENABLED=False 短路,self-upgrade 跳过。此处不再检查,避免每小时假告警。 - log "[SKIP] TencentDB: 已退役 2026-09-05,不再自检" -} - - # ── CBM 代码记忆 ────────────────────────────────────────────── check_cbm() { local ok=true @@ -187,7 +179,6 @@ log "=== 记忆系统统一自检 $(date '+%Y-%m-%d %H:%M') ===" check_unified_layer check_zhiyi check_soulful -check_tddb check_cbm # ── 告警 ───────────────────────────────────────────────────── diff --git a/scripts/memory-system-self-upgrade.py b/scripts/memory-system-self-upgrade.py index 023f5b99..e3a53955 100644 --- a/scripts/memory-system-self-upgrade.py +++ b/scripts/memory-system-self-upgrade.py @@ -7,8 +7,7 @@ memory-system-self-upgrade.py — 记忆系统自我升级(方案A统一架构 1. L7 llm_context.json v2:验证 9 字段完整,distill_status 检查 2. 织忆(L1/L2):健康度 + pattern 节点增长 + 索引 3. Soulful(L5/L6):过期 cares 清理 + distilled_rules 补充 + 心迹去重 -4. TencentDB(L3/L4):capture 写入验证 + 数据量报告 -5. 统一写入优化报告到飞书 +4. 统一写入优化报告到飞书 """ import json, os, sys, subprocess from datetime import datetime, timezone, timedelta @@ -16,7 +15,6 @@ from datetime import datetime, timezone, timedelta HERMES = os.path.expanduser("~/.hermes") ZHIYI_URL = "http://127.0.0.1:7821" ZHIYI_KEY = "zhiyi-dev-key-2026" -TDDB_URL = "http://127.0.0.1:8420" FEISHU_WEBHOOK = "https://open.feishu.cn/open-apis/bot/v2/hook/446db983-e392-4d2c-bfb8-f9060e5df3ad" REPORT = [] # 收集升级报告 @@ -207,7 +205,6 @@ def upgrade_soulful(): log(f" Soulful 升级动作: {actions or '无需操作'}") return actions -# ── 3. TencentDB 自我升级 ──────────────────────────────────────────────────── # ── Phase 5: Consolidation 引擎 ───────────────────────────────────────────── def _consolidate_memories(): """ @@ -288,40 +285,6 @@ def _consolidate_memories(): return triggers -def upgrade_tddb(): - # TencentDB 已退役(2026-09-05):不再自检,返回空动作 - log("=== TencentDB 自检(已退役 2026-09-05,跳过)===") - return [] - - # Health - try: - req = urllib.request.Request(f"{TDDB_URL}/health", method="GET") - with urllib.request.urlopen(req, timeout=5) as resp: - health = json.loads(resp.read().decode()) - log(f" status: {health.get('status')}") - log(f" pipeline consumed: {health.get('pipeline_tasks', {}).get('consumed', '?')}") - except Exception as e: - REPORT.append(f"❌ TencentDB 健康检查失败: {e}") - return actions - - # L0/L1 count via search (total = L1 count; L0 not directly exposed) - try: - req = urllib.request.Request( - f"{TDDB_URL}/search/memories", - data=json.dumps({"query": "牧尘", "top_k": 3}).encode("utf-8"), - headers={"Content-Type": "application/json"}, - method="POST" - ) - with urllib.request.urlopen(req, timeout=5) as resp: - result = json.loads(resp.read().decode()) - total = result.get("total", 0) - log(f" total_memories={total}") - actions.append(f"总记忆={total}") - except Exception as e: - REPORT.append(f"❌ TencentDB 数据量检查失败: {e}") - - return actions - # ── 主流程 ────────────────────────────────────────────────────────────────── if __name__ == "__main__": log("记忆系统自我升级开始") @@ -347,7 +310,6 @@ if __name__ == "__main__": all_actions = {} all_actions["织忆"] = upgrade_zhiyi() all_actions["Soulful"] = upgrade_soulful() - all_actions["TencentDB"] = upgrade_tddb() all_actions["Consolidation"] = _consolidate_memories() # 汇总报告 diff --git a/scripts/model-health.py b/scripts/model-health.py index 201b7978..c177abd5 100755 --- a/scripts/model-health.py +++ b/scripts/model-health.py @@ -891,7 +891,7 @@ def main(): _heal_hardcoded_models() # ============ 蒸馏模型自愈(2026-08-02 新增)============ - # 守护 zhiyid.service LLM_MODEL + tdai-gateway.yaml model(织忆 distill + TencentDB L1) + # 守护 zhiyid.service LLM_MODEL(织忆 distill) # 注意:蒸馏需要 JSON 输出能力,不能只看"对话可用"——用 _verify_model_usable 之外 # 还要确认模型不是 reasoning 型(content=null)。这里直接复用本脚本的探针结果: # 若配置中的模型在 results 里非 stable,或结果缺失(未测试),则用 JSON 能力复核后替换。 @@ -899,7 +899,6 @@ def main(): def _heal_distill_models(): import re as _re zhiyid_svc = os.path.expanduser("~/.config/systemd/user/zhiyid.service") - tddb_cfg = os.path.expanduser("~/.memory-tencentdb/memory-tdai/tdai-gateway.yaml") if not os.path.exists(zhiyid_svc): return @@ -1027,10 +1026,6 @@ def main(): except Exception as e: print(f" ❌ [蒸馏] 更新 zhiyid.service 失败: {e}") - # TencentDB 已退役(2026-09-05):tdai-gateway.yaml 不再更新 - if os.path.exists(tddb_cfg): - print(f" [SKIP] tdai-gateway.yaml 已退役,跳过更新") - _heal_distill_models() print(f"\n{'='*50}")