Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistency in titles generated by GPT #fixed #1137

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,18 @@ public void onMessageContext(MessageContextInteractionEvent event) {
String originalChannelId = event.getTarget().getChannel().getId();
String authorId = event.getTarget().getAuthor().getId();
String mostCommonTag = tags.getFirst();
final int TITLE_MAX_LENGTH = 50;
alisha2501 marked this conversation as resolved.
Show resolved Hide resolved
String chatGptPrompt =
"Summarize the following text into a concise title or heading not more than 4-5 words, remove quotations if any: %s"
.formatted(originalMessage);
Optional<String> chatGptResponse = chatGptService.ask(chatGptPrompt, "");
String title = chatGptResponse.orElse(createTitle(originalMessage));
title = title.replaceAll("^\"|\"$", "").replaceAll("^'|'$", "");
alisha2501 marked this conversation as resolved.
Show resolved Hide resolved
alisha2501 marked this conversation as resolved.
Show resolved Hide resolved
if (title.length() > TITLE_MAX_LENGTH) {
title = title.substring(0, TITLE_MAX_LENGTH);
}


TextInput modalTitle = TextInput.create(MODAL_TITLE_ID, "Title", TextInputStyle.SHORT)
.setMaxLength(TITLE_MAX_LENGTH)
.setMinLength(TITLE_MIN_LENGTH)
Expand Down Expand Up @@ -176,8 +179,7 @@ private void transferFlow(ModalInteractionEvent event, String channelId, String
.retrieveUserById(authorId)
.flatMap(fetchedUser -> createForumPost(event, fetchedUser))
.flatMap(createdForumPost -> dmUser(event.getChannel(), createdForumPost,
event.getGuild())
.and(sendMessageToTransferrer.apply(createdForumPost)))
event.getGuild()).and(sendMessageToTransferrer.apply(createdForumPost)))
.flatMap(dmSent -> deleteOriginalMessage(event.getJDA(), channelId, messageId))
.queue();
}
Expand Down