Skip to content

Commit cd871ea

Browse files
ogbozoyanilayaperumalg
authored andcommitted
VectorStoreChatMemoryAdvisor constructors cleanup
- Deprecate all constructors except one with all fields - Update the build method to include order in the VectorStoreChatMemoryAdvisor's constructor
1 parent 6035516 commit cd871ea

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
*
4646
* @author Christian Tzolov
4747
* @author Thomas Vitale
48+
* @author Oganes Bozoyan
4849
* @since 1.0.0
4950
*/
5051
public class VectorStoreChatMemoryAdvisor extends AbstractChatMemoryAdvisor<VectorStore> {
@@ -65,20 +66,45 @@ public class VectorStoreChatMemoryAdvisor extends AbstractChatMemoryAdvisor<Vect
6566

6667
private final String systemTextAdvise;
6768

69+
@Deprecated(forRemoval = true, since = "1.0.0-M6")
70+
/**
71+
* @deprecated use {@link Builder} instead.
72+
*/
6873
public VectorStoreChatMemoryAdvisor(VectorStore vectorStore) {
6974
this(vectorStore, DEFAULT_SYSTEM_TEXT_ADVISE);
7075
}
7176

77+
@Deprecated(forRemoval = true, since = "1.0.0-M6")
78+
/**
79+
* @deprecated use {@link Builder} instead.
80+
*/
7281
public VectorStoreChatMemoryAdvisor(VectorStore vectorStore, String systemTextAdvise) {
7382
super(vectorStore);
7483
this.systemTextAdvise = systemTextAdvise;
7584
}
7685

86+
@Deprecated(forRemoval = true, since = "1.0.0-M6")
87+
/**
88+
* @deprecated use {@link Builder} instead.
89+
*/
7790
public VectorStoreChatMemoryAdvisor(VectorStore vectorStore, String defaultConversationId,
7891
int chatHistoryWindowSize) {
7992
this(vectorStore, defaultConversationId, chatHistoryWindowSize, DEFAULT_SYSTEM_TEXT_ADVISE);
8093
}
8194

95+
@Deprecated(forRemoval = true, since = "1.0.0-M6")
96+
/**
97+
* @deprecated use {@link Builder} instead.
98+
*/
99+
public VectorStoreChatMemoryAdvisor(VectorStore vectorStore, String defaultConversationId,
100+
int chatHistoryWindowSize, int order) {
101+
this(vectorStore, defaultConversationId, chatHistoryWindowSize, DEFAULT_SYSTEM_TEXT_ADVISE, order);
102+
}
103+
104+
@Deprecated(forRemoval = true, since = "1.0.0-M6")
105+
/**
106+
* @deprecated use {@link Builder} instead.
107+
*/
82108
public VectorStoreChatMemoryAdvisor(VectorStore vectorStore, String defaultConversationId,
83109
int chatHistoryWindowSize, String systemTextAdvise) {
84110
this(vectorStore, defaultConversationId, chatHistoryWindowSize, systemTextAdvise,
@@ -95,7 +121,7 @@ public VectorStoreChatMemoryAdvisor(VectorStore vectorStore, String defaultConve
95121
* @param systemTextAdvise the system text advice used for the chat advisor system.
96122
* @param order the order of precedence for this advisor in the chain.
97123
*/
98-
public VectorStoreChatMemoryAdvisor(VectorStore vectorStore, String defaultConversationId,
124+
private VectorStoreChatMemoryAdvisor(VectorStore vectorStore, String defaultConversationId,
99125
int chatHistoryWindowSize, String systemTextAdvise, int order) {
100126
super(vectorStore, defaultConversationId, chatHistoryWindowSize, true, order);
101127
this.systemTextAdvise = systemTextAdvise;
@@ -222,7 +248,7 @@ public Builder systemTextAdvise(String systemTextAdvise) {
222248
@Override
223249
public VectorStoreChatMemoryAdvisor build() {
224250
return new VectorStoreChatMemoryAdvisor(this.chatMemory, this.conversationId, this.chatMemoryRetrieveSize,
225-
this.systemTextAdvise);
251+
this.systemTextAdvise, this.order);
226252
}
227253

228254
}

vector-stores/spring-ai-pgvector-store/src/test/java/org/springframework/ai/vectorstore/pgvector/PgVectorStoreWithChatMemoryAdvisorIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ void advisedChatShouldHaveSimilarMessagesFromVectorStore() throws Exception {
135135
.build()
136136
.prompt()
137137
.user("joke")
138-
.advisors(new VectorStoreChatMemoryAdvisor(store))
138+
.advisors(VectorStoreChatMemoryAdvisor.builder(store).build())
139139
.call()
140140
.chatResponse();
141141

0 commit comments

Comments
 (0)