From 26c5674acba9ff5a0ef58b6e8aee8fca4c0a99b6 Mon Sep 17 00:00:00 2001 From: Peter Dolukhanov Date: Thu, 5 Sep 2024 12:27:02 -0700 Subject: [PATCH] Fix where previous Assistant Messages were not being added to the parts list. Results in: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Unable to submit request because it must include at least one parts field, which describes the prompt input. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini --- .../ai/vertexai/gemini/VertexAiGeminiChatModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatModel.java b/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatModel.java index 497a839140..faca97ae27 100644 --- a/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatModel.java +++ b/models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatModel.java @@ -431,7 +431,7 @@ else if (message instanceof UserMessage userMessage) { else if (message instanceof AssistantMessage assistantMessage) { List parts = new ArrayList<>(); if (StringUtils.hasText(assistantMessage.getContent())) { - List.of(Part.newBuilder().setText(assistantMessage.getContent()).build()); + parts.add(Part.newBuilder().setText(assistantMessage.getContent()).build()); } if (!CollectionUtils.isEmpty(assistantMessage.getToolCalls())) { parts.addAll(assistantMessage.getToolCalls()