From eac83eb61998c9762c12db033480630d73dad56b Mon Sep 17 00:00:00 2001 From: Roman Rizzi Date: Thu, 22 Aug 2024 18:32:42 -0300 Subject: [PATCH] FIX: Triage's search_for_text should be case-insensitive (#767) --- lib/automation/llm_triage.rb | 2 +- spec/lib/modules/automation/llm_triage_spec.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) 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