Skip to content

Commit b6ce7f3

Browse files
committed
Remove deprecations/cleanup
- Remove deprecated AbstractChatMemoryAdvisor#DEFAULT_CHAT_MEMORY_CONVERSATION_ID - Remove deprecated InMemoryChatMemory and replace it with MessageWindowChatMemory - Update references - Remove deprecated TemplateFormat Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
1 parent 4fe74d8 commit b6ce7f3

File tree

6 files changed

+16
-126
lines changed

6 files changed

+16
-126
lines changed

spring-ai-client-chat/src/main/java/org/springframework/ai/chat/client/advisor/AbstractChatMemoryAdvisor.java

-7
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ public abstract class AbstractChatMemoryAdvisor<T> implements CallAdvisor, Strea
5353
*/
5454
public static final String CHAT_MEMORY_RETRIEVE_SIZE_KEY = "chat_memory_response_size";
5555

56-
/**
57-
* The default conversation id to use when no conversation id is provided.
58-
* @deprecated in favor of {@link ChatMemory#DEFAULT_CONVERSATION_ID}.
59-
*/
60-
@Deprecated
61-
public static final String DEFAULT_CHAT_MEMORY_CONVERSATION_ID = "default";
62-
6356
/**
6457
* The default chat memory retrieve size to use when no retrieve size is provided.
6558
*/

spring-ai-client-chat/src/main/java/org/springframework/ai/chat/memory/InMemoryChatMemory.java

-62
This file was deleted.

spring-ai-client-chat/src/test/java/org/springframework/ai/chat/client/ChatClientAdvisorTests.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
import org.springframework.ai.chat.client.advisor.PromptChatMemoryAdvisor;
3131
import org.springframework.ai.chat.memory.ChatMemory;
32-
import org.springframework.ai.chat.memory.InMemoryChatMemory;
32+
import org.springframework.ai.chat.memory.InMemoryChatMemoryRepository;
33+
import org.springframework.ai.chat.memory.MessageWindowChatMemory;
3334
import org.springframework.ai.chat.messages.AssistantMessage;
3435
import org.springframework.ai.chat.messages.Message;
3536
import org.springframework.ai.chat.messages.MessageType;
@@ -76,8 +77,10 @@ public void promptChatMemory() {
7677
.willReturn(new ChatResponse(List.of(new Generation(new AssistantMessage("Your name is John"))),
7778
chatResponseMetadata));
7879

79-
// Initialize an in-memory chat memory to store conversation history
80-
ChatMemory chatMemory = new InMemoryChatMemory();
80+
// Initialize a message window chat memory to store conversation history
81+
ChatMemory chatMemory = MessageWindowChatMemory.builder()
82+
.chatMemoryRepository(new InMemoryChatMemoryRepository())
83+
.build();
8184

8285
// Build a ChatClient with default system text and a memory advisor
8386
var chatClient = ChatClient.builder(this.chatModel)
@@ -153,8 +156,10 @@ public void streamingPromptChatMemory() {
153156
return state;
154157
}));
155158

156-
// Initialize an in-memory chat memory to store conversation history
157-
ChatMemory chatMemory = new InMemoryChatMemory();
159+
// Initialize a message window chat memory to store conversation history
160+
ChatMemory chatMemory = MessageWindowChatMemory.builder()
161+
.chatMemoryRepository(new InMemoryChatMemoryRepository())
162+
.build();
158163

159164
// Build a ChatClient with default system text and a memory advisor
160165
var chatClient = ChatClient.builder(this.chatModel)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ IMPORTANT: Refer to the new xref:api/chat-memory.adoc[Chat Memory] documentation
534534

535535
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.
536536

537-
There are currently four implementations: `InMemoryChatMemory`, `CassandraChatMemory`, `Neo4jChatMemory`, and `JdbcChatMemory`, which provide storage for chat conversation history in-memory, persisted with `time-to-live` in Cassandra, and persisted without `time-to-live` in Neo4j and Jdbc, respectively.
537+
There are currently four implementations: `CassandraChatMemory`, `Neo4jChatMemory`, and `JdbcChatMemory`, which provide storage for chat conversation history in-memory, persisted with `time-to-live` in Cassandra, and persisted without `time-to-live` in Neo4j and Jdbc, respectively.
538538

539539
=== CassandraChatMemory
540540

spring-ai-integration-tests/src/test/java/org/springframework/ai/integration/tests/client/advisor/RetrievalAugmentationAdvisorIT.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
import org.springframework.ai.chat.client.ChatClient;
2727
import org.springframework.ai.chat.client.advisor.AbstractChatMemoryAdvisor;
2828
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
29-
import org.springframework.ai.chat.memory.InMemoryChatMemory;
29+
import org.springframework.ai.chat.evaluation.RelevancyEvaluator;
30+
import org.springframework.ai.chat.memory.MessageWindowChatMemory;
3031
import org.springframework.ai.chat.model.ChatResponse;
3132
import org.springframework.ai.document.Document;
3233
import org.springframework.ai.document.DocumentReader;
3334
import org.springframework.ai.evaluation.EvaluationRequest;
3435
import org.springframework.ai.evaluation.EvaluationResponse;
35-
import org.springframework.ai.chat.evaluation.RelevancyEvaluator;
3636
import org.springframework.ai.integration.tests.TestApplication;
3737
import org.springframework.ai.openai.OpenAiChatModel;
3838
import org.springframework.ai.rag.advisor.RetrievalAugmentationAdvisor;
@@ -133,7 +133,9 @@ void ragWithRequestFilter() {
133133

134134
@Test
135135
void ragWithCompression() {
136-
MessageChatMemoryAdvisor memoryAdvisor = MessageChatMemoryAdvisor.builder(new InMemoryChatMemory()).build();
136+
MessageChatMemoryAdvisor memoryAdvisor = MessageChatMemoryAdvisor
137+
.builder(MessageWindowChatMemory.builder().build())
138+
.build();
137139

138140
RetrievalAugmentationAdvisor ragAdvisor = RetrievalAugmentationAdvisor.builder()
139141
.queryTransformers(CompressionQueryTransformer.builder()

spring-ai-model/src/main/java/org/springframework/ai/chat/prompt/TemplateFormat.java

-48
This file was deleted.

0 commit comments

Comments
 (0)