Skip to content

Commit 9e78796

Browse files
committed
Fix(Anthropic): Remove use of deprecated model in integration tests
- The Claude Sonnet 3.5 models are retired on October 28th, 2025. - Update the tests to use Claude Sonnet 3.7 instead Signed-off-by: Ilayaperumal Gopinathan <[email protected]>
1 parent 30af4e8 commit 9e78796

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

auto-configurations/models/spring-ai-autoconfigure-model-anthropic/src/test/java/org/springframework/ai/model/anthropic/autoconfigure/AnthropicChatAutoConfigurationIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ void call() {
5959
@Test
6060
void callWith8KResponseContext() {
6161
this.contextRunner
62-
.withPropertyValues("spring.ai.anthropic.beta-version=" + AnthropicApi.BETA_MAX_TOKENS,
63-
"spring.ai.anthropic.chat.options.model=" + AnthropicApi.ChatModel.CLAUDE_3_5_SONNET.getValue())
62+
.withPropertyValues(
63+
"spring.ai.anthropic.chat.options.model=" + AnthropicApi.ChatModel.CLAUDE_3_7_SONNET.getValue())
6464
.run(context -> {
6565
AnthropicChatModel chatModel = context.getBean(AnthropicChatModel.class);
6666
var options = AnthropicChatOptions.builder().maxTokens(8192).build();

models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/api/AnthropicApi.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ public static Builder builder() {
8888

8989
public static final String DEFAULT_ANTHROPIC_BETA_VERSION = "tools-2024-04-04,pdfs-2024-09-25";
9090

91-
public static final String BETA_MAX_TOKENS = "max-tokens-3-5-sonnet-2024-07-15";
92-
9391
public static final String BETA_EXTENDED_CACHE_TTL = "extended-cache-ttl-2025-04-11";
9492

9593
private static final String HEADER_X_API_KEY = "x-api-key";
@@ -301,7 +299,7 @@ public enum ChatModel implements ChatModelDescription {
301299
CLAUDE_3_7_SONNET("claude-3-7-sonnet-latest"),
302300

303301
/**
304-
* The claude-3-5-sonnet-latest model.
302+
* The claude-3-5-sonnet-latest model.(Deprecated on October 28, 2025)
305303
*/
306304
CLAUDE_3_5_SONNET("claude-3-5-sonnet-latest"),
307305

models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/AnthropicChatModelIT.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void testMessageHistory() {
116116
SystemPromptTemplate systemPromptTemplate = new SystemPromptTemplate(this.systemResource);
117117
Message systemMessage = systemPromptTemplate.createMessage(Map.of("name", "Bob", "voice", "pirate"));
118118
Prompt prompt = new Prompt(List.of(userMessage, systemMessage),
119-
AnthropicChatOptions.builder().model("claude-3-5-sonnet-latest").build());
119+
AnthropicChatOptions.builder().model(AnthropicApi.ChatModel.CLAUDE_3_7_SONNET).build());
120120

121121
ChatResponse response = this.chatModel.call(prompt);
122122
assertThat(response.getResult().getOutput().getText()).containsAnyOf("Blackbeard", "Bartholomew");
@@ -269,7 +269,7 @@ void multiModalityPdfTest() throws IOException {
269269
.build();
270270

271271
var response = this.chatModel.call(new Prompt(List.of(userMessage),
272-
ToolCallingChatOptions.builder().model(AnthropicApi.ChatModel.CLAUDE_3_5_SONNET.getName()).build()));
272+
ToolCallingChatOptions.builder().model(AnthropicApi.ChatModel.CLAUDE_3_7_SONNET.getName()).build()));
273273

274274
assertThat(response.getResult().getOutput().getText()).containsAnyOf("Spring AI", "portable API");
275275
}
@@ -315,7 +315,7 @@ void streamFunctionCallTest() {
315315
List<Message> messages = new ArrayList<>(List.of(userMessage));
316316

317317
var promptOptions = AnthropicChatOptions.builder()
318-
.model(AnthropicApi.ChatModel.CLAUDE_3_5_SONNET.getName())
318+
.model(AnthropicApi.ChatModel.CLAUDE_3_7_SONNET.getName())
319319
.toolCallbacks(FunctionToolCallback.builder("getCurrentWeather", new MockWeatherService())
320320
.description(
321321
"Get the weather in location. Return temperature in 36°F or 36°C format. Use multi-turn if needed.")
@@ -345,7 +345,7 @@ void streamFunctionCallUsageTest() {
345345
List<Message> messages = new ArrayList<>(List.of(userMessage));
346346

347347
var promptOptions = AnthropicChatOptions.builder()
348-
.model(AnthropicApi.ChatModel.CLAUDE_3_5_SONNET.getName())
348+
.model(AnthropicApi.ChatModel.CLAUDE_3_7_SONNET.getName())
349349
.toolCallbacks(FunctionToolCallback.builder("getCurrentWeather", new MockWeatherService())
350350
.description(
351351
"Get the weather in location. Return temperature in 36°F or 36°C format. Use multi-turn if needed.")
@@ -381,7 +381,7 @@ void validateCallResponseMetadata() {
381381

382382
@Test
383383
void validateStreamCallResponseMetadata() {
384-
String model = AnthropicApi.ChatModel.CLAUDE_3_5_SONNET.getName();
384+
String model = AnthropicApi.ChatModel.CLAUDE_3_7_SONNET.getName();
385385
// @formatter:off
386386
ChatResponse response = ChatClient.create(this.chatModel).prompt()
387387
.options(AnthropicChatOptions.builder().model(model).build())
@@ -499,7 +499,7 @@ void testToolChoiceAny() {
499499
List<Message> messages = new ArrayList<>(List.of(userMessage));
500500

501501
var promptOptions = AnthropicChatOptions.builder()
502-
.model(AnthropicApi.ChatModel.CLAUDE_3_5_SONNET.getName())
502+
.model(AnthropicApi.ChatModel.CLAUDE_3_7_SONNET.getName())
503503
.toolChoice(new AnthropicApi.ToolChoiceAny())
504504
.internalToolExecutionEnabled(false)
505505
.toolCallbacks(FunctionToolCallback.builder("getCurrentWeather", new MockWeatherService())
@@ -528,7 +528,7 @@ void testToolChoiceTool() {
528528
List<Message> messages = new ArrayList<>(List.of(userMessage));
529529

530530
var promptOptions = AnthropicChatOptions.builder()
531-
.model(AnthropicApi.ChatModel.CLAUDE_3_5_SONNET.getName())
531+
.model(AnthropicApi.ChatModel.CLAUDE_3_7_SONNET.getName())
532532
.toolChoice(new AnthropicApi.ToolChoiceTool("getFunResponse", true))
533533
.internalToolExecutionEnabled(false)
534534
.toolCallbacks(FunctionToolCallback.builder("getCurrentWeather", new MockWeatherService())
@@ -566,7 +566,7 @@ void testToolChoiceNone() {
566566
List<Message> messages = new ArrayList<>(List.of(userMessage));
567567

568568
var promptOptions = AnthropicChatOptions.builder()
569-
.model(AnthropicApi.ChatModel.CLAUDE_3_5_SONNET.getName())
569+
.model(AnthropicApi.ChatModel.CLAUDE_3_7_SONNET.getName())
570570
.toolChoice(new AnthropicApi.ToolChoiceNone())
571571
.toolCallbacks(FunctionToolCallback.builder("getCurrentWeather", new MockWeatherService())
572572
.description(

models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/client/AnthropicChatClientIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ void streamingMultiModality() throws IOException {
327327

328328
// @formatter:off
329329
Flux<String> response = ChatClient.create(this.chatModel).prompt()
330-
.options(AnthropicChatOptions.builder().model(AnthropicApi.ChatModel.CLAUDE_3_5_SONNET)
330+
.options(AnthropicChatOptions.builder().model(AnthropicApi.ChatModel.CLAUDE_3_7_SONNET)
331331
.build())
332332
.user(u -> u.text("Explain what do you see on this picture?")
333333
.media(MimeTypeUtils.IMAGE_PNG, new ClassPathResource("/test.png")))

0 commit comments

Comments
 (0)