| 
23 | 23 | import java.util.stream.Collectors;  | 
24 | 24 | 
 
  | 
25 | 25 | import org.junit.jupiter.api.Test;  | 
 | 26 | +import org.junit.jupiter.params.ParameterizedTest;  | 
 | 27 | +import org.junit.jupiter.params.provider.ValueSource;  | 
26 | 28 | import org.slf4j.Logger;  | 
27 | 29 | import org.slf4j.LoggerFactory;  | 
28 | 30 | import reactor.core.publisher.Flux;  | 
@@ -186,13 +188,38 @@ void toolAnnotationWeatherForecast() {  | 
186 | 188 | 		assertThat(response).contains("20 degrees");  | 
187 | 189 | 	}  | 
188 | 190 | 
 
  | 
 | 191 | +	// https://github.com/spring-projects/spring-ai/issues/1878  | 
 | 192 | +	@ParameterizedTest  | 
 | 193 | +	@ValueSource(strings = { "amazon.nova-pro-v1:0", "us.anthropic.claude-3-7-sonnet-20250219-v1:0" })  | 
 | 194 | +	void toolAnnotationWeatherForecastStreaming(String modelName) {  | 
 | 195 | + | 
 | 196 | +		ChatClient chatClient = ChatClient.builder(this.chatModel).build();  | 
 | 197 | + | 
 | 198 | +		Flux<ChatResponse> responses = chatClient.prompt()  | 
 | 199 | +			.options(ToolCallingChatOptions.builder().model(modelName).build())  | 
 | 200 | +			.tools(new DummyWeatherForecastTools())  | 
 | 201 | +			.user("Get current weather in Amsterdam")  | 
 | 202 | +			.stream()  | 
 | 203 | +			.chatResponse();  | 
 | 204 | + | 
 | 205 | +		String content = responses.collectList()  | 
 | 206 | +			.block()  | 
 | 207 | +			.stream()  | 
 | 208 | +			.filter(cr -> cr.getResult() != null)  | 
 | 209 | +			.map(cr -> cr.getResult().getOutput().getText())  | 
 | 210 | +			.collect(Collectors.joining());  | 
 | 211 | + | 
 | 212 | +		assertThat(content).contains("20 degrees");  | 
 | 213 | +	}  | 
 | 214 | + | 
189 | 215 | 	@Test  | 
190 |  | -	void toolAnnotationWeatherForecastStreaming() {  | 
 | 216 | +	void streamingToolCallingWithArgumentlessToolSonnet() {  | 
191 | 217 | 
 
  | 
192 | 218 | 		ChatClient chatClient = ChatClient.builder(this.chatModel).build();  | 
193 | 219 | 
 
  | 
194 | 220 | 		Flux<ChatResponse> responses = chatClient.prompt()  | 
195 | 221 | 			.tools(new DummyWeatherForecastTools())  | 
 | 222 | +			.options(ToolCallingChatOptions.builder().model("us.anthropic.claude-3-7-sonnet-20250219-v1:0").build())  | 
196 | 223 | 			.user("Get current weather in Amsterdam")  | 
197 | 224 | 			.stream()  | 
198 | 225 | 			.chatResponse();  | 
@@ -257,6 +284,7 @@ public static class Config {  | 
257 | 284 | 		public BedrockProxyChatModel bedrockConverseChatModel() {  | 
258 | 285 | 
 
  | 
259 | 286 | 			String modelId = "amazon.nova-pro-v1:0";  | 
 | 287 | +			// String modelId = "us.anthropic.claude-3-7-sonnet-20250219-v1:0";  | 
260 | 288 | 
 
  | 
261 | 289 | 			return BedrockProxyChatModel.builder()  | 
262 | 290 | 				.credentialsProvider(EnvironmentVariableCredentialsProvider.create())  | 
 | 
0 commit comments