Skip to content

Commit 2c18332

Browse files
authored
Merge branch 'spring-projects:main' into main
2 parents da347c3 + d1ead23 commit 2c18332

File tree

230 files changed

+2101
-1137
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+2101
-1137
lines changed

advisors/spring-ai-advisors-vector-store/src/main/java/org/springframework/ai/chat/client/advisor/vectorstore/QuestionAnswerAdvisor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
import java.util.Map;
2222
import java.util.stream.Collectors;
2323

24+
import reactor.core.scheduler.Scheduler;
25+
import reactor.core.scheduler.Schedulers;
26+
2427
import org.springframework.ai.chat.client.ChatClientRequest;
2528
import org.springframework.ai.chat.client.ChatClientResponse;
2629
import org.springframework.ai.chat.client.advisor.api.AdvisorChain;
2730
import org.springframework.ai.chat.client.advisor.api.BaseAdvisor;
2831
import org.springframework.ai.chat.messages.UserMessage;
29-
import reactor.core.scheduler.Scheduler;
30-
import reactor.core.scheduler.Schedulers;
31-
3232
import org.springframework.ai.chat.model.ChatResponse;
3333
import org.springframework.ai.chat.prompt.PromptTemplate;
3434
import org.springframework.ai.document.Document;

advisors/spring-ai-advisors-vector-store/src/main/java/org/springframework/ai/chat/client/advisor/vectorstore/VectorStoreChatMemoryAdvisor.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@
2121
import java.util.List;
2222
import java.util.Map;
2323

24-
import org.springframework.util.Assert;
24+
import reactor.core.publisher.Flux;
25+
import reactor.core.publisher.Mono;
2526
import reactor.core.scheduler.Scheduler;
2627

28+
import org.springframework.ai.chat.client.ChatClientMessageAggregator;
2729
import org.springframework.ai.chat.client.ChatClientRequest;
2830
import org.springframework.ai.chat.client.ChatClientResponse;
2931
import org.springframework.ai.chat.client.advisor.api.Advisor;
3032
import org.springframework.ai.chat.client.advisor.api.AdvisorChain;
3133
import org.springframework.ai.chat.client.advisor.api.BaseAdvisor;
3234
import org.springframework.ai.chat.client.advisor.api.BaseChatMemoryAdvisor;
35+
import org.springframework.ai.chat.client.advisor.api.StreamAdvisorChain;
3336
import org.springframework.ai.chat.memory.ChatMemory;
3437
import org.springframework.ai.chat.messages.AssistantMessage;
3538
import org.springframework.ai.chat.messages.Message;
@@ -38,6 +41,7 @@
3841
import org.springframework.ai.chat.prompt.PromptTemplate;
3942
import org.springframework.ai.document.Document;
4043
import org.springframework.ai.vectorstore.VectorStore;
44+
import org.springframework.util.Assert;
4145

