diff --git a/lib/automation/llm_triage.rb b/lib/automation/llm_triage.rb index 073a45d2..9e7c57b9 100644 --- a/lib/automation/llm_triage.rb +++ b/lib/automation/llm_triage.rb @@ -38,7 +38,7 @@ module DiscourseAi feature_name: "llm_triage", )&.strip - if result.present? && result.downcase.include?(search_for_text) + if result.present? && result.downcase.include?(search_for_text.downcase) user = User.find_by_username(canned_reply_user) if canned_reply_user.present? user = user || Discourse.system_user if canned_reply.present? diff --git a/spec/lib/modules/automation/llm_triage_spec.rb b/spec/lib/modules/automation/llm_triage_spec.rb index 0c588359..36bc5f32 100644 --- a/spec/lib/modules/automation/llm_triage_spec.rb +++ b/spec/lib/modules/automation/llm_triage_spec.rb @@ -108,4 +108,21 @@ describe DiscourseAi::Automation::LlmTriage do expect(reviewable&.target).to eq(post) end + + it "treats search_for_text as case-insensitive" do + DiscourseAi::Completions::Llm.with_prepared_responses(["bad"]) do + triage( + post: post, + model: "custom:#{llm_model.id}", + system_prompt: "test %%POST%%", + search_for_text: "BAD", + flag_post: true, + automation: nil, + ) + end + + reviewable = ReviewablePost.last + + expect(reviewable.target).to eq(post) + end end