Skip to content

Commit

Permalink
Fix where previous Assistant Messages were not being added to the par…
Browse files Browse the repository at this point in the history
…ts 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
  • Loading branch information
Peter Dolukhanov authored and tzolov committed Sep 10, 2024
1 parent 2a62235 commit 26c5674
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ else if (message instanceof UserMessage userMessage) {
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()
Expand Down

0 comments on commit 26c5674

Please sign in to comment.