Fixes #2185 - googleSearchRetrieval(true) causes INVALID_ARGUMENT error with Gemini 2.0 (use google_search instead)
This commit is contained in:
@@ -714,11 +714,8 @@ public class VertexAiGeminiChatModel implements ChatModel, DisposableBean {
|
||||
}
|
||||
|
||||
if (prompt.getOptions() instanceof VertexAiGeminiChatOptions options && options.getGoogleSearchRetrieval()) {
|
||||
// final var googleSearchRetrieval = GoogleSearchRetrieval.newBuilder().getDefaultInstanceForType();
|
||||
var googleSearch = GoogleSearch.newBuilder().getDefaultInstanceForType();
|
||||
final var googleSearchRetrievalTool = Tool.newBuilder()
|
||||
.setGoogleSearch(googleSearch)
|
||||
.build();
|
||||
final var googleSearchRetrievalTool = Tool.newBuilder().setGoogleSearch(googleSearch).build();
|
||||
tools.add(googleSearchRetrievalTool);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,9 +103,9 @@ class VertexAiGeminiChatModelIT {
|
||||
@Test
|
||||
void googleSearchToolFlash() {
|
||||
Prompt prompt = createPrompt(VertexAiGeminiChatOptions.builder()
|
||||
.model(ChatModel.GEMINI_2_0_FLASH)
|
||||
.googleSearchRetrieval(true)
|
||||
.build());
|
||||
.model(ChatModel.GEMINI_2_0_FLASH)
|
||||
.googleSearchRetrieval(true)
|
||||
.build());
|
||||
ChatResponse response = this.chatModel.call(prompt);
|
||||
assertThat(response.getResult().getOutput().getText()).containsAnyOf("Blackbeard", "Bartholomew", "Bob");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user