diff --git a/assets/javascripts/discourse/components/ai-llm-editor-form.gjs b/assets/javascripts/discourse/components/ai-llm-editor-form.gjs index f76c28ae..1def5510 100644 --- a/assets/javascripts/discourse/components/ai-llm-editor-form.gjs +++ b/assets/javascripts/discourse/components/ai-llm-editor-form.gjs @@ -1,7 +1,7 @@ import Component from "@glimmer/component"; import { tracked } from "@glimmer/tracking"; import { Input } from "@ember/component"; -import { concat, get } from "@ember/helper"; +import { concat, get, hash } from "@ember/helper"; import { on } from "@ember/modifier"; import { action, computed } from "@ember/object"; import { LinkTo } from "@ember/routing"; @@ -189,6 +189,7 @@ export default class AiLlmEditorForm extends Component { class="ai-llm-editor-input ai-llm-editor__display-name" @type="text" @value={{@model.display_name}} + disabled={{this.seeded}} />
@@ -197,24 +198,26 @@ export default class AiLlmEditorForm extends Component { class="ai-llm-editor-input ai-llm-editor__name" @type="text" @value={{@model.name}} + disabled={{this.seeded}} />
- +
{{#unless this.seeded}} {{#if this.canEditURL}}
- + {{/if}}
- +
{{#each-in this.metaProviderParams as |field type|}}
-
{{/each-in}}
- +
- +
- +
- {{#if @model.user}} -
- - - {{Avatar @model.user.avatar_template "small"}} - - - {{@model.user.username}} - -
- {{/if}} + {{/unless}} + + {{#if @model.user}} +
+ + + {{Avatar @model.user.avatar_template "small"}} + + + {{@model.user.username}} + +
+ {{/if}} + + {{#unless this.seeded}}
- {{I18n.t "discourse_ai.llms.tests.title"}} - + @label="discourse_ai.llms.tests.title" + /> - {{I18n.t "discourse_ai.llms.save"}} - + @label="discourse_ai.llms.save" + /> {{#unless @model.isNew}} - {{I18n.t "discourse_ai.llms.delete"}} - + @label="discourse_ai.llms.delete" + /> {{/unless}}
{{/unless}} @@ -343,12 +347,12 @@ export default class AiLlmEditorForm extends Component { {{#if this.displayTestResult}} {{#if this.testRunning}}
- {{I18n.t "discourse_ai.llms.tests.running"}} + {{i18n "discourse_ai.llms.tests.running"}} {{else}} {{#if this.testResult}}
{{icon "check"}} - {{I18n.t "discourse_ai.llms.tests.success"}} + {{i18n "discourse_ai.llms.tests.success"}}
{{else}}
diff --git a/assets/javascripts/discourse/components/ai-llms-list-editor.gjs b/assets/javascripts/discourse/components/ai-llms-list-editor.gjs index b806a854..fed9aeed 100644 --- a/assets/javascripts/discourse/components/ai-llms-list-editor.gjs +++ b/assets/javascripts/discourse/components/ai-llms-list-editor.gjs @@ -135,7 +135,7 @@ export default class AiLlmsListEditor extends Component { {{#each @llms as |llm|}} - +

{{llm.display_name}}

@@ -149,7 +149,7 @@ export default class AiLlmsListEditor extends Component { {{/if}} - + {{i18n (concat "discourse_ai.llms.providers." llm.provider) }} diff --git a/spec/fabricators/llm_model_fabricator.rb b/spec/fabricators/llm_model_fabricator.rb index 64f17725..421c2a6c 100644 --- a/spec/fabricators/llm_model_fabricator.rb +++ b/spec/fabricators/llm_model_fabricator.rb @@ -89,3 +89,14 @@ Fabricator(:ollama_model, from: :llm_model) do url "http://api.ollama.ai/api/chat" provider_params { { enable_native_tool: true } } end + +Fabricator(:seeded_model, from: :llm_model) do + id "-2" + display_name "CDCK Hosted Model" + name "cdck-hosted" + provider "fake" + api_key "DSC" + tokenizer "DiscourseAi::Tokenizer::OpenAiTokenizer" + url "https://cdck.test/" + enabled_chat_bot true +end diff --git a/spec/system/llms/ai_llm_spec.rb b/spec/system/llms/ai_llm_spec.rb index 4aeede18..ec5f4003 100644 --- a/spec/system/llms/ai_llm_spec.rb +++ b/spec/system/llms/ai_llm_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe "Managing LLM configurations", type: :system do +RSpec.describe "Managing LLM configurations", type: :system, js: true do fab!(:admin) before do @@ -69,4 +69,33 @@ RSpec.describe "Managing LLM configurations", type: :system do expect(llm.vision_enabled).to eq(true) expect(llm.user_id).not_to be_nil end + + context "when seeded LLM is present" do + fab!(:llm_model) { Fabricate(:seeded_model) } + + it "shows the provider as CDCK in the UI" do + visit "/admin/plugins/discourse-ai/ai-llms" + expect(page).to have_css( + "[data-llm-id='cdck-hosted'] .column-provider", + text: I18n.t("js.discourse_ai.llms.providers.CDCK"), + ) + end + + it "shows an info alert to the user about the seeded LLM" do + visit "/admin/plugins/discourse-ai/ai-llms" + find("[data-llm-id='#{llm_model.name}'] .column-edit .btn").click() + expect(page).to have_css( + ".alert.alert-info", + text: I18n.t("js.discourse_ai.llms.seeded_warning"), + ) + end + + it "limits and shows disabled inputs for the seeded LLM" do + visit "/admin/plugins/discourse-ai/ai-llms" + find("[data-llm-id='cdck-hosted'] .column-edit .btn").click() + expect(page).to have_css(".ai-llm-editor__display-name[disabled]") + expect(page).to have_css(".ai-llm-editor__name[disabled]") + expect(page).to have_css(".ai-llm-editor__provider.is-disabled") + end + end end