mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-03-04 08:20:03 +00:00
This allows users to share a static page of an AI conversation with the rest of the world. By default this feature is disabled, it is enabled by turning on ai_bot_allow_public_sharing via site settings Precautions are taken when sharing 1. We make a carbonite copy 2. We minimize work generating page 3. We limit to 100 interactions 4. Many security checks - including disallowing if there is a mix of users in the PM. * Bonus commit, large PRs like this PR did not work with github tool large objects would destroy context Co-authored-by: Martin Brennan <martin@discourse.org>
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import { ajax } from "discourse/lib/ajax";
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
import Composer from "discourse/models/composer";
|
|
import I18n from "I18n";
|
|
import ShareFullTopicModal from "../components/modal/share-full-topic-modal";
|
|
|
|
export function showShareConversationModal(modal, topicId) {
|
|
ajax(`/discourse-ai/ai-bot/shared-ai-conversations/preview/${topicId}.json`)
|
|
.then((payload) => {
|
|
modal.show(ShareFullTopicModal, { model: payload });
|
|
})
|
|
.catch(popupAjaxError);
|
|
}
|
|
|
|
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: "private_message_ai",
|
|
hasGroups: false,
|
|
warningsDisabled: true,
|
|
skipDraftCheck: true,
|
|
},
|
|
});
|
|
}
|