2024-06-18 14:32:14 -03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DiscourseAi::ChatBotHelper
|
|
|
|
def toggle_enabled_bots(bots: [])
|
2024-10-16 07:20:31 +11:00
|
|
|
models = LlmModel.all
|
|
|
|
models = models.where("id not in (?)", bots.map(&:id)) if bots.present?
|
|
|
|
models.update_all(enabled_chat_bot: false)
|
|
|
|
|
2024-06-18 14:32:14 -03:00
|
|
|
bots.each { |b| b.update!(enabled_chat_bot: true) }
|
|
|
|
DiscourseAi::AiBot::SiteSettingsExtension.enable_or_disable_ai_bots
|
|
|
|
end
|
2024-06-19 18:01:35 -03:00
|
|
|
|
|
|
|
def assign_fake_provider_to(setting_name)
|
2024-07-30 13:44:57 -03:00
|
|
|
Fabricate(:fake_model).tap do |fake_llm|
|
2024-06-19 18:01:35 -03:00
|
|
|
SiteSetting.public_send("#{setting_name}=", "custom:#{fake_llm.id}")
|
|
|
|
end
|
|
|
|
end
|
2024-06-18 14:32:14 -03:00
|
|
|
end
|
|
|
|
|
2024-10-28 15:36:42 +02:00
|
|
|
RSpec.configure { |config| config.include DiscourseAi::ChatBotHelper }
|