Skip to content

Commit d7bd0a8

Browse files
committed
fix(memory): Replace the outdated manual way of creating the ChatMemoryRepository
- Update the document information and replace the unavailable creation method of ChatMemoryRepository. - Increase the create function to create Neo4jChatMemoryRepository, this way to manually create the way. Signed-off-by: Caiyu Liu <[email protected]>
1 parent d8c728e commit d7bd0a8

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

auto-configurations/models/chat/memory/repository/spring-ai-autoconfigure-model-chat-memory-repository-neo4j/src/main/java/org/springframework/ai/model/chat/memory/repository/neo4j/autoconfigure/Neo4jChatMemoryRepositoryAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public Neo4jChatMemoryRepository neo4jChatMemoryRepository(Neo4jChatMemoryReposi
5353
.withToolResponseLabel(properties.getToolResponseLabel())
5454
.withDriver(driver);
5555

56-
return new Neo4jChatMemoryRepository(builder.build());
56+
return Neo4jChatMemoryRepository.create(builder.build());
5757
}
5858

5959
}

memory/repository/spring-ai-model-chat-memory-repository-neo4j/src/main/java/org/springframework/ai/chat/memory/repository/neo4j/Neo4jChatMemoryRepository.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public Neo4jChatMemoryRepository(Neo4jChatMemoryRepositoryConfig config) {
5656
this.config = config;
5757
}
5858

59+
public static Neo4jChatMemoryRepository create(Neo4jChatMemoryRepositoryConfig conf) {
60+
return new Neo4jChatMemoryRepository(conf);
61+
}
62+
5963
@Override
6064
public List<String> findConversationIds() {
6165
return this.config.getDriver()

memory/repository/spring-ai-model-chat-memory-repository-neo4j/src/test/java/org/springframework/ai/chat/memory/repository/neo4j/Neo4jChatMemoryRepositoryIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Neo4jChatMemoryRepositoryIT {
7777
void setUp() {
7878
this.driver = Neo4jDriverFactory.create(neo4jContainer.getBoltUrl());
7979
this.config = Neo4jChatMemoryRepositoryConfig.builder().withDriver(this.driver).build();
80-
this.chatMemoryRepository = new Neo4jChatMemoryRepository(this.config);
80+
this.chatMemoryRepository = Neo4jChatMemoryRepository.create(this.config);
8181
}
8282

8383
@AfterEach

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat-memory.adoc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ If you'd rather create the `CassandraChatMemoryRepository` manually, you can do
222222
[source,java]
223223
----
224224
ChatMemoryRepository chatMemoryRepository = CassandraChatMemoryRepository
225-
.create(CassandraChatMemoryConfig.builder().withCqlSession(cqlSession));
225+
.create(CassandraChatMemoryRepositoryConfig.builder().withCqlSession(cqlSession).build());
226226
227227
ChatMemory chatMemory = MessageWindowChatMemory.builder()
228228
.chatMemoryRepository(chatMemoryRepository)
@@ -296,9 +296,8 @@ If you'd rather create the `Neo4jChatMemoryRepository` manually, you can do so b
296296

297297
[source,java]
298298
----
299-
ChatMemoryRepository chatMemoryRepository = Neo4jChatMemoryRepository.builder()
300-
.driver(driver)
301-
.build();
299+
ChatMemoryRepository chatMemoryRepository = Neo4jChatMemoryRepository
300+
.create(Neo4jChatMemoryRepositoryConfig.builder().withDriver(driver).build());
302301
303302
ChatMemory chatMemory = MessageWindowChatMemory.builder()
304303
.chatMemoryRepository(chatMemoryRepository)

0 commit comments

Comments
 (0)