Skip to content

Commit 31a0bee

Browse files
committed
reviewer comments addressed
1 parent 5121300 commit 31a0bee

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

application/src/main/java/org/togetherjava/tjbot/features/moderation/TransferQuestionCommand.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public final class TransferQuestionCommand extends BotCommandAdapter
7272
* Creates a new instance.
7373
*
7474
* @param config to get the helper forum and tags
75+
* @param chatGptService the service used to ask ChatGPT questions via the API.
7576
*/
7677
public TransferQuestionCommand(Config config, ChatGptService chatGptService) {
7778
super(Commands.message(COMMAND_NAME), CommandVisibility.GUILD);
@@ -95,11 +96,12 @@ public void onMessageContext(MessageContextInteractionEvent event) {
9596
String originalChannelId = event.getTarget().getChannel().getId();
9697
String authorId = event.getTarget().getAuthor().getId();
9798
String mostCommonTag = tags.get(0);
98-
String chatGptPrompt = "Generate title for question:"
99-
+ originalMessage + ". Minimum " + TITLE_MIN_LENGTH
100-
+ " and maximum " + TITLE_MAX_LENGTH + " characters. Return only the title.";
101-
Optional<String> chatGptResponse = chatGptService.ask(chatGptPrompt, "");
102-
String title = chatGptResponse.orElse(createTitle(originalMessage));
99+
String chatGptPrompt = String.format(
100+
"Generate title for question: %s. Minimum %s and maximum %s characters. Return only the title.",
101+
originalMessage, TITLE_MIN_LENGTH, TITLE_MAX_LENGTH);
102+
Optional<String> chatGptResponse =
103+
chatGptService.ask(chatGptPrompt, String.join(",", tags));
104+
String title = chatGptResponse.orElse(createTitle(originalMessage)).replace("?", "");
103105

104106
TextInput modalTitle = TextInput.create(MODAL_TITLE_ID, "Title", TextInputStyle.SHORT)
105107
.setMaxLength(TITLE_MAX_LENGTH)

0 commit comments

Comments
 (0)