seratch / ChatGPT-in-Slack

Swift demonstration of how to build a Slack app that enables end-users to interact with a ChatGPT bot
MIT License
441 stars 168 forks source link

Bot references itself in its reply #12

Closed Christolito closed 1 year ago

Christolito commented 1 year ago

So, this might be down to the prompt. But im not shure. The bot keeps referencing itself with @, in its reply. Could i change something here, so that it references the user instead? I added the "prepend part" in the prompt, is i because of that? (See included screen shot of my bot - and system prompt)

image

System message;

You are a strategist Slack chatbot designed to assist UX designers, copywriters, strategists, and product owners at a digital services and PR agency. Your role is to provide expert insights and recommendations on various digital strategies, including content strategy, social media strategy, search engine optimization (SEO), user experience (UX), user interface (UI), service design and website design. As a Slack chatbot, you should be able to engage in conversations with users, answer their questions, and provide personalized recommendations based on their specific needs and goals. Your ultimate goal is to be user-friendly, conversational, and a part of a Slack channel , so that users can seamlessly access your expertise and insights. You might receive messages from multiple people. Each message has the author id prepended, like this: "<@U1234> message text". You are called "Sensei".

seratch commented 1 year ago

Hey @Christolito, you can customize the system prompt with SYSTEM_TEXT env variable. Can you explore a reasonable one for your use case? Refer to https://github.com/seratch/ChatGPT-in-Slack#running-the-app-on-your-local-machine for more details.

From my experience, whether the bot includes mentions depends on how a human asks a question. So, adjusting the system text plus how your end-users ask questions may change the behavior.

Christolito commented 1 year ago

Thx. It's just that it seems to use it's own Slack ID / pings it self, in its reply - instead of the user asking the question... Is this because of the prepended part of the prompt, that it gets confused?

seratch commented 1 year ago

Hmm, I’ve never observed the behavior with my app

c-renton commented 1 year ago

I have seen this too, and it is caused by the prompt Each message has the author id prepended, like this: "<@U1234> message text", since the Slack messages don't seem to have the user IDs prepended in the message text as the prompt would suggest. When you start a new thread with @ChatGPT initial prompt, it is interpreted as if @ChatGPT said initial prompt.

As a workaround, you can change this part of the prompt to Slack user IDs match the regex `<@U.*?>`. so that it knows what the tags are that appear in messages, but it still doesn't know who sent each message.

A better fix might actually be to prepend the messages sent to OpenAI with the user ID that sent them, but then we need to ensure that the prompt tells the bot what its own user ID is, and that it shouldn't include it in its own replies.