Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit ec20ca5

Browse files
committed
DEV: Apply suggestions from review
1 parent 8947a7d commit ec20ca5

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

app/services/problem_check/ai_llm_status.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@
22

33
class ProblemCheck::AiLlmStatus < ProblemCheck
44
self.priority = "high"
5-
self.perform_every = 1.hour
5+
self.perform_every = 6.hours
66

77
def call
8-
[*llm_errors]
8+
llm_errors
99
end
1010

1111
private
1212

13-
def targets
14-
[*LlmModel.in_use.pluck(:id)]
15-
end
16-
1713
def llm_errors
1814
return [] if !SiteSetting.discourse_ai_enabled
1915

@@ -28,7 +24,7 @@ def try_validate(model, &blk)
2824
blk.call
2925
nil
3026
rescue => e
31-
error_message = JSON.parse(e.message)["message"]
27+
error_message = parse_error_message(e.message)
3228
message =
3329
"#{I18n.t("dashboard.problem.ai_llm_status", { model_name: model.display_name, model_id: model.id })}"
3430

@@ -49,4 +45,12 @@ def try_validate(model, &blk)
4945
def validator
5046
@validator ||= DiscourseAi::Configuration::LlmValidator.new
5147
end
48+
49+
def parse_error_message(message)
50+
begin
51+
JSON.parse(message)["message"]
52+
rescue JSON::ParserError
53+
message.to_s
54+
end
55+
end
5256
end

0 commit comments

Comments
 (0)