Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class AiLlmEditorForm extends Component {
provider: model.provider,
enabled_chat_bot: model.enabled_chat_bot,
vision_enabled: model.vision_enabled,
provider_params: model.provider_params,
provider_params: this.computeProviderParams(model.provider),
llm_quotas: model.llm_quotas,
};
}
Expand Down
11 changes: 9 additions & 2 deletions lib/completions/dialects/chat_gpt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,17 @@ def tools_dialect
end
end

# developer messages are preferred on reasoning models
# developer messages are preferred on recent reasoning models
def supports_developer_messages?
llm_model.provider == "open_ai" &&
!legacy_reasoning_model? && llm_model.provider == "open_ai" &&
(llm_model.name.start_with?("o1") || llm_model.name.start_with?("o3"))
end

def legacy_reasoning_model?
llm_model.provider == "open_ai" &&
(llm_model.name.start_with?("o1-preview") || llm_model.name.start_with?("o1-mini"))
end

def system_msg(msg)
content = msg[:content]
if disable_native_tools? && tools_dialect.instructions.present?
Expand All @@ -69,6 +74,8 @@ def system_msg(msg)

if supports_developer_messages?
{ role: "developer", content: content }
elsif legacy_reasoning_model?
{ role: "user", content: content }
else
{ role: "system", content: content }
end
Expand Down
9 changes: 9 additions & 0 deletions spec/system/llms/ai_llm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@
end

context "when changing the provider" do
it "has the correct provider params when visiting the edit page" do
llm = Fabricate(:llm_model, provider: "open_ai", provider_params: {})
visit "/admin/plugins/discourse-ai/ai-llms/#{llm.id}/edit"

expect(form).to have_field_with_name("provider_params.organization")
expect(form).to have_field_with_name("provider_params.disable_native_tools")
expect(form).to have_field_with_name("provider_params.disable_streaming")
expect(form).to have_field_with_name("provider_params.reasoning_effort")
end
it "correctly changes the provider params" do
visit "/admin/plugins/discourse-ai/ai-llms"
find("[data-llm-id='none'] button").click()
Expand Down