Skip to content

Commit c87d0eb

Browse files
committed
Simplify config
1 parent 79b8d46 commit c87d0eb

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

app/controllers/discourse_ai/admin/ai_llms_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class AiLlmsController < ::Admin::AdminController
66
requires_plugin ::DiscourseAi::PLUGIN_NAME
77

88
def index
9-
llms = LlmModel.all
9+
llms = LlmModel.all.order(:display_name)
1010

1111
render json: {
1212
ai_llms:

assets/javascripts/discourse/components/ai-llms-list-editor.gjs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import Component from "@glimmer/component";
2-
import { concat } from "@ember/helper";
2+
import { concat, fn } from "@ember/helper";
3+
import { on } from "@ember/modifier";
4+
import { action } from "@ember/object";
35
import { LinkTo } from "@ember/routing";
6+
import DToggleSwitch from "discourse/components/d-toggle-switch";
7+
import { popupAjaxError } from "discourse/lib/ajax-error";
48
import icon from "discourse-common/helpers/d-icon";
59
import i18n from "discourse-common/helpers/i18n";
610
import I18n from "discourse-i18n";
@@ -11,6 +15,21 @@ export default class AiLlmsListEditor extends Component {
1115
return this.args.llms.length !== 0;
1216
}
1317

18+
@action
19+
async toggleEnabledChatBot(llm) {
20+
const oldValue = llm.enabled_chat_bot;
21+
const newValue = !oldValue;
22+
try {
23+
llm.set("enabled_chat_bot", newValue);
24+
await llm.update({
25+
enabled_chat_bot: newValue,
26+
});
27+
} catch (err) {
28+
llm.set("enabled_chat_bot", oldValue);
29+
popupAjaxError(err);
30+
}
31+
}
32+
1433
<template>
1534
<section class="ai-llms-list-editor admin-detail pull-left">
1635
{{#if @currentLlm}}
@@ -35,6 +54,7 @@ export default class AiLlmsListEditor extends Component {
3554
<tr>
3655
<th>{{i18n "discourse_ai.llms.display_name"}}</th>
3756
<th>{{i18n "discourse_ai.llms.provider"}}</th>
57+
<th>{{i18n "discourse_ai.llms.enabled_chat_bot"}}</th>
3858
<th></th>
3959
</tr>
4060
</thead>
@@ -45,6 +65,12 @@ export default class AiLlmsListEditor extends Component {
4565
<td>{{i18n
4666
(concat "discourse_ai.llms.providers." llm.provider)
4767
}}</td>
68+
<td>
69+
<DToggleSwitch
70+
@state={{llm.enabled_chat_bot}}
71+
{{on "click" (fn this.toggleEnabledChatBot llm)}}
72+
/>
73+
</td>
4874
<td>
4975
<LinkTo
5076
@route="adminPlugins.show.discourse-ai-llms.show"

config/locales/client.en.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ en:
210210
max_prompt_tokens: "Number of tokens for the prompt"
211211
url: "URL of the service hosting the model"
212212
api_key: "API Key of the service hosting the model"
213-
enabled_chat_bot: "Allow Companion user to act as an AI Bot"
213+
enabled_chat_bot: "Allow AI Bot"
214214
save: "Save"
215215
edit: "Edit"
216216
saved: "LLM Model Saved"

0 commit comments

Comments
 (0)