23 lines
883 B
Python
23 lines
883 B
Python
from __future__ import annotations
|
|
|
|
from memory_gateway_plugin.config import PluginConfig
|
|
from memory_gateway_plugin.policy import should_append_episode, should_commit_session, should_search_memory
|
|
|
|
|
|
def test_policy_should_append_for_explicit_remember():
|
|
assert should_append_episode("请记住:我偏好中文技术说明。", "", {}, PluginConfig())
|
|
|
|
|
|
def test_policy_should_not_append_for_small_talk():
|
|
assert not should_append_episode("你好", "", {}, PluginConfig())
|
|
|
|
|
|
def test_policy_should_search_when_enabled():
|
|
assert should_search_memory("这个项目之前有什么约束?", {}, PluginConfig(auto_search=True))
|
|
|
|
|
|
def test_policy_should_commit_only_when_enabled_or_forced():
|
|
assert not should_commit_session({}, PluginConfig(auto_commit_session=False))
|
|
assert should_commit_session({"force_commit": True}, PluginConfig(auto_commit_session=False))
|
|
|