From bdf55192d1cf03cda8de3b3c9a09a2c222f9564f Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Wed, 5 Mar 2025 18:31:44 +1100 Subject: [PATCH] correct spec --- lib/completions/prompt_messages_builder.rb | 3 +-- spec/lib/modules/ai_bot/playground_spec.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/completions/prompt_messages_builder.rb b/lib/completions/prompt_messages_builder.rb index eab624a3f..26fb24fa7 100644 --- a/lib/completions/prompt_messages_builder.rb +++ b/lib/completions/prompt_messages_builder.rb @@ -132,7 +132,6 @@ def push(type:, content:, name: nil, upload_ids: nil, id: nil, thinking: nil) def topic_array raw_messages = @raw_messages.dup - user_content = +"You are operating in a Discourse forum.\n\n" if @topic @@ -169,7 +168,7 @@ def topic_array if last_user_message user_content << "You are responding to #{last_user_message[:name] || "User"} who just said:\n #{last_user_message[:content]}" if last_user_message[:upload_ids].present? - upload_ids.concat(last_user__message[:upload_ids]) + upload_ids.concat(last_user_message[:upload_ids]) end end diff --git a/spec/lib/modules/ai_bot/playground_spec.rb b/spec/lib/modules/ai_bot/playground_spec.rb index 3bcd4c12e..6261aef89 100644 --- a/spec/lib/modules/ai_bot/playground_spec.rb +++ b/spec/lib/modules/ai_bot/playground_spec.rb @@ -141,18 +141,20 @@ it "can force usage of a tool" do tool_name = "custom-#{custom_tool.id}" ai_persona.update!(tools: [[tool_name, nil, true]], forced_tool_count: 1) - responses = [tool_call, "custom tool did stuff (maybe)"] + responses = [tool_call, ["custom tool did stuff (maybe)"], ["new PM title"]] prompts = nil reply_post = nil + private_message = Fabricate(:private_message_topic, user: user) + DiscourseAi::Completions::Llm.with_prepared_responses(responses) do |_, _, _prompts| - new_post = Fabricate(:post, raw: "Can you use the custom tool?") + new_post = Fabricate(:post, raw: "Can you use the custom tool?", topic: private_message) reply_post = playground.reply_to(new_post) prompts = _prompts end - expect(prompts.length).to eq(2) + expect(prompts.length).to eq(3) expect(prompts[0].tool_choice).to eq("search") expect(prompts[1].tool_choice).to eq(nil) @@ -381,7 +383,7 @@ }}} Your instructions: - #{user.username} said Hello + #{user.username}: Hello TEXT expect(content.strip).to eq(expected)