@@ -78,8 +78,6 @@ public class VertexAiGeminiChatClient
|
||||
|
||||
private final GenerationConfig generationConfig;
|
||||
|
||||
private GenerativeModel generativeModel;
|
||||
|
||||
public enum GeminiMessageType {
|
||||
|
||||
USER("user"),
|
||||
@@ -140,7 +138,6 @@ public class VertexAiGeminiChatClient
|
||||
this.vertexAI = vertexAI;
|
||||
this.defaultOptions = options;
|
||||
this.generationConfig = toGenerationConfig(options);
|
||||
this.generativeModel = new GenerativeModel(options.getModel(), vertexAI);
|
||||
}
|
||||
|
||||
// https://cloud.google.com/vertex-ai/docs/generative-ai/model-reference/gemini
|
||||
@@ -204,7 +201,8 @@ public class VertexAiGeminiChatClient
|
||||
Set<String> functionsForThisRequest = new HashSet<>();
|
||||
|
||||
GenerationConfig generationConfig = this.generationConfig;
|
||||
GenerativeModel generativeModel = this.generativeModel;
|
||||
|
||||
GenerativeModel generativeModel = new GenerativeModel(this.defaultOptions.getModel(), this.vertexAI);
|
||||
|
||||
VertexAiGeminiChatOptions updatedRuntimeOptions = null;
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ public class VertexAiGeminiChatClientFunctionCallingIT {
|
||||
public void functionCallTestInferredOpenApiSchemaStream() {
|
||||
|
||||
UserMessage userMessage = new UserMessage(
|
||||
"What's the weather like in San Francisco, in Paris and in Tokyo? Use Multi-turn function calling.");
|
||||
"What's the weather like in San Francisco, in Paris and in Tokyo, Japan? Use Multi-turn function calling. Provide answer for all requested locations.");
|
||||
|
||||
List<Message> messages = new ArrayList<>(List.of(userMessage));
|
||||
|
||||
|
||||
@@ -83,6 +83,13 @@ class FunctionCallWithFunctionBeanIT {
|
||||
|
||||
assertThat(response.getResult().getOutput().getContent()).contains("30", "10", "15");
|
||||
|
||||
response = chatClient
|
||||
.call(new Prompt(List.of(systemMessage, userMessage), VertexAiGeminiChatOptions.builder().build()));
|
||||
|
||||
logger.info("Response: {}", response);
|
||||
|
||||
assertThat(response.getResult().getOutput().getContent()).doesNotContain("30", "10", "15");
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,15 @@ public class FunctionCallWithPromptFunctionIT {
|
||||
logger.info("Response: {}", response);
|
||||
|
||||
assertThat(response.getResult().getOutput().getContent()).contains("30", "10", "15");
|
||||
|
||||
// Verify that no function call is made.
|
||||
response = chatClient
|
||||
.call(new Prompt(List.of(systemMessage, userMessage), VertexAiGeminiChatOptions.builder().build()));
|
||||
|
||||
logger.info("Response: {}", response);
|
||||
|
||||
assertThat(response.getResult().getOutput().getContent()).doesNotContain("30", "10", "15");
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user