2024-01-29 14:04:25 -05: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"
|
|
|
|
|
2024-06-19 17:01:35 -04:00
|
|
|
@llm_dependency_setting_name =
|
|
|
|
DiscourseAi::Configuration::LlmValidator.new.choose_llm_setting_for(@opts[:name])
|
2024-01-29 14:04:25 -05:00
|
|
|
|
2024-06-19 17:01:35 -04:00
|
|
|
SiteSetting.public_send(@llm_dependency_setting_name).present?
|
2024-01-29 14:04:25 -05:00
|
|
|
end
|
|
|
|
|
2024-06-19 17:01:35 -04:00
|
|
|
def error_message
|
|
|
|
I18n.t(
|
|
|
|
"discourse_ai.llm.configuration.set_llm_first",
|
|
|
|
setting: @llm_dependency_setting_name,
|
|
|
|
)
|
2024-01-29 14:04:25 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|