mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-06-26 09:32:40 +00:00
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
This commit is contained in:
parent
2486e0e2dd
commit
84e791a941
@ -61,7 +61,7 @@ export default class AiLlmEditorForm extends Component {
|
|||||||
provider: model.provider,
|
provider: model.provider,
|
||||||
enabled_chat_bot: model.enabled_chat_bot,
|
enabled_chat_bot: model.enabled_chat_bot,
|
||||||
vision_enabled: model.vision_enabled,
|
vision_enabled: model.vision_enabled,
|
||||||
provider_params: model.provider_params,
|
provider_params: this.computeProviderParams(model.provider),
|
||||||
llm_quotas: model.llm_quotas,
|
llm_quotas: model.llm_quotas,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -55,12 +55,17 @@ module DiscourseAi
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# developer messages are preferred on reasoning models
|
# developer messages are preferred on recent reasoning models
|
||||||
def supports_developer_messages?
|
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"))
|
(llm_model.name.start_with?("o1") || llm_model.name.start_with?("o3"))
|
||||||
end
|
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)
|
def system_msg(msg)
|
||||||
content = msg[:content]
|
content = msg[:content]
|
||||||
if disable_native_tools? && tools_dialect.instructions.present?
|
if disable_native_tools? && tools_dialect.instructions.present?
|
||||||
@ -69,6 +74,8 @@ module DiscourseAi
|
|||||||
|
|
||||||
if supports_developer_messages?
|
if supports_developer_messages?
|
||||||
{ role: "developer", content: content }
|
{ role: "developer", content: content }
|
||||||
|
elsif legacy_reasoning_model?
|
||||||
|
{ role: "user", content: content }
|
||||||
else
|
else
|
||||||
{ role: "system", content: content }
|
{ role: "system", content: content }
|
||||||
end
|
end
|
||||||
|
@ -72,6 +72,15 @@ RSpec.describe "Managing LLM configurations", type: :system, js: true do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "when changing the provider" do
|
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
|
it "correctly changes the provider params" do
|
||||||
visit "/admin/plugins/discourse-ai/ai-llms"
|
visit "/admin/plugins/discourse-ai/ai-llms"
|
||||||
find("[data-llm-id='none'] button").click()
|
find("[data-llm-id='none'] button").click()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user