mattermost / mattermost-plugin-ai

Mattermost Copilot plugin supporting multiple LLMs
https://mattermost.com/copilot
Apache License 2.0
136 stars 30 forks source link

Add withUserId configuration for OpenAI #259

Closed hun-a closed 1 week ago

hun-a commented 2 weeks ago

Closes #258

Description

Hello!

I'm thoroughly enjoying the Mattermost AI plugin and appreciate how useful it has been for our team. As I’ve been using it, I thought of a small enhancement that could add value, so I put together a PR to share with you.

The OpenAI Chat Completion API supports a user parameter, which can help with user monitoring and detecting abuse. I’ve implemented a feature that allows admins to toggle whether or not to send the Username when using OpenAI models. This option is accessible in the plugin settings, providing greater flexibility and control.

Additionally, I have a suggestion that might improve the user experience for a more global audience. Currently, in direct messages (DMs), the plugin uses a combination of Firstname and Lastname to identify users. https://github.com/mattermost/mattermost-plugin-ai/blob/master/server/ai/prompts/standard_personality_without_locale.tmpl#L9

{{if .RequestingUser.FirstName}}
Their full name is {{.RequestingUser.FirstName}} {{.RequestingUser.LastName}}.
{{end}}

Modifying this to pass the Username instead might feel more relatable for users from different cultural backgrounds, which could further support Mattermost’s positioning as a globally inclusive collaboration tool.

If you find the suggestion to use Username agreeable, I’d be happy to incorporate it into this PR.

Thank you for considering this enhancement!

hun-a commented 1 week ago

Hi @crspeller!

Thank you so much for fixing the linting issues and refining the code! 🙏

I initially suggested using Username instead because I was aiming for the LLM to prioritize the user's FirstName over their full username. However, I overlooked the fact that Username is already being supplied in the existing template. Given that, I agree that it makes more sense to stick with the current approach as you suggested.

Thanks again for your help! 😊