mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-02-11 14:04:42 +00:00
* FEATURE: optional warning attached to all AI bot conversations This commit introduces `ai_bot_enable_chat_warning` which can be used to warn people prior to starting a chat with the bot. In particular this is useful if moderators are regularly reading chat transcripts as it sets expectations early. By default this is disabled. Also: - Stops making ajax call prior to opening composer - Hides PM title when starting a bot PM Co-authored-by: Rafael dos Santos Silva <xfalcox@gmail.com>
24 lines
664 B
JavaScript
24 lines
664 B
JavaScript
import Composer from "discourse/models/composer";
|
|
import I18n from "I18n";
|
|
|
|
export function composeAiBotMessage(targetBot, composer) {
|
|
const currentUser = composer.currentUser;
|
|
|
|
let botUsername = currentUser.ai_enabled_chat_bots.find(
|
|
(bot) => bot.model_name === targetBot
|
|
).username;
|
|
|
|
composer.focusComposer({
|
|
fallbackToNewTopic: true,
|
|
openOpts: {
|
|
action: Composer.PRIVATE_MESSAGE,
|
|
recipients: botUsername,
|
|
topicTitle: I18n.t("discourse_ai.ai_bot.default_pm_prefix"),
|
|
archetypeId: "private_message",
|
|
draftKey: Composer.NEW_PRIVATE_MESSAGE_KEY,
|
|
hasGroups: false,
|
|
warningsDisabled: true,
|
|
},
|
|
});
|
|
}
|