generated from discourse/discourse-plugin-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: Prevent LLM enumerator from erroring when spam enabled (#1045)
This PR fixes an issue where LLM enumerator would error out when `SiteSetting.ai_spam_detection = true` but there was no `AiModerationSetting.spam` present. Typically, we add an `LlmDependencyValidator` for the setting itself, however, since Spam is unique in that it has it's model set in `AiModerationSetting` instead of a `SiteSetting`, we'll add a simple check here to prevent erroring out.
- Loading branch information
1 parent
47ecf86
commit b480f13
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe DiscourseAi::Configuration::LlmEnumerator do | ||
fab!(:fake_model) | ||
|
||
describe "#global_usage" do | ||
before do | ||
SiteSetting.ai_helper_model = "custom:#{fake_model.id}" | ||
SiteSetting.ai_helper_enabled = true | ||
end | ||
|
||
it "returns a hash of Llm models in use globally" do | ||
expect(described_class.global_usage).to eq(fake_model.id => [{ type: :ai_helper }]) | ||
end | ||
|
||
it "doesn't error on spam when spam detection is enabled but moderation setting is missing" do | ||
SiteSetting.ai_spam_detection_enabled = true | ||
expect { described_class.global_usage }.not_to raise_error | ||
end | ||
end | ||
end |