Skip to content

Commit be4aa53

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 356ae8f commit be4aa53

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
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
@@ -60,8 +60,8 @@ void call() {
6060
@Test
6161
void callWith8KResponseContext() {
6262
this.contextRunner
63-
.withPropertyValues("spring.ai.anthropic.beta-version=" + AnthropicApi.BETA_MAX_TOKENS,
64-
"spring.ai.anthropic.chat.options.model=" + AnthropicApi.ChatModel.CLAUDE_3_5_SONNET.getValue())
63+
.withPropertyValues(
64+
"spring.ai.anthropic.chat.options.model=" + AnthropicApi.ChatModel.CLAUDE_3_7_SONNET.getValue())
6565
.run(context -> {
6666
AnthropicChatModel chatModel = context.getBean(AnthropicChatModel.class);
6767
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
@@ -86,8 +86,6 @@ public static Builder builder() {
8686

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

89-
public static final String BETA_MAX_TOKENS = "max-tokens-3-5-sonnet-2024-07-15";
90-
9189
private static final String HEADER_X_API_KEY = "x-api-key";
9290

9391
private static final String HEADER_ANTHROPIC_VERSION = "anthropic-version";
@@ -288,7 +286,7 @@ public enum ChatModel implements ChatModelDescription {
288286
CLAUDE_3_7_SONNET("claude-3-7-sonnet-latest"),
289287

290288
/**
291-
* The claude-3-5-sonnet-latest model.
289+
* The claude-3-5-sonnet-latest model.(Retired on October 28, 2025)
292290
*/
293291
CLAUDE_3_5_SONNET("claude-3-5-sonnet-latest"),
294292

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

Lines changed: 5 additions & 5 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())

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)