Skip to content

Commit

Permalink
Requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SquidXTV committed Oct 3, 2023
1 parent d89c029 commit d1c34c0
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,18 @@ RestAction<Message> constructChatGptAttempt(ThreadChannel threadChannel,
"""::formatted)
.flatMap(threadChannel::sendMessage)
.onSuccess(m -> ids.add(m.getId()));
String[] answers = chatGPTAnswer.get();
String[] answers = chatGPTAnswer.orElseThrow();

for (int i = 0; i < answers.length; i++) {
MessageCreateAction messageCreateAction = threadChannel.sendMessage(answers[i]);
MessageCreateAction answer = threadChannel.sendMessage(answers[i]);

if (i == answers.length - 1) {
message = message.flatMap(ignored -> messageCreateAction
message = message.flatMap(any -> answer
.addActionRow(generateDismissButton(componentIdInteractor, ids)));
continue;
}

message = message
.flatMap(ignored -> messageCreateAction.onSuccess(m -> ids.add(m.getId())));
message = message.flatMap(ignored -> answer.onSuccess(m -> ids.add(m.getId())));
}

return message;
Expand Down

0 comments on commit d1c34c0

Please sign in to comment.