Skip to content

Commit

Permalink
correct spec
Browse files Browse the repository at this point in the history
  • Loading branch information
SamSaffron committed Mar 5, 2025
1 parent 94658cd commit bdf5519
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 1 addition & 2 deletions lib/completions/prompt_messages_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
10 changes: 6 additions & 4 deletions spec/lib/modules/ai_bot/playground_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -381,7 +383,7 @@
}}}
Your instructions:
#{user.username} said Hello
#{user.username}: Hello
TEXT

expect(content.strip).to eq(expected)
Expand Down

0 comments on commit bdf5519

Please sign in to comment.