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
This commit is contained in:
Peter Dolukhanov
2024-09-05 12:27:02 -07:00
committed by Christian Tzolov
parent 2a62235f73
commit 26c5674acb

View File

@@ -431,7 +431,7 @@ public class VertexAiGeminiChatModel extends AbstractToolCallSupport implements
else if (message instanceof AssistantMessage assistantMessage) {
List<Part> 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()