2023-03-07 13:39:28 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require_relative "support/toxicity_inference_stubs"
|
|
|
|
|
|
|
|
describe Plugin::Instance do
|
|
|
|
before { SiteSetting.discourse_ai_enabled = true }
|
|
|
|
|
|
|
|
describe "on reviewable_transitioned_to event" do
|
|
|
|
fab!(:post) { Fabricate(:post) }
|
|
|
|
fab!(:admin) { Fabricate(:admin) }
|
|
|
|
|
|
|
|
it "adjusts model accuracy" do
|
|
|
|
ToxicityInferenceStubs.stub_post_classification(post, toxic: true)
|
|
|
|
SiteSetting.ai_toxicity_flag_automatically = true
|
2023-03-14 15:03:50 -04:00
|
|
|
classification = DiscourseAi::Toxicity::ToxicityClassification.new
|
|
|
|
classificator = DiscourseAi::PostClassificator.new(classification)
|
2023-03-07 13:39:28 -05:00
|
|
|
classificator.classify!(post)
|
2023-03-14 15:03:50 -04:00
|
|
|
reviewable = ReviewableAiPost.find_by(target: post)
|
2023-03-07 13:39:28 -05:00
|
|
|
|
|
|
|
reviewable.perform admin, :agree_and_keep
|
|
|
|
accuracy = ModelAccuracy.find_by(classification_type: classification.type)
|
|
|
|
|
|
|
|
expect(accuracy.flags_agreed).to eq(1)
|
|
|
|
end
|
|
|
|
end
|
2024-02-16 13:57:14 -05:00
|
|
|
|
|
|
|
describe "current_user_serializer#ai_helper_prompts" do
|
|
|
|
fab!(:user)
|
|
|
|
|
|
|
|
before do
|
|
|
|
SiteSetting.ai_helper_model = "fake:fake"
|
|
|
|
SiteSetting.composer_ai_helper_enabled = true
|
|
|
|
SiteSetting.ai_helper_illustrate_post_model = "disabled"
|
|
|
|
Group.find_by(id: Group::AUTO_GROUPS[:admins]).add(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:serializer) { CurrentUserSerializer.new(user, scope: Guardian.new(user)) }
|
|
|
|
|
|
|
|
it "returns the available prompts" do
|
|
|
|
expect(serializer.ai_helper_prompts).to be_present
|
|
|
|
expect(serializer.ai_helper_prompts.object.count).to eq(6)
|
|
|
|
end
|
|
|
|
end
|
2023-03-07 13:39:28 -05:00
|
|
|
end
|