Skip to content

Commit 9ff6d3b

Browse files
ThomasVitalemarkpollack
authored andcommitted
Update memory docs and ensure consistent naming
Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
1 parent f5f0212 commit 9ff6d3b

File tree

5 files changed

+29
-26
lines changed

5 files changed

+29
-26
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/Neo4jChatMemoryRepositoryProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
@ConfigurationProperties(Neo4jChatMemoryRepositoryProperties.CONFIG_PREFIX)
2828
public class Neo4jChatMemoryRepositoryProperties {
2929

30-
public static final String CONFIG_PREFIX = "spring.ai.chat.memory.neo4j";
30+
public static final String CONFIG_PREFIX = "spring.ai.chat.memory.repository.neo4j";
3131

3232
private String sessionLabel = Neo4jChatMemoryRepositoryConfig.DEFAULT_SESSION_LABEL;
3333

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void setCustomConfiguration() {
140140
final String toolResponseLabel = "LabelToolResponse";
141141
final String mediaLabel = "LabelMedia";
142142

143-
final String propertyBase = "spring.ai.chat.memory.neo4j.%s=%s";
143+
final String propertyBase = "spring.ai.chat.memory.repository.neo4j.%s=%s";
144144
this.contextRunner
145145
.withPropertyValues("spring.neo4j.uri=" + neo4jContainer.getBoltUrl(),
146146
propertyBase.formatted("sessionlabel", sessionLabel),

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Maven::
7878
----
7979
<dependency>
8080
<groupId>org.springframework.ai</groupId>
81-
<artifactId>spring-ai-starter-model-chat-memory-jdbc</artifactId>
81+
<artifactId>spring-ai-starter-model-chat-memory-repository-jdbc</artifactId>
8282
</dependency>
8383
----
8484
@@ -87,7 +87,7 @@ Gradle::
8787
[source,groovy]
8888
----
8989
dependencies {
90-
implementation 'org.springframework.ai:spring-ai-starter-model-chat-memory-jdbc'
90+
implementation 'org.springframework.ai:spring-ai-starter-model-chat-memory-repository-jdbc'
9191
}
9292
----
9393
======
@@ -105,13 +105,13 @@ ChatMemory chatMemory = MessageWindowChatMemory.builder()
105105
.build();
106106
----
107107

108-
If you'd rather create the `JdbcChatMemoryRepository` manually, you can do so by providing a `JdbcTemplate` instance and optionally a custom `JdbcChatMemoryRepositoryDialect`:
108+
If you'd rather create the `JdbcChatMemoryRepository` manually, you can do so by providing a `JdbcTemplate` instance and a `JdbcChatMemoryRepositoryDialect`:
109109

110110
[source,java]
111111
----
112112
ChatMemoryRepository chatMemoryRepository = JdbcChatMemoryRepository.builder()
113113
.jdbcTemplate(jdbcTemplate)
114-
.dialect(new PostgresChatMemoryDialect()) // Optional: custom dialect, auto-detected by default
114+
.dialect(new PostgresChatMemoryDialect())
115115
.build();
116116
117117
ChatMemory chatMemory = MessageWindowChatMemory.builder()
@@ -129,7 +129,7 @@ Spring AI supports multiple relational databases via a dialect abstraction. The
129129
- SQL Server
130130
- HSQLDB
131131

132-
The correct dialect is auto-detected from the JDBC URL. You can extend support for other databases by implementing the `JdbcChatMemoryRepositoryDialect` interface.
132+
The correct dialect can be auto-detected from the JDBC URL when using `JdbcChatMemoryRepositoryDialect.from(DataSource)`. You can extend support for other databases by implementing the `JdbcChatMemoryRepositoryDialect` interface.
133133

134134
==== Configuration Properties
135135

@@ -138,6 +138,7 @@ The correct dialect is auto-detected from the JDBC URL. You can extend support f
138138
|Property | Description | Default Value
139139
| `spring.ai.chat.memory.repository.jdbc.initialize-schema` | Controls when to initialize the schema. Values: `embedded` (default), `always`, `never`. | `embedded`
140140
| `spring.ai.chat.memory.repository.jdbc.schema` | Location of the schema script to use for initialization. Supports `classpath:` URLs and platform placeholders. | `classpath:org/springframework/ai/chat/memory/repository/jdbc/schema-@@platform@@.sql`
141+
| `spring.ai.chat.memory.repository.jdbc.platform` | Platform to use in initialization scripts if the @@platform@@ placeholder is used. | _auto-detected_
141142
|===
142143

143144
==== Schema Initialization
@@ -189,7 +190,7 @@ Maven::
189190
----
190191
<dependency>
191192
<groupId>org.springframework.ai</groupId>
192-
<artifactId>spring-ai-starter-model-chat-memory-cassandra</artifactId>
193+
<artifactId>spring-ai-starter-model-chat-memory-repository-cassandra</artifactId>
193194
</dependency>
194195
----
195196
@@ -198,7 +199,7 @@ Gradle::
198199
[source,groovy]
199200
----
200201
dependencies {
201-
implementation 'org.springframework.ai:spring-ai-starter-model-chat-memory-cassandra'
202+
implementation 'org.springframework.ai:spring-ai-starter-model-chat-memory-repository-cassandra'
202203
}
203204
----
204205
======
@@ -239,6 +240,7 @@ ChatMemory chatMemory = MessageWindowChatMemory.builder()
239240
| `spring.cassandra.localDatacenter` | Cassandra datacenter to connect to | `datacenter1`
240241
| `spring.ai.chat.memory.cassandra.time-to-live` | Time to live (TTL) for messages written in Cassandra |
241242
| `spring.ai.chat.memory.cassandra.keyspace` | Cassandra keyspace | `springframework`
243+
| `spring.ai.chat.memory.cassandra.messages-column` | Cassandra column name for messages | `springframework`
242244
| `spring.ai.chat.memory.cassandra.table` | Cassandra table | `ai_chat_memory`
243245
| `spring.ai.chat.memory.cassandra.initialize-schema` | Whether to initialize the schema on startup. | `true`
244246
|===
@@ -263,7 +265,7 @@ Maven::
263265
----
264266
<dependency>
265267
<groupId>org.springframework.ai</groupId>
266-
<artifactId>spring-ai-starter-model-chat-memory-neo4j</artifactId>
268+
<artifactId>spring-ai-starter-model-chat-memory-repository-neo4j</artifactId>
267269
</dependency>
268270
----
269271
@@ -272,7 +274,7 @@ Gradle::
272274
[source,groovy]
273275
----
274276
dependencies {
275-
implementation 'org.springframework.ai:spring-ai-starter-model-chat-memory-neo4j'
277+
implementation 'org.springframework.ai:spring-ai-starter-model-chat-memory-repository-neo4j'
276278
}
277279
----
278280
======
@@ -309,12 +311,12 @@ ChatMemory chatMemory = MessageWindowChatMemory.builder()
309311
[cols="2,5,1",stripes=even]
310312
|===
311313
|Property | Description | Default Value
312-
| `spring.ai.chat.memory.neo4j.sessionLabel` | The label for the nodes that store conversation sessions | `Session`
313-
| `spring.ai.chat.memory.neo4j.messageLabel` | The label for the nodes that store messages | `Message`
314-
| `spring.ai.chat.memory.neo4j.toolCallLabel` | The label for nodes that store tool calls (e.g. in Assistant Messages) | `ToolCall`
315-
| `spring.ai.chat.memory.neo4j.metadataLabel` | The label for nodes that store message metadata | `Metadata`
316-
| `spring.ai.chat.memory.neo4j.toolResponseLabel` | The label for the nodes that store tool responses | `ToolResponse`
317-
| `spring.ai.chat.memory.neo4j.mediaLabel` | The label for the nodes that store media associated with a message | `Media`
314+
| `spring.ai.chat.memory.repository.neo4j.sessionLabel` | The label for the nodes that store conversation sessions | `Session`
315+
| `spring.ai.chat.memory.repository.neo4j.messageLabel` | The label for the nodes that store messages | `Message`
316+
| `spring.ai.chat.memory.repository.neo4j.toolCallLabel` | The label for nodes that store tool calls (e.g. in Assistant Messages) | `ToolCall`
317+
| `spring.ai.chat.memory.repository.neo4j.metadataLabel` | The label for nodes that store message metadata | `Metadata`
318+
| `spring.ai.chat.memory.repository.neo4j.toolResponseLabel` | The label for the nodes that store tool responses | `ToolResponse`
319+
| `spring.ai.chat.memory.repository.neo4j.mediaLabel` | The label for the nodes that store media associated with a message | `Media`
318320
|===
319321

320322
==== Index Initialization
@@ -352,7 +354,7 @@ String conversationId = "007";
352354
353355
chatClient.prompt()
354356
.user("Do I have license to code?")
355-
.advisors(a -> a.param(AbstractChatMemoryAdvisor.CHAT_MEMORY_CONVERSATION_ID_KEY, conversationId))
357+
.advisors(a -> a.param(ChatMemory.CONVERSATION_ID, conversationId))
356358
.call()
357359
.content();
358360
----

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,8 @@ ChatClient.builder(chatModel)
542542
.build()
543543
.prompt()
544544
.advisors(
545-
new MessageChatMemoryAdvisor(chatMemory),
546-
new QuestionAnswerAdvisor(vectorStore)
545+
MessageChatMemoryAdvisor.builder(chatMemory).build(),
546+
QuestionAnswerAdvisor.builder(vectorStore).build()
547547
)
548548
.user(userText)
549549
.call()
@@ -611,13 +611,12 @@ TIP: Be cautious about logging sensitive information in production environments.
611611

612612
== Chat Memory
613613

614-
The interface `ChatMemory` represents a storage for chat conversation history. It provides methods to add messages to a conversation, retrieve messages from a conversation, and clear the conversation history.
614+
The interface `ChatMemory` represents a storage for chat conversation memory. It provides methods to add messages to a conversation, retrieve messages from a conversation, and clear the conversation history.
615615

616-
There is currently one implementation: `MessageWindowChatMemory`.
616+
There is currently one built-in implementation: `MessageWindowChatMemory`.
617617

618618
`MessageWindowChatMemory` is a chat memory implementation that maintains a window of messages up to a specified maximum size (default: 20 messages). When the number of messages exceeds this limit, older messages are evicted, but system messages are preserved. If a new system message is added, all previous system messages are removed from memory. This ensures that the most recent context is always available for the conversation while keeping memory usage bounded.
619619

620+
The `MessageWindowChatMemory` is backed by the `ChatMemoryRepository` abstraction which provides storage implementations for the chat conversation memory. There are several implementations available, including the `InMemoryChatMemoryRepository`, `JdbcChatMemoryRepository`, `CassandraChatMemoryRepository` and `Neo4jChatMemoryRepository`.
620621

621-
The `MessageWindowChatMemory` is backed by the `ChatMemoryRepository` abstraction which provides storage implementations for the chat conversation history. There are several implementations available, including the `InMemoryChatMemoryRepository`, `JdbcChatMemoryRepository`, `CassandraChatMemoryRepository` and `Neo4jChatMemoryRepository`.
622-
623-
This implementation is the default for conversation history management in Spring AI. For more details and usage examples, see the xref:api/chat-memory.adoc[Chat Memory] section.
622+
For more details and usage examples, see the xref:api/chat-memory.adoc[Chat Memory] documentation.

spring-ai-docs/src/main/antora/modules/ROOT/pages/upgrade-notes.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ For details, refer to:
2929
[[upgrading-to-1-0-0-RC1]]
3030
== Upgrading to 1.0.0-RC1
3131

32-
=== Chat ClientAnd Advisors
32+
=== Chat Client and Advisors
3333

3434
* When building a `Prompt` from the ChatClient input, the `SystemMessage` built from `systemText()` is now placed first in the message list. Before, it was put last, resulting in errors with several model providers.
3535
* `MessageAggregator` has a new method to aggregate messages from `ChatClientRequest`. The previous method aggregating messages from the old `AdvisedRequest` has been removed, since it was already marked as deprecated in M8.
@@ -60,6 +60,7 @@ If you were providing custom templates for the following advisors, you'll need t
6060
** a `long_term_memory` placeholder to receive the retrieved conversation memory.
6161

6262
=== Breaking Changes
63+
6364
The Watson AI model was removed as it was based on the older text generation that is considered outdated as there is a new chat generation model available.
6465
Hopefully Watson will reappear in a future version of Spring AI
6566

@@ -82,6 +83,7 @@ In 1.0.0-RC1, the chat memory modules, starters, and autoconfiguration classes f
8283

8384
- Java packages now use `.repository.` (e.g., `org.springframework.ai.chat.memory.repository.jdbc.JdbcChatMemoryRepository` and `org.springframework.ai.model.chat.memory.repository.jdbc.autoconfigure.JdbcChatMemoryRepositoryAutoConfiguration`).
8485
- Main autoconfiguration classes are now named `JdbcChatMemoryRepositoryAutoConfiguration`, `CassandraChatMemoryRepositoryAutoConfiguration`, etc.
86+
- Properties have also been renamed to reflect the new naming convention, from `spring.ai.chat.memory.<storage>...` to `spring.ai.chat.memory.repository.<storage>...`.
8587

8688
**Migration Required:**
8789
- Update your Maven/Gradle dependencies to use the new artifact IDs.

0 commit comments

Comments
 (0)