Skip to content

Commit

Permalink
prevent chatgpt autopost when attachment is available (Together-Java#…
Browse files Browse the repository at this point in the history
  • Loading branch information
firasrg authored Jul 4, 2024
1 parent bf56085 commit f49d430
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private RestAction<Message> createAIResponse(ThreadChannel threadChannel, Messag
}

private static boolean isContextSufficient(Message message) {
return !MessageUtils.containsImage(message)
return !MessageUtils.containsAttachments(message)
&& !LinkDetection.containsLink(message.getContentRaw());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,16 @@ public static Optional<CodeFence> extractCode(String fullMessage) {
}

/**
* Checks if a given message contains any image attachments.
*
* Checks if a given message contains any attachments.
*
* @param message the message to be checked
* @return {@code true} if the message contains at least one image attachment
* @return {@code true} if the message contains at least one attachment
*
* @see Message
* @see Message.Attachment
*/
public static boolean containsImage(Message message) {
return message.getAttachments().stream().anyMatch(Message.Attachment::isImage);
public static boolean containsAttachments(Message message) {
return !message.getAttachments().isEmpty();
}

}

0 comments on commit f49d430

Please sign in to comment.