Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 84e791a

Browse files
authored
FIX: legacy reasoning models not working, missing provider params (#1149)
* FIX: legacy reasoning models not working, missing provider params 1. Legacy reasoning models (o1-preview / o1-mini) do not support developer or system messages, do not use them. 2. LLM editor form not showing all provider params due to missing remap * add system test
1 parent 2486e0e commit 84e791a

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default class AiLlmEditorForm extends Component {
6161
provider: model.provider,
6262
enabled_chat_bot: model.enabled_chat_bot,
6363
vision_enabled: model.vision_enabled,
64-
provider_params: model.provider_params,
64+
provider_params: this.computeProviderParams(model.provider),
6565
llm_quotas: model.llm_quotas,
6666
};
6767
}

lib/completions/dialects/chat_gpt.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,17 @@ def tools_dialect
5555
end
5656
end
5757

58-
# developer messages are preferred on reasoning models
58+
# developer messages are preferred on recent reasoning models
5959
def supports_developer_messages?
60-
llm_model.provider == "open_ai" &&
60+
!legacy_reasoning_model? && llm_model.provider == "open_ai" &&
6161
(llm_model.name.start_with?("o1") || llm_model.name.start_with?("o3"))
6262
end
6363

64+
def legacy_reasoning_model?
65+
llm_model.provider == "open_ai" &&
66+
(llm_model.name.start_with?("o1-preview") || llm_model.name.start_with?("o1-mini"))
67+
end
68+
6469
def system_msg(msg)
6570
content = msg[:content]
6671
if disable_native_tools? && tools_dialect.instructions.present?
@@ -69,6 +74,8 @@ def system_msg(msg)
6974

7075
if supports_developer_messages?
7176
{ role: "developer", content: content }
77+
elsif legacy_reasoning_model?
78+
{ role: "user", content: content }
7279
else
7380
{ role: "system", content: content }
7481
end

spec/system/llms/ai_llm_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@
7272
end
7373

7474
context "when changing the provider" do
75+
it "has the correct provider params when visiting the edit page" do
76+
llm = Fabricate(:llm_model, provider: "open_ai", provider_params: {})
77+
visit "/admin/plugins/discourse-ai/ai-llms/#{llm.id}/edit"
78+
79+
expect(form).to have_field_with_name("provider_params.organization")
80+
expect(form).to have_field_with_name("provider_params.disable_native_tools")
81+
expect(form).to have_field_with_name("provider_params.disable_streaming")
82+
expect(form).to have_field_with_name("provider_params.reasoning_effort")
83+
end
7584
it "correctly changes the provider params" do
7685
visit "/admin/plugins/discourse-ai/ai-llms"
7786
find("[data-llm-id='none'] button").click()

0 commit comments

Comments
 (0)