Skip to content

Commit e6454db

Browse files
committed
Updated tests in Spring AI, Langchain4j, dependency for Spering AI and GenAI SDK
1 parent 28a8cd0 commit e6454db

4 files changed

Lines changed: 48 additions & 34 deletions

File tree

contrib/langchain4j/src/test/java/com/google/adk/models/langchain4j/LangChain4jIntegrationTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
class LangChain4jIntegrationTest {
4646

47-
public static final String CLAUDE_3_7_SONNET_20250219 = "claude-3-7-sonnet-20250219";
47+
public static final String CLAUDE_4_6_SONNET = "claude-sonnet-4-6";
4848
public static final String GEMINI_2_0_FLASH = "gemini-2.0-flash";
4949
public static final String GPT_4_O_MINI = "gpt-4o-mini";
5050

@@ -55,14 +55,14 @@ void testSimpleAgent() {
5555
AnthropicChatModel claudeModel =
5656
AnthropicChatModel.builder()
5757
.apiKey(System.getenv("ANTHROPIC_API_KEY"))
58-
.modelName(CLAUDE_3_7_SONNET_20250219)
58+
.modelName(CLAUDE_4_6_SONNET)
5959
.build();
6060

6161
LlmAgent agent =
6262
LlmAgent.builder()
6363
.name("science-app")
6464
.description("Science teacher agent")
65-
.model(new LangChain4j(claudeModel, CLAUDE_3_7_SONNET_20250219))
65+
.model(new LangChain4j(claudeModel, CLAUDE_4_6_SONNET))
6666
.instruction(
6767
"""
6868
You are a helpful science teacher that explains science concepts
@@ -91,14 +91,14 @@ void testSingleAgentWithTools() {
9191
AnthropicChatModel claudeModel =
9292
AnthropicChatModel.builder()
9393
.apiKey(System.getenv("ANTHROPIC_API_KEY"))
94-
.modelName(CLAUDE_3_7_SONNET_20250219)
94+
.modelName(CLAUDE_4_6_SONNET)
9595
.build();
9696

9797
BaseAgent agent =
9898
LlmAgent.builder()
9999
.name("friendly-weather-app")
100100
.description("Friend agent that knows about the weather")
101-
.model(new LangChain4j(claudeModel, CLAUDE_3_7_SONNET_20250219))
101+
.model(new LangChain4j(claudeModel, CLAUDE_4_6_SONNET))
102102
.instruction(
103103
"""
104104
You are a friendly assistant.
@@ -155,7 +155,7 @@ void testSingleAgentWithTools() {
155155
List<Part> partsThree = contentThree.parts().get();
156156
assertEquals(1, partsThree.size());
157157
assertTrue(partsThree.get(0).text().isPresent());
158-
assertTrue(partsThree.get(0).text().get().contains("beautiful"));
158+
assertTrue(partsThree.get(0).text().get().contains("sunny"));
159159
}
160160

161161
@Test
@@ -352,10 +352,10 @@ void testSimpleStreamingResponse() {
352352
AnthropicStreamingChatModel claudeStreamingModel =
353353
AnthropicStreamingChatModel.builder()
354354
.apiKey(System.getenv("ANTHROPIC_API_KEY"))
355-
.modelName(CLAUDE_3_7_SONNET_20250219)
355+
.modelName(CLAUDE_4_6_SONNET)
356356
.build();
357357

358-
LangChain4j lc4jClaude = new LangChain4j(claudeStreamingModel, CLAUDE_3_7_SONNET_20250219);
358+
LangChain4j lc4jClaude = new LangChain4j(claudeStreamingModel, CLAUDE_4_6_SONNET);
359359

360360
// when
361361
Flowable<LlmResponse> responses =

contrib/spring-ai/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<description>Spring AI integration for the Agent Development Kit.</description>
3030

3131
<properties>
32-
<spring-ai.version>2.0.0-M2</spring-ai.version>
32+
<spring-ai.version>2.0.0-M3</spring-ai.version>
3333
<testcontainers.version>1.21.3</testcontainers.version>
3434
</properties>
3535

contrib/spring-ai/src/test/java/com/google/adk/models/springai/integrations/AnthropicApiIntegrationTest.java

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
3535
import org.springframework.ai.anthropic.AnthropicChatModel;
3636
import org.springframework.ai.anthropic.AnthropicChatOptions;
37-
import org.springframework.ai.anthropic.api.AnthropicApi;
3837

3938
/**
4039
* Integration tests with real Anthropic API.
@@ -53,10 +52,14 @@ void testSimpleAgentWithRealAnthropicApi() throws InterruptedException {
5352
Thread.sleep(2000);
5453

5554
// Create Anthropic model using Spring AI's builder pattern
56-
AnthropicApi anthropicApi =
57-
AnthropicApi.builder().apiKey(System.getenv("ANTHROPIC_API_KEY")).build();
58-
AnthropicChatModel anthropicModel =
59-
AnthropicChatModel.builder().anthropicApi(anthropicApi).build();
55+
var options =
56+
AnthropicChatOptions.builder()
57+
.model(CLAUDE_MODEL)
58+
.maxTokens(1024)
59+
.apiKey(System.getenv("ANTHROPIC_API_KEY"))
60+
.build();
61+
62+
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
6063

6164
// Wrap with SpringAI
6265
SpringAI springAI = new SpringAI(anthropicModel, CLAUDE_MODEL);
@@ -92,10 +95,14 @@ void testStreamingWithRealAnthropicApi() throws InterruptedException {
9295
// Add delay to avoid rapid requests
9396
Thread.sleep(2000);
9497

95-
AnthropicApi anthropicApi =
96-
AnthropicApi.builder().apiKey(System.getenv("ANTHROPIC_API_KEY")).build();
97-
AnthropicChatModel anthropicModel =
98-
AnthropicChatModel.builder().anthropicApi(anthropicApi).build();
98+
var options =
99+
AnthropicChatOptions.builder()
100+
.model(CLAUDE_MODEL)
101+
.maxTokens(1024)
102+
.apiKey(System.getenv("ANTHROPIC_API_KEY"))
103+
.build();
104+
105+
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
99106

100107
SpringAI springAI = new SpringAI(anthropicModel, CLAUDE_MODEL);
101108

@@ -134,10 +141,14 @@ void testStreamingWithRealAnthropicApi() throws InterruptedException {
134141

135142
@Test
136143
void testAgentWithToolsAndRealApi() {
137-
AnthropicApi anthropicApi =
138-
AnthropicApi.builder().apiKey(System.getenv("ANTHROPIC_API_KEY")).build();
139-
AnthropicChatModel anthropicModel =
140-
AnthropicChatModel.builder().anthropicApi(anthropicApi).build();
144+
var options =
145+
AnthropicChatOptions.builder()
146+
.model(CLAUDE_MODEL)
147+
.maxTokens(1024)
148+
.apiKey(System.getenv("ANTHROPIC_API_KEY"))
149+
.build();
150+
151+
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
141152

142153
LlmAgent agent =
143154
LlmAgent.builder()
@@ -175,10 +186,13 @@ void testAgentWithToolsAndRealApi() {
175186
@Test
176187
void testDirectComparisonNonStreamingVsStreaming() throws InterruptedException {
177188
// Test both non-streaming and streaming with the same model to compare behavior
178-
AnthropicApi anthropicApi =
179-
AnthropicApi.builder().apiKey(System.getenv("ANTHROPIC_API_KEY")).build();
180-
AnthropicChatModel anthropicModel =
181-
AnthropicChatModel.builder().anthropicApi(anthropicApi).build();
189+
var options =
190+
AnthropicChatOptions.builder()
191+
.model(CLAUDE_MODEL)
192+
.maxTokens(1024)
193+
.apiKey(System.getenv("ANTHROPIC_API_KEY"))
194+
.build();
195+
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
182196

183197
SpringAI springAI = new SpringAI(anthropicModel, CLAUDE_MODEL);
184198

@@ -271,13 +285,13 @@ void testDirectComparisonNonStreamingVsStreaming() throws InterruptedException {
271285
@Test
272286
void testConfigurationOptions() {
273287
// Test with custom configuration
274-
AnthropicChatOptions options =
275-
AnthropicChatOptions.builder().model(CLAUDE_MODEL).temperature(0.7).maxTokens(100).build();
276-
277-
AnthropicApi anthropicApi =
278-
AnthropicApi.builder().apiKey(System.getenv("ANTHROPIC_API_KEY")).build();
279-
AnthropicChatModel anthropicModel =
280-
AnthropicChatModel.builder().anthropicApi(anthropicApi).defaultOptions(options).build();
288+
var options =
289+
AnthropicChatOptions.builder()
290+
.model(CLAUDE_MODEL)
291+
.maxTokens(1024)
292+
.apiKey(System.getenv("ANTHROPIC_API_KEY"))
293+
.build();
294+
AnthropicChatModel anthropicModel = AnthropicChatModel.builder().options(options).build();
281295

282296
SpringAI springAI = new SpringAI(anthropicModel, CLAUDE_MODEL);
283297

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<otel.version>1.51.0</otel.version>
5252
<mcp.version>0.17.2</mcp.version>
5353
<errorprone.version>2.47.0</errorprone.version>
54-
<google.genai.version>1.41.0</google.genai.version>
54+
<google.genai.version>1.43.0</google.genai.version>
5555
<protobuf.version>4.33.5</protobuf.version>
5656
<junit.version>5.11.4</junit.version>
5757
<mockito.version>5.20.0</mockito.version>

0 commit comments

Comments
 (0)