FIX: Triage's search_for_text should be case-insensitive (#767)

This commit is contained in:
Roman Rizzi 2024-08-22 18:32:42 -03:00 committed by GitHub
parent 9019e90b87
commit eac83eb619
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View File

@ -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?

View File

@ -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