fix: MEMORY.md补全现金铁律+报告规则, guardian支持模式清理
This commit is contained in:
@@ -70,13 +70,56 @@ def check_memory_tool():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def cleanup_known_patterns():
|
||||||
|
"""通过gateway API自动清理已知的profile专属memory条目"""
|
||||||
|
patterns = [
|
||||||
|
"Dad 会直接报自己的现金余额",
|
||||||
|
"Dad confirmed workflow",
|
||||||
|
"报告前必须手算验算",
|
||||||
|
"LLM cron delivery diagnosis",
|
||||||
|
"现金当前分三级",
|
||||||
|
"止盈来自技术阻力位",
|
||||||
|
"现金铁律:load_cash",
|
||||||
|
"报告分层规则",
|
||||||
|
"自愈系统核心规则",
|
||||||
|
]
|
||||||
|
cleaned = 0
|
||||||
|
for p in patterns:
|
||||||
|
try:
|
||||||
|
# 通过memory tool API清理:用hermes chat调memory工具
|
||||||
|
# 但因为no_agent脚本没有hermes工具,只能通过gateway
|
||||||
|
import urllib.request
|
||||||
|
payload = json.dumps({
|
||||||
|
"model": "default",
|
||||||
|
"messages": [{"role": "user",
|
||||||
|
"content": f"执行 memory(action='remove', target='memory', old_text='{p}') 不要回复"}],
|
||||||
|
"max_tokens": 10,
|
||||||
|
}).encode()
|
||||||
|
req = urllib.request.Request(
|
||||||
|
"http://localhost:8643/v1/chat/completions",
|
||||||
|
data=payload,
|
||||||
|
headers={"Content-Type": "application/json",
|
||||||
|
"Authorization": "Bearer hermes123",
|
||||||
|
"X-Hermes-Session-Id": "memory-guardian-cleanup"}
|
||||||
|
)
|
||||||
|
resp = urllib.request.urlopen(req, timeout=60)
|
||||||
|
cleaned += 1
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return cleaned
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print(f"记忆守卫 | {datetime.now().strftime('%Y-%m-%d %H:%M')}")
|
print(f"记忆守卫 | {datetime.now().strftime('%Y-%m-%d %H:%M')}")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
check_memory_md()
|
check_memory_md()
|
||||||
check_shared_memory()
|
check_shared_memory()
|
||||||
check_memory_tool()
|
|
||||||
|
# 自动清理已知模式
|
||||||
|
n = cleanup_known_patterns()
|
||||||
|
if n > 0:
|
||||||
|
print(f" 🧹 自动清理了 {n} 条profile专属memory(已迁到MEMORY.md)")
|
||||||
|
|
||||||
if ISSUES:
|
if ISSUES:
|
||||||
print()
|
print()
|
||||||
|
|||||||
Reference in New Issue
Block a user