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

Commit fdc8c70

Browse files
committed
FEATURE: Add periodic problem checks for each LLM in use
1 parent 34f43f3 commit fdc8c70

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# frozen_string_literal: true
2+
3+
class ProblemCheck::AiLlmStatus < ProblemCheck
4+
self.priority = "high"
5+
# self.perform_every = 1.hour
6+
7+
def call
8+
return no_problem if !SiteSetting.discourse_ai_enabled?
9+
return no_problem if llm_operational?
10+
11+
problem
12+
end
13+
14+
private
15+
16+
def llm_operational?
17+
model_ids = DiscourseAi::Configuration::LlmEnumerator.global_usage.keys
18+
models_to_check = LlmModel.where(id: model_ids)
19+
20+
models_to_check.each do |model|
21+
begin
22+
result = validator.run_test(model)
23+
return false unless result
24+
rescue StandardError => e
25+
Rails.logger.warn("LlmValidator encountered an error for model #{model.id}: #{e.message}")
26+
return false
27+
end
28+
end
29+
30+
return true
31+
end
32+
33+
def validator
34+
@validator ||= DiscourseAi::Configuration::LlmValidator.new
35+
end
36+
end

config/locales/server.en.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,3 +452,6 @@ en:
452452
no_default_llm: The persona must have a default_llm defined.
453453
user_not_allowed: The user is not allowed to participate in the topic.
454454
prompt_message_length: The message %{idx} is over the 1000 character limit.
455+
dashboard:
456+
problem:
457+
ai_llm_status: "An LLM Model needs attention!"

plugin.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ def self.public_asset_path(name)
7373
DiscourseAi::AiBot::EntryPoint.new,
7474
].each { |a_module| a_module.inject_into(self) }
7575

76+
register_problem_check ProblemCheck::AiLlmStatus
77+
7678
register_reviewable_type ReviewableAiChatMessage
7779
register_reviewable_type ReviewableAiPost
7880

0 commit comments

Comments
 (0)