Commit 918b788
committed
Chat Memory Enhancements
* ChatMemory will become a generic interface to implement different memory management strategies. It’s been moved from the “”spring-ai-client-chat” package to “spring-ai-model” package while retaining the same package, so it’s transparent to users.
* A MessageWindowChatMemory has been introduced to provide support for a chat memory that keeps at most N messages in the memory.
* A ChatMemoryRepository interface has been introduced to support different storage strategies for the chat memory. It’s meant to be used as part of a ChatMemory implementation. This is different than before, where the storage-specific implementation was directly tied to the ChatMemory. This design is familiar to Spring users since it’s used already in the ecosystem. The goal was to use a programming model similar to Spring Session and Spring Data.
* The JdbcChatMemory has been supersed by JdbcChatMemoryRepository.
* A ChatMemory bean is auto-configured for you whenever using one of the Spring AI Model starters. By default, it uses the MessageWindowChatMemory implementation and stores the conversation history in memory. If a different repository is already configured (e.g., Cassandra, JDBC, or Neo4j), Spring AI will use that instead.
* First-class documentation has been introduced to describe the ChatMemory API and related features.
* All the changes introduced in this PR are backward-compatible.
Signed-off-by: Thomas Vitale <[email protected]>1 parent 2bc29da commit 918b788
File tree
62 files changed
+2200
-151
lines changed- auto-configurations/models/chat/memory
- spring-ai-autoconfigure-model-chat-memory-cassandra
- src/main/java/org/springframework/ai/model/chat/memory/cassandra/autoconfigure
- spring-ai-autoconfigure-model-chat-memory-jdbc
- src
- main
- java/org/springframework/ai/model/chat/memory/jdbc/autoconfigure
- resources/META-INF
- test/java/org/springframework/ai/model/chat/memory/jdbc/autoconfigure
- spring-ai-autoconfigure-model-chat-memory-neo4j
- src/main/java/org/springframework/ai/model/chat/memory/neo4j/autoconfigure
- spring-ai-autoconfigure-model-chat-memory
- src
- main
- java/org/springframework/ai/model/chat/memory/autoconfigure
- resources/META-INF/spring
- test/java/org/springframework/ai/model/chat/memory/autoconfigure
- memory/spring-ai-model-chat-memory-jdbc
- src
- main
- java/org/springframework/ai/chat/memory/jdbc
- aot/hint
- resources
- META-INF/spring
- org/springframework/ai/chat/memory/jdbc
- test/java/org/springframework/ai/chat/memory/jdbc
- aot/hint
- models
- spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai
- spring-ai-ollama/src/test/java/org/springframework/ai/ollama
- spring-ai-openai/src/test/java/org/springframework/ai/openai/chat
- spring-ai-bom
- spring-ai-client-chat/src/main/java/org/springframework/ai/chat
- client/advisor
- memory
- spring-ai-docs/src/main/antora/modules/ROOT
- pages
- api
- spring-ai-model/src
- main/java/org/springframework/ai/chat/memory
- test/java/org/springframework/ai/chat/memory
- spring-ai-spring-boot-starters
- spring-ai-starter-model-anthropic
- spring-ai-starter-model-azure-openai
- spring-ai-starter-model-bedrock-converse
- spring-ai-starter-model-chat-memory-cassandra
- spring-ai-starter-model-chat-memory-jdbc
- spring-ai-starter-model-chat-memory-neo4j
- spring-ai-starter-model-huggingface
- spring-ai-starter-model-minimax
- spring-ai-starter-model-mistral-ai
- spring-ai-starter-model-oci-genai
- spring-ai-starter-model-ollama
- spring-ai-starter-model-openai
- spring-ai-starter-model-vertex-ai-gemini
- spring-ai-starter-model-watsonx-ai
- spring-ai-starter-model-zhipuai
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
62 files changed
+2200
-151
lines changedauto-configurations/models/chat/memory/spring-ai-autoconfigure-model-chat-memory-cassandra/pom.xml
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | | - | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
29 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
30 | 36 | | |
31 | 37 | | |
32 | | - | |
33 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
34 | 42 | | |
35 | 43 | | |
36 | 44 | | |
37 | 45 | | |
| 46 | + | |
38 | 47 | | |
39 | 48 | | |
40 | | - | |
41 | | - | |
| 49 | + | |
| 50 | + | |
42 | 51 | | |
43 | 52 | | |
44 | 53 | | |
45 | 54 | | |
46 | 55 | | |
47 | 56 | | |
48 | 57 | | |
49 | | - | |
50 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
51 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
52 | 72 | | |
53 | 73 | | |
54 | 74 | | |
55 | 75 | | |
56 | 76 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
62 | 80 | | |
63 | 81 | | |
64 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
65 | 113 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | | - | |
| 29 | + | |
29 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
0 commit comments