2024-01-29 16:04:25 -03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DiscourseAi
|
|
|
|
module Configuration
|
|
|
|
class LlmDependencyValidator
|
|
|
|
def initialize(opts = {})
|
|
|
|
@opts = opts
|
|
|
|
end
|
|
|
|
|
|
|
|
def valid_value?(val)
|
|
|
|
return true if val == "f"
|
|
|
|
|
2025-07-16 14:51:32 -07:00
|
|
|
@llm_dependency_setting_name = :ai_default_llm_model
|
2024-01-29 16:04:25 -03:00
|
|
|
|
2025-07-16 07:08:29 -07:00
|
|
|
SiteSetting.public_send(@llm_dependency_setting_name).present?
|
2024-01-29 16:04:25 -03:00
|
|
|
end
|
|
|
|
|
2024-06-19 18:01:35 -03:00
|
|
|
def error_message
|
2025-04-02 12:54:47 -03:00
|
|
|
if @llm_dependency_setting_name
|
|
|
|
I18n.t(
|
|
|
|
"discourse_ai.llm.configuration.set_llm_first",
|
|
|
|
setting: @llm_dependency_setting_name,
|
|
|
|
)
|
|
|
|
elsif @no_llms_configured
|
|
|
|
I18n.t("discourse_ai.llm.configuration.create_llm")
|
|
|
|
end
|
2024-01-29 16:04:25 -03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|