72 lines
2.7 KiB
Python
72 lines
2.7 KiB
Python
import os, sys
|
|
os.environ['HERMES_HOME'] = '/home/muc/.hermes'
|
|
sys.path.insert(0, '/home/muc/.hermes/hermes-agent')
|
|
from plugins.memory.holographic.store import MemoryStore
|
|
from plugins.memory.holographic.retrieval import FactRetriever
|
|
|
|
DB = '/home/muc/.hermes/memory_store.db'
|
|
if os.path.exists(DB): os.remove(DB)
|
|
|
|
print("=" * 60)
|
|
print("HOLO Test - 9 actions + feedback")
|
|
print("=" * 60)
|
|
|
|
store = MemoryStore(DB)
|
|
retr = FactRetriever(store)
|
|
|
|
print("\n[1] ADD_FACT 5 facts")
|
|
f1 = store.add_fact("小唯喜欢 16yo 172cm porcelain skin 人物设定", category="preference")
|
|
f2 = store.add_fact("商汤 SenseNova 出图大于 Agnes", category="tool")
|
|
f3 = store.add_fact("删 skill 前必须经牧尘同意", category="rule")
|
|
f4 = store.add_fact("v0.21.0 已升级 gateway 跑通", category="event")
|
|
f5 = store.add_fact("KOCR 修复铁律:只动需要改的列", category="rule")
|
|
print(f"IDs: {[f1, f2, f3, f4, f5]}")
|
|
|
|
print("\n[2] LIST_FACTS")
|
|
for f in store.list_facts():
|
|
print(f" [{f['fact_id']}] trust={f['trust_score']:.2f} {f['category']}: {f['content'][:50]}")
|
|
|
|
print("\n[3] SEARCH 'KOCR'")
|
|
for r in retr.search("KOCR", limit=3):
|
|
print(f" [{r['fact_id']}] score={r.get('score',0):.3f}: {r['content'][:50]}")
|
|
|
|
print("\n[4] PROBE '人物设定'")
|
|
for r in retr.probe("人物设定", limit=3):
|
|
print(f" [{r['fact_id']}] score={r.get('score',0):.3f}: {r['content'][:50]}")
|
|
|
|
print("\n[5] RELATED 'KOCR'")
|
|
for r in retr.related("KOCR", limit=3):
|
|
print(f" [{r['fact_id']}]: {r['content'][:50]}")
|
|
|
|
print("\n[6] REASON ['人物设定', 'preference']")
|
|
for r in retr.reason(["人物设定", "preference"], limit=3):
|
|
print(f" [{r['fact_id']}] conf={r.get('confidence',0):.3f}: {r['content'][:50]}")
|
|
|
|
print("\n[7] CONTRADICT (scan all category=tool)")
|
|
f6 = store.add_fact("Agnes 出图比商汤好", category="tool")
|
|
contras = retr.contradict(category="tool", limit=5)
|
|
print(f" f6: {f6}, 矛盾扫描: {len(contras)}")
|
|
for c in contras[:5]:
|
|
print(f" [{c['fact_id']}]: {c['content'][:50]}")
|
|
|
|
print("\n[8] UPDATE_FACT f4 trust_delta -0.25")
|
|
print(f" Result: {store.update_fact(f4, trust_delta=-0.25)}")
|
|
|
|
print("\n[9] REMOVE_FACT f6")
|
|
print(f" Result: {store.remove_fact(f6)}")
|
|
|
|
print("\n[10] FEEDBACK f1 helpful=True")
|
|
print(f" Result: {store.record_feedback(f1, helpful=True)}")
|
|
|
|
print("\n[11] FEEDBACK f2 helpful=False")
|
|
print(f" Result: {store.record_feedback(f2, helpful=False)}")
|
|
|
|
print("\n" + "=" * 60)
|
|
print("FINAL (含 trust 变化)")
|
|
print("=" * 60)
|
|
for f in store.list_facts():
|
|
print(f" [{f['fact_id']}] trust={f['trust_score']:.2f} help={f['helpful_count']}: {f['content'][:50]}")
|
|
print(f"\nTotal: {len(store.list_facts())} facts")
|
|
print(f"DB size: {os.path.getsize(DB)} bytes")
|
|
store.close()
|