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

Commit 5f451a6

Browse files
committed
FIX: pass bot feature name when responding as bot
1 parent 4ce8973 commit 5f451a6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

app/jobs/regular/create_ai_reply.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def execute(args)
1515

1616
bot = DiscourseAi::Personas::Bot.as(bot_user, persona: persona.new)
1717

18-
DiscourseAi::AiBot::Playground.new(bot).reply_to(post)
18+
DiscourseAi::AiBot::Playground.new(bot).reply_to(post, feature_name: "bot")
1919
rescue DiscourseAi::Personas::Bot::BOT_NOT_FOUND
2020
Rails.logger.warn(
2121
"Bot not found for post #{post.id} - perhaps persona was deleted or bot was disabled",

spec/lib/modules/ai_bot/playground_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176

177177
reply_post = nil
178178

179-
DiscourseAi::Completions::Llm.with_prepared_responses(responses) do |_, _, _prompt|
179+
DiscourseAi::Completions::Llm.with_prepared_responses(responses) do
180180
new_post = Fabricate(:post, raw: "Can you use the custom tool?")
181181
reply_post = playground.reply_to(new_post)
182182
end
@@ -255,14 +255,18 @@
255255
body = "Hey @#{persona.user.username}, can you help me with this image? #{image}"
256256

257257
prompts = nil
258+
options = nil
258259
DiscourseAi::Completions::Llm.with_prepared_responses(
259260
["I understood image"],
260-
) do |_, _, inner_prompts|
261+
) do |_, _, inner_prompts, inner_options|
262+
options = inner_options
261263
post = create_post(title: "some new topic I created", raw: body)
262264

263265
prompts = inner_prompts
264266
end
265267

268+
expect(options[0][:feature_name]).to eq("bot")
269+
266270
content = prompts[0].messages[1][:content]
267271

268272
expect(content).to include({ upload_id: upload.id })

0 commit comments

Comments
 (0)