Together-Java / TJ-Bot

TJ-Bot is a Discord Bot used on the Together Java server. It is maintained by the community, anyone can contribute.
https://togetherjava.org
GNU General Public License v3.0
98 stars 82 forks source link

inconsistency in titles generated by GPT #1134

Open ankitsmt211 opened 1 week ago

ankitsmt211 commented 1 week ago

Describe the bug

image

as shown in the screenshot, title is quoted sometimes when question is transfered via TransferQuestionCommand, mainly due to inconsistency in response from GPT. Expected behavior

Title shouldnt have any quotation marks

Additional context

 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));
        if (title.length() > TITLE_MAX_LENGTH) {
            title = title.substring(0, TITLE_MAX_LENGTH);
        }

Above piece of code is responsible for generating title in TransferQuestionCommand#onMessageContext, to solve this issue instead of directly assigning generated text from GPT as title, it should be santized by removing quotations if present.

arslanaka commented 1 week ago

I'd like to work on this, assign it to me.

Taz03 commented 1 week ago

@arslanaka remove the prompt check and add a manual check https://github.com/Together-Java/TJ-Bot/pull/1059#issuecomment-2017473576