File tree 3 files changed +20
-7
lines changed
models/spring-ai-vertex-ai-gemini/src
main/java/org/springframework/ai/vertexai/gemini
test/java/org/springframework/ai/vertexai/gemini 3 files changed +20
-7
lines changed Original file line number Diff line number Diff line change 16
16
17
17
package org .springframework .ai .vertexai .gemini ;
18
18
19
+ import com .google .cloud .vertexai .api .Tool .GoogleSearch ;
19
20
import java .util .ArrayList ;
20
21
import java .util .Collection ;
21
22
import java .util .List ;
@@ -713,9 +714,10 @@ GeminiRequest createGeminiRequest(Prompt prompt) {
713
714
}
714
715
715
716
if (prompt .getOptions () instanceof VertexAiGeminiChatOptions options && options .getGoogleSearchRetrieval ()) {
716
- final var googleSearchRetrieval = GoogleSearchRetrieval .newBuilder ().getDefaultInstanceForType ();
717
+ // final var googleSearchRetrieval = GoogleSearchRetrieval.newBuilder().getDefaultInstanceForType();
718
+ var googleSearch = GoogleSearch .newBuilder ().getDefaultInstanceForType ();
717
719
final var googleSearchRetrievalTool = Tool .newBuilder ()
718
- .setGoogleSearchRetrieval ( googleSearchRetrieval )
720
+ .setGoogleSearch ( googleSearch )
719
721
.build ();
720
722
tools .add (googleSearchRetrievalTool );
721
723
}
@@ -969,7 +971,7 @@ public enum ChatModel implements ChatModelDescription {
969
971
970
972
GEMINI_2_0_FLASH_LIGHT ("gemini-2.0-flash-lite" ),
971
973
972
- GEMINI_2_5_PRO ("gemini-2.5-pro-exp-03-28 " );
974
+ GEMINI_2_5_PRO ("gemini-2.5-pro-exp-03-25 " );
973
975
974
976
public final String value ;
975
977
Original file line number Diff line number Diff line change @@ -88,17 +88,28 @@ void testMessageHistory() {
88
88
assertThat (response .getResult ().getOutput ().getText ()).containsAnyOf ("Blackbeard" , "Bartholomew" );
89
89
}
90
90
91
+ // Disabled until Gemini 2.5 PRO has an official release
92
+ @ Disabled
91
93
@ Test
92
- void googleSearchTool () {
94
+ void googleSearchToolPro () {
93
95
Prompt prompt = createPrompt (VertexAiGeminiChatOptions .builder ()
94
- .model (ChatModel .GEMINI_1_5_PRO ) // Only the pro model supports the google
95
- // search tool
96
+ .model (ChatModel .GEMINI_2_5_PRO )
96
97
.googleSearchRetrieval (true )
97
98
.build ());
98
99
ChatResponse response = this .chatModel .call (prompt );
99
100
assertThat (response .getResult ().getOutput ().getText ()).containsAnyOf ("Blackbeard" , "Bartholomew" );
100
101
}
101
102
103
+ @ Test
104
+ void googleSearchToolFlash () {
105
+ Prompt prompt = createPrompt (VertexAiGeminiChatOptions .builder ()
106
+ .model (ChatModel .GEMINI_2_0_FLASH )
107
+ .googleSearchRetrieval (true )
108
+ .build ());
109
+ ChatResponse response = this .chatModel .call (prompt );
110
+ assertThat (response .getResult ().getOutput ().getText ()).containsAnyOf ("Blackbeard" , "Bartholomew" , "Bob" );
111
+ }
112
+
102
113
@ Test
103
114
@ Disabled
104
115
void testSafetySettings () {
Original file line number Diff line number Diff line change 268
268
<djl .version>0.30.0</djl .version>
269
269
<onnxruntime .version>1.19.2</onnxruntime .version>
270
270
<oci-sdk-version >3.51.0</oci-sdk-version >
271
- <com .google.cloud.version>26.48 .0</com .google.cloud.version>
271
+ <com .google.cloud.version>26.59 .0</com .google.cloud.version>
272
272
<ibm .sdk.version>9.20.0</ibm .sdk.version>
273
273
<jsonschema .version>4.37.0</jsonschema .version>
274
274
<swagger-annotations .version>2.2.25</swagger-annotations .version>
You can’t perform that action at this time.
0 commit comments