diff --git a/admin/assets/javascripts/discourse/routes/admin-plugins-show-discourse-ai-personas-new.js b/admin/assets/javascripts/discourse/routes/admin-plugins-show-discourse-ai-personas-new.js index 03be10ea..0964027c 100644 --- a/admin/assets/javascripts/discourse/routes/admin-plugins-show-discourse-ai-personas-new.js +++ b/admin/assets/javascripts/discourse/routes/admin-plugins-show-discourse-ai-personas-new.js @@ -10,6 +10,8 @@ export default DiscourseRoute.extend({ record.set("rag_chunk_tokens", 374); record.set("rag_chunk_overlap_tokens", 10); record.set("rag_conversation_chunks", 10); + record.set("allow_personal_messages", true); + record.set("tool_details", false); return record; }, diff --git a/app/controllers/discourse_ai/admin/ai_llms_controller.rb b/app/controllers/discourse_ai/admin/ai_llms_controller.rb index 6505c174..3727a090 100644 --- a/app/controllers/discourse_ai/admin/ai_llms_controller.rb +++ b/app/controllers/discourse_ai/admin/ai_llms_controller.rb @@ -14,6 +14,9 @@ module DiscourseAi llms, each_serializer: LlmModelSerializer, root: false, + scope: { + llm_usage: DiscourseAi::Configuration::LlmEnumerator.global_usage, + }, ).as_json, meta: { provider_params: LlmModel.provider_params, diff --git a/app/serializers/llm_model_serializer.rb b/app/serializers/llm_model_serializer.rb index f4bce72e..48e6e46c 100644 --- a/app/serializers/llm_model_serializer.rb +++ b/app/serializers/llm_model_serializer.rb @@ -22,7 +22,16 @@ class LlmModelSerializer < ApplicationSerializer has_one :user, serializer: BasicUserSerializer, embed: :object def used_by - DiscourseAi::Configuration::LlmValidator.new.modules_using(object) + llm_usage = + ( + if (scope && scope[:llm_usage]) + scope[:llm_usage] + else + DiscourseAi::Configuration::LlmEnumerator.global_usage + end + ) + + llm_usage[object.id] end def api_key diff --git a/assets/javascripts/discourse/components/ai-llm-editor-form.gjs b/assets/javascripts/discourse/components/ai-llm-editor-form.gjs index df17e832..f76c28ae 100644 --- a/assets/javascripts/discourse/components/ai-llm-editor-form.gjs +++ b/assets/javascripts/discourse/components/ai-llm-editor-form.gjs @@ -9,7 +9,6 @@ import { later } from "@ember/runloop"; import { inject as service } from "@ember/service"; import { eq } from "truth-helpers"; import DButton from "discourse/components/d-button"; -import DToggleSwitch from "discourse/components/d-toggle-switch"; import Avatar from "discourse/helpers/bound-avatar-template"; import { popupAjaxError } from "discourse/lib/ajax-error"; import icon from "discourse-common/helpers/d-icon"; @@ -59,7 +58,20 @@ export default class AiLlmEditorForm extends Component { } get modulesUsingModel() { - return this.args.model.used_by?.join(", "); + const usedBy = this.args.model.used_by?.filter((m) => m.type !== "ai_bot"); + + if (!usedBy || usedBy.length === 0) { + return null; + } + + const localized = usedBy.map((m) => { + return I18n.t(`discourse_ai.llms.usage.${m.type}`, { + persona: m.name, + }); + }); + + // TODO: this is not perfectly localized + return localized.join(", "); } get seeded() { @@ -157,20 +169,6 @@ export default class AiLlmEditorForm extends Component { }); } - @action - async toggleEnabledChatBot() { - this.args.model.set("enabled_chat_bot", !this.args.model.enabled_chat_bot); - if (!this.args.model.isNew) { - try { - await this.args.model.update({ - enabled_chat_bot: this.args.model.enabled_chat_bot, - }); - } catch (e) { - popupAjaxError(e); - } - } - } -