discourse-ai/lib/configuration/llm_dependency_validator.rb
Roman Rizzi 0d60aca6ef
FEATURE: Personas powered summaries. (#1232)
* REFACTOR: Move personas into it's own module.

* WIP: Use personas for summarization

* Prioritize persona default LLM or fallback to newest one

* Simplify summarization strategy

* Keep ai_sumarization_model as a fallback
2025-04-02 12:54:47 -03:00

38 lines
973 B
Ruby

# 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"
if @opts[:name] == :ai_summarization_enabled
has_llms = LlmModel.count > 0
@no_llms_configured = !has_llms
has_llms
else
@llm_dependency_setting_name =
DiscourseAi::Configuration::LlmValidator.new.choose_llm_setting_for(@opts[:name])
SiteSetting.public_send(@llm_dependency_setting_name).present?
end
end
def error_message
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
end
end
end
end