This repository was archived by the owner on Jul 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +47
-2
lines changed
app/services/problem_check
spec/services/problem_check Expand file tree Collapse file tree 2 files changed +47
-2
lines changed Original file line number Diff line number Diff line change 22
33class ProblemCheck ::AiLlmStatus < ProblemCheck
44 self . priority = "high"
5- # self.perform_every = 1.hour
5+ self . perform_every = 1 . hour
66
77 def call
88 [ *llm_errors ]
@@ -24,6 +24,7 @@ def llm_errors
2424
2525 def try_validate ( model , &blk )
2626 begin
27+ raise ( { message : "Forced error for testing" } . to_json ) if Rails . env . test?
2728 blk . call
2829 nil
2930 rescue => e
@@ -34,7 +35,7 @@ def try_validate(model, &blk)
3435 Problem . new (
3536 message ,
3637 priority : "high" ,
37- identifier : "ai_llm_checker " ,
38+ identifier : "ai_llm_status " ,
3839 target : model . id ,
3940 details : {
4041 model_id : model . id ,
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ require "rails_helper"
4+
5+ RSpec . describe ProblemCheck ::AiLlmStatus do
6+ subject ( :check ) { described_class . new }
7+
8+ before do
9+ assign_fake_provider_to ( :ai_summarization_model )
10+ SiteSetting . ai_summarization_enabled = true
11+ end
12+
13+ describe "#call" do
14+ it "does nothing if discourse-ai plugin disabled" do
15+ SiteSetting . discourse_ai_enabled = false
16+ expect ( check ) . to be_chill_about_it
17+ end
18+
19+ context "with discourse-ai plugin enabled for the site" do
20+ let ( :llm_model ) { LlmModel . in_use . first }
21+
22+ before { SiteSetting . discourse_ai_enabled = true }
23+
24+ it "returns a problem with an LLM model" do
25+ message =
26+ "#{ I18n . t ( "dashboard.problem.ai_llm_status" , { model_name : llm_model . display_name , model_id : llm_model . id } ) } "
27+
28+ expect ( described_class . new . call ) . to contain_exactly (
29+ have_attributes (
30+ identifier : "ai_llm_status" ,
31+ target : llm_model . id ,
32+ priority : "high" ,
33+ message : message ,
34+ details : {
35+ model_id : llm_model . id ,
36+ model_name : llm_model . display_name ,
37+ error : "Forced error for testing" ,
38+ } ,
39+ ) ,
40+ )
41+ end
42+ end
43+ end
44+ end
You can’t perform that action at this time.
0 commit comments