mirror of
https://ghfast.top/https://github.com/discourse/discourse-ai.git
synced 2026-07-18 11:49:33 +08:00
- Remove unused 'toggleAiBotPanel' widget action
- Switch from appEvents to closure actions
- Convert widget definition to native class syntax, so that we can use `@action` decorator. (alternatively, we could have done `{ closePanel: this.hideAiBotPanel.bind(this) }` in `RenderGlimmer`
34 lines
888 B
JavaScript
34 lines
888 B
JavaScript
import { action } from "@ember/object";
|
|
import { inject as service } from "@ember/service";
|
|
import Component from "@glimmer/component";
|
|
import { composeAiBotMessage } from "discourse/plugins/discourse-ai/discourse/lib/ai-bot-helper";
|
|
|
|
import I18n from "I18n";
|
|
|
|
export default class AiBotHeaderPanel extends Component {
|
|
@service siteSettings;
|
|
@service composer;
|
|
|
|
@action
|
|
async composeMessageWithTargetBot(target) {
|
|
this.#composeAiBotMessage(target);
|
|
}
|
|
|
|
get botNames() {
|
|
return this.enabledBotOptions.map((bot) => {
|
|
return {
|
|
humanized: I18n.t(`discourse_ai.ai_bot.bot_names.${bot}`),
|
|
modelName: bot,
|
|
};
|
|
});
|
|
}
|
|
|
|
get enabledBotOptions() {
|
|
return this.siteSettings.ai_bot_enabled_chat_bots.split("|");
|
|
}
|
|
|
|
async #composeAiBotMessage(targetBot) {
|
|
this.args.closePanel();
|
|
composeAiBotMessage(targetBot, this.composer);
|
|
}
|
|
}
|