diff --git a/lib/automation/report_runner.rb b/lib/automation/report_runner.rb index cf81058d..fe53adf1 100644 --- a/lib/automation/report_runner.rb +++ b/lib/automation/report_runner.rb @@ -237,6 +237,10 @@ Follow the provided writing composition instructions carefully and precisely ste parsed .css("a") .each do |a| + if a["class"] == "mention" + a.inner_html = a.inner_html.sub("@", "") + next + end href = a["href"] if href.present? && (href.start_with?("#{Discourse.base_url}") || href.start_with?("/")) begin @@ -255,13 +259,6 @@ Follow the provided writing composition instructions carefully and precisely ste end end - parsed - .css("span.mention") - .each do |mention| - no_at_username = mention.text.sub("@", "") - mention.replace("#{no_at_username}") - end - parsed.to_html end end diff --git a/lib/summarization/models/anthropic.rb b/lib/summarization/models/anthropic.rb index 2ce5ff61..138a7697 100644 --- a/lib/summarization/models/anthropic.rb +++ b/lib/summarization/models/anthropic.rb @@ -9,7 +9,8 @@ module DiscourseAi end def correctly_configured? - SiteSetting.ai_anthropic_api_key.present? + SiteSetting.ai_anthropic_api_key.present? || + DiscourseAi::Completions::Endpoints::AwsBedrock.correctly_configured?("claude-2") end def configuration_hint diff --git a/spec/lib/modules/automation/report_runner_spec.rb b/spec/lib/modules/automation/report_runner_spec.rb index aa8e0e6f..9fbc9b55 100644 --- a/spec/lib/modules/automation/report_runner_spec.rb +++ b/spec/lib/modules/automation/report_runner_spec.rb @@ -82,8 +82,10 @@ module DiscourseAi end it "can suppress notifications by remapping content" do + user = Fabricate(:user) + markdown = <<~MD - @sam is a person + @#{user.username} is a person [test1](/test) is an internal link [test2](/test?1=2) is an internal link [test3](https://example.com) is an external link @@ -117,7 +119,7 @@ module DiscourseAi # note, magic surprise & is correct HTML 5 representation expected = <<~HTML -

sam is a person
+

#{user.username} is a person
test1 is an internal link
test2 is an internal link
test3 is an external link
@@ -127,7 +129,10 @@ module DiscourseAi test7 is a link with an invalid URL

HTML - expect(report.ordered_posts.first.raw.strip).to eq(expected.strip) + post = report.ordered_posts.first + + expect(post.mentions.to_a).to eq([]) + expect(post.raw.strip).to eq(expected.strip) end it "can exclude tags" do