添加dateIndex(记忆切片的日期索引)、dialogMap(近期对话缓存)、staticMemory(确定性记忆)等字段,并实现相关更新操作;

调整了MemorySlice中的部分结构;
添加了必要的注释;
This commit is contained in:
2025-04-10 17:51:01 +08:00
parent d75f83b1a2
commit 24d4510270
7 changed files with 125 additions and 33 deletions

View File

@@ -124,7 +124,6 @@ public class InsertTest {
private MemorySlice createTestMemorySlice(String id) {
MemorySlice slice = new MemorySlice();
slice.setMemoryId(id);
slice.setMemoryRank(1);
// 可以设置其他必要属性
return slice;
}
@@ -134,7 +133,6 @@ public class InsertTest {
// 构造 MemorySlice
MemorySlice slice = new MemorySlice();
slice.setMemoryId("001");
slice.setMemoryRank(5);
slice.setSlicePath("/demo/path");
List<String> topicPath = Arrays.asList("生活", "学习", "Java");
@@ -162,7 +160,6 @@ public class InsertTest {
// 校验MemorySlice 内容一致
MemorySlice deserializedSlice = javaNode.getMemoryNodes().get(0).getMemorySliceList().get(0);
assertEquals("001", deserializedSlice.getMemoryId());
assertEquals(Integer.valueOf(5), deserializedSlice.getMemoryRank());
assertEquals("/demo/path", deserializedSlice.getSlicePath());
}

View File

@@ -57,7 +57,7 @@ class SearchTest {
List<String> queryPath = new ArrayList<>();
queryPath.add("算法");
queryPath.add("排序");
List<MemorySlice> results = memoryGraph.selectMemory(queryPath);
List<MemorySlice> results = memoryGraph.selectMemoryByPath(queryPath);
// 验证结果应包含:
// 1. 目标节点所有记忆java1
@@ -75,7 +75,7 @@ class SearchTest {
invalidPath.add("不存在的主题");
assertThrows(UnExistedTopicException.class, () -> {
memoryGraph.selectMemory(invalidPath);
memoryGraph.selectMemoryByPath(invalidPath);
});
}
@@ -92,7 +92,7 @@ class SearchTest {
List<String> queryPath = new ArrayList<>();
queryPath.add("编程");
queryPath.add("Java");
List<MemorySlice> results = memoryGraph.selectMemory(queryPath);
List<MemorySlice> results = memoryGraph.selectMemoryByPath(queryPath);
// 应包含Java记忆 + 父级最新记忆
assertTrue(results.stream().anyMatch(m -> "java1".equals(m.getMemoryId())));
@@ -134,7 +134,7 @@ class SearchTest {
// 执行查询
List<String> queryPath = createTopicPath("编程", "Java");
List<MemorySlice> results = memoryGraph.selectMemory(queryPath);
List<MemorySlice> results = memoryGraph.selectMemoryByPath(queryPath);
// 验证结果应包含最新关联记忆dbNew
assertTrue(results.stream().anyMatch(m -> "dbNew".equals(m.getMemoryId())),
@@ -152,7 +152,6 @@ class SearchTest {
private MemorySlice createMemorySlice(String id) {
MemorySlice slice = new MemorySlice();
slice.setMemoryId(id);
slice.setMemoryRank(1);
return slice;
}