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

Commit f366ded

Browse files
committed
DEV: Force default to be set if it was found not to be set!
1 parent 87c4214 commit f366ded

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

lib/ai_helper/assistant.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,13 @@ def self.find_ai_helper_model(helper_mode, persona_klass)
320320
if model_id.present?
321321
LlmModel.find_by(id: model_id)
322322
else
323+
last_model_id = LlmModel.last&.id
324+
325+
# SiteSetting.ai_default_llm_model shouldn't be empty, but if it is, we set it to the last model.
326+
if last_model_id.present? && SiteSetting.ai_default_llm_model.empty?
327+
SiteSetting.set_and_log("ai_default_llm_model", "custom:#{last_model_id}", Discourse.system_user) # Remove legacy custom provider.
328+
end
329+
323330
LlmModel.last
324331
end
325332
end

lib/embeddings/semantic_search.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,19 @@ def find_ai_hyde_model(persona_klass)
215215
model_id =
216216
persona_klass.default_llm_id || SiteSetting.ai_default_llm_model&.split(":")&.last # Remove legacy custom provider.
217217

218-
return if model_id.blank?
218+
if model_id.present?
219+
LlmModel.find_by(id: model_id)
220+
else
221+
last_model_id = LlmModel.last&.id
222+
223+
# SiteSetting.ai_default_llm_model shouldn't be empty, but if it is, we set it to the last model.
224+
if last_model_id.present? && SiteSetting.ai_default_llm_model.empty?
225+
SiteSetting.set_and_log("ai_default_llm_model", "custom:#{last_model_id}", Discourse.system_user) # Remove legacy custom provider.
226+
end
227+
228+
LlmModel.last
229+
end
219230

220-
LlmModel.find_by(id: model_id)
221231
end
222232

223233
private

lib/summarization.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ def find_summarization_model(persona_klass)
6262
if model_id.present?
6363
LlmModel.find_by(id: model_id)
6464
else
65+
last_model_id = LlmModel.last&.id
66+
67+
# SiteSetting.ai_default_llm_model shouldn't be empty, but if it is, we set it to the last model.
68+
if last_model_id.present? && SiteSetting.ai_default_llm_model.empty?
69+
SiteSetting.set_and_log("ai_default_llm_model", "custom:#{last_model_id}", Discourse.system_user) # Remove legacy custom provider.
70+
end
71+
6572
LlmModel.last
6673
end
6774
end

0 commit comments

Comments
 (0)