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

Commit 848692c

Browse files
committed
fix more specs
1 parent 938a445 commit 848692c

File tree

6 files changed

+12
-15
lines changed

6 files changed

+12
-15
lines changed

app/models/ai_persona.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def class_instance
165165
vision_enabled
166166
vision_max_pixels
167167
rag_conversation_chunks
168-
question_consolidator_llm
168+
question_consolidator_llm_id
169169
allow_chat_channel_mentions
170170
allow_chat_direct_messages
171171
allow_topic_mentions

lib/ai_bot/bot.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def self.guess_model(bot_user)
246246

247247
return if associated_llm.nil? # Might be a persona user. Handled by constructor.
248248

249-
"custom:#{associated_llm.id}"
249+
associated_llm
250250
end
251251

252252
def build_placeholder(summary, details, custom_raw: nil)

lib/ai_bot/personas/persona.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,11 @@ def craft_prompt(context, llm: nil)
173173
TEXT
174174

175175
question_consolidator_llm = llm
176-
if self.class.question_consolidator_llm.present?
177-
question_consolidator_llm =
178-
DiscourseAi::Completions::Llm.proxy(self.class.question_consolidator_llm)
176+
if self.class.question_consolidator_llm_id.present?
177+
question_consolidator_llm ||=
178+
DiscourseAi::Completions::Llm.proxy(
179+
LlmModel.find_by(id: self.class.question_consolidator_llm_id),
180+
)
179181
end
180182

181183
if context[:custom_instructions].present?

spec/jobs/regular/digest_rag_upload_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
RSpec.describe Jobs::DigestRagUpload do
44
fab!(:persona) { Fabricate(:ai_persona) }
5-
fab!(:upload)
6-
5+
fab!(:upload) { Fabricate(:upload, extension: "txt") }
76
let(:document_file) { StringIO.new("some text" * 200) }
87

98
fab!(:cloudflare_embedding_def)

spec/lib/modules/ai_bot/personas/persona_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ def tools
88
DiscourseAi::AiBot::Tools::Image,
99
]
1010
end
11-
1211
def system_prompt
1312
<<~PROMPT
1413
{site_url}
@@ -337,7 +336,7 @@ def system_prompt
337336
name: "custom",
338337
rag_conversation_chunks: 3,
339338
allowed_group_ids: [Group::AUTO_GROUPS[:trust_level_0]],
340-
question_consolidator_llm: "custom:#{llm_model.id}",
339+
question_consolidator_llm_id: llm_model.id,
341340
)
342341

343342
UploadReference.ensure_exist!(target: custom_ai_persona, upload_ids: [upload.id])

spec/lib/modules/ai_bot/playground_spec.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@
661661
expect(last_post.user_id).to eq(persona.user_id)
662662

663663
# tether llm, so it can no longer be switched
664-
persona.update!(force_default_llm: true, default_llm: "custom:#{claude_2.id}")
664+
persona.update!(force_default_llm: true, default_llm_id: claude_2.id)
665665

666666
DiscourseAi::Completions::Llm.with_prepared_responses(["Hi from bot one"], llm: claude_2) do
667667
create_post(
@@ -762,7 +762,7 @@
762762

763763
DiscourseAi::Completions::Llm.with_prepared_responses(
764764
["Yes I can", "Magic Title"],
765-
llm: "custom:#{gpt_35_turbo.id}",
765+
llm: gpt_35_turbo,
766766
) do
767767
messages =
768768
MessageBus.track_publish do
@@ -799,10 +799,7 @@
799799
)
800800

801801
# replies as correct persona if replying direct to persona
802-
DiscourseAi::Completions::Llm.with_prepared_responses(
803-
["Another reply"],
804-
llm: "custom:#{gpt_35_turbo.id}",
805-
) do
802+
DiscourseAi::Completions::Llm.with_prepared_responses(["Another reply"], llm: gpt_35_turbo) do
806803
create_post(
807804
raw: "Please ignore this bot, I am replying to a user",
808805
topic: post.topic,

0 commit comments

Comments
 (0)