-
Notifications
You must be signed in to change notification settings - Fork 40
UX: move templates to main LLM config tab, restyle #813
Changes from 6 commits
9c4aca3
b61b819
3523e99
82ade98
0cba3da
d164038
2f367af
1f3d7ae
b8b3c61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| <AiLlmsListEditor @llms={{this.allLlms}} @currentLlm={{this.model}} /> | ||
| <AiLlmsListEditor | ||
| @llms={{this.allLlms}} | ||
| @currentLlm={{this.model}} | ||
| @llmTemplate={{this.llmTemplate}} | ||
| /> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,9 @@ import { on } from "@ember/modifier"; | |
| import { action } from "@ember/object"; | ||
| import { LinkTo } from "@ember/routing"; | ||
| import { inject as service } from "@ember/service"; | ||
| import { or } from "truth-helpers"; | ||
| import DBreadcrumbsItem from "discourse/components/d-breadcrumbs-item"; | ||
| import DButton from "discourse/components/d-button"; | ||
| import DToggleSwitch from "discourse/components/d-toggle-switch"; | ||
| import { popupAjaxError } from "discourse/lib/ajax-error"; | ||
| import icon from "discourse-common/helpers/d-icon"; | ||
|
|
@@ -14,11 +16,60 @@ import AiLlmEditor from "./ai-llm-editor"; | |
|
|
||
| export default class AiLlmsListEditor extends Component { | ||
| @service adminPluginNavManager; | ||
| @service router; | ||
|
|
||
| get hasLLMElements() { | ||
| sanitizedTranslationKey(id) { | ||
| return id.replace(/\./g, "-"); | ||
| } | ||
|
|
||
| get hasLlmElements() { | ||
| return this.args.llms.length !== 0; | ||
| } | ||
|
|
||
| get preConfiguredLlms() { | ||
| let options = [ | ||
| { | ||
| id: "none", | ||
| name: I18n.t("discourse_ai.llms.preconfigured.fake"), | ||
| provider: "fake", | ||
| }, | ||
| ]; | ||
|
|
||
| const llmsContent = this.args.llms.content.map((llm) => ({ | ||
| provider: llm.provider, | ||
| name: llm.name, | ||
| })); | ||
|
|
||
| this.args.llms.resultSetMeta.presets.forEach((llm) => { | ||
| if (llm.models) { | ||
| llm.models.forEach((model) => { | ||
| const id = `${llm.id}-${model.name}`; | ||
| const isConfigured = llmsContent.some( | ||
| (content) => | ||
| content.provider === llm.provider && content.name === model.name | ||
| ); | ||
|
|
||
| if (!isConfigured) { | ||
| options.push({ | ||
| id, | ||
| name: model.display_name, | ||
| provider: llm.provider, | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| return options; | ||
| } | ||
|
|
||
| @action | ||
| transitionToLlmEditor(llmTemplate) { | ||
| this.router.transitionTo("adminPlugins.show.discourse-ai-llms.new", { | ||
| queryParams: { llmTemplate }, | ||
| }); | ||
| } | ||
|
|
||
| @action | ||
| async toggleEnabledChatBot(llm) { | ||
| const oldValue = llm.enabled_chat_bot; | ||
|
|
@@ -39,60 +90,118 @@ export default class AiLlmsListEditor extends Component { | |
| @path="/admin/plugins/{{this.adminPluginNavManager.currentPlugin.name}}/ai-llms" | ||
| @label={{i18n "discourse_ai.llms.short_title"}} | ||
| /> | ||
| <section class="ai-llms-list-editor admin-detail pull-left"> | ||
|
|
||
| <section class="ai-llm-list-editor admin-detail"> | ||
| {{#if @currentLlm}} | ||
| <AiLlmEditor @model={{@currentLlm}} @llms={{@llms}} /> | ||
| <AiLlmEditor | ||
| @model={{@currentLlm}} | ||
| @llms={{@llms}} | ||
| @llmTemplate={{@llmTemplate}} | ||
| /> | ||
| {{else}} | ||
| <div class="ai-llms-list-editor__header"> | ||
| <h3>{{i18n "discourse_ai.llms.short_title"}}</h3> | ||
| {{#unless @currentLlm.isNew}} | ||
| <LinkTo | ||
| @route="adminPlugins.show.discourse-ai-llms.new" | ||
| class="btn btn-small btn-primary ai-llms-list-editor__new" | ||
| > | ||
| {{icon "plus"}} | ||
| <span>{{I18n.t "discourse_ai.llms.new"}}</span> | ||
| </LinkTo> | ||
| {{/unless}} | ||
| </div> | ||
|
|
||
| {{#if this.hasLLMElements}} | ||
| <table class="content-list ai-persona-list-editor"> | ||
| <thead> | ||
| <tr> | ||
| <th>{{i18n "discourse_ai.llms.display_name"}}</th> | ||
| <th>{{i18n "discourse_ai.llms.provider"}}</th> | ||
| <th>{{i18n "discourse_ai.llms.enabled_chat_bot"}}</th> | ||
| <th></th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {{#each @llms as |llm|}} | ||
| <tr data-persona-id={{llm.id}} class="ai-llm-list__row"> | ||
| <td><strong>{{llm.display_name}}</strong></td> | ||
| <td>{{i18n | ||
| (concat "discourse_ai.llms.providers." llm.provider) | ||
| }}</td> | ||
| <td> | ||
| <DToggleSwitch | ||
| @state={{llm.enabled_chat_bot}} | ||
| {{on "click" (fn this.toggleEnabledChatBot llm)}} | ||
| /> | ||
| </td> | ||
| <td> | ||
| <LinkTo | ||
| @route="adminPlugins.show.discourse-ai-llms.show" | ||
| current-when="true" | ||
| class="btn btn-text btn-small" | ||
| @model={{llm}} | ||
| >{{i18n "discourse_ai.llms.edit"}}</LinkTo> | ||
| </td> | ||
| {{#if this.hasLlmElements}} | ||
| <section class="ai-llms-list-editor__configured"> | ||
| <div class="admin-page-subheader"> | ||
SamSaffron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <div class="admin-page-subheader__title-row"> | ||
| <h2 class="admin-page-subheader__title"> | ||
| {{i18n "discourse_ai.llms.configured.title"}} | ||
| </h2> | ||
| </div> | ||
| </div> | ||
| <table> | ||
| <thead> | ||
| <tr> | ||
| <th>{{i18n "discourse_ai.llms.display_name"}}</th> | ||
| <th>{{i18n "discourse_ai.llms.provider"}}</th> | ||
| <th>{{i18n "discourse_ai.llms.enabled_chat_bot"}}</th> | ||
| <th></th> | ||
| </tr> | ||
| {{/each}} | ||
| </tbody> | ||
| </table> | ||
| </thead> | ||
| <tbody> | ||
| {{#each @llms as |llm|}} | ||
| <tr data-persona-id={{llm.id}} class="ai-llm-list__row"> | ||
| <td class="column-name"> | ||
| <h3>{{llm.display_name}}</h3> | ||
| <p> | ||
| {{i18n | ||
| (concat | ||
| "discourse_ai.llms.model_description." | ||
| llm.provider | ||
| "-" | ||
| llm.name | ||
| ) | ||
| }} | ||
| </p> | ||
| </td> | ||
| <td> | ||
| {{i18n | ||
| (concat "discourse_ai.llms.providers." llm.provider) | ||
| }} | ||
| </td> | ||
| <td> | ||
| <DToggleSwitch | ||
| @state={{llm.enabled_chat_bot}} | ||
| {{on "click" (fn this.toggleEnabledChatBot llm)}} | ||
| /> | ||
| </td> | ||
| <td class="column-edit"> | ||
| <LinkTo | ||
| @route="adminPlugins.show.discourse-ai-llms.show" | ||
| class="btn btn-default" | ||
| @model={{or llm.id llm.llm.id}} | ||
|
||
| > | ||
| {{icon "wrench"}} | ||
| <div class="d-button-label"> | ||
| {{i18n "discourse_ai.llms.edit"}} | ||
| </div> | ||
| </LinkTo> | ||
| </td> | ||
| </tr> | ||
| {{/each}} | ||
| </tbody> | ||
| </table> | ||
| </section> | ||
| {{/if}} | ||
| <section class="ai-llms-list-editor__templates"> | ||
| <div class="admin-page-subheader"> | ||
|
||
| <div class="admin-page-subheader__title-row"> | ||
| <h2 class="admin-page-subheader__title"> | ||
| {{#if this.hasLlmElements}} | ||
| {{i18n "discourse_ai.llms.preconfigured.title"}} | ||
| {{else}} | ||
| {{i18n "discourse_ai.llms.preconfigured.title_no_llms"}} | ||
| {{/if}} | ||
| </h2> | ||
| </div> | ||
| </div> | ||
| <div class="ai-llms-list-editor__templates-list"> | ||
| {{#each this.preConfiguredLlms as |llm|}} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would really prefer these "section landing" tiles are reusable components, this is why I opened this draft PR https://github.com/discourse/discourse/pull/28477/files . At the least could you please extract this to a component in this PR then we can replace with a core version later?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets do this in a followup, really want to land this. I addressed the rest of the feedback. |
||
| <div | ||
| data-llm-id={{llm.id}} | ||
| class="ai-llms-list-editor__templates-list-item" | ||
| > | ||
| <h4> | ||
| {{i18n (concat "discourse_ai.llms.providers." llm.provider)}} | ||
| </h4> | ||
| <h3> | ||
| {{llm.name}} | ||
| </h3> | ||
| <p> | ||
| {{i18n | ||
| (concat | ||
| "discourse_ai.llms.model_description." | ||
| (this.sanitizedTranslationKey llm.id) | ||
| ) | ||
| }} | ||
| </p> | ||
| <DButton | ||
| @action={{fn this.transitionToLlmEditor llm.id}} | ||
| @icon="gear" | ||
| @label="discourse_ai.llms.preconfigured.button" | ||
| /> | ||
| </div> | ||
| {{/each}} | ||
| </div> | ||
| </section> | ||
| {{/if}} | ||
| </section> | ||
| </template> | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.