Skip to content

Commit 53f1b90

Browse files
committed
Clean up tests with Flash 2.0 and 2.5
Signed-off-by: ddobrin <[email protected]>
1 parent ede08c0 commit 53f1b90

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

models/spring-ai-google-genai/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatModelIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ void jsonTextToolCallingTest() {
368368
.genAiClient(genAiClient())
369369
.toolCallingManager(toolCallingManager)
370370
.defaultOptions(VertexAiGeminiChatOptions.builder()
371-
.model(VertexAiGeminiChatModel.ChatModel.GEMINI_2_5_FLASH)
371+
.model(VertexAiGeminiChatModel.ChatModel.GEMINI_2_0_FLASH)
372372
.temperature(0.1)
373373
.build())
374374
.build();
@@ -384,7 +384,7 @@ void jsonTextToolCallingTest() {
384384
.content();
385385

386386
assertThat(response).isNotEmpty();
387-
assertThat(response).contains("2025-05-08T10:10:10+02:00[Europe/Berlin]");
387+
assertThat(response).contains("2025-05-08T10:10:10+02:00");
388388
}
389389

390390
/**

models/spring-ai-google-genai/src/test/java/org/springframework/ai/vertexai/gemini/tool/VertexAiGeminiChatModelToolCallingIT.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public void functionCallTestInferredOpenApiSchemaStream() {
170170
}
171171

172172
@Test
173-
public void functionCallUsageTestInferredOpenApiSchemaStream() {
173+
public void functionCallUsageTestInferredOpenApiSchemaStreamFlash20() {
174174

175175
UserMessage userMessage = new UserMessage(
176176
"What's the weather like in San Francisco, Paris and in Tokyo? Return the temperature in Celsius.");
@@ -204,6 +204,41 @@ public void functionCallUsageTestInferredOpenApiSchemaStream() {
204204

205205
}
206206

207+
@Test
208+
public void functionCallUsageTestInferredOpenApiSchemaStreamFlash25() {
209+
210+
UserMessage userMessage = new UserMessage(
211+
"What's the weather like in San Francisco, Paris and in Tokyo? Return the temperature in Celsius.");
212+
213+
List<Message> messages = new ArrayList<>(List.of(userMessage));
214+
215+
var promptOptions = VertexAiGeminiChatOptions.builder()
216+
.model(VertexAiGeminiChatModel.ChatModel.GEMINI_2_5_FLASH)
217+
.toolCallbacks(List.of(
218+
FunctionToolCallback.builder("get_current_weather", new MockWeatherService())
219+
.description("Get the current weather in a given location.")
220+
.inputType(MockWeatherService.Request.class)
221+
.build(),
222+
FunctionToolCallback.builder("get_payment_status", new PaymentStatus())
223+
.description(
224+
"Retrieves the payment status for transaction. For example what is the payment status for transaction 700?")
225+
.inputType(PaymentInfoRequest.class)
226+
.build()))
227+
.build();
228+
229+
Flux<ChatResponse> response = this.chatModel.stream(new Prompt(messages, promptOptions));
230+
231+
ChatResponse chatResponse = response.blockLast();
232+
233+
logger.info("Response: {}", chatResponse);
234+
235+
assertThat(chatResponse).isNotNull();
236+
assertThat(chatResponse.getMetadata()).isNotNull();
237+
assertThat(chatResponse.getMetadata().getUsage()).isNotNull();
238+
assertThat(chatResponse.getMetadata().getUsage().getTotalTokens()).isGreaterThan(150).isLessThan(600);
239+
240+
}
241+
207242
public record PaymentInfoRequest(String id) {
208243

209244
}

0 commit comments

Comments
 (0)