temp
This commit is contained in:
@@ -351,13 +351,12 @@ public class VertexAiGeminiChatClient
|
||||
|
||||
final var tool = Tool.newBuilder();
|
||||
|
||||
final var functionDeclarations = this.resolveFunctionCallbacks(functionNames)
|
||||
final List<FunctionDeclaration> functionDeclarations = this.resolveFunctionCallbacks(functionNames)
|
||||
.stream()
|
||||
.map(functionCallback -> FunctionDeclaration.newBuilder()
|
||||
.setName(functionCallback.getName())
|
||||
.setDescription(functionCallback.getDescription())
|
||||
.setParameters(jsonToSchema(functionCallback.getInputTypeSchema()))
|
||||
// .setParameters(toOpenApiSchema(functionCallback.getInputTypeSchema()))
|
||||
.build())
|
||||
.toList();
|
||||
tool.addAllFunctionDeclarations(functionDeclarations);
|
||||
|
||||
@@ -179,7 +179,8 @@ public class VertexAiGeminiChatClientFunctionCallingIT {
|
||||
|
||||
}
|
||||
|
||||
//Gemini wants single tool with multiple function, instead multiple tools with single function
|
||||
// Gemini wants single tool with multiple function, instead multiple tools with single
|
||||
// function
|
||||
@Test
|
||||
public void canDeclareMultipleFunctions() {
|
||||
|
||||
@@ -200,8 +201,12 @@ public class VertexAiGeminiChatClientFunctionCallingIT {
|
||||
.build();
|
||||
var promptOptions = VertexAiGeminiChatOptions.builder()
|
||||
.withModel(VertexAiGeminiChatClient.ChatModel.GEMINI_PRO.getValue())
|
||||
.withFunctionCallbacks(List.of(weatherFunction, theAnswer))
|
||||
.withFunctionCallbacks(List.of(weatherFunction))
|
||||
.build();
|
||||
// var promptOptions = VertexAiGeminiChatOptions.builder()
|
||||
// .withModel(VertexAiGeminiChatClient.ChatModel.GEMINI_PRO.getValue())
|
||||
// .withFunctionCallbacks(List.of(weatherFunction, theAnswer))
|
||||
// .build();
|
||||
|
||||
ChatResponse response = vertexGeminiClient.call(new Prompt(messages, promptOptions));
|
||||
|
||||
@@ -210,6 +215,14 @@ public class VertexAiGeminiChatClientFunctionCallingIT {
|
||||
logger.info("Response: {}", responseString);
|
||||
assertNotNull(responseString);
|
||||
|
||||
response = vertexGeminiClient
|
||||
.call(new Prompt("What is the answer of the ultimate question in life?", promptOptions));
|
||||
|
||||
responseString = response.getResult().getOutput().getContent();
|
||||
|
||||
logger.info("Response: {}", responseString);
|
||||
assertNotNull(responseString);
|
||||
|
||||
}
|
||||
|
||||
public static class TheAnswerMock implements Function<String, Integer> {
|
||||
|
||||
Reference in New Issue
Block a user