4246
/**
4347
* Memory is retrieved from a VectorStore added into the prompt's system text.
@@ -50,7 +54,7 @@
5054
* @author Mark Pollack
5155
* @since 1.0.0
5256
*/
53-
public class VectorStoreChatMemoryAdvisor implements BaseChatMemoryAdvisor {
57+
public final class VectorStoreChatMemoryAdvisor implements BaseChatMemoryAdvisor {
5458

5559
public static final String TOP_K = "chat_memory_vector_store_top_k";
5660

@@ -104,7 +108,7 @@ public static Builder builder(VectorStore chatMemory) {
104108

105109
@Override
106110
public int getOrder() {
107-
return order;
111+
return this.order;
108112
}
109113

110114
@Override
@@ -167,6 +171,20 @@ public ChatClientResponse after(ChatClientResponse chatClientResponse, AdvisorCh
167171
return chatClientResponse;
168172
}
169173

174+
@Override
175+
public Flux<ChatClientResponse> adviseStream(ChatClientRequest chatClientRequest,
176+
StreamAdvisorChain streamAdvisorChain) {
177+
// Get the scheduler from BaseAdvisor
178+
Scheduler scheduler = this.getScheduler();
179+
// Process the request with the before method
180+
return Mono.just(chatClientRequest)
181+
.publishOn(scheduler)
182+
.map(request -> this.before(request, streamAdvisorChain))
183+
.flatMapMany(streamAdvisorChain::nextStream)
184+
.transform(flux -> new ChatClientMessageAggregator().aggregateChatClientResponse(flux,
185+
response -> this.after(response, streamAdvisorChain)));
186+
}
187+
170188
private List<Document> toDocuments(List<Message> messages, String conversationId) {
171189
List<Document> docs = messages.stream()
172190
.filter(m -> m.getMessageType() == MessageType.USER || m.getMessageType() == MessageType.ASSISTANT)

advisors/spring-ai-advisors-vector-store/src/test/java/org/springframework/ai/chat/client/advisor/vectorstore/VectorStoreChatMemoryAdvisorTests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1+
/*
2+
* Copyright 2025-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.springframework.ai.chat.client.advisor.vectorstore;
218

319
import org.junit.jupiter.api.Test;
420
import org.mockito.Mockito;
21+
522
import org.springframework.ai.vectorstore.VectorStore;
623

724
import static org.assertj.core.api.Assertions.assertThatThrownBy;

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/main/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpClientCommonProperties.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -109,33 +109,6 @@ public enum ClientType {
109109
*/
110110
private Toolcallback toolcallback = new Toolcallback();
111111

112-
/**
113-
* Represents a callback configuration for tools.
114-
* <p>
115-
* This record is used to encapsulate the configuration for enabling or disabling tool
116-
* callbacks in the MCP client.
117-
*
118-
* @param enabled A boolean flag indicating whether the tool callback is enabled. If
119-
* true, the tool callback is active; otherwise, it is disabled.
120-
*/
121-
public static class Toolcallback {
122-
123-
/**
124-
* A boolean flag indicating whether the tool callback is enabled. If true, the
125-
* tool callback is active; otherwise, it is disabled.
126-
*/
127-
private boolean enabled = true;
128-
129-
public void setEnabled(boolean enabled) {
130-
this.enabled = enabled;
131-
}
132-
133-
public boolean isEnabled() {
134-
return this.enabled;
135-
}
136-
137-
}
138-
139112
public boolean isEnabled() {
140113
return this.enabled;
141114
}
@@ -193,11 +166,38 @@ public void setRootChangeNotification(boolean rootChangeNotification) {
193166
}
194167

195168
public Toolcallback getToolcallback() {
196-
return toolcallback;
169+
return this.toolcallback;
197170
}
198171

199172
public void setToolcallback(Toolcallback toolcallback) {
200173
this.toolcallback = toolcallback;
201174
}
202175

176+
/**
177+
* Represents a callback configuration for tools.
178+
* <p>
179+
* This record is used to encapsulate the configuration for enabling or disabling tool
180+
* callbacks in the MCP client.
181+
*
182+
* @param enabled A boolean flag indicating whether the tool callback is enabled. If
183+
* true, the tool callback is active; otherwise, it is disabled.
184+
*/
185+
public static class Toolcallback {
186+
187+
/**
188+
* A boolean flag indicating whether the tool callback is enabled. If true, the
189+
* tool callback is active; otherwise, it is disabled.
190+
*/
191+
private boolean enabled = true;
192+
193+
public void setEnabled(boolean enabled) {
194+
this.enabled = enabled;
195+
}
196+
197+
public boolean isEnabled() {
198+
return this.enabled;
199+
}
200+
201+
}
202+
203203
}

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpClientCommonPropertiesTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616

1717
package org.springframework.ai.mcp.client.autoconfigure.properties;
1818

19+
import java.time.Duration;
20+
1921
import org.junit.jupiter.api.Test;
22+
2023
import org.springframework.boot.context.properties.EnableConfigurationProperties;
2124
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
2225
import org.springframework.context.annotation.Configuration;
2326

24-
import java.time.Duration;
25-
2627
import static org.assertj.core.api.Assertions.assertThat;
2728

2829
/**

auto-configurations/mcp/spring-ai-autoconfigure-mcp-client/src/test/java/org/springframework/ai/mcp/client/autoconfigure/properties/McpSseClientPropertiesTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616

1717
package org.springframework.ai.mcp.client.autoconfigure.properties;
1818

19+
import java.util.Map;
20+
1921
import org.junit.jupiter.api.Test;
22+
2023
import org.springframework.boot.context.properties.EnableConfigurationProperties;
2124
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
2225
import org.springframework.context.annotation.Configuration;
2326

24-
import java.util.Map;
25-
2627
import static org.assertj.core.api.Assertions.assertThat;
2728

2829
/**

0 commit comments

Comments
 (0)