Skip to content

Commit 9019e90

Browse files
authored
FIX: urlEditable must be true for all providers except Bedrock (#766)
1 parent 3c7bd9b commit 9019e90

File tree

2 files changed

+53
-8
lines changed

2 files changed

+53
-8
lines changed

assets/javascripts/discourse/components/ai-llm-editor-form.gjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default class AiLlmEditorForm extends Component {
5555

5656
@computed("args.model.provider")
5757
get canEditURL() {
58-
return this.args.model.provider === "aws_bedrock";
58+
return this.args.model.provider !== "aws_bedrock";
5959
}
6060

6161
get modulesUsingModel() {
@@ -202,6 +202,7 @@ export default class AiLlmEditorForm extends Component {
202202
<ComboBox
203203
@value={{@model.provider}}
204204
@content={{this.selectedProviders}}
205+
@class="ai-llm-editor__provider"
205206
/>
206207
</div>
207208
{{#if this.canEditURL}}
@@ -251,6 +252,7 @@ export default class AiLlmEditorForm extends Component {
251252
<ComboBox
252253
@value={{@model.tokenizer}}
253254
@content={{@llms.resultSetMeta.tokenizers}}
255+
@class="ai-llm-editor__tokenizer"
254256
/>
255257
</div>
256258
<div class="control-group">

spec/system/llms/ai_llm_spec.rb

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
# frozen_string_literal: true
22

3-
RSpec.describe "Admin dashboard", type: :system do
3+
RSpec.describe "Managing LLM configurations", type: :system do
44
fab!(:admin)
55

6-
it "correctly sets defaults" do
6+
before do
77
SiteSetting.ai_bot_enabled = true
8-
98
sign_in(admin)
9+
end
1010

11-
visit "/admin/plugins/discourse-ai/ai-llms"
12-
13-
find(".ai-llms-list-editor__new").click()
14-
11+
def select_preset(option)
1512
select_kit = PageObjects::Components::SelectKit.new(".ai-llm-editor__presets")
1613

1714
select_kit.expand
1815
select_kit.select_row_by_value("anthropic-claude-3-haiku")
1916

2017
find(".ai-llm-editor__next").click()
18+
end
19+
20+
it "correctly sets defaults" do
21+
visit "/admin/plugins/discourse-ai/ai-llms"
22+
23+
find(".ai-llms-list-editor__new").click()
24+
select_preset("anthropic-claude-3-haiku")
25+
2126
find("input.ai-llm-editor__api-key").fill_in(with: "abcd")
2227

2328
PageObjects::Components::DToggleSwitch.new(".ai-llm-editor__enabled-chat-bot").toggle
@@ -41,4 +46,42 @@
4146
expect(llm.display_name).to eq(model_preset[:display_name])
4247
expect(llm.user_id).not_to be_nil
4348
end
49+
50+
it "manually configures an LLM" do
51+
visit "/admin/plugins/discourse-ai/ai-llms"
52+
53+
find(".ai-llms-list-editor__new").click()
54+
select_preset("none")
55+
56+
find("input.ai-llm-editor__display-name").fill_in(with: "Self-hosted LLM")
57+
find("input.ai-llm-editor__name").fill_in(with: "llava-hf/llava-v1.6-mistral-7b-hf")
58+
find("input.ai-llm-editor__url").fill_in(with: "srv://self-hostest.test")
59+
find("input.ai-llm-editor__api-key").fill_in(with: "1234")
60+
find("input.ai-llm-editor__max-prompt-tokens").fill_in(with: 8000)
61+
62+
find(".ai-llm-editor__provider").click
63+
find(".select-kit-row[data-value=\"vllm\"]").click
64+
65+
find(".ai-llm-editor__tokenizer").click
66+
find(".select-kit-row[data-name=\"Llama3Tokenizer\"]").click
67+
68+
find(".ai-llm-editor__vision-enabled input").click
69+
70+
PageObjects::Components::DToggleSwitch.new(".ai-llm-editor__enabled-chat-bot").toggle
71+
72+
find(".ai-llm-editor__save").click()
73+
74+
expect(page).to have_current_path("/admin/plugins/discourse-ai/ai-llms")
75+
76+
llm = LlmModel.order(:id).last
77+
78+
expect(llm.display_name).to eq("Self-hosted LLM")
79+
expect(llm.name).to eq("llava-hf/llava-v1.6-mistral-7b-hf")
80+
expect(llm.url).to eq("srv://self-hostest.test")
81+
expect(llm.tokenizer).to eq("DiscourseAi::Tokenizer::Llama3Tokenizer")
82+
expect(llm.max_prompt_tokens.to_i).to eq(8000)
83+
expect(llm.provider).to eq("vllm")
84+
expect(llm.vision_enabled).to eq(true)
85+
expect(llm.user_id).not_to be_nil
86+
end
4487
end

0 commit comments

Comments
 (0)