Skip to content

Commit 9cd01c5

Browse files
committed
temp
1 parent b4194bd commit 9cd01c5

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatClient.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,12 @@ private List<Tool> getFunctionTools(Set<String> functionNames) {
351351

352352
final var tool = Tool.newBuilder();
353353

354-
final var functionDeclarations = this.resolveFunctionCallbacks(functionNames)
354+
final List<FunctionDeclaration> functionDeclarations = this.resolveFunctionCallbacks(functionNames)
355355
.stream()
356356
.map(functionCallback -> FunctionDeclaration.newBuilder()
357357
.setName(functionCallback.getName())
358358
.setDescription(functionCallback.getDescription())
359359
.setParameters(jsonToSchema(functionCallback.getInputTypeSchema()))
360-
// .setParameters(toOpenApiSchema(functionCallback.getInputTypeSchema()))
361360
.build())
362361
.toList();
363362
tool.addAllFunctionDeclarations(functionDeclarations);

models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/function/VertexAiGeminiChatClientFunctionCallingIT.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ public void functionCallTestInferredOpenApiSchemaStream() {
179179

180180
}
181181

182-
//Gemini wants single tool with multiple function, instead multiple tools with single function
182+
// Gemini wants single tool with multiple function, instead multiple tools with single
183+
// function
183184
@Test
184185
public void canDeclareMultipleFunctions() {
185186

@@ -200,8 +201,12 @@ public void canDeclareMultipleFunctions() {
200201
.build();
201202
var promptOptions = VertexAiGeminiChatOptions.builder()
202203
.withModel(VertexAiGeminiChatClient.ChatModel.GEMINI_PRO.getValue())
203-
.withFunctionCallbacks(List.of(weatherFunction, theAnswer))
204+
.withFunctionCallbacks(List.of(weatherFunction))
204205
.build();
206+
// var promptOptions = VertexAiGeminiChatOptions.builder()
207+
// .withModel(VertexAiGeminiChatClient.ChatModel.GEMINI_PRO.getValue())
208+
// .withFunctionCallbacks(List.of(weatherFunction, theAnswer))
209+
// .build();
205210

206211
ChatResponse response = vertexGeminiClient.call(new Prompt(messages, promptOptions));
207212

@@ -210,6 +215,14 @@ public void canDeclareMultipleFunctions() {
210215
logger.info("Response: {}", responseString);
211216
assertNotNull(responseString);
212217

218+
response = vertexGeminiClient
219+
.call(new Prompt("What is the answer of the ultimate question in life?", promptOptions));
220+
221+
responseString = response.getResult().getOutput().getContent();
222+
223+
logger.info("Response: {}", responseString);
224+
assertNotNull(responseString);
225+
213226
}
214227

215228
public static class TheAnswerMock implements Function<String, Integer> {

0 commit comments

Comments
 (0